@mlightcad/data-model 1.7.7 → 1.7.8
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.
- package/dist/data-model.cjs +3 -3
- package/dist/data-model.js +308 -299
- package/lib/converter/AcDbDxfConverter.d.ts.map +1 -1
- package/lib/converter/AcDbDxfConverter.js +4 -0
- package/lib/converter/AcDbDxfConverter.js.map +1 -1
- package/lib/converter/AcDbObjectConverter.d.ts.map +1 -1
- package/lib/converter/AcDbObjectConverter.js +13 -5
- package/lib/converter/AcDbObjectConverter.js.map +1 -1
- package/package.json +4 -4
package/dist/data-model.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ha=(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))(Ha||{});const vl=[{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 er{constructor(t){if(typeof t=="string"){const e=vl.find(s=>s.name===t);if(!e)throw new Error(`Unknown DWG version name: ${t}`);this.name=e.name,this.value=e.value;return}if(typeof t=="number"){const e=vl.find(s=>s.value===t);if(!e)throw new Error(`Unknown DWG version value: ${t}`);this.name=e.name,this.value=e.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class Vl{constructor(t={}){this._database=t.database,this._precision=Math.max(0,Math.min(16,t.precision??16)),this._version=t.version instanceof er?t.version:t.version!=null?new er(t.version):void 0,this._lines=[],this._handleMap=new Map,this._nextHandle=1}get database(){return this._database}set database(t){this._database=t}get precision(){return this._precision}setPrecision(t){return this._precision=Math.max(0,Math.min(16,t)),this}get version(){return this._version}setVersion(t){return this._version=t instanceof er?t:new er(t),this}toString(){return this._lines.join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`}registerHandle(t){return this._handleMap.has(t)||(this._handleMap.set(t,this._nextHandle.toString(16).toUpperCase()),this._nextHandle+=1),this._handleMap.get(t)}resolveHandle(t){if(t)return this.registerHandle(t)}writeGroup(t,e){return e==null?this:(this._lines.push(String(Math.trunc(t))),this._lines.push(this.formatValue(e)),this)}writeStart(t){return this.writeString(0,t)}writeSubclassMarker(t){return this.writeString(100,t)}writeString(t,e){return!e&&e!==""?this:this.writeGroup(t,e)}writeInt8(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt16(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt32(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt64(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeUInt16(t,e){return e==null?this:this.writeGroup(t,Math.max(0,e))}writeUInt32(t,e){return e==null?this:this.writeGroup(t,Math.max(0,e))}writeBoolean(t,e){return e==null?this:this.writeGroup(t,e?1:0)}writeBool(t,e){return this.writeBoolean(t,e)}writeDouble(t,e){return e==null||!Number.isFinite(e)?this:this.writeGroup(t,e)}writeAngle(t,e){return e==null||!Number.isFinite(e)?this:this.writeDouble(t,e*180/Math.PI)}writeHandle(t,e){const s=this.resolveHandle(e);return s?this.writeString(t,s):this}writeObjectId(t,e){return this.writeHandle(t,e)}writePoint2d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this):this}writePoint3d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this.writeDouble(t+20,e.z??0),this):this}writeVector3d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this.writeDouble(t+20,e.z??0),this):this}writeCmColor(t,e=62,s=420){if(!t)return this;const a=t.colorIndex;a!=null&&this.writeInt16(e,a);const h=t.RGB;return h!=null&&t.colorIndex==null&&this.writeInt32(s,h),this}writeTransparency(t,e=440){return t?this.writeInt32(e,t.serialize()):this}writeResultBuffer(t){if(!t)return this;for(const e of t)this.writeGroup(e.code,e.value);return this}startSection(t){return this.writeStart("SECTION"),this.writeString(2,t),this}endSection(){return this.writeStart("ENDSEC"),this}startTable(t,e){return this.writeStart("TABLE"),this.writeString(2,t),this.writeInt16(70,e),this}endTable(){return this.writeStart("ENDTAB"),this}formatValue(t){return typeof t=="string"?t:typeof t=="boolean"?t?"1":"0":typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this._precision).replace(/\.?0+$/,""):"0":String(t)}}function Kc(n,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in n)){const h=Object.getOwnPropertyDescriptor(s,a);h&&Object.defineProperty(n,a,h.get?h:{enumerable:!0,get:()=>s[a]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var lt=(n=>(n[n.ByColor=1]="ByColor",n[n.ByACI=2]="ByACI",n[n.ByLayer=3]="ByLayer",n[n.ByBlock=4]="ByBlock",n[n.None=0]="None",n))(lt||{});const bl={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},ya=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];let nn=class{static getColorByIndex(t){return ya[t]}static getIndexByColor(t){const e=ya.length-1;for(let s=1;s<e;++s)if(ya[s]===t)return s}static getColorByName(t){return bl[t.toLowerCase()]}static getNameByColor(t){for(const[e,s]of Object.entries(bl))if(s===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},ce=class jr{constructor(t=lt.ByLayer,e){this._colorMethod=t,this._colorMethod==lt.ByColor&&e==null?this._value=16777215:this._colorMethod==lt.ByACI?e==null?this._value=8:e===0?this._colorMethod=lt.ByBlock:e===256?this._colorMethod=lt.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}get colorMethod(){return this._colorMethod}set colorMethod(t){this._colorMethod=t}get red(){const t=this.RGB;return t!=null?t>>16&255:void 0}get green(){const t=this.RGB;return t!=null?t>>8&255:void 0}get blue(){const t=this.RGB;return t!=null?t&255:void 0}get RGB(){switch(this._colorMethod){case lt.ByColor:case lt.ByBlock:case lt.ByLayer:return this._value;case lt.ByACI:return this._value?nn.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,s){const a=Math.max(0,Math.min(255,Math.round(t))),h=Math.max(0,Math.min(255,Math.round(e))),u=Math.max(0,Math.min(255,Math.round(s)));return this._value=a<<16|h<<8|u,this._colorMethod=lt.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=lt.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let h=0,u=0,p=0;if(e.length===7)h=parseInt(e.substr(1,2),16),u=parseInt(e.substr(3,2),16),p=parseInt(e.substr(5,2),16);else if(e.length===4)h=parseInt(e[1]+e[1],16),u=parseInt(e[2]+e[2],16),p=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(h,u,p)}const s=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(s){const h=parseInt(s[1],10),u=parseInt(s[2],10),p=parseInt(s[3],10);return this.setRGB(h,u,p)}const a=nn.getColorByName(t);return a!==void 0?this.setRGBValue(a):(console.warn("Unknown CSS color string:",t),this)}setScalar(t){return this.setRGB(t,t,t)}get hexColor(){const t=this.RGB;return t==null?void 0:"0x"+t.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const t=this.RGB;if(t!=null)return`rgb(${t>>16&255},${t>>8&255},${t&255})`}get colorIndex(){return this._colorMethod===lt.ByACI?this._value:this._colorMethod===lt.ByLayer?256:this._colorMethod===lt.ByBlock?0:void 0}set colorIndex(t){if(t==null)return;const e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=lt.ByBlock,this._value=void 0):e===256?(this._colorMethod=lt.ByLayer,this._value=void 0):(this._colorMethod=lt.ByACI,this._value=e)}get isByColor(){return this._colorMethod===lt.ByColor}get isByACI(){return this._colorMethod===lt.ByACI}get isForeground(){return this._colorMethod===lt.ByACI&&this._value===7}setForeground(){return this._colorMethod=lt.ByACI,this._value=7,this}get isByLayer(){return this._colorMethod===lt.ByLayer}setByLayer(t){return this._colorMethod=lt.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===lt.ByBlock}setByBlock(t){return this._colorMethod=lt.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case lt.ByLayer:return"ByLayer";case lt.ByBlock:return"ByBlock";case lt.ByColor:return this._value?nn.getNameByColor(this._value):"";case lt.ByACI:return this._value?nn.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=nn.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=lt.ByColor):console.warn("Unknown color name:",t)}clone(){const t=new jr;return t._colorMethod=this._colorMethod,t._value=this._value,t}copy(t){return this._colorMethod=t._colorMethod,this._value=t._value,this}equals(t){return this._colorMethod===t._colorMethod&&this._value===t._value}toString(){switch(this._colorMethod){case lt.ByLayer:return"ByLayer";case lt.ByBlock:return"ByBlock";case lt.ByACI:return this._value!==void 0?String(this._value):"";case lt.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(t){if(!t)return;const e=t.trim();if(/^bylayer$/i.test(e))return new jr(lt.ByLayer);if(/^byblock$/i.test(e))return new jr(lt.ByBlock);const s=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(s){const h=Number(s[1]),u=Number(s[2]),p=Number(s[3]),v=new jr(lt.ByColor);return v.setRGB(h,u,p),v}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){const[h,u,p]=e.split(",").map(Number),v=new jr(lt.ByColor);return v.setRGB(h,u,p),v}if(/^\d+$/.test(e)){const h=parseInt(e,10);return new jr(lt.ByACI,h)}if(/^book\$/i.test(e)){const h=e.substring(e.indexOf("$")+1),u=nn.getColorByName(h);if(u!=null)return new jr(lt.ByColor,u);console.warn("Unknown color book entry:",t);return}const a=nn.getColorByName(e);if(a!=null)return new jr(lt.ByColor,a);console.warn("Unknown color name:",t)}};class $c{constructor(t=lt.ByColor,e=0){this._colorMethod=t,this._value=e}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(t){this._colorMethod=lt.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=lt.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=lt.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,s){this._colorMethod=lt.ByColor,this._value=(t&255)<<16|(e&255)<<8|s&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=lt.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=lt.ByLayer,this._value=t}isByColor(){return this._colorMethod===lt.ByColor}isByLayer(){return this._colorMethod===lt.ByLayer}isByBlock(){return this._colorMethod===lt.ByBlock}isByACI(){return this._colorMethod===lt.ByACI}isNone(){return this._colorMethod===lt.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const Ze={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")}};class Zc{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let a=0,h=s.length;a<h;a++)s[a].call(this,t)}}}let he=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};function Ws(n){return n===null||typeof n!="object"?n:Array.isArray(n)?[...n]:{...n}}function Oa(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(Oa);const t={};for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=Oa(n[e]));return t}function ns(n,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&n[s]===void 0&&(n[s]=e[s]);return n}function jl(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function Dl(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 Jn(n,t){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(let a=0;a<n.length;a++)if(!Jn(n[a],t[a]))return!1;return!0}const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(const a of e)if(!Object.prototype.hasOwnProperty.call(t,a)||!Jn(n[a],t[a]))return!1;return!0}var Qc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ul={exports:{}};(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(Qc,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],h={},u=null;function p(C,V){var z=C[V];if(typeof z.bind=="function")return z.bind(C);try{return Function.prototype.bind.call(z,C)}catch{return function(){return Function.prototype.apply.apply(z,[C,arguments])}}}function v(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function f(C){return C==="debug"&&(C="log"),typeof console===e?!1:C==="trace"&&s?v:console[C]!==void 0?p(console,C):console.log!==void 0?p(console,"log"):t}function x(){for(var C=this.getLevel(),V=0;V<a.length;V++){var z=a[V];this[z]=V<C?t:this.methodFactory(z,C,this.name)}if(this.log=this.debug,typeof console===e&&C<this.levels.SILENT)return"No console available for logging"}function w(C){return function(){typeof console!==e&&(x.call(this),this[C].apply(this,arguments))}}function A(C,V,z){return f(C)||w.apply(this,arguments)}function k(C,V){var z=this,at,_t,st,H="loglevel";typeof C=="string"?H+=":"+C:typeof C=="symbol"&&(H=void 0);function dt(xt){var Bt=(a[xt]||"silent").toUpperCase();if(!(typeof window===e||!H)){try{window.localStorage[H]=Bt;return}catch{}try{window.document.cookie=encodeURIComponent(H)+"="+Bt+";"}catch{}}}function it(){var xt;if(!(typeof window===e||!H)){try{xt=window.localStorage[H]}catch{}if(typeof xt===e)try{var Bt=window.document.cookie,be=encodeURIComponent(H),we=Bt.indexOf(be+"=");we!==-1&&(xt=/^([^;]+)/.exec(Bt.slice(we+be.length+1))[1])}catch{}return z.levels[xt]===void 0&&(xt=void 0),xt}}function Wt(){if(!(typeof window===e||!H)){try{window.localStorage.removeItem(H)}catch{}try{window.document.cookie=encodeURIComponent(H)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function $t(xt){var Bt=xt;if(typeof Bt=="string"&&z.levels[Bt.toUpperCase()]!==void 0&&(Bt=z.levels[Bt.toUpperCase()]),typeof Bt=="number"&&Bt>=0&&Bt<=z.levels.SILENT)return Bt;throw new TypeError("log.setLevel() called with invalid level: "+xt)}z.name=C,z.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},z.methodFactory=V||A,z.getLevel=function(){return st??_t??at},z.setLevel=function(xt,Bt){return st=$t(xt),Bt!==!1&&dt(st),x.call(z)},z.setDefaultLevel=function(xt){_t=$t(xt),it()||z.setLevel(xt,!1)},z.resetLevel=function(){st=null,Wt(),x.call(z)},z.enableAll=function(xt){z.setLevel(z.levels.TRACE,xt)},z.disableAll=function(xt){z.setLevel(z.levels.SILENT,xt)},z.rebuild=function(){if(u!==z&&(at=$t(u.getLevel())),x.call(z),u===z)for(var xt in h)h[xt].rebuild()},at=$t(u?u.getLevel():"WARN");var Xt=it();Xt!=null&&(st=$t(Xt)),x.call(z)}u=new k,u.getLogger=function(C){if(typeof C!="symbol"&&typeof C!="string"||C==="")throw new TypeError("You must supply a name when creating a logger.");var V=h[C];return V||(V=h[C]=new k(C,u.methodFactory)),V};var L=typeof window!==e?window.log:void 0;return u.noConflict=function(){return typeof window!==e&&window.log===u&&(window.log=L),u},u.getLoggers=function(){return h},u.default=u,u})})(Ul);var Gl=Ul.exports;const td=Jc(Gl),ed=Kc({__proto__:null,default:td},[Gl]),rd=!0,Ys=ed;Ys.setLevel("debug");const nd=n=>{try{Ys.setLevel(n)}catch(t){Ys.setLevel("error"),Ys.error(t)}};let Wl=class Hl{constructor(t,e){this.events={attrChanged:new he,modelChanged:new he},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&ns(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let a;typeof t=="object"?(a=t,s=e):(a={},a[t]=e),s||(s={});const h=s.unset,u=s.silent,p=[],v=this._changing;this._changing=!0,v||(this._previousAttributes=Ws(this.attributes),this.changed={});const f=this.attributes,x=this.changed,w=this._previousAttributes;for(const A in a)e=a[A],Jn(f[A],e)||p.push(A),Jn(w[A],e)?delete x[A]:x[A]=e,h?delete f[A]:f[A]=e;if(!u){p.length&&(this._pending=s);for(let A=0;A<p.length;A++)this.events.attrChanged.dispatch({object:this,attrName:p[A],attrValue:f[p[A]],options:s})}if(v)return this;if(!u)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!Dl(this.changed):jl(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?Ws(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const a in t){const h=t[a];Jn(e[a],h)||(s[a]=h)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return Ws(this._previousAttributes)}clone(){const t=Ws(this.attributes);return new Hl(t)}},Ya=class Hs{constructor(){this.entries=new Map}static getInstance(){return Hs.instance||(Hs.instance=new Hs),Hs.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class sd{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,a=Math.max(0,e),h=["B","KB","MB","GB","TB"],u=Math.floor(Math.log(t)/Math.log(s)),p=t/Math.pow(s,u);return`${parseFloat(p.toFixed(a))} ${h[u]}`}}var Ne=(n=>(n[n.ByLayer=0]="ByLayer",n[n.ByBlock=1]="ByBlock",n[n.ByAlpha=2]="ByAlpha",n[n.ErrorValue=3]="ErrorValue",n))(Ne||{});let na=class yr{constructor(t){t!==void 0?(this._method=Ne.ByAlpha,this._alpha=yr.clampAlpha(t)):(this._method=Ne.ByLayer,this._alpha=255)}get method(){return this._method}set method(t){this._method=t}get alpha(){return this._alpha}set alpha(t){this._alpha=yr.clampAlpha(t),this._method=Ne.ByAlpha}get percentage(){if(this._method===Ne.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),s=Math.round(255*(1-e/100));this.alpha=s}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===Ne.ByAlpha}get isByBlock(){return this._method===Ne.ByBlock}get isByLayer(){return this._method===Ne.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===Ne.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new yr;return t._method=this._method,t._alpha=this._alpha,t}equals(t){return this._method===t._method&&this._alpha===t._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(t){const e=t.trim();if(/^bylayer$/i.test(e)){const h=new yr;return h._method=Ne.ByLayer,h}if(/^byblock$/i.test(e)){const h=new yr;return h._method=Ne.ByBlock,h}const s=Number(e);if(Number.isInteger(s)&&s>=0&&s<=255)return new yr(s);const a=new yr;return a._method=Ne.ErrorValue,a}static deserialize(t){const e=t>>>24&255,s=t&255,a=Object.values(Ne)[e]??Ne.ErrorValue,h=new yr;return h._method=a,h._alpha=yr.clampAlpha(s),h}};class Yl{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}let Xl=class{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,s)=>{const a=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let a=0;a<e;a++){const h=this.tasks[a];try{s=await this.scheduleTask(async()=>{const u=await h.run(s);return this.onProgress((a+1)/e,h),u})}catch(u){if(this.onError({error:u,taskIndex:a,task:h}))return Promise.reject(u)}}this.onComplete(s)}},ql=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const a=this.handlers[e],h=this.handlers[e+1];if(a.global&&(a.lastIndex=0),a.test(t))return h}return null}};const Kl=new ql;class id{constructor(t){this.manager=t!==void 0?t:Kl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,a)=>{this.load(t,s,e,a)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}var kn=256,$l=[],wl=256,gi;for(;kn--;)$l[kn]=(kn+256).toString(16).substring(1);function ad(n){var t=0,e=11;if(!gi||kn+e>wl*2)for(gi="",kn=0;t<wl;t++)gi+=$l[Math.random()*256|0];return gi.substring(kn,kn+++e)}let Ca;function Zl(n){Ca=n}class Hr{constructor(t,e){t=t||{},ns(t,{objectId:ad()}),this._attrs=new Wl(t,e),this._xDataMap=new Map}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get extensionDictionary(){return this.getAttrWithoutException("extensionDictionary")}set extensionDictionary(t){this._attrs.set("extensionDictionary",t)}get database(){if(this._database)return this._database;if(Ca)return Ca().workingDatabase;throw new Error("The current working database must be set before using it!")}set database(t){this._database=t}getXData(t){return this._xDataMap.get(t)}setXData(t){for(const e of t)e.code===Ha.ExtendedDataRegAppName&&this._xDataMap.set(e.value,t)}removeXData(t){this._xDataMap.delete(t)}createExtensionDictionary(){}close(){}dxfOut(...t){const[e,s=!1]=t;if(e.writeHandle(5,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),s)for(const a of this._xDataMap.values())e.writeResultBuffer(a);return this}dxfOutFields(t){return this}}let Ba;function Ql(n){Ba=n}function Xa(){return ki.instance}const Ji=class Ji{constructor(){this._workingDatabase=null}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){if(!this._layoutManager){if(!Ba)throw new Error("The layout manager factory must be registered before using it!");this._layoutManager=Ba()}return this._layoutManager}};Ji.instance=new Ji;let ki=Ji;Zl(Xa);var Jl=(n=>(n.kForRead="kForRead",n.kForWrite="kForWrite",n))(Jl||{});class qa{constructor(t){if(this._values=[],t)for(const e of t)this._values.push({...e})}get length(){return this._values.length}at(t){return this._values[t]}add(t){this._values.push(t)}addRange(t){for(const e of t)this._values.push(e)}clear(){this._values.length=0}toArray(){return this._values.map(t=>({...t}))}clone(){return new qa(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}class Ka{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const a=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,0)})}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let s=0;const a=async()=>{const h=s,u=Math.min(s+this._chunkSize,this._count);await t(h,u),s=u,s<this._count&&await this.scheduleTask(a)};await a(),await(e==null?void 0:e())}}var Xs=(n=>(n.DXF="dxf",n.DWG="dwg",n))(Xs||{});class vr{constructor(){this.events={registered:new he,unregistered:new he},this._converters=new Map,this.register("dxf",new Nc)}static createInstance(){return vr._instance==null&&(vr._instance=new vr),this._instance}static get instance(){return vr._instance||(vr._instance=new vr),vr._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 Se=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let xl=1234567;const $a=Math.PI/180,Za=180/Math.PI;function th(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Se[n&255]+Se[n>>8&255]+Se[n>>16&255]+Se[n>>24&255]+"-"+Se[t&255]+Se[t>>8&255]+"-"+Se[t>>16&15|64]+Se[t>>24&255]+"-"+Se[e&63|128]+Se[e>>8&255]+"-"+Se[e>>16&255]+Se[e>>24&255]+Se[s&255]+Se[s>>8&255]+Se[s>>16&255]+Se[s>>24&255]).toLowerCase()}function Dr(n,t,e){return Math.max(t,Math.min(e,n))}function Qa(n,t){return(n%t+t)%t}function eh(n,t,e,s,a){return s+(n-t)*(a-s)/(e-t)}function rh(n,t,e){return n!==t?(e-n)/(t-n):0}function Ja(n,t,e){return(1-e)*n+e*t}function nh(n,t,e,s){return Ja(n,t,1-Math.exp(-e*s))}function sh(n,t=1){return t-Math.abs(Qa(n,t*2)-t)}function ih(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function ah(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function oh(n,t){return n+Math.floor(Math.random()*(t-n+1))}function lh(n,t){return n+Math.random()*(t-n)}function hh(n){return n*(.5-Math.random())}function uh(n){n!==void 0&&(xl=n);let t=xl+=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 ch(n){return n*$a}function dh(n){return n*Za}function ph(n){return(n&n-1)===0&&n!==0}function mh(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function gh(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function qs(n){const t=Math.PI*2;return(n%t+t)%t}function _h(n,t,e){return n>t&&n<e||n>e&&n<t}function fh(n,t,e,s=!1){return n=qs(n),t=qs(t),e=qs(e),s?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function to(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function yh(n,t=1e-7){const e=to(n);return Math.max(Math.pow(10,e)*t,t)}const St={DEG2RAD:$a,RAD2DEG:Za,generateUUID:th,clamp:Dr,euclideanModulo:Qa,mapLinear:eh,inverseLerp:rh,lerp:Ja,damp:nh,pingpong:sh,smoothstep:ih,smootherstep:ah,randInt:oh,randFloat:lh,randFloatSpread:hh,seededRandom:uh,degToRad:ch,radToDeg:dh,isPowerOfTwo:ph,ceilPowerOfTwo:mh,floorPowerOfTwo:gh,normalizeAngle:qs,isBetween:_h,isBetweenAngle:fh,intPartLength:to,relativeEps:yh},Ra=class vh{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:a,y:h}=t;this.x=a,this.y=h;return}if(s===2){this.x=t,this.y=e;return}throw Ze.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new vh(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,a=t.elements;return this.x=a[0]*e+a[3]*s+a[6],this.y=a[1]*e+a[4]*s+a[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),a=Math.sin(e),h=this.x-t.x,u=this.y-t.y;return this.x=h*s-u*a+t.x,this.y=h*a+u*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(St.relativeEps(this.x,t),St.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};Ra.EMPTY=Object.freeze(new Ra(0,0));let te=Ra;const Fa=class bh{constructor(t,e,s,a,h,u,p,v,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&a!=null&&h!=null&&u!=null&&p!=null&&v!=null&&f!=null&&this.set(t,e,s,a,h,u,p,v,f)}set(t,e,s,a,h,u,p,v,f){const x=this.elements;return x[0]=t,x[1]=a,x[2]=p,x[3]=e,x[4]=h,x[5]=v,x[6]=s,x[7]=u,x[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,a=e.elements,h=this.elements,u=s[0],p=s[3],v=s[6],f=s[1],x=s[4],w=s[7],A=s[2],k=s[5],L=s[8],C=a[0],V=a[3],z=a[6],at=a[1],_t=a[4],st=a[7],H=a[2],dt=a[5],it=a[8];return h[0]=u*C+p*at+v*H,h[3]=u*V+p*_t+v*dt,h[6]=u*z+p*st+v*it,h[1]=f*C+x*at+w*H,h[4]=f*V+x*_t+w*dt,h[7]=f*z+x*st+w*it,h[2]=A*C+k*at+L*H,h[5]=A*V+k*_t+L*dt,h[8]=A*z+k*st+L*it,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],a=t[2],h=t[3],u=t[4],p=t[5],v=t[6],f=t[7],x=t[8];return e*u*x-e*p*f-s*h*x+s*p*v+a*h*f-a*u*v}invert(){const t=this.elements,e=t[0],s=t[1],a=t[2],h=t[3],u=t[4],p=t[5],v=t[6],f=t[7],x=t[8],w=x*u-p*f,A=p*v-x*h,k=f*h-u*v,L=e*w+s*A+a*k;if(L===0)return this.set(0,0,0,0,0,0,0,0,0);const C=1/L;return t[0]=w*C,t[1]=(a*f-x*s)*C,t[2]=(p*s-a*u)*C,t[3]=A*C,t[4]=(x*e-a*v)*C,t[5]=(a*h-p*e)*C,t[6]=k*C,t[7]=(s*v-f*e)*C,t[8]=(u*e-s*h)*C,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,a,h,u,p){const v=Math.cos(h),f=Math.sin(h);return this.set(s*v,s*f,-s*(v*u+f*p)+u+t,-a*f,a*v,-a*(-f*u+v*p)+p+e,0,0,1),this}scale(t,e){return this.premultiply(va.makeScale(t,e)),this}rotate(t){return this.premultiply(va.makeRotation(-t)),this}translate(t,e){return this.premultiply(va.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof te?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let a=0;a<9;a++)if(e[a]!==s[a])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new bh().fromArray(this.elements)}};Fa.IDENTITY=Object.freeze(new Fa);let sa=Fa;const va=new sa,En=1e-6,Qt=2*Math.PI,od={x:0,y:0},eo={x:0,y:0,z:0};class ro{constructor(){this.equalPointTol=En,this.equalVectorTol=En}equalPoint2d(t,e){return new te(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new q(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=En){return t<e&&t>-e}static equal(t,e,s=En){return Math.abs(t-e)<s}static great(t,e,s=En){return t-e>s}static less(t,e,s=En){return t-e<s}}const no=new ro;function so(n,t,e=!1){const s=n.x,a=n.y;let h=!1;const u=t.length;for(let p=0,v=u-1;p<u;v=p++){const f=t[p].x,x=t[p].y,w=t[v].x,A=t[v].y;let k=x>a!=A>a;e&&(k=x>=a!=A>=a),k&&s<(w-f)*(a-x)/(A-x)+f&&(h=!h)}return h}function wh(n,t){if(n.length===0||t.length===0)return!1;const e=new ve().setFromPoints(n),s=new ve().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let a=0;a<n.length;){if(so(n[a],t,!0))return!0;a<n.length-1&&no.equalPoint2d(n[a+1],n[a])&&++a,++a}return!1}const xh={isPointInPolygon:so,isPolygonIntersect:wh};function Ih(n,t){const e=[],s=t-1,a=n;for(let h=0;h<=a;h++)e.push(0);for(let h=1;h<=s-a;h++)e.push(h);for(let h=0;h<=a;h++)e.push(s-a+1);return e}function Sh(n,t){const e=t.length-1,s=n,a=[0];let h=0;for(let p=1;p<=e;p++){const v=t[p][0]-t[p-1][0],f=t[p][1]-t[p-1][1],x=t[p][2]-t[p-1][2],w=Math.sqrt(v*v+f*f+x*x);h+=w,a.push(h)}const u=[];for(let p=0;p<=s;p++)u.push(0);for(let p=1;p<=e-s;p++){const v=a[p]/h;u.push(v*(e-s+1))}for(let p=0;p<=s;p++)u.push(e-s+1);return u}function Ph(n,t){const e=t.length-1,s=n,a=[0];let h=0;for(let p=1;p<=e;p++){const v=t[p][0]-t[p-1][0],f=t[p][1]-t[p-1][1],x=t[p][2]-t[p-1][2],w=Math.sqrt(v*v+f*f+x*x),A=Math.sqrt(w);h+=A,a.push(h)}const u=[];for(let p=0;p<=s;p++)u.push(0);for(let p=1;p<=e-s;p++){const v=a[p]/h;u.push(v*(e-s+1))}for(let p=0;p<=s;p++)u.push(e-s+1);return u}function Mi(n,t,e,s){if(t===0)return e>=s[n]&&e<s[n+1]?1:0;const a=s[n+t]-s[n],h=s[n+t+1]-s[n+1],u=a>1e-10?(e-s[n])/a:0,p=h>1e-10?(s[n+t+1]-e)/h:0;return u*Mi(n,t-1,e,s)+p*Mi(n+1,t-1,e,s)}function Ks(n,t,e,s,a){const h=s.length-1,u=t;if(n=Math.max(e[u],Math.min(e[h+1],n)),Math.abs(n-e[h+1])<1e-8)return[...s[h]];if(Math.abs(n-e[u])<1e-8)return[...s[0]];const p=[0,0,0];let v=0;for(let f=0;f<=h;f++){const x=Mi(f,u,n,e),w=a[f]*x;p[0]+=s[f][0]*w,p[1]+=s[f][1]*w,p[2]+=s[f][2]*w,v+=w}if(v<1e-10){const f=e[e.length-u-1];if(Math.abs(n-f)<1e-8)return[...s[h]];if(Math.abs(n-e[u])<1e-8)return[...s[0]]}return v>1e-10&&(p[0]/=v,p[1]/=v,p[2]/=v),p}function Ah(n,t,e,s){const a=n,h=t[a],u=t[t.length-a-1];let p=0;const v=1e3,f=(u-h)/v;let x=Ks(h,n,t,e,s);for(let C=1;C<=v;C++){const V=h+C*f,z=Ks(V,n,t,e,s),at=z[0]-x[0],_t=z[1]-x[1],st=z[2]-x[2];p+=Math.sqrt(at*at+_t*_t+st*st),x=z}const w=Ks(u,n,t,e,s),A=w[0]-x[0],k=w[1]-x[1],L=w[2]-x[2];return p+=Math.sqrt(A*A+k*k+L*L),p}function ld(n){return n.map(t=>[...t])}class Cn{constructor(t=0,e=0,s=0,a=1){this._x=t,this._y=e,this._z=s,this._w=a}static slerpFlat(t,e,s,a,h,u,p){let v=s[a+0],f=s[a+1],x=s[a+2],w=s[a+3];const A=h[u+0],k=h[u+1],L=h[u+2],C=h[u+3];if(p===0){t[e+0]=v,t[e+1]=f,t[e+2]=x,t[e+3]=w;return}if(p===1){t[e+0]=A,t[e+1]=k,t[e+2]=L,t[e+3]=C;return}if(w!==C||v!==A||f!==k||x!==L){let V=1-p;const z=v*A+f*k+x*L+w*C,at=z>=0?1:-1,_t=1-z*z;if(_t>Number.EPSILON){const H=Math.sqrt(_t),dt=Math.atan2(H,z*at);V=Math.sin(V*dt)/H,p=Math.sin(p*dt)/H}const st=p*at;if(v=v*V+A*st,f=f*V+k*st,x=x*V+L*st,w=w*V+C*st,V===1-p){const H=1/Math.sqrt(v*v+f*f+x*x+w*w);v*=H,f*=H,x*=H,w*=H}}t[e]=v,t[e+1]=f,t[e+2]=x,t[e+3]=w}static multiplyQuaternionsFlat(t,e,s,a,h,u){const p=s[a],v=s[a+1],f=s[a+2],x=s[a+3],w=h[u],A=h[u+1],k=h[u+2],L=h[u+3];return t[e]=p*L+x*w+v*k-f*A,t[e+1]=v*L+x*A+f*w-p*k,t[e+2]=f*L+x*k+p*A-v*w,t[e+3]=x*L-p*w-v*A-f*k,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,a){return this._x=t,this._y=e,this._z=s,this._w=a,this._onChangeCallback(),this}clone(){return new Cn(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t.x,a=t.y,h=t.z,u=t.order,p=Math.cos,v=Math.sin,f=p(s/2),x=p(a/2),w=p(h/2),A=v(s/2),k=v(a/2),L=v(h/2);switch(u){case"XYZ":this._x=A*x*w+f*k*L,this._y=f*k*w-A*x*L,this._z=f*x*L+A*k*w,this._w=f*x*w-A*k*L;break;case"YXZ":this._x=A*x*w+f*k*L,this._y=f*k*w-A*x*L,this._z=f*x*L-A*k*w,this._w=f*x*w+A*k*L;break;case"ZXY":this._x=A*x*w-f*k*L,this._y=f*k*w+A*x*L,this._z=f*x*L+A*k*w,this._w=f*x*w-A*k*L;break;case"ZYX":this._x=A*x*w-f*k*L,this._y=f*k*w+A*x*L,this._z=f*x*L-A*k*w,this._w=f*x*w+A*k*L;break;case"YZX":this._x=A*x*w+f*k*L,this._y=f*k*w+A*x*L,this._z=f*x*L-A*k*w,this._w=f*x*w-A*k*L;break;case"XZY":this._x=A*x*w-f*k*L,this._y=f*k*w-A*x*L,this._z=f*x*L+A*k*w,this._w=f*x*w+A*k*L;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,a=Math.sin(s);return this._x=t.x*a,this._y=t.y*a,this._z=t.z*a,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],a=e[4],h=e[8],u=e[1],p=e[5],v=e[9],f=e[2],x=e[6],w=e[10],A=s+p+w;if(A>0){const k=.5/Math.sqrt(A+1);this._w=.25/k,this._x=(x-v)*k,this._y=(h-f)*k,this._z=(u-a)*k}else if(s>p&&s>w){const k=2*Math.sqrt(1+s-p-w);this._w=(x-v)/k,this._x=.25*k,this._y=(a+u)/k,this._z=(h+f)/k}else if(p>w){const k=2*Math.sqrt(1+p-s-w);this._w=(h-f)/k,this._x=(a+u)/k,this._y=.25*k,this._z=(v+x)/k}else{const k=2*Math.sqrt(1+w-s-p);this._w=(u-a)/k,this._x=(h+f)/k,this._y=(v+x)/k,this._z=.25*k}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Dr(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const a=Math.min(1,e/s);return this.slerp(t,a),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,a=t._y,h=t._z,u=t._w,p=e._x,v=e._y,f=e._z,x=e._w;return this._x=s*x+u*p+a*f-h*v,this._y=a*x+u*v+h*p-s*f,this._z=h*x+u*f+s*v-a*p,this._w=u*x-s*p-a*v-h*f,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,a=this._y,h=this._z,u=this._w;let p=u*t._w+s*t._x+a*t._y+h*t._z;if(p<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,p=-p):this.copy(t),p>=1)return this._w=u,this._x=s,this._y=a,this._z=h,this;const v=1-p*p;if(v<=Number.EPSILON){const k=1-e;return this._w=k*u+e*this._w,this._x=k*s+e*this._x,this._y=k*a+e*this._y,this._z=k*h+e*this._z,this.normalize(),this}const f=Math.sqrt(v),x=Math.atan2(f,p),w=Math.sin((1-e)*x)/f,A=Math.sin(e*x)/f;return this._w=u*w+this._w*A,this._x=s*w+this._x*A,this._y=a*w+this._y*A,this._z=h*w+this._z*A,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),a=Math.sqrt(1-s),h=Math.sqrt(s);return this.set(a*Math.sin(t),a*Math.cos(t),h*Math.sin(e),h*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Te=class Eh{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const a=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0);if(a!==0){if(a===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(a===1){const{x:h,y:u,z:p}=t;this.x=h,this.y=u,this.z=p||0;return}if(a===3){this.x=t,this.y=e,this.z=s;return}throw Ze.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new Eh(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Il.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Il.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[3]*s+h[6]*a,this.y=h[1]*e+h[4]*s+h[7]*a,this.z=h[2]*e+h[5]*s+h[8]*a,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,a=this.z,h=t.elements,u=1/(h[3]*e+h[7]*s+h[11]*a+h[15]);return this.x=(h[0]*e+h[4]*s+h[8]*a+h[12])*u,this.y=(h[1]*e+h[5]*s+h[9]*a+h[13])*u,this.z=(h[2]*e+h[6]*s+h[10]*a+h[14])*u,this}applyQuaternion(t){const e=this.x,s=this.y,a=this.z,h=t.x,u=t.y,p=t.z,v=t.w,f=2*(u*a-p*s),x=2*(p*e-h*a),w=2*(h*s-u*e);return this.x=e+v*f+u*w-p*x,this.y=s+v*x+p*f-h*w,this.z=a+v*w+h*x-u*f,this}transformDirection(t){const e=this.x,s=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[4]*s+h[8]*a,this.y=h[1]*e+h[5]*s+h[9]*a,this.z=h[2]*e+h[6]*s+h[10]*a,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),s=this.length(),a=t.length();return Math.abs(e)===s*a}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,a=t.y,h=t.z,u=e.x,p=e.y,v=e.z;return this.x=a*v-h*p,this.y=h*u-s*v,this.z=s*p-a*u,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return ba.copy(this).projectOnVector(t),this.sub(ba)}reflect(t){return this.sub(ba.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,a=this.z-t.z;return e*e+s*s+a*a}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),a=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=a,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Te.ORIGIN=Object.freeze(new Te(0,0,0)),Te.X_AXIS=Object.freeze(new Te(1,0,0)),Te.NEGATIVE_X_AXIS=Object.freeze(new Te(-1,0,0)),Te.Y_AXIS=Object.freeze(new Te(0,1,0)),Te.NEGATIVE_Y_AXIS=Object.freeze(new Te(0,-1,0)),Te.Z_AXIS=Object.freeze(new Te(0,0,1)),Te.NEGATIVE_Z_AXIS=Object.freeze(new Te(0,0,-1));let q=Te;const ba=new q,Il=new Cn,za=class kh{constructor(t,e,s,a,h,u,p,v,f,x,w,A,k,L,C,V){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&a!=null&&h!=null&&u!=null&&p!=null&&v!=null&&f!=null&&x!=null&&w!=null&&A!=null&&k!=null&&L!=null&&C!=null&&V!=null&&this.set(t,e,s,a,h,u,p,v,f,x,w,A,k,L,C,V)}set(t,e,s,a,h,u,p,v,f,x,w,A,k,L,C,V){const z=this.elements;return z[0]=t,z[4]=e,z[8]=s,z[12]=a,z[1]=h,z[5]=u,z[9]=p,z[13]=v,z[2]=f,z[6]=x,z[10]=w,z[14]=A,z[3]=k,z[7]=L,z[11]=C,z[15]=V,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new kh().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(no.equalPoint3d(t,q.Z_AXIS))this.identity();else{const e=new q(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(q.Y_AXIS,t).normalize():e.crossVectors(q.Z_AXIS,t).normalize();const s=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,s.x,s.y,s.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,a=1/qn.setFromMatrixColumn(t,0).length(),h=1/qn.setFromMatrixColumn(t,1).length(),u=1/qn.setFromMatrixColumn(t,2).length();return e[0]=s[0]*a,e[1]=s[1]*a,e[2]=s[2]*a,e[3]=0,e[4]=s[4]*h,e[5]=s[5]*h,e[6]=s[6]*h,e[7]=0,e[8]=s[8]*u,e[9]=s[9]*u,e[10]=s[10]*u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(hd,t,ud)}lookAt(t,e,s){const a=this.elements;return Ge.subVectors(t,e),Ge.lengthSq()===0&&(Ge.z=1),Ge.normalize(),rn.crossVectors(s,Ge),rn.lengthSq()===0&&(Math.abs(s.z)===1?Ge.x+=1e-4:Ge.z+=1e-4,Ge.normalize(),rn.crossVectors(s,Ge)),rn.normalize(),_i.crossVectors(Ge,rn),a[0]=rn.x,a[4]=_i.x,a[8]=Ge.x,a[1]=rn.y,a[5]=_i.y,a[9]=Ge.y,a[2]=rn.z,a[6]=_i.z,a[10]=Ge.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,a=e.elements,h=this.elements,u=s[0],p=s[4],v=s[8],f=s[12],x=s[1],w=s[5],A=s[9],k=s[13],L=s[2],C=s[6],V=s[10],z=s[14],at=s[3],_t=s[7],st=s[11],H=s[15],dt=a[0],it=a[4],Wt=a[8],$t=a[12],Xt=a[1],xt=a[5],Bt=a[9],be=a[13],we=a[2],ze=a[6],se=a[10],pe=a[14],Q=a[3],Lt=a[7],me=a[11],wr=a[15];return h[0]=u*dt+p*Xt+v*we+f*Q,h[4]=u*it+p*xt+v*ze+f*Lt,h[8]=u*Wt+p*Bt+v*se+f*me,h[12]=u*$t+p*be+v*pe+f*wr,h[1]=x*dt+w*Xt+A*we+k*Q,h[5]=x*it+w*xt+A*ze+k*Lt,h[9]=x*Wt+w*Bt+A*se+k*me,h[13]=x*$t+w*be+A*pe+k*wr,h[2]=L*dt+C*Xt+V*we+z*Q,h[6]=L*it+C*xt+V*ze+z*Lt,h[10]=L*Wt+C*Bt+V*se+z*me,h[14]=L*$t+C*be+V*pe+z*wr,h[3]=at*dt+_t*Xt+st*we+H*Q,h[7]=at*it+_t*xt+st*ze+H*Lt,h[11]=at*Wt+_t*Bt+st*se+H*me,h[15]=at*$t+_t*be+st*pe+H*wr,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],a=t[8],h=t[12],u=t[1],p=t[5],v=t[9],f=t[13],x=t[2],w=t[6],A=t[10],k=t[14],L=t[3],C=t[7],V=t[11],z=t[15];return L*(+h*v*w-a*f*w-h*p*A+s*f*A+a*p*k-s*v*k)+C*(+e*v*k-e*f*A+h*u*A-a*u*k+a*f*x-h*v*x)+V*(+e*f*w-e*p*k-h*u*w+s*u*k+h*p*x-s*f*x)+z*(-a*p*x-e*v*w+e*p*A+a*u*w-s*u*A+s*v*x)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const a=this.elements;return t instanceof q?(a[12]=t.x,a[13]=t.y,a[14]=t.z):(a[12]=t,a[13]=e,a[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],a=t[2],h=t[3],u=t[4],p=t[5],v=t[6],f=t[7],x=t[8],w=t[9],A=t[10],k=t[11],L=t[12],C=t[13],V=t[14],z=t[15],at=w*V*f-C*A*f+C*v*k-p*V*k-w*v*z+p*A*z,_t=L*A*f-x*V*f-L*v*k+u*V*k+x*v*z-u*A*z,st=x*C*f-L*w*f+L*p*k-u*C*k-x*p*z+u*w*z,H=L*w*v-x*C*v-L*p*A+u*C*A+x*p*V-u*w*V,dt=e*at+s*_t+a*st+h*H;if(dt===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const it=1/dt;return t[0]=at*it,t[1]=(C*A*h-w*V*h-C*a*k+s*V*k+w*a*z-s*A*z)*it,t[2]=(p*V*h-C*v*h+C*a*f-s*V*f-p*a*z+s*v*z)*it,t[3]=(w*v*h-p*A*h-w*a*f+s*A*f+p*a*k-s*v*k)*it,t[4]=_t*it,t[5]=(x*V*h-L*A*h+L*a*k-e*V*k-x*a*z+e*A*z)*it,t[6]=(L*v*h-u*V*h-L*a*f+e*V*f+u*a*z-e*v*z)*it,t[7]=(u*A*h-x*v*h+x*a*f-e*A*f-u*a*k+e*v*k)*it,t[8]=st*it,t[9]=(L*w*h-x*C*h-L*s*k+e*C*k+x*s*z-e*w*z)*it,t[10]=(u*C*h-L*p*h+L*s*f-e*C*f-u*s*z+e*p*z)*it,t[11]=(x*p*h-u*w*h-x*s*f+e*w*f+u*s*k-e*p*k)*it,t[12]=H*it,t[13]=(x*C*a-L*w*a+L*s*A-e*C*A-x*s*V+e*w*V)*it,t[14]=(L*p*a-u*C*a-L*s*v+e*C*v+u*s*V-e*p*V)*it,t[15]=(u*w*a-x*p*a+x*s*v-e*w*v-u*s*A+e*p*A)*it,this}scale(t){const e=this.elements,s=t.x,a=t.y,h=t.z;return e[0]*=s,e[4]*=a,e[8]*=h,e[1]*=s,e[5]*=a,e[9]*=h,e[2]*=s,e[6]*=a,e[10]*=h,e[3]*=s,e[7]*=a,e[11]*=h,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],a=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,a))}makeTranslation(t,e,s){return t instanceof q?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),a=Math.sin(e),h=1-s,u=t.x,p=t.y,v=t.z,f=h*u,x=h*p;return this.set(f*u+s,f*p-a*v,f*v+a*p,0,f*p+a*v,x*p+s,x*v-a*u,0,f*v-a*p,x*v+a*u,h*v*v+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,a,h,u){return this.set(1,s,h,0,t,1,u,0,e,a,1,0,0,0,0,1),this}compose(t,e,s){const a=this.elements,h=e.x,u=e.y,p=e.z,v=e.w,f=h+h,x=u+u,w=p+p,A=h*f,k=h*x,L=h*w,C=u*x,V=u*w,z=p*w,at=v*f,_t=v*x,st=v*w,H=s.x,dt=s.y,it=s.z;return a[0]=(1-(C+z))*H,a[1]=(k+st)*H,a[2]=(L-_t)*H,a[3]=0,a[4]=(k-st)*dt,a[5]=(1-(A+z))*dt,a[6]=(V+at)*dt,a[7]=0,a[8]=(L+_t)*it,a[9]=(V-at)*it,a[10]=(1-(A+C))*it,a[11]=0,a[12]=t.x,a[13]=t.y,a[14]=t.z,a[15]=1,this}decompose(t,e,s){const a=this.elements;let h=qn.set(a[0],a[1],a[2]).length();const u=qn.set(a[4],a[5],a[6]).length(),p=qn.set(a[8],a[9],a[10]).length();this.determinant()<0&&(h=-h),t.x=a[12],t.y=a[13],t.z=a[14],hr.copy(this);const v=1/h,f=1/u,x=1/p;return hr.elements[0]*=v,hr.elements[1]*=v,hr.elements[2]*=v,hr.elements[4]*=f,hr.elements[5]*=f,hr.elements[6]*=f,hr.elements[8]*=x,hr.elements[9]*=x,hr.elements[10]*=x,e.setFromRotationMatrix(hr),s.x=h,s.y=u,s.z=p,this}equals(t){const e=this.elements,s=t.elements;for(let a=0;a<16;a++)if(e[a]!==s[a])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};za.IDENTITY=Object.freeze(new za);let $e=za;const qn=new q,hr=new $e,hd=new q(0,0,0),ud=new q(1,1,1),rn=new q,_i=new q,Ge=new q;class Nt{constructor(t=void 0,e=void 0){this.min=t==null?new q(1/0,1/0,1/0):new q(t.x,t.y,t.z),this.max=e==null?new q(-1/0,-1/0,-1/0):new q(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(wa.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=wa.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Nt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new q(0,0,0):new q(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new q(0,0,0):new q(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,wa).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ar[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ar[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ar[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ar[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ar[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ar[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ar[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ar[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ar),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Ar=[new q,new q,new q,new q,new q,new q,new q,new q],wa=new q,Sl=new te;class ve{constructor(t=void 0,e=void 0){this.min=t==null?new te(1/0,1/0):new te(t.x,t.y),this.max=e==null?new te(-1/0,-1/0):new te(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Sl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new ve().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new te(0,0):new te(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new te(0,0):new te(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Sl).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Pl=new q,cd=new q,dd=new sa;class ai{constructor(t=new q(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,a){return this.normal.set(t,e,s),this.constant=a,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const a=Pl.subVectors(s,e).cross(cd.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(a,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||dd.getNormalMatrix(t),a=this.coplanarPoint(Pl).applyMatrix4(t),h=this.normal.applyMatrix3(s).normalize();return this.constant=-a.dot(h),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new ai().copy(this)}}class Et extends te{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,a)=>{s.toArray(e,a*2)}),e}}class G extends q{static pointArrayToNumberArray(t,e=!0){const s=e?3:2,a=new Array(t.length*s);return t.forEach((h,u)=>{h.toArray(a,u*s)}),a}}const Al=new $e,El=new Cn,Mh=class Va{constructor(t=0,e=0,s=0,a=Va.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=a}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,a=this._order){return this._x=t,this._y=e,this._z=s,this._order=a,this._onChangeCallback(),this}clone(){return new Va(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const a=t.elements,h=a[0],u=a[4],p=a[8],v=a[1],f=a[5],x=a[9],w=a[2],A=a[6],k=a[10];switch(e){case"XYZ":this._y=Math.asin(Dr(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(-x,k),this._z=Math.atan2(-u,h)):(this._x=Math.atan2(A,f),this._z=0);break;case"YXZ":this._x=Math.asin(-Dr(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(p,k),this._z=Math.atan2(v,f)):(this._y=Math.atan2(-w,h),this._z=0);break;case"ZXY":this._x=Math.asin(Dr(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(-w,k),this._z=Math.atan2(-u,f)):(this._y=0,this._z=Math.atan2(v,h));break;case"ZYX":this._y=Math.asin(-Dr(w,-1,1)),Math.abs(w)<.9999999?(this._x=Math.atan2(A,k),this._z=Math.atan2(v,h)):(this._x=0,this._z=Math.atan2(-u,f));break;case"YZX":this._z=Math.asin(Dr(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(-x,f),this._y=Math.atan2(-w,h)):(this._x=0,this._y=Math.atan2(p,k));break;case"XZY":this._z=Math.asin(-Dr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(A,f),this._y=Math.atan2(p,h)):(this._x=Math.atan2(-x,k),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return Al.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Al,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return El.setFromEuler(this),this.setFromQuaternion(El,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Mh.DEFAULT_ORDER="XYZ";let pd=Mh;class Th{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}let io=class extends Th{translate(t){return this.transform(new sa().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}};class ia extends io{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new ve}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const a=this.loops[s].getPoints(t);e.push(a)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),a=this.sortBoundaryBoxesByAreas(s),h=new Map,u=a.length;for(let v=0;v<u;v++)h.set(a[v],{index:a[v],children:[]});const p={index:-1,children:[]};for(let v=0;v<u;v++){const f=a[v],x=e[f],w=s[f];let A=v+1;for(;A<u;A++){const k=a[A],L=e[k];if(s[k].containsBox(w)&&xh.isPointInPolygon(x[St.randInt(0,x.length-1)],L)){(t=h.get(k))==null||t.children.push(h.get(f));break}}A===u&&p.children.push(h.get(f))}return p}get area(){if(this._loops.length===0)return 0;let t=0;for(let e=0;e<this._loops.length;e++){const s=this._loops[e].getPoints(128),a=this.polygonArea(s);e===0?t+=Math.abs(a):t-=Math.abs(a)}return t}polygonArea(t){const e=t.length;if(e<3)return 0;let s=0;for(let a=0,h=e-1;a<e;h=a++){const u=t[h],p=t[a];s+=u.x*p.y-p.x*u.y}return s*.5}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new ve().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((a,h)=>{const u=a.size,p=u.width*u.height;e.push({area:p,index:h})}),e.sort((a,h)=>a.area-h.area);const s=[];return e.forEach(a=>{s.push(a.index)}),s}}class ss extends io{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,a=this.getPoint(0),h=0;e.push(0);for(let u=1;u<=t;u++)s=this.getPoint(u/t),h+=s.distanceTo(a),e.push(h),a=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let a=0;const h=s.length;let u;e?u=e:u=t*s[h-1];let p=0,v=h-1,f;for(;p<=v;)if(a=Math.floor(p+(v-p)/2),f=s[a]-u,f<0)p=a+1;else if(f>0)v=a-1;else{v=a;break}if(a=v,s[a]===u)return a/(h-1);const x=s[a],w=s[a+1]-x,A=(u-x)/w;return(a+A)/(h-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const a=this.getPoint(e),h=this.getPoint(s),u=new Et;return u.copy(h).sub(a).normalize(),u}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class Nn extends ss{constructor(t,e,s,a,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(u==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(u==5){const p=t;this.center=new Et(p.x,p.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(s)):St.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(a)):St.normalizeAngle(a)}else throw Ze.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const a=(it,Wt)=>({x:(it.x+Wt.x)/2,y:(it.y+Wt.y)/2}),h=(it,Wt)=>(Wt.y-it.y)/(Wt.x-it.x),u=it=>-1/it,p=a(t,e),v=a(e,s),f=h(t,e),x=h(e,s),w=u(f),A=u(x),k=(it,Wt,$t,Xt)=>{const xt=(Xt-Wt)/(it-$t),Bt=it*xt+Wt;return{x:xt,y:Bt}},L=p.y-w*p.x,C=v.y-A*v.x,V=k(w,L,A,C),z=Math.sqrt(Math.pow(t.x-V.x,2)+Math.pow(t.y-V.y,2)),at=(it,Wt)=>Math.atan2(it.y-Wt.y,it.x-Wt.x),_t=at(t,V),st=at(e,V),H=at(s,V),dt=H>_t&&H<st||_t>H&&_t<st||st>H&&st<_t;this.center=V,this.radius=z,this._clockwise=!dt,this._startAngle=_t,this._endAngle=H}createByStartEndPointsAndBulge(t,e,s){let a,h,u;s<0?(a=Math.atan(-s)*4,h=new te(t),u=new te(e)):(a=Math.atan(s)*4,h=new te(e),u=new te(t));const p=new te().subVectors(u,h),v=p.length(),f=new te().addVectors(h,p.multiplyScalar(.5)),x=Math.abs(v/2/Math.tan(a/2)),w=p.normalize();let A;if(a<Math.PI){const k=new te(w.x*Math.cos(Math.PI/2)-w.y*Math.sin(Math.PI/2),w.y*Math.cos(Math.PI/2)+w.x*Math.sin(Math.PI/2));A=f.add(k.multiplyScalar(-x))}else{const k=new te(w.x*Math.cos(Math.PI/2)-w.y*Math.sin(Math.PI/2),w.y*Math.cos(Math.PI/2)+w.x*Math.sin(Math.PI/2));A=f.add(k.multiplyScalar(x))}s<0?(this._startAngle=Math.atan2(h.y-A.y,h.x-A.x),this._endAngle=Math.atan2(u.y-A.y,u.x-A.x)):(this._startAngle=Math.atan2(u.y-A.y,u.x-A.x),this._endAngle=Math.atan2(h.y-A.y,h.x-A.x)),this._clockwise=s<0,this.center=A,this.radius=u.sub(A).length()}get center(){return this._center}set center(t){this._center=new Et(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(t)):St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const e=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(e):e,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return this.clockwise?St.normalizeAngle(t-e):St.normalizeAngle(e-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=St.normalizeAngle((t+e)/2),a=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(a)}get closed(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return Math.abs(e-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of e){const u=this._getInternalAngle(h);St.isBetweenAngle(u,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const s=t.map(h=>h.x),a=t.map(h=>h.y);return new ve(new Et(Math.min(...s),Math.min(...a)),new Et(Math.max(...s),Math.max(...a)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Nn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),s=this.center.x+this.radius*Math.cos(e),a=this.center.y+this.radius*Math.sin(e);return new Et(s,a)}getPoints(t=100){const e=[];let s=this.deltaAngle,a=this._getInternalAngle(this.startAngle);if(this.closed&&(s=Qt,a=0),this.clockwise)for(let h=0;h<=t;h++){const u=a-s*(h/t),p=this._clockwise?this._mirrorAngle(u):u,v=this.getPointAtAngle(p);e.push(new Et(v.x,v.y))}else for(let h=0;h<=t;h++){const u=a+s*(h/t),p=this._clockwise?this._mirrorAngle(u):u,v=this.getPointAtAngle(p);e.push(new Et(v.x,v.y))}return e}}class md extends Th{translate(t){return this.transform(new $e().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class oi extends md{}let es=class Nh extends oi{constructor(t,e){super(),this._start=new G(t),this._end=new G(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new q().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new G((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(t){return this.project(t)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const s=this.delta(yn).normalize();return new G(this._start).addScaledVector(s,t)}else{const s=this.delta(yn).normalize();return new G(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=yn.subVectors(this._start,this._end).normalize();this._start=new G(this._start).addScaledVector(s,t)}else{const s=this.delta(yn).normalize();this._end=new G(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){kl.subVectors(t,this._start),fi.subVectors(this.endPoint,this.startPoint);const s=fi.dot(fi);let a=fi.dot(kl)/s;return e&&(a=St.clamp(a,0,1)),a}closestPointToPoint(t,e,s){const a=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(a).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=yn.subVectors(t,this.startPoint).dot(e);return new G().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,a=yn.subVectors(t,s).dot(e),h=yn.copy(e).multiplyScalar(a);return new G().addVectors(s,h)}calculateBoundingBox(){const t=new G(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new G(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 Nt(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Nh(this._start.clone(),this._end.clone())}};const yn=new q,kl=new q,fi=new q;let ao=class wi extends oi{static computeCenterPoint(t,e,s){const a=new q().addVectors(t,e).multiplyScalar(.5),h=new q().addVectors(t,s).multiplyScalar(.5),u=new q().subVectors(e,t),p=new q().subVectors(s,t),v=new q().crossVectors(u,p).normalize();if(v.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new q().crossVectors(u,v).normalize(),x=new q().crossVectors(p,v).normalize(),w=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),A=x.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),k=new es(a,a.clone().add(w)),L=new es(h,h.clone().add(A)),C=new q;return k.closestPointToPoint(L.startPoint,!0,C)?C:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const a=wi.computeCenterPoint(t,e,s);if(a){const h=a.distanceTo(t),u=new q().subVectors(t,a),p=new q().subVectors(e,a),v=Math.atan2(u.y,u.x),f=Math.atan2(p.y,p.x);return new wi(a,h,v,f,q.Z_AXIS)}}constructor(t,e,s,a,h,u=q.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=a,this.normal=h,this.refVec=u,(a-s)%Qt==0?(this.startAngle=0,this.endAngle=Qt):(this.startAngle=s,this.endAngle=a)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return St.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new q(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new q(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;this.closed&&(t=0,e=Qt);const s=t+e*.5;return this.getPointAtAngle(s)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const e=new q(t.x,t.y,t.z||0),s=this.center,a=this.normal,h=e.clone().sub(s).dot(a),u=e.clone().sub(a.clone().multiplyScalar(h)).clone().sub(s);if(u.lengthSq()===0)return this.startPoint.clone();u.normalize().multiplyScalar(this.radius);const p=s.clone().add(u),v=this.getAngle(p.clone()),f=this.startAngle,x=this.deltaAngle;let w=St.normalizeAngle(v-f);w<0&&(w=0),w>x&&(w=x);const A=this.getPointAtAngle(f+w),k=A.distanceTo(e),L=this.startPoint.distanceTo(e),C=this.endPoint.distanceTo(e);return L<k&&L<=C?this.startPoint.clone():C<k&&C<L?this.endPoint.clone():A}tangentPoints(t){const e=[],s=new q(t.x,t.y,t.z||0),a=this.center,h=this.normal,u=this.radius,p=s.clone().sub(a).dot(h),v=s.clone().sub(h.clone().multiplyScalar(p)),f=a.clone(),x=v.clone().sub(f).length();if(x<u)return e;const w=Math.acos(u/x),A=this.getAngle(v.clone()),k=[A+w,A-w];for(const L of k){const C=St.normalizeAngle(L-this.startAngle);C>=0&&C<=this.deltaAngle&&e.push(this.getPointAtAngle(this.startAngle+C))}return e}nearestTangentPoint(t){const e=this.tangentPoints(t);if(e.length===0)return null;const s=new G(t.x,t.y,t.z||0);return e.length===1||e[0].distanceTo(s)<e[1].distanceTo(s)?e[0]:e[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let v=0;v<2*Math.PI;v+=Math.PI/2)St.isBetweenAngle(v,this.startAngle,this.endAngle)&&t.push(v);let e=1/0,s=1/0,a=1/0,h=-1/0,u=-1/0,p=-1/0;for(const v of t){const f=this.getPointAtAngle(v);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>p&&(p=f.z)}return new Nt({x:e,y:s,z:a},{x:h,y:u,z:p})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,a=this.startAngle;this.closed&&(s=Qt,a=0);for(let h=0;h<=t;h++){const u=a+s*(h/t),p=this.getPointAtAngle(u);e.push(p)}return e}transform(t){const e=xa.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=xa.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),s.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new wi(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(xa.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,a={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},h=this.center,u=this.radius;return new G(h.x+u*(s.x*Math.cos(t)+a.x*Math.sin(t)),h.y+u*(s.y*Math.cos(t)+a.y*Math.sin(t)),h.z+u*(s.z*Math.cos(t)+a.z*Math.sin(t)))}get plane(){const t=new q(this.center).distanceTo(eo);return new ai(this.normal,t)}};const xa=new q;class li extends ss{constructor(t,e,s,a=0,h=Qt,u=!1,p=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(h-a)%Qt==0?(this.startAngle=0,this.endAngle=Qt):(this.startAngle=a,this.endAngle=h),this.clockwise=u,this.rotation=p}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return St.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,a=-1/0;for(let h=0;h<=100;h++){const u=this.getPoint(h/100);t=Math.min(t,u.x),e=Math.min(e,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y)}return new ve({x:t,y:e},{x:s,y:a})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(a?s=0:s=e),this.clockwise===!0&&!a&&(s===e?s=-e:s=s-e);const h=this.startAngle+t*s;let u=this.center.x+this.majorAxisRadius*Math.cos(h),p=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const v=Math.cos(this.rotation),f=Math.sin(this.rotation),x=u-this.center.x,w=p-this.center.y;u=x*v-w*f+this.center.x,p=x*f+w*v+this.center.y}return new Et(u,p)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new li(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class aa extends oi{constructor(t,e,s,a,h,u=0,p=Qt){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=a,this.minorAxisRadius=h;const v=Math.abs(p-u);Math.abs(v-Qt)<1e-10||Math.abs(v-2*Qt)<1e-10?(this.startAngle=0,this.endAngle=Qt):(this.startAngle=u,this.endAngle=p)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-Qt)<1e-10?Qt:St.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new q(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new q(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new q().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;(this.closed||Math.abs(e-Qt)<1e-10)&&(t=0,e=Qt);const s=t+e/2;return this.getPointAtAngle(s)}get isCircular(){return ro.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let s=0,a=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const u=this.startAngle+h*e,p=this.getPointAtAngle(u),v=p.x-a.x,f=p.y-a.y,x=p.z-a.z;s+=Math.sqrt(v*v+f*f+x*x),a=p}return s}get area(){const t=this.majorAxisRadius,e=this.minorAxisRadius,s=this.startAngle,a=s+this.deltaAngle;if(Math.abs(this.deltaAngle-Qt)<1e-10)return Math.PI*t*e;const h=t*e/2*(a-s-(Math.sin(a)*Math.cos(a)-Math.sin(s)*Math.cos(s)));return Math.abs(h)}calculateBoundingBox(){if(this.majorAxis.equals(q.X_AXIS)||this.majorAxis.equals(q.Y_AXIS)||this.majorAxis.isParallelTo(q.X_AXIS)||this.majorAxis.isParallelTo(q.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let v=0;v<2*Math.PI;v+=Math.PI/2)St.isBetweenAngle(v,this.startAngle,this.endAngle)&&t.push(v);let e=1/0,s=1/0,a=1/0,h=-1/0,u=-1/0,p=-1/0;for(const v of t){const f=this.getPointAtAngle(v);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>p&&(p=f.z)}return new Nt({x:e,y:s,z:a},{x:h,y:u,z:p})}else{let t=1/0,e=1/0,s=1/0,a=-1/0,h=-1/0,u=-1/0;for(let p=0;p<=100;p++){const v=this.startAngle+this.deltaAngle*(p/100),f=this.getPointAtAngle(v);t=Math.min(t,f.x),e=Math.min(e,f.y),s=Math.min(s,f.z),a=Math.max(a,f.x),h=Math.max(h,f.y),u=Math.max(u,f.z)}return new Nt({x:t,y:e,z:s},{x:a,y:h,z:u})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,a=this.startAngle;this.closed&&(s=Qt,a=0);for(let h=0;h<=t;h++){const u=a+s*(h/t),p=this.getPointAtAngle(u);e.push(p)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),a=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(a);return new G(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(t){const e=new q(t).sub(this.center),s=e.dot(this.majorAxis),a=e.dot(this.minorAxis),h=s/this.majorAxisRadius,u=a/this.minorAxisRadius;return h*h+u*u<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new aa(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new q(this.center).distanceTo(eo);return new ai(this.normal,t)}}class un extends ss{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new Et(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new Et(e.x,e.y)}else{const e=this._vertices[t-1];return new Et(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let s=0;s<e;++s){const a=this._vertices[s];let h=null;if(s<e-1?h=this._vertices[s+1]:s==e-1&&this.closed&&(h=this._vertices[0]),h)if(a.bulge){const u=new Nn(a,h,a.bulge);t+=u.length}else t+=new Et(a.x,a.y).distanceTo(h)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}removeVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error(`Index ${t} is out of bounds. Valid range is 0 to ${this._vertices.length-1}.`);this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0}reset(t,e){t?e!==void 0&&e>=0&&e<this._vertices.length&&(this._vertices=this._vertices.slice(0,e),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(t){const e=this._vertices[t];return new Et(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new ve().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(a=>s.push(new G().set(a.x,a.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let a=0;a<s;++a){const h=this._vertices[a];if(h.bulge){let u=null;if(a<s-1?u=this._vertices[a+1]:a==s-1&&this.closed&&(u=this._vertices[0]),u){const p=new Nn(h,u,h.bulge).getPoints(t),v=p.length;for(let f=0;f<v;++f){const x=p[f];e.push(new Et(x.x,x.y))}}}else e.push(new Et(h.x,h.y)),a==s-1&&this.closed&&e.push(e[0])}return e}}let ts=class Lh extends ss{constructor(t,e){super(),this._start=new Et(t),this._end=new Et(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new Et(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new Et(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new ve(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Lh(this._start.clone(),this._end.clone())}},oa=class extends ss{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new Et(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new ve;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(a=>{e.push(new Et(a.x,a.y))})}),e}};function gd(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Oh={exports:{}};(function(n,t){(function(e){n.exports=e()})(function(){var e={},s=this;new Function("try {return this===window;}catch(e){ return false;}");var a=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(a()&&h(),a()||h()){var u=s;if(h()){var p=function(v,f){var x=s;return v.split(".").forEach(function(w){x&&(x=x[w])}),x?x[f]:null};onmessage=function(v){if(!(!v.data.className||!v.data.methodName)){var f=p(v.data.className,v.data.methodName);if(!f)return console.error("could not find "+v.data.className+"."+v.data.methodName);postMessage({result:f.apply(null,v.data.args),id:v.data.id})}}}}return function(v,f,x){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var w={},A=function(){return Lt.__string_rec(this,"")};function k(r,i){function o(){}o.prototype=r;var l=new o;for(var c in i)l[c]=i[c];return i.toString!==Object.prototype.toString&&(l.toString=i.toString),l}var L=function(){};w.HxOverrides=L,L.__name__=["HxOverrides"],L.strDate=function(r){var i=r.length;switch(i){case 8:var o=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(o[0]),l.setUTCMinutes(o[1]),l.setUTCSeconds(o[2]),l;case 10:var c=r.split("-");return new Date(c[0],c[1]-1,c[2],0,0,0);case 19:var d=r.split(" "),g=d[0].split("-"),_=d[1].split(":");return new Date(g[0],g[1]-1,g[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},L.cca=function(r,i){var o=r.charCodeAt(i);if(o==o)return o},L.substr=function(r,i,o){return i!=null&&i!=0&&o!=null&&o<0?"":(o==null&&(o=r.length),i<0?(i=r.length+i,i<0&&(i=0)):o<0&&(o=r.length+o-i),r.substr(i,o))},L.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var C=function(){};w.Lambda=C,C.__name__=["Lambda"],C.fold=function(r,i,o){for(var l=sr(r)();l.hasNext();){var c=l.next();o=i(c,o)}return o};var V=function(){this.length=0};w.List=V,V.__name__=["List"],V.prototype={add:function(r){var i=[r];this.h==null?this.h=i:this.q[1]=i,this.q=i,this.length++},pop:function(){if(this.h==null)return null;var r=this.h[0];return this.h=this.h[1],this.h==null&&(this.q=null),this.length--,r},isEmpty:function(){return this.h==null},__class__:V},Math.__name__=["Math"];var z=function(){};w.Reflect=z,z.__name__=["Reflect"],z.field=function(r,i){try{return r[i]}catch(o){return o instanceof Q&&(o=o.val),null}},z.callMethod=function(r,i,o){return i.apply(r,o)},z.fields=function(r){var i=[];if(r!=null){var o=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&o.call(r,l)&&i.push(l)}return i},z.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},z.deleteField=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)?(delete r[i],!0):!1};var at=function(){};w.Std=at,at.__name__=["Std"],at.string=function(r){return Lt.__string_rec(r,"")},at.parseFloat=function(r){return parseFloat(r)};var _t=function(){this.b=""};w.StringBuf=_t,_t.__name__=["StringBuf"],_t.prototype={add:function(r){this.b+=at.string(r)},__class__:_t};var st=function(){};w.StringTools=st,st.__name__=["StringTools"],st.fastCodeAt=function(r,i){return r.charCodeAt(i)};var H=w.ValueType={__ename__:["ValueType"],__constructs__:["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]};H.TNull=["TNull",0],H.TNull.toString=A,H.TNull.__enum__=H,H.TInt=["TInt",1],H.TInt.toString=A,H.TInt.__enum__=H,H.TFloat=["TFloat",2],H.TFloat.toString=A,H.TFloat.__enum__=H,H.TBool=["TBool",3],H.TBool.toString=A,H.TBool.__enum__=H,H.TObject=["TObject",4],H.TObject.toString=A,H.TObject.__enum__=H,H.TFunction=["TFunction",5],H.TFunction.toString=A,H.TFunction.__enum__=H,H.TClass=function(r){var i=["TClass",6,r];return i.__enum__=H,i.toString=A,i},H.TEnum=function(r){var i=["TEnum",7,r];return i.__enum__=H,i.toString=A,i},H.TUnknown=["TUnknown",8],H.TUnknown.toString=A,H.TUnknown.__enum__=H;var dt=function(){};w.Type=dt,dt.__name__=["Type"],dt.getClassName=function(r){var i=r.__name__;return i==null?null:i.join(".")},dt.getEnumName=function(r){var i=r.__ename__;return i.join(".")},dt.resolveClass=function(r){var i=w[r];return i==null||!i.__name__?null:i},dt.resolveEnum=function(r){var i=w[r];return i==null||!i.__ename__?null:i},dt.createEmptyInstance=function(r){function i(){}return i.prototype=r.prototype,new i},dt.createEnum=function(r,i,o){var l=z.field(r,i);if(l==null)throw new Q("No such constructor "+i);if(z.isFunction(l)){if(o==null)throw new Q("Constructor "+i+" need parameters");return z.callMethod(r,l,o)}if(o!=null&&o.length!=0)throw new Q("Constructor "+i+" does not need parameters");return l},dt.getEnumConstructs=function(r){var i=r.__constructs__;return i.slice()},dt.typeof=function(r){var i=typeof r;switch(i){case"boolean":return H.TBool;case"string":return H.TClass(String);case"number":return Math.ceil(r)==r%2147483648?H.TInt:H.TFloat;case"object":if(r==null)return H.TNull;var o=r.__enum__;if(o!=null)return H.TEnum(o);var l=Lt.getClass(r);return l!=null?H.TClass(l):H.TObject;case"function":return r.__name__||r.__ename__?H.TObject:H.TFunction;case"undefined":return H.TNull;default:return H.TUnknown}};var it=function(){};w["haxe.IMap"]=it,it.__name__=["haxe","IMap"];var Wt=function(r,i){this.high=r,this.low=i};w["haxe._Int64.___Int64"]=Wt,Wt.__name__=["haxe","_Int64","___Int64"],Wt.prototype={__class__:Wt};var $t=function(){this.buf=new _t,this.cache=[],this.useCache=$t.USE_CACHE,this.useEnumIndex=$t.USE_ENUM_INDEX,this.shash=new we,this.scount=0};w["haxe.Serializer"]=$t,$t.__name__=["haxe","Serializer"],$t.prototype={toString:function(){return this.buf.b},serializeString:function(r){var i=this.shash.get(r);if(i!=null){this.buf.b+="R",i==null?this.buf.b+="null":this.buf.b+=""+i;return}this.shash.set(r,this.scount++),this.buf.b+="y",r=encodeURIComponent(r),r.length==null?this.buf.b+="null":this.buf.b+=""+r.length,this.buf.b+=":",r==null?this.buf.b+="null":this.buf.b+=""+r},serializeRef:function(r){for(var i=typeof r,o=0,l=this.cache.length;o<l;){var c=o++,d=this.cache[c];if(typeof d==i&&d==r)return this.buf.b+="r",c==null?this.buf.b+="null":this.buf.b+=""+c,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var i=0,o=z.fields(r);i<o.length;){var l=o[i];++i,this.serializeString(l),this.serialize(z.field(r,l))}this.buf.b+="g"},serialize:function(r){{var i=dt.typeof(r);switch(i[1]){case 0:this.buf.b+="n";break;case 1:var o=r;if(o==0){this.buf.b+="z";return}this.buf.b+="i",o==null?this.buf.b+="null":this.buf.b+=""+o;break;case 2:var l=r;isNaN(l)?this.buf.b+="k":isFinite(l)?(this.buf.b+="d",l==null?this.buf.b+="null":this.buf.b+=""+l):l<0?this.buf.b+="m":this.buf.b+="p";break;case 3:r?this.buf.b+="t":this.buf.b+="f";break;case 6:var c=i[2];if(c==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(c){case Array:var d=0;this.buf.b+="a";for(var g=r.length,_=0;_<g;){var y=_++;r[y]==null?d++:(d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d),d=0),this.serialize(r[y]))}d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d)),this.buf.b+="h";break;case V:this.buf.b+="l";for(var I=r,P=I.h,S=null;P!=null;){var E;S=P[0],P=P[1],E=S,this.serialize(E)}this.buf.b+="h";break;case Date:var M=r;this.buf.b+="v",this.buf.add(M.getTime());break;case we:this.buf.b+="b";for(var T=r,B=T.keys();B.hasNext();){var O=B.next();this.serializeString(O),this.serialize(da[O]!=null?T.getReserved(O):T.h[O])}this.buf.b+="h";break;case xt:this.buf.b+="q";for(var F=r,R=F.keys();R.hasNext();){var j=R.next();this.buf.b+=":",j==null?this.buf.b+="null":this.buf.b+=""+j,this.serialize(F.h[j])}this.buf.b+="h";break;case Bt:this.buf.b+="M";for(var D=r,X=D.keys();X.hasNext();){var J=X.next(),Y=z.field(J,"__id__");z.deleteField(J,"__id__"),this.serialize(J),J.__id__=Y,this.serialize(D.h[J.__id__])}this.buf.b+="h";break;case ze:for(var U=r,$=0,tt=U.length-2,et=new _t,ot=$t.BASE64;$<tt;){var ct=U.get($++),ht=U.get($++),pt=U.get($++);et.add(ot.charAt(ct>>2)),et.add(ot.charAt((ct<<4|ht>>4)&63)),et.add(ot.charAt((ht<<2|pt>>6)&63)),et.add(ot.charAt(pt&63))}if($==tt){var nt=U.get($++),mt=U.get($++);et.add(ot.charAt(nt>>2)),et.add(ot.charAt((nt<<4|mt>>4)&63)),et.add(ot.charAt(mt<<2&63))}else if($==tt+1){var K=U.get($++);et.add(ot.charAt(K>>2)),et.add(ot.charAt(K<<4&63))}var ft=et.b;this.buf.b+="s",ft.length==null?this.buf.b+="null":this.buf.b+=""+ft.length,this.buf.b+=":",ft==null?this.buf.b+="null":this.buf.b+=""+ft;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(dt.getClassName(c)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(dt.getClassName(c)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Lt.__instanceof(r,il)){var kt=dt.getClassName(r);this.buf.b+="A",this.serializeString(kt)}else if(Lt.__instanceof(r,al))this.buf.b+="B",this.serializeString(dt.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Yt=i[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(dt.getEnumName(Yt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=at.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Zt=r.length;this.buf.b+=at.string(Zt-2);for(var Ut=2;Ut<Zt;){var Jt=Ut++;this.serialize(r[Jt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+at.string(r))}}},__class__:$t};var Xt=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var i=Xt.DEFAULT_RESOLVER;i==null&&(i=dt,Xt.DEFAULT_RESOLVER=i),this.setResolver(i)};w["haxe.Unserializer"]=Xt,Xt.__name__=["haxe","Unserializer"],Xt.initCodes=function(){for(var r=[],i=0,o=Xt.BASE64.length;i<o;){var l=i++;r[Xt.BASE64.charCodeAt(l)]=l}return r},Xt.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(i){return null},resolveEnum:function(i){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,i=!1,o=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=o)break;i=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return i&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var i=this.buf.charCodeAt(this.pos);if(i>=43&&i<58||i==101||i==69)this.pos++;else break}return at.parseFloat(L.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var i=this.unserialize();if(typeof i!="string")throw new Q("Invalid object key");var o=this.unserialize();r[i]=o}this.pos++},unserializeEnum:function(r,i){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var o=this.readDigits();if(o==0)return dt.createEnum(r,i);for(var l=[];o-- >0;)l.push(this.unserialize());return dt.createEnum(r,i,l)},unserialize:function(){var r=this.get(this.pos++);switch(r){case 110:return null;case 116:return!0;case 102:return!1;case 122:return 0;case 105:return this.readDigits();case 100:return this.readFloat();case 121:var i=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<i)throw new Q("Invalid string length");var o=L.substr(this.buf,this.pos,i);return this.pos+=i,o=decodeURIComponent(o.split("+").join(" ")),this.scache.push(o),o;case 107:return NaN;case 109:return-1/0;case 112:return 1/0;case 97:this.buf;var l=[];for(this.cache.push(l);;){var c=this.buf.charCodeAt(this.pos);if(c==104){this.pos++;break}if(c==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var g={};return this.cache.push(g),this.unserializeObject(g),g;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var y=this.readDigits();if(y<0||y>=this.scache.length)throw new Q("Invalid string reference");return this.scache[y];case 120:throw new Q(this.unserialize());case 99:var I=this.unserialize(),P=this.resolver.resolveClass(I);if(P==null)throw new Q("Class not found "+I);var S=dt.createEmptyInstance(P);return this.cache.push(S),this.unserializeObject(S),S;case 119:var E=this.unserialize(),M=this.resolver.resolveEnum(E);if(M==null)throw new Q("Enum not found "+E);var T=this.unserializeEnum(M,this.unserialize());return this.cache.push(T),T;case 106:var B=this.unserialize(),O=this.resolver.resolveEnum(B);if(O==null)throw new Q("Enum not found "+B);this.pos++;var F=this.readDigits(),R=dt.getEnumConstructs(O)[F];if(R==null)throw new Q("Unknown enum index "+B+"@"+F);var j=this.unserializeEnum(O,R);return this.cache.push(j),j;case 108:var D=new V;for(this.cache.push(D),this.buf;this.buf.charCodeAt(this.pos)!=104;)D.add(this.unserialize());return this.pos++,D;case 98:var X=new we;for(this.cache.push(X),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();X.set(J,this.unserialize())}return this.pos++,X;case 113:var Y=new xt;this.cache.push(Y),this.buf;for(var U=this.get(this.pos++);U==58;){var $=this.readDigits();Y.set($,this.unserialize()),U=this.get(this.pos++)}if(U!=104)throw new Q("Invalid IntMap format");return Y;case 77:var tt=new Bt;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var ot;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var ct=L.substr(this.buf,this.pos,19);ot=L.strDate(ct),this.pos+=19}else{var ht=this.readFloat(),pt=new Date;pt.setTime(ht),ot=pt}return this.cache.push(ot),ot;case 115:var nt=this.readDigits(),mt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var K=Xt.CODES;K==null&&(K=Xt.initCodes(),Xt.CODES=K);var ft=this.pos,kt=nt&3,Yt;Yt=(nt>>2)*3+(kt>=2?kt-1:0);for(var Zt=ft+(nt-kt),Ut=ze.alloc(Yt),Jt=0;ft<Zt;){var Be=K[st.fastCodeAt(mt,ft++)],tr=K[st.fastCodeAt(mt,ft++)];Ut.set(Jt++,Be<<2|tr>>4);var Ae=K[st.fastCodeAt(mt,ft++)];Ut.set(Jt++,tr<<4|Ae>>2);var Ie=K[st.fastCodeAt(mt,ft++)];Ut.set(Jt++,Ae<<6|Ie)}if(kt>=2){var Re=K[st.fastCodeAt(mt,ft++)],Ue=K[st.fastCodeAt(mt,ft++)];if(Ut.set(Jt++,Re<<2|Ue>>4),kt==3){var ir=K[st.fastCodeAt(mt,ft++)];Ut.set(Jt++,Ue<<4|ir>>2)}}return this.pos+=nt,this.cache.push(Ut),Ut;case 67:var fr=this.unserialize(),ar=this.resolver.resolveClass(fr);if(ar==null)throw new Q("Class not found "+fr);var or=dt.createEmptyInstance(ar);if(this.cache.push(or),or.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return or;case 65:var lr=this.unserialize(),Sr=this.resolver.resolveClass(lr);if(Sr==null)throw new Q("Class not found "+lr);return Sr;case 66:var Yn=this.unserialize(),gn=this.resolver.resolveEnum(Yn);if(gn==null)throw new Q("Enum not found "+Yn);return gn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Xt};var xt=function(){this.h={}};w["haxe.ds.IntMap"]=xt,xt.__name__=["haxe","ds","IntMap"],xt.__interfaces__=[it],xt.prototype={set:function(r,i){this.h[r]=i},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var i in this.h)this.h.hasOwnProperty(i)&&r.push(i|0);return L.iter(r)},__class__:xt};var Bt=function(){this.h={},this.h.__keys__={}};w["haxe.ds.ObjectMap"]=Bt,Bt.__name__=["haxe","ds","ObjectMap"],Bt.__interfaces__=[it],Bt.prototype={set:function(r,i){var o=r.__id__||(r.__id__=++Bt.count);this.h[o]=i,this.h.__keys__[o]=r},keys:function(){var r=[];for(var i in this.h.__keys__)this.h.hasOwnProperty(i)&&r.push(this.h.__keys__[i]);return L.iter(r)},__class__:Bt};var be=w["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};be.Some=function(r){var i=["Some",0,r];return i.__enum__=be,i.toString=A,i},be.None=["None",1],be.None.toString=A,be.None.__enum__=be;var we=function(){this.h={}};w["haxe.ds.StringMap"]=we,we.__name__=["haxe","ds","StringMap"],we.__interfaces__=[it],we.prototype={set:function(r,i){da[r]!=null?this.setReserved(r,i):this.h[r]=i},get:function(r){return da[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,i){this.rh==null&&(this.rh={}),this.rh["$"+r]=i},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return L.iter(r)},arrayKeys:function(){var r=[];for(var i in this.h)this.h.hasOwnProperty(i)&&r.push(i);if(this.rh!=null)for(var i in this.rh)i.charCodeAt(0)==36&&r.push(i.substr(1));return r},__class__:we};var ze=function(r){this.length=r.byteLength,this.b=new pa(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};w["haxe.io.Bytes"]=ze,ze.__name__=["haxe","io","Bytes"],ze.alloc=function(r){return new ze(new mi(r))},ze.prototype={get:function(r){return this.b[r]},set:function(r,i){this.b[r]=i&255},__class__:ze};var se=w["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};se.Blocked=["Blocked",0],se.Blocked.toString=A,se.Blocked.__enum__=se,se.Overflow=["Overflow",1],se.Overflow.toString=A,se.Overflow.__enum__=se,se.OutsideBounds=["OutsideBounds",2],se.OutsideBounds.toString=A,se.OutsideBounds.__enum__=se,se.Custom=function(r){var i=["Custom",3,r];return i.__enum__=se,i.toString=A,i};var pe=function(){};w["haxe.io.FPHelper"]=pe,pe.__name__=["haxe","io","FPHelper"],pe.i32ToFloat=function(r){var i=1-(r>>>31<<1),o=r>>>23&255,l=r&8388607;return l==0&&o==0?0:i*(1+Math.pow(2,-23)*l)*Math.pow(2,o-127)},pe.floatToI32=function(r){if(r==0)return 0;var i;r<0?i=-r:i=r;var o=Math.floor(Math.log(i)/.6931471805599453);o<-127?o=-127:o>128&&(o=128);var l=Math.round((i/Math.pow(2,o)-1)*8388608)&8388607;return(r<0?-2147483648:0)|o+127<<23|l},pe.i64ToDouble=function(r,i){var o=1-(i>>>31<<1),l=(i>>20&2047)-1023,c=(i&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return c==0&&l==-1023?0:o*(1+Math.pow(2,-52)*c)*Math.pow(2,l)},pe.doubleToI64=function(r){var i=pe.i64tmp;if(r==0)i.low=0,i.high=0;else{var o;r<0?o=-r:o=r;var l=Math.floor(Math.log(o)/.6931471805599453),c,d=(o/Math.pow(2,l)-1)*4503599627370496;c=Math.round(d);var g=c|0,_=c/4294967296|0;i.low=g,i.high=(r<0?-2147483648:0)|l+1023<<20|_}return i};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};w["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=k(Error.prototype,{__class__:Q});var Lt=function(){};w["js.Boot"]=Lt,Lt.__name__=["js","Boot"],Lt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var i=r.__class__;if(i!=null)return i;var o=Lt.__nativeClassName(r);return o!=null?Lt.__resolveNativeClass(o):null},Lt.__string_rec=function(r,i){if(r==null)return"null";if(i.length>=5)return"<...>";var o=typeof r;switch(o=="function"&&(r.__name__||r.__ename__)&&(o="object"),o){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";i+=" ";for(var c=2,d=r.length;c<d;){var g=c++;g!=2?l+=","+Lt.__string_rec(r[g],i):l+=Lt.__string_rec(r[g],i)}return l+")"}var _=r.length,y="[";i+=" ";for(var I=0;I<_;){var P=I++;y+=(P>0?",":"")+Lt.__string_rec(r[P],i)}return y+="]",y}var S;try{S=r.toString}catch(O){return O instanceof Q&&(O=O.val),"???"}if(S!=null&&S!=Object.toString&&typeof S=="function"){var E=r.toString();if(E!="[object Object]")return E}var M=null,T=`{
|
|
3
|
+
`}registerHandle(t){return this._handleMap.has(t)||(this._handleMap.set(t,this._nextHandle.toString(16).toUpperCase()),this._nextHandle+=1),this._handleMap.get(t)}resolveHandle(t){if(t)return this.registerHandle(t)}writeGroup(t,e){return e==null?this:(this._lines.push(String(Math.trunc(t))),this._lines.push(this.formatValue(e)),this)}writeStart(t){return this.writeString(0,t)}writeSubclassMarker(t){return this.writeString(100,t)}writeString(t,e){return!e&&e!==""?this:this.writeGroup(t,e)}writeInt8(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt16(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt32(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt64(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeUInt16(t,e){return e==null?this:this.writeGroup(t,Math.max(0,e))}writeUInt32(t,e){return e==null?this:this.writeGroup(t,Math.max(0,e))}writeBoolean(t,e){return e==null?this:this.writeGroup(t,e?1:0)}writeBool(t,e){return this.writeBoolean(t,e)}writeDouble(t,e){return e==null||!Number.isFinite(e)?this:this.writeGroup(t,e)}writeAngle(t,e){return e==null||!Number.isFinite(e)?this:this.writeDouble(t,e*180/Math.PI)}writeHandle(t,e){const s=this.resolveHandle(e);return s?this.writeString(t,s):this}writeObjectId(t,e){return this.writeHandle(t,e)}writePoint2d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this):this}writePoint3d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this.writeDouble(t+20,e.z??0),this):this}writeVector3d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this.writeDouble(t+20,e.z??0),this):this}writeCmColor(t,e=62,s=420){if(!t)return this;const a=t.colorIndex;a!=null&&this.writeInt16(e,a);const h=t.RGB;return h!=null&&t.colorIndex==null&&this.writeInt32(s,h),this}writeTransparency(t,e=440){return t?this.writeInt32(e,t.serialize()):this}writeResultBuffer(t){if(!t)return this;for(const e of t)this.writeGroup(e.code,e.value);return this}startSection(t){return this.writeStart("SECTION"),this.writeString(2,t),this}endSection(){return this.writeStart("ENDSEC"),this}startTable(t,e){return this.writeStart("TABLE"),this.writeString(2,t),this.writeInt16(70,e),this}endTable(){return this.writeStart("ENDTAB"),this}formatValue(t){return typeof t=="string"?t:typeof t=="boolean"?t?"1":"0":typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this._precision).replace(/\.?0+$/,""):"0":String(t)}}function $c(n,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in n)){const h=Object.getOwnPropertyDescriptor(s,a);h&&Object.defineProperty(n,a,h.get?h:{enumerable:!0,get:()=>s[a]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var lt=(n=>(n[n.ByColor=1]="ByColor",n[n.ByACI=2]="ByACI",n[n.ByLayer=3]="ByLayer",n[n.ByBlock=4]="ByBlock",n[n.None=0]="None",n))(lt||{});const bl={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},ya=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];let nn=class{static getColorByIndex(t){return ya[t]}static getIndexByColor(t){const e=ya.length-1;for(let s=1;s<e;++s)if(ya[s]===t)return s}static getColorByName(t){return bl[t.toLowerCase()]}static getNameByColor(t){for(const[e,s]of Object.entries(bl))if(s===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},ce=class jr{constructor(t=lt.ByLayer,e){this._colorMethod=t,this._colorMethod==lt.ByColor&&e==null?this._value=16777215:this._colorMethod==lt.ByACI?e==null?this._value=8:e===0?this._colorMethod=lt.ByBlock:e===256?this._colorMethod=lt.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}get colorMethod(){return this._colorMethod}set colorMethod(t){this._colorMethod=t}get red(){const t=this.RGB;return t!=null?t>>16&255:void 0}get green(){const t=this.RGB;return t!=null?t>>8&255:void 0}get blue(){const t=this.RGB;return t!=null?t&255:void 0}get RGB(){switch(this._colorMethod){case lt.ByColor:case lt.ByBlock:case lt.ByLayer:return this._value;case lt.ByACI:return this._value?nn.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,s){const a=Math.max(0,Math.min(255,Math.round(t))),h=Math.max(0,Math.min(255,Math.round(e))),u=Math.max(0,Math.min(255,Math.round(s)));return this._value=a<<16|h<<8|u,this._colorMethod=lt.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=lt.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let h=0,u=0,p=0;if(e.length===7)h=parseInt(e.substr(1,2),16),u=parseInt(e.substr(3,2),16),p=parseInt(e.substr(5,2),16);else if(e.length===4)h=parseInt(e[1]+e[1],16),u=parseInt(e[2]+e[2],16),p=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(h,u,p)}const s=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(s){const h=parseInt(s[1],10),u=parseInt(s[2],10),p=parseInt(s[3],10);return this.setRGB(h,u,p)}const a=nn.getColorByName(t);return a!==void 0?this.setRGBValue(a):(console.warn("Unknown CSS color string:",t),this)}setScalar(t){return this.setRGB(t,t,t)}get hexColor(){const t=this.RGB;return t==null?void 0:"0x"+t.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const t=this.RGB;if(t!=null)return`rgb(${t>>16&255},${t>>8&255},${t&255})`}cssColorAlpha(t){const e=this.RGB;if(e!=null)return`rgba(${e>>16&255},${e>>8&255},${e&255},${t})`}get colorIndex(){return this._colorMethod===lt.ByACI?this._value:this._colorMethod===lt.ByLayer?256:this._colorMethod===lt.ByBlock?0:void 0}set colorIndex(t){if(t==null)return;const e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=lt.ByBlock,this._value=void 0):e===256?(this._colorMethod=lt.ByLayer,this._value=void 0):(this._colorMethod=lt.ByACI,this._value=e)}get isByColor(){return this._colorMethod===lt.ByColor}get isByACI(){return this._colorMethod===lt.ByACI}get isForeground(){return this._colorMethod===lt.ByACI&&this._value===7}setForeground(){return this._colorMethod=lt.ByACI,this._value=7,this}get isByLayer(){return this._colorMethod===lt.ByLayer}setByLayer(t){return this._colorMethod=lt.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===lt.ByBlock}setByBlock(t){return this._colorMethod=lt.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case lt.ByLayer:return"ByLayer";case lt.ByBlock:return"ByBlock";case lt.ByColor:return this._value?nn.getNameByColor(this._value):"";case lt.ByACI:return this._value?nn.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=nn.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=lt.ByColor):console.warn("Unknown color name:",t)}clone(){const t=new jr;return t._colorMethod=this._colorMethod,t._value=this._value,t}copy(t){return this._colorMethod=t._colorMethod,this._value=t._value,this}equals(t){return this._colorMethod===t._colorMethod&&this._value===t._value}toString(){switch(this._colorMethod){case lt.ByLayer:return"ByLayer";case lt.ByBlock:return"ByBlock";case lt.ByACI:return this._value!==void 0?String(this._value):"";case lt.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(t){if(!t)return;const e=t.trim();if(/^bylayer$/i.test(e))return new jr(lt.ByLayer);if(/^byblock$/i.test(e))return new jr(lt.ByBlock);const s=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(s){const h=Number(s[1]),u=Number(s[2]),p=Number(s[3]),v=new jr(lt.ByColor);return v.setRGB(h,u,p),v}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){const[h,u,p]=e.split(",").map(Number),v=new jr(lt.ByColor);return v.setRGB(h,u,p),v}if(/^\d+$/.test(e)){const h=parseInt(e,10);return new jr(lt.ByACI,h)}if(/^book\$/i.test(e)){const h=e.substring(e.indexOf("$")+1),u=nn.getColorByName(h);if(u!=null)return new jr(lt.ByColor,u);console.warn("Unknown color book entry:",t);return}const a=nn.getColorByName(e);if(a!=null)return new jr(lt.ByColor,a);console.warn("Unknown color name:",t)}};class Kc{constructor(t=lt.ByColor,e=0){this._colorMethod=t,this._value=e}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(t){this._colorMethod=lt.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=lt.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=lt.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,s){this._colorMethod=lt.ByColor,this._value=(t&255)<<16|(e&255)<<8|s&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=lt.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=lt.ByLayer,this._value=t}isByColor(){return this._colorMethod===lt.ByColor}isByLayer(){return this._colorMethod===lt.ByLayer}isByBlock(){return this._colorMethod===lt.ByBlock}isByACI(){return this._colorMethod===lt.ByACI}isNone(){return this._colorMethod===lt.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const Ze={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")}};class Zc{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let a=0,h=s.length;a<h;a++)s[a].call(this,t)}}}let he=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};function Ws(n){return n===null||typeof n!="object"?n:Array.isArray(n)?[...n]:{...n}}function Oa(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(Oa);const t={};for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=Oa(n[e]));return t}function ns(n,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&n[s]===void 0&&(n[s]=e[s]);return n}function jl(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function Dl(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 Jn(n,t){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(let a=0;a<n.length;a++)if(!Jn(n[a],t[a]))return!1;return!0}const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(const a of e)if(!Object.prototype.hasOwnProperty.call(t,a)||!Jn(n[a],t[a]))return!1;return!0}var Qc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ul={exports:{}};(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(Qc,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],h={},u=null;function p(C,V){var z=C[V];if(typeof z.bind=="function")return z.bind(C);try{return Function.prototype.bind.call(z,C)}catch{return function(){return Function.prototype.apply.apply(z,[C,arguments])}}}function v(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function f(C){return C==="debug"&&(C="log"),typeof console===e?!1:C==="trace"&&s?v:console[C]!==void 0?p(console,C):console.log!==void 0?p(console,"log"):t}function x(){for(var C=this.getLevel(),V=0;V<a.length;V++){var z=a[V];this[z]=V<C?t:this.methodFactory(z,C,this.name)}if(this.log=this.debug,typeof console===e&&C<this.levels.SILENT)return"No console available for logging"}function w(C){return function(){typeof console!==e&&(x.call(this),this[C].apply(this,arguments))}}function A(C,V,z){return f(C)||w.apply(this,arguments)}function k(C,V){var z=this,st,_t,it,H="loglevel";typeof C=="string"?H+=":"+C:typeof C=="symbol"&&(H=void 0);function dt(xt){var Bt=(a[xt]||"silent").toUpperCase();if(!(typeof window===e||!H)){try{window.localStorage[H]=Bt;return}catch{}try{window.document.cookie=encodeURIComponent(H)+"="+Bt+";"}catch{}}}function at(){var xt;if(!(typeof window===e||!H)){try{xt=window.localStorage[H]}catch{}if(typeof xt===e)try{var Bt=window.document.cookie,be=encodeURIComponent(H),we=Bt.indexOf(be+"=");we!==-1&&(xt=/^([^;]+)/.exec(Bt.slice(we+be.length+1))[1])}catch{}return z.levels[xt]===void 0&&(xt=void 0),xt}}function Wt(){if(!(typeof window===e||!H)){try{window.localStorage.removeItem(H)}catch{}try{window.document.cookie=encodeURIComponent(H)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Kt(xt){var Bt=xt;if(typeof Bt=="string"&&z.levels[Bt.toUpperCase()]!==void 0&&(Bt=z.levels[Bt.toUpperCase()]),typeof Bt=="number"&&Bt>=0&&Bt<=z.levels.SILENT)return Bt;throw new TypeError("log.setLevel() called with invalid level: "+xt)}z.name=C,z.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},z.methodFactory=V||A,z.getLevel=function(){return it??_t??st},z.setLevel=function(xt,Bt){return it=Kt(xt),Bt!==!1&&dt(it),x.call(z)},z.setDefaultLevel=function(xt){_t=Kt(xt),at()||z.setLevel(xt,!1)},z.resetLevel=function(){it=null,Wt(),x.call(z)},z.enableAll=function(xt){z.setLevel(z.levels.TRACE,xt)},z.disableAll=function(xt){z.setLevel(z.levels.SILENT,xt)},z.rebuild=function(){if(u!==z&&(st=Kt(u.getLevel())),x.call(z),u===z)for(var xt in h)h[xt].rebuild()},st=Kt(u?u.getLevel():"WARN");var Xt=at();Xt!=null&&(it=Kt(Xt)),x.call(z)}u=new k,u.getLogger=function(C){if(typeof C!="symbol"&&typeof C!="string"||C==="")throw new TypeError("You must supply a name when creating a logger.");var V=h[C];return V||(V=h[C]=new k(C,u.methodFactory)),V};var L=typeof window!==e?window.log:void 0;return u.noConflict=function(){return typeof window!==e&&window.log===u&&(window.log=L),u},u.getLoggers=function(){return h},u.default=u,u})})(Ul);var Gl=Ul.exports;const td=Jc(Gl),ed=$c({__proto__:null,default:td},[Gl]),rd=!0,Ys=ed;Ys.setLevel("debug");const nd=n=>{try{Ys.setLevel(n)}catch(t){Ys.setLevel("error"),Ys.error(t)}};let Wl=class Hl{constructor(t,e){this.events={attrChanged:new he,modelChanged:new he},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&ns(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let a;typeof t=="object"?(a=t,s=e):(a={},a[t]=e),s||(s={});const h=s.unset,u=s.silent,p=[],v=this._changing;this._changing=!0,v||(this._previousAttributes=Ws(this.attributes),this.changed={});const f=this.attributes,x=this.changed,w=this._previousAttributes;for(const A in a)e=a[A],Jn(f[A],e)||p.push(A),Jn(w[A],e)?delete x[A]:x[A]=e,h?delete f[A]:f[A]=e;if(!u){p.length&&(this._pending=s);for(let A=0;A<p.length;A++)this.events.attrChanged.dispatch({object:this,attrName:p[A],attrValue:f[p[A]],options:s})}if(v)return this;if(!u)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!Dl(this.changed):jl(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?Ws(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const a in t){const h=t[a];Jn(e[a],h)||(s[a]=h)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return Ws(this._previousAttributes)}clone(){const t=Ws(this.attributes);return new Hl(t)}},Ya=class Hs{constructor(){this.entries=new Map}static getInstance(){return Hs.instance||(Hs.instance=new Hs),Hs.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class sd{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,a=Math.max(0,e),h=["B","KB","MB","GB","TB"],u=Math.floor(Math.log(t)/Math.log(s)),p=t/Math.pow(s,u);return`${parseFloat(p.toFixed(a))} ${h[u]}`}}var Ne=(n=>(n[n.ByLayer=0]="ByLayer",n[n.ByBlock=1]="ByBlock",n[n.ByAlpha=2]="ByAlpha",n[n.ErrorValue=3]="ErrorValue",n))(Ne||{});let na=class yr{constructor(t){t!==void 0?(this._method=Ne.ByAlpha,this._alpha=yr.clampAlpha(t)):(this._method=Ne.ByLayer,this._alpha=255)}get method(){return this._method}set method(t){this._method=t}get alpha(){return this._alpha}set alpha(t){this._alpha=yr.clampAlpha(t),this._method=Ne.ByAlpha}get percentage(){if(this._method===Ne.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),s=Math.round(255*(1-e/100));this.alpha=s}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===Ne.ByAlpha}get isByBlock(){return this._method===Ne.ByBlock}get isByLayer(){return this._method===Ne.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===Ne.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new yr;return t._method=this._method,t._alpha=this._alpha,t}equals(t){return this._method===t._method&&this._alpha===t._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(t){const e=t.trim();if(/^bylayer$/i.test(e)){const h=new yr;return h._method=Ne.ByLayer,h}if(/^byblock$/i.test(e)){const h=new yr;return h._method=Ne.ByBlock,h}const s=Number(e);if(Number.isInteger(s)&&s>=0&&s<=255)return new yr(s);const a=new yr;return a._method=Ne.ErrorValue,a}static deserialize(t){const e=t>>>24&255,s=t&255,a=Object.values(Ne)[e]??Ne.ErrorValue,h=new yr;return h._method=a,h._alpha=yr.clampAlpha(s),h}};class Yl{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}let Xl=class{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,s)=>{const a=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let a=0;a<e;a++){const h=this.tasks[a];try{s=await this.scheduleTask(async()=>{const u=await h.run(s);return this.onProgress((a+1)/e,h),u})}catch(u){if(this.onError({error:u,taskIndex:a,task:h}))return Promise.reject(u)}}this.onComplete(s)}},ql=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const a=this.handlers[e],h=this.handlers[e+1];if(a.global&&(a.lastIndex=0),a.test(t))return h}return null}};const $l=new ql;class id{constructor(t){this.manager=t!==void 0?t:$l,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,a)=>{this.load(t,s,e,a)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}var kn=256,Kl=[],wl=256,gi;for(;kn--;)Kl[kn]=(kn+256).toString(16).substring(1);function ad(n){var t=0,e=11;if(!gi||kn+e>wl*2)for(gi="",kn=0;t<wl;t++)gi+=Kl[Math.random()*256|0];return gi.substring(kn,kn+++e)}let Ca;function Zl(n){Ca=n}class Hr{constructor(t,e){t=t||{},ns(t,{objectId:ad()}),this._attrs=new Wl(t,e),this._xDataMap=new Map}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get extensionDictionary(){return this.getAttrWithoutException("extensionDictionary")}set extensionDictionary(t){this._attrs.set("extensionDictionary",t)}get database(){if(this._database)return this._database;if(Ca)return Ca().workingDatabase;throw new Error("The current working database must be set before using it!")}set database(t){this._database=t}getXData(t){return this._xDataMap.get(t)}setXData(t){for(const e of t)e.code===Ha.ExtendedDataRegAppName&&this._xDataMap.set(e.value,t)}removeXData(t){this._xDataMap.delete(t)}createExtensionDictionary(){}close(){}dxfOut(...t){const[e,s=!1]=t;if(e.writeHandle(5,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),s)for(const a of this._xDataMap.values())e.writeResultBuffer(a);return this}dxfOutFields(t){return this}}let Ba;function Ql(n){Ba=n}function Xa(){return ki.instance}const Ji=class Ji{constructor(){this._workingDatabase=null}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){if(!this._layoutManager){if(!Ba)throw new Error("The layout manager factory must be registered before using it!");this._layoutManager=Ba()}return this._layoutManager}};Ji.instance=new Ji;let ki=Ji;Zl(Xa);var Jl=(n=>(n.kForRead="kForRead",n.kForWrite="kForWrite",n))(Jl||{});class qa{constructor(t){if(this._values=[],t)for(const e of t)this._values.push({...e})}get length(){return this._values.length}at(t){return this._values[t]}add(t){this._values.push(t)}addRange(t){for(const e of t)this._values.push(e)}clear(){this._values.length=0}toArray(){return this._values.map(t=>({...t}))}clone(){return new qa(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}class $a{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const a=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(a):setTimeout(a,0)})}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let s=0;const a=async()=>{const h=s,u=Math.min(s+this._chunkSize,this._count);await t(h,u),s=u,s<this._count&&await this.scheduleTask(a)};await a(),await(e==null?void 0:e())}}var Xs=(n=>(n.DXF="dxf",n.DWG="dwg",n))(Xs||{});class vr{constructor(){this.events={registered:new he,unregistered:new he},this._converters=new Map,this.register("dxf",new Nc)}static createInstance(){return vr._instance==null&&(vr._instance=new vr),this._instance}static get instance(){return vr._instance||(vr._instance=new vr),vr._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 Se=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let xl=1234567;const Ka=Math.PI/180,Za=180/Math.PI;function th(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Se[n&255]+Se[n>>8&255]+Se[n>>16&255]+Se[n>>24&255]+"-"+Se[t&255]+Se[t>>8&255]+"-"+Se[t>>16&15|64]+Se[t>>24&255]+"-"+Se[e&63|128]+Se[e>>8&255]+"-"+Se[e>>16&255]+Se[e>>24&255]+Se[s&255]+Se[s>>8&255]+Se[s>>16&255]+Se[s>>24&255]).toLowerCase()}function Dr(n,t,e){return Math.max(t,Math.min(e,n))}function Qa(n,t){return(n%t+t)%t}function eh(n,t,e,s,a){return s+(n-t)*(a-s)/(e-t)}function rh(n,t,e){return n!==t?(e-n)/(t-n):0}function Ja(n,t,e){return(1-e)*n+e*t}function nh(n,t,e,s){return Ja(n,t,1-Math.exp(-e*s))}function sh(n,t=1){return t-Math.abs(Qa(n,t*2)-t)}function ih(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function ah(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function oh(n,t){return n+Math.floor(Math.random()*(t-n+1))}function lh(n,t){return n+Math.random()*(t-n)}function hh(n){return n*(.5-Math.random())}function uh(n){n!==void 0&&(xl=n);let t=xl+=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 ch(n){return n*Ka}function dh(n){return n*Za}function ph(n){return(n&n-1)===0&&n!==0}function mh(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function gh(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function qs(n){const t=Math.PI*2;return(n%t+t)%t}function _h(n,t,e){return n>t&&n<e||n>e&&n<t}function fh(n,t,e,s=!1){return n=qs(n),t=qs(t),e=qs(e),s?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function to(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function yh(n,t=1e-7){const e=to(n);return Math.max(Math.pow(10,e)*t,t)}const St={DEG2RAD:Ka,RAD2DEG:Za,generateUUID:th,clamp:Dr,euclideanModulo:Qa,mapLinear:eh,inverseLerp:rh,lerp:Ja,damp:nh,pingpong:sh,smoothstep:ih,smootherstep:ah,randInt:oh,randFloat:lh,randFloatSpread:hh,seededRandom:uh,degToRad:ch,radToDeg:dh,isPowerOfTwo:ph,ceilPowerOfTwo:mh,floorPowerOfTwo:gh,normalizeAngle:qs,isBetween:_h,isBetweenAngle:fh,intPartLength:to,relativeEps:yh},Ra=class vh{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:a,y:h}=t;this.x=a,this.y=h;return}if(s===2){this.x=t,this.y=e;return}throw Ze.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new vh(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,a=t.elements;return this.x=a[0]*e+a[3]*s+a[6],this.y=a[1]*e+a[4]*s+a[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),a=Math.sin(e),h=this.x-t.x,u=this.y-t.y;return this.x=h*s-u*a+t.x,this.y=h*a+u*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(St.relativeEps(this.x,t),St.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};Ra.EMPTY=Object.freeze(new Ra(0,0));let te=Ra;const Fa=class bh{constructor(t,e,s,a,h,u,p,v,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&a!=null&&h!=null&&u!=null&&p!=null&&v!=null&&f!=null&&this.set(t,e,s,a,h,u,p,v,f)}set(t,e,s,a,h,u,p,v,f){const x=this.elements;return x[0]=t,x[1]=a,x[2]=p,x[3]=e,x[4]=h,x[5]=v,x[6]=s,x[7]=u,x[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,a=e.elements,h=this.elements,u=s[0],p=s[3],v=s[6],f=s[1],x=s[4],w=s[7],A=s[2],k=s[5],L=s[8],C=a[0],V=a[3],z=a[6],st=a[1],_t=a[4],it=a[7],H=a[2],dt=a[5],at=a[8];return h[0]=u*C+p*st+v*H,h[3]=u*V+p*_t+v*dt,h[6]=u*z+p*it+v*at,h[1]=f*C+x*st+w*H,h[4]=f*V+x*_t+w*dt,h[7]=f*z+x*it+w*at,h[2]=A*C+k*st+L*H,h[5]=A*V+k*_t+L*dt,h[8]=A*z+k*it+L*at,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],a=t[2],h=t[3],u=t[4],p=t[5],v=t[6],f=t[7],x=t[8];return e*u*x-e*p*f-s*h*x+s*p*v+a*h*f-a*u*v}invert(){const t=this.elements,e=t[0],s=t[1],a=t[2],h=t[3],u=t[4],p=t[5],v=t[6],f=t[7],x=t[8],w=x*u-p*f,A=p*v-x*h,k=f*h-u*v,L=e*w+s*A+a*k;if(L===0)return this.set(0,0,0,0,0,0,0,0,0);const C=1/L;return t[0]=w*C,t[1]=(a*f-x*s)*C,t[2]=(p*s-a*u)*C,t[3]=A*C,t[4]=(x*e-a*v)*C,t[5]=(a*h-p*e)*C,t[6]=k*C,t[7]=(s*v-f*e)*C,t[8]=(u*e-s*h)*C,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,a,h,u,p){const v=Math.cos(h),f=Math.sin(h);return this.set(s*v,s*f,-s*(v*u+f*p)+u+t,-a*f,a*v,-a*(-f*u+v*p)+p+e,0,0,1),this}scale(t,e){return this.premultiply(va.makeScale(t,e)),this}rotate(t){return this.premultiply(va.makeRotation(-t)),this}translate(t,e){return this.premultiply(va.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof te?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let a=0;a<9;a++)if(e[a]!==s[a])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new bh().fromArray(this.elements)}};Fa.IDENTITY=Object.freeze(new Fa);let sa=Fa;const va=new sa,En=1e-6,Qt=2*Math.PI,od={x:0,y:0},eo={x:0,y:0,z:0};class ro{constructor(){this.equalPointTol=En,this.equalVectorTol=En}equalPoint2d(t,e){return new te(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new q(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=En){return t<e&&t>-e}static equal(t,e,s=En){return Math.abs(t-e)<s}static great(t,e,s=En){return t-e>s}static less(t,e,s=En){return t-e<s}}const no=new ro;function so(n,t,e=!1){const s=n.x,a=n.y;let h=!1;const u=t.length;for(let p=0,v=u-1;p<u;v=p++){const f=t[p].x,x=t[p].y,w=t[v].x,A=t[v].y;let k=x>a!=A>a;e&&(k=x>=a!=A>=a),k&&s<(w-f)*(a-x)/(A-x)+f&&(h=!h)}return h}function wh(n,t){if(n.length===0||t.length===0)return!1;const e=new ve().setFromPoints(n),s=new ve().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let a=0;a<n.length;){if(so(n[a],t,!0))return!0;a<n.length-1&&no.equalPoint2d(n[a+1],n[a])&&++a,++a}return!1}const xh={isPointInPolygon:so,isPolygonIntersect:wh};function Ih(n,t){const e=[],s=t-1,a=n;for(let h=0;h<=a;h++)e.push(0);for(let h=1;h<=s-a;h++)e.push(h);for(let h=0;h<=a;h++)e.push(s-a+1);return e}function Sh(n,t){const e=t.length-1,s=n,a=[0];let h=0;for(let p=1;p<=e;p++){const v=t[p][0]-t[p-1][0],f=t[p][1]-t[p-1][1],x=t[p][2]-t[p-1][2],w=Math.sqrt(v*v+f*f+x*x);h+=w,a.push(h)}const u=[];for(let p=0;p<=s;p++)u.push(0);for(let p=1;p<=e-s;p++){const v=a[p]/h;u.push(v*(e-s+1))}for(let p=0;p<=s;p++)u.push(e-s+1);return u}function Ph(n,t){const e=t.length-1,s=n,a=[0];let h=0;for(let p=1;p<=e;p++){const v=t[p][0]-t[p-1][0],f=t[p][1]-t[p-1][1],x=t[p][2]-t[p-1][2],w=Math.sqrt(v*v+f*f+x*x),A=Math.sqrt(w);h+=A,a.push(h)}const u=[];for(let p=0;p<=s;p++)u.push(0);for(let p=1;p<=e-s;p++){const v=a[p]/h;u.push(v*(e-s+1))}for(let p=0;p<=s;p++)u.push(e-s+1);return u}function Mi(n,t,e,s){if(t===0)return e>=s[n]&&e<s[n+1]?1:0;const a=s[n+t]-s[n],h=s[n+t+1]-s[n+1],u=a>1e-10?(e-s[n])/a:0,p=h>1e-10?(s[n+t+1]-e)/h:0;return u*Mi(n,t-1,e,s)+p*Mi(n+1,t-1,e,s)}function $s(n,t,e,s,a){const h=s.length-1,u=t;if(n=Math.max(e[u],Math.min(e[h+1],n)),Math.abs(n-e[h+1])<1e-8)return[...s[h]];if(Math.abs(n-e[u])<1e-8)return[...s[0]];const p=[0,0,0];let v=0;for(let f=0;f<=h;f++){const x=Mi(f,u,n,e),w=a[f]*x;p[0]+=s[f][0]*w,p[1]+=s[f][1]*w,p[2]+=s[f][2]*w,v+=w}if(v<1e-10){const f=e[e.length-u-1];if(Math.abs(n-f)<1e-8)return[...s[h]];if(Math.abs(n-e[u])<1e-8)return[...s[0]]}return v>1e-10&&(p[0]/=v,p[1]/=v,p[2]/=v),p}function Ah(n,t,e,s){const a=n,h=t[a],u=t[t.length-a-1];let p=0;const v=1e3,f=(u-h)/v;let x=$s(h,n,t,e,s);for(let C=1;C<=v;C++){const V=h+C*f,z=$s(V,n,t,e,s),st=z[0]-x[0],_t=z[1]-x[1],it=z[2]-x[2];p+=Math.sqrt(st*st+_t*_t+it*it),x=z}const w=$s(u,n,t,e,s),A=w[0]-x[0],k=w[1]-x[1],L=w[2]-x[2];return p+=Math.sqrt(A*A+k*k+L*L),p}function ld(n){return n.map(t=>[...t])}class Cn{constructor(t=0,e=0,s=0,a=1){this._x=t,this._y=e,this._z=s,this._w=a}static slerpFlat(t,e,s,a,h,u,p){let v=s[a+0],f=s[a+1],x=s[a+2],w=s[a+3];const A=h[u+0],k=h[u+1],L=h[u+2],C=h[u+3];if(p===0){t[e+0]=v,t[e+1]=f,t[e+2]=x,t[e+3]=w;return}if(p===1){t[e+0]=A,t[e+1]=k,t[e+2]=L,t[e+3]=C;return}if(w!==C||v!==A||f!==k||x!==L){let V=1-p;const z=v*A+f*k+x*L+w*C,st=z>=0?1:-1,_t=1-z*z;if(_t>Number.EPSILON){const H=Math.sqrt(_t),dt=Math.atan2(H,z*st);V=Math.sin(V*dt)/H,p=Math.sin(p*dt)/H}const it=p*st;if(v=v*V+A*it,f=f*V+k*it,x=x*V+L*it,w=w*V+C*it,V===1-p){const H=1/Math.sqrt(v*v+f*f+x*x+w*w);v*=H,f*=H,x*=H,w*=H}}t[e]=v,t[e+1]=f,t[e+2]=x,t[e+3]=w}static multiplyQuaternionsFlat(t,e,s,a,h,u){const p=s[a],v=s[a+1],f=s[a+2],x=s[a+3],w=h[u],A=h[u+1],k=h[u+2],L=h[u+3];return t[e]=p*L+x*w+v*k-f*A,t[e+1]=v*L+x*A+f*w-p*k,t[e+2]=f*L+x*k+p*A-v*w,t[e+3]=x*L-p*w-v*A-f*k,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,a){return this._x=t,this._y=e,this._z=s,this._w=a,this._onChangeCallback(),this}clone(){return new Cn(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t.x,a=t.y,h=t.z,u=t.order,p=Math.cos,v=Math.sin,f=p(s/2),x=p(a/2),w=p(h/2),A=v(s/2),k=v(a/2),L=v(h/2);switch(u){case"XYZ":this._x=A*x*w+f*k*L,this._y=f*k*w-A*x*L,this._z=f*x*L+A*k*w,this._w=f*x*w-A*k*L;break;case"YXZ":this._x=A*x*w+f*k*L,this._y=f*k*w-A*x*L,this._z=f*x*L-A*k*w,this._w=f*x*w+A*k*L;break;case"ZXY":this._x=A*x*w-f*k*L,this._y=f*k*w+A*x*L,this._z=f*x*L+A*k*w,this._w=f*x*w-A*k*L;break;case"ZYX":this._x=A*x*w-f*k*L,this._y=f*k*w+A*x*L,this._z=f*x*L-A*k*w,this._w=f*x*w+A*k*L;break;case"YZX":this._x=A*x*w+f*k*L,this._y=f*k*w+A*x*L,this._z=f*x*L-A*k*w,this._w=f*x*w-A*k*L;break;case"XZY":this._x=A*x*w-f*k*L,this._y=f*k*w-A*x*L,this._z=f*x*L+A*k*w,this._w=f*x*w+A*k*L;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,a=Math.sin(s);return this._x=t.x*a,this._y=t.y*a,this._z=t.z*a,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],a=e[4],h=e[8],u=e[1],p=e[5],v=e[9],f=e[2],x=e[6],w=e[10],A=s+p+w;if(A>0){const k=.5/Math.sqrt(A+1);this._w=.25/k,this._x=(x-v)*k,this._y=(h-f)*k,this._z=(u-a)*k}else if(s>p&&s>w){const k=2*Math.sqrt(1+s-p-w);this._w=(x-v)/k,this._x=.25*k,this._y=(a+u)/k,this._z=(h+f)/k}else if(p>w){const k=2*Math.sqrt(1+p-s-w);this._w=(h-f)/k,this._x=(a+u)/k,this._y=.25*k,this._z=(v+x)/k}else{const k=2*Math.sqrt(1+w-s-p);this._w=(u-a)/k,this._x=(h+f)/k,this._y=(v+x)/k,this._z=.25*k}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Dr(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const a=Math.min(1,e/s);return this.slerp(t,a),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,a=t._y,h=t._z,u=t._w,p=e._x,v=e._y,f=e._z,x=e._w;return this._x=s*x+u*p+a*f-h*v,this._y=a*x+u*v+h*p-s*f,this._z=h*x+u*f+s*v-a*p,this._w=u*x-s*p-a*v-h*f,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,a=this._y,h=this._z,u=this._w;let p=u*t._w+s*t._x+a*t._y+h*t._z;if(p<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,p=-p):this.copy(t),p>=1)return this._w=u,this._x=s,this._y=a,this._z=h,this;const v=1-p*p;if(v<=Number.EPSILON){const k=1-e;return this._w=k*u+e*this._w,this._x=k*s+e*this._x,this._y=k*a+e*this._y,this._z=k*h+e*this._z,this.normalize(),this}const f=Math.sqrt(v),x=Math.atan2(f,p),w=Math.sin((1-e)*x)/f,A=Math.sin(e*x)/f;return this._w=u*w+this._w*A,this._x=s*w+this._x*A,this._y=a*w+this._y*A,this._z=h*w+this._z*A,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),a=Math.sqrt(1-s),h=Math.sqrt(s);return this.set(a*Math.sin(t),a*Math.cos(t),h*Math.sin(e),h*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Te=class Eh{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const a=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0);if(a!==0){if(a===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(a===1){const{x:h,y:u,z:p}=t;this.x=h,this.y=u,this.z=p||0;return}if(a===3){this.x=t,this.y=e,this.z=s;return}throw Ze.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new Eh(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Il.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Il.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[3]*s+h[6]*a,this.y=h[1]*e+h[4]*s+h[7]*a,this.z=h[2]*e+h[5]*s+h[8]*a,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,a=this.z,h=t.elements,u=1/(h[3]*e+h[7]*s+h[11]*a+h[15]);return this.x=(h[0]*e+h[4]*s+h[8]*a+h[12])*u,this.y=(h[1]*e+h[5]*s+h[9]*a+h[13])*u,this.z=(h[2]*e+h[6]*s+h[10]*a+h[14])*u,this}applyQuaternion(t){const e=this.x,s=this.y,a=this.z,h=t.x,u=t.y,p=t.z,v=t.w,f=2*(u*a-p*s),x=2*(p*e-h*a),w=2*(h*s-u*e);return this.x=e+v*f+u*w-p*x,this.y=s+v*x+p*f-h*w,this.z=a+v*w+h*x-u*f,this}transformDirection(t){const e=this.x,s=this.y,a=this.z,h=t.elements;return this.x=h[0]*e+h[4]*s+h[8]*a,this.y=h[1]*e+h[5]*s+h[9]*a,this.z=h[2]*e+h[6]*s+h[10]*a,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),s=this.length(),a=t.length();return Math.abs(e)===s*a}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,a=t.y,h=t.z,u=e.x,p=e.y,v=e.z;return this.x=a*v-h*p,this.y=h*u-s*v,this.z=s*p-a*u,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return ba.copy(this).projectOnVector(t),this.sub(ba)}reflect(t){return this.sub(ba.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,a=this.z-t.z;return e*e+s*s+a*a}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),a=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=a,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Te.ORIGIN=Object.freeze(new Te(0,0,0)),Te.X_AXIS=Object.freeze(new Te(1,0,0)),Te.NEGATIVE_X_AXIS=Object.freeze(new Te(-1,0,0)),Te.Y_AXIS=Object.freeze(new Te(0,1,0)),Te.NEGATIVE_Y_AXIS=Object.freeze(new Te(0,-1,0)),Te.Z_AXIS=Object.freeze(new Te(0,0,1)),Te.NEGATIVE_Z_AXIS=Object.freeze(new Te(0,0,-1));let q=Te;const ba=new q,Il=new Cn,za=class kh{constructor(t,e,s,a,h,u,p,v,f,x,w,A,k,L,C,V){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&a!=null&&h!=null&&u!=null&&p!=null&&v!=null&&f!=null&&x!=null&&w!=null&&A!=null&&k!=null&&L!=null&&C!=null&&V!=null&&this.set(t,e,s,a,h,u,p,v,f,x,w,A,k,L,C,V)}set(t,e,s,a,h,u,p,v,f,x,w,A,k,L,C,V){const z=this.elements;return z[0]=t,z[4]=e,z[8]=s,z[12]=a,z[1]=h,z[5]=u,z[9]=p,z[13]=v,z[2]=f,z[6]=x,z[10]=w,z[14]=A,z[3]=k,z[7]=L,z[11]=C,z[15]=V,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new kh().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(no.equalPoint3d(t,q.Z_AXIS))this.identity();else{const e=new q(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(q.Y_AXIS,t).normalize():e.crossVectors(q.Z_AXIS,t).normalize();const s=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,s.x,s.y,s.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,a=1/qn.setFromMatrixColumn(t,0).length(),h=1/qn.setFromMatrixColumn(t,1).length(),u=1/qn.setFromMatrixColumn(t,2).length();return e[0]=s[0]*a,e[1]=s[1]*a,e[2]=s[2]*a,e[3]=0,e[4]=s[4]*h,e[5]=s[5]*h,e[6]=s[6]*h,e[7]=0,e[8]=s[8]*u,e[9]=s[9]*u,e[10]=s[10]*u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(hd,t,ud)}lookAt(t,e,s){const a=this.elements;return Ge.subVectors(t,e),Ge.lengthSq()===0&&(Ge.z=1),Ge.normalize(),rn.crossVectors(s,Ge),rn.lengthSq()===0&&(Math.abs(s.z)===1?Ge.x+=1e-4:Ge.z+=1e-4,Ge.normalize(),rn.crossVectors(s,Ge)),rn.normalize(),_i.crossVectors(Ge,rn),a[0]=rn.x,a[4]=_i.x,a[8]=Ge.x,a[1]=rn.y,a[5]=_i.y,a[9]=Ge.y,a[2]=rn.z,a[6]=_i.z,a[10]=Ge.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,a=e.elements,h=this.elements,u=s[0],p=s[4],v=s[8],f=s[12],x=s[1],w=s[5],A=s[9],k=s[13],L=s[2],C=s[6],V=s[10],z=s[14],st=s[3],_t=s[7],it=s[11],H=s[15],dt=a[0],at=a[4],Wt=a[8],Kt=a[12],Xt=a[1],xt=a[5],Bt=a[9],be=a[13],we=a[2],ze=a[6],se=a[10],pe=a[14],Q=a[3],Lt=a[7],me=a[11],wr=a[15];return h[0]=u*dt+p*Xt+v*we+f*Q,h[4]=u*at+p*xt+v*ze+f*Lt,h[8]=u*Wt+p*Bt+v*se+f*me,h[12]=u*Kt+p*be+v*pe+f*wr,h[1]=x*dt+w*Xt+A*we+k*Q,h[5]=x*at+w*xt+A*ze+k*Lt,h[9]=x*Wt+w*Bt+A*se+k*me,h[13]=x*Kt+w*be+A*pe+k*wr,h[2]=L*dt+C*Xt+V*we+z*Q,h[6]=L*at+C*xt+V*ze+z*Lt,h[10]=L*Wt+C*Bt+V*se+z*me,h[14]=L*Kt+C*be+V*pe+z*wr,h[3]=st*dt+_t*Xt+it*we+H*Q,h[7]=st*at+_t*xt+it*ze+H*Lt,h[11]=st*Wt+_t*Bt+it*se+H*me,h[15]=st*Kt+_t*be+it*pe+H*wr,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],a=t[8],h=t[12],u=t[1],p=t[5],v=t[9],f=t[13],x=t[2],w=t[6],A=t[10],k=t[14],L=t[3],C=t[7],V=t[11],z=t[15];return L*(+h*v*w-a*f*w-h*p*A+s*f*A+a*p*k-s*v*k)+C*(+e*v*k-e*f*A+h*u*A-a*u*k+a*f*x-h*v*x)+V*(+e*f*w-e*p*k-h*u*w+s*u*k+h*p*x-s*f*x)+z*(-a*p*x-e*v*w+e*p*A+a*u*w-s*u*A+s*v*x)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const a=this.elements;return t instanceof q?(a[12]=t.x,a[13]=t.y,a[14]=t.z):(a[12]=t,a[13]=e,a[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],a=t[2],h=t[3],u=t[4],p=t[5],v=t[6],f=t[7],x=t[8],w=t[9],A=t[10],k=t[11],L=t[12],C=t[13],V=t[14],z=t[15],st=w*V*f-C*A*f+C*v*k-p*V*k-w*v*z+p*A*z,_t=L*A*f-x*V*f-L*v*k+u*V*k+x*v*z-u*A*z,it=x*C*f-L*w*f+L*p*k-u*C*k-x*p*z+u*w*z,H=L*w*v-x*C*v-L*p*A+u*C*A+x*p*V-u*w*V,dt=e*st+s*_t+a*it+h*H;if(dt===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const at=1/dt;return t[0]=st*at,t[1]=(C*A*h-w*V*h-C*a*k+s*V*k+w*a*z-s*A*z)*at,t[2]=(p*V*h-C*v*h+C*a*f-s*V*f-p*a*z+s*v*z)*at,t[3]=(w*v*h-p*A*h-w*a*f+s*A*f+p*a*k-s*v*k)*at,t[4]=_t*at,t[5]=(x*V*h-L*A*h+L*a*k-e*V*k-x*a*z+e*A*z)*at,t[6]=(L*v*h-u*V*h-L*a*f+e*V*f+u*a*z-e*v*z)*at,t[7]=(u*A*h-x*v*h+x*a*f-e*A*f-u*a*k+e*v*k)*at,t[8]=it*at,t[9]=(L*w*h-x*C*h-L*s*k+e*C*k+x*s*z-e*w*z)*at,t[10]=(u*C*h-L*p*h+L*s*f-e*C*f-u*s*z+e*p*z)*at,t[11]=(x*p*h-u*w*h-x*s*f+e*w*f+u*s*k-e*p*k)*at,t[12]=H*at,t[13]=(x*C*a-L*w*a+L*s*A-e*C*A-x*s*V+e*w*V)*at,t[14]=(L*p*a-u*C*a-L*s*v+e*C*v+u*s*V-e*p*V)*at,t[15]=(u*w*a-x*p*a+x*s*v-e*w*v-u*s*A+e*p*A)*at,this}scale(t){const e=this.elements,s=t.x,a=t.y,h=t.z;return e[0]*=s,e[4]*=a,e[8]*=h,e[1]*=s,e[5]*=a,e[9]*=h,e[2]*=s,e[6]*=a,e[10]*=h,e[3]*=s,e[7]*=a,e[11]*=h,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],a=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,a))}makeTranslation(t,e,s){return t instanceof q?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),a=Math.sin(e),h=1-s,u=t.x,p=t.y,v=t.z,f=h*u,x=h*p;return this.set(f*u+s,f*p-a*v,f*v+a*p,0,f*p+a*v,x*p+s,x*v-a*u,0,f*v-a*p,x*v+a*u,h*v*v+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,a,h,u){return this.set(1,s,h,0,t,1,u,0,e,a,1,0,0,0,0,1),this}compose(t,e,s){const a=this.elements,h=e.x,u=e.y,p=e.z,v=e.w,f=h+h,x=u+u,w=p+p,A=h*f,k=h*x,L=h*w,C=u*x,V=u*w,z=p*w,st=v*f,_t=v*x,it=v*w,H=s.x,dt=s.y,at=s.z;return a[0]=(1-(C+z))*H,a[1]=(k+it)*H,a[2]=(L-_t)*H,a[3]=0,a[4]=(k-it)*dt,a[5]=(1-(A+z))*dt,a[6]=(V+st)*dt,a[7]=0,a[8]=(L+_t)*at,a[9]=(V-st)*at,a[10]=(1-(A+C))*at,a[11]=0,a[12]=t.x,a[13]=t.y,a[14]=t.z,a[15]=1,this}decompose(t,e,s){const a=this.elements;let h=qn.set(a[0],a[1],a[2]).length();const u=qn.set(a[4],a[5],a[6]).length(),p=qn.set(a[8],a[9],a[10]).length();this.determinant()<0&&(h=-h),t.x=a[12],t.y=a[13],t.z=a[14],hr.copy(this);const v=1/h,f=1/u,x=1/p;return hr.elements[0]*=v,hr.elements[1]*=v,hr.elements[2]*=v,hr.elements[4]*=f,hr.elements[5]*=f,hr.elements[6]*=f,hr.elements[8]*=x,hr.elements[9]*=x,hr.elements[10]*=x,e.setFromRotationMatrix(hr),s.x=h,s.y=u,s.z=p,this}equals(t){const e=this.elements,s=t.elements;for(let a=0;a<16;a++)if(e[a]!==s[a])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};za.IDENTITY=Object.freeze(new za);let Ke=za;const qn=new q,hr=new Ke,hd=new q(0,0,0),ud=new q(1,1,1),rn=new q,_i=new q,Ge=new q;class Nt{constructor(t=void 0,e=void 0){this.min=t==null?new q(1/0,1/0,1/0):new q(t.x,t.y,t.z),this.max=e==null?new q(-1/0,-1/0,-1/0):new q(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(wa.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=wa.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Nt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new q(0,0,0):new q(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new q(0,0,0):new q(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,wa).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ar[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ar[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ar[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ar[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ar[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ar[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ar[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ar[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ar),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Ar=[new q,new q,new q,new q,new q,new q,new q,new q],wa=new q,Sl=new te;class ve{constructor(t=void 0,e=void 0){this.min=t==null?new te(1/0,1/0):new te(t.x,t.y),this.max=e==null?new te(-1/0,-1/0):new te(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Sl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new ve().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new te(0,0):new te(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new te(0,0):new te(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Sl).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Pl=new q,cd=new q,dd=new sa;class ai{constructor(t=new q(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,a){return this.normal.set(t,e,s),this.constant=a,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const a=Pl.subVectors(s,e).cross(cd.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(a,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||dd.getNormalMatrix(t),a=this.coplanarPoint(Pl).applyMatrix4(t),h=this.normal.applyMatrix3(s).normalize();return this.constant=-a.dot(h),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new ai().copy(this)}}class Et extends te{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,a)=>{s.toArray(e,a*2)}),e}}class G extends q{static pointArrayToNumberArray(t,e=!0){const s=e?3:2,a=new Array(t.length*s);return t.forEach((h,u)=>{h.toArray(a,u*s)}),a}}const Al=new Ke,El=new Cn,Mh=class Va{constructor(t=0,e=0,s=0,a=Va.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=a}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,a=this._order){return this._x=t,this._y=e,this._z=s,this._order=a,this._onChangeCallback(),this}clone(){return new Va(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const a=t.elements,h=a[0],u=a[4],p=a[8],v=a[1],f=a[5],x=a[9],w=a[2],A=a[6],k=a[10];switch(e){case"XYZ":this._y=Math.asin(Dr(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(-x,k),this._z=Math.atan2(-u,h)):(this._x=Math.atan2(A,f),this._z=0);break;case"YXZ":this._x=Math.asin(-Dr(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(p,k),this._z=Math.atan2(v,f)):(this._y=Math.atan2(-w,h),this._z=0);break;case"ZXY":this._x=Math.asin(Dr(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(-w,k),this._z=Math.atan2(-u,f)):(this._y=0,this._z=Math.atan2(v,h));break;case"ZYX":this._y=Math.asin(-Dr(w,-1,1)),Math.abs(w)<.9999999?(this._x=Math.atan2(A,k),this._z=Math.atan2(v,h)):(this._x=0,this._z=Math.atan2(-u,f));break;case"YZX":this._z=Math.asin(Dr(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(-x,f),this._y=Math.atan2(-w,h)):(this._x=0,this._y=Math.atan2(p,k));break;case"XZY":this._z=Math.asin(-Dr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(A,f),this._y=Math.atan2(p,h)):(this._x=Math.atan2(-x,k),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return Al.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Al,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return El.setFromEuler(this),this.setFromQuaternion(El,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Mh.DEFAULT_ORDER="XYZ";let pd=Mh;class Th{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}let io=class extends Th{translate(t){return this.transform(new sa().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}};class ia extends io{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new ve}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const a=this.loops[s].getPoints(t);e.push(a)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),a=this.sortBoundaryBoxesByAreas(s),h=new Map,u=a.length;for(let v=0;v<u;v++)h.set(a[v],{index:a[v],children:[]});const p={index:-1,children:[]};for(let v=0;v<u;v++){const f=a[v],x=e[f],w=s[f];let A=v+1;for(;A<u;A++){const k=a[A],L=e[k];if(s[k].containsBox(w)&&xh.isPointInPolygon(x[St.randInt(0,x.length-1)],L)){(t=h.get(k))==null||t.children.push(h.get(f));break}}A===u&&p.children.push(h.get(f))}return p}get area(){if(this._loops.length===0)return 0;let t=0;for(let e=0;e<this._loops.length;e++){const s=this._loops[e].getPoints(128),a=this.polygonArea(s);e===0?t+=Math.abs(a):t-=Math.abs(a)}return t}polygonArea(t){const e=t.length;if(e<3)return 0;let s=0;for(let a=0,h=e-1;a<e;h=a++){const u=t[h],p=t[a];s+=u.x*p.y-p.x*u.y}return s*.5}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new ve().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((a,h)=>{const u=a.size,p=u.width*u.height;e.push({area:p,index:h})}),e.sort((a,h)=>a.area-h.area);const s=[];return e.forEach(a=>{s.push(a.index)}),s}}class ss extends io{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,a=this.getPoint(0),h=0;e.push(0);for(let u=1;u<=t;u++)s=this.getPoint(u/t),h+=s.distanceTo(a),e.push(h),a=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let a=0;const h=s.length;let u;e?u=e:u=t*s[h-1];let p=0,v=h-1,f;for(;p<=v;)if(a=Math.floor(p+(v-p)/2),f=s[a]-u,f<0)p=a+1;else if(f>0)v=a-1;else{v=a;break}if(a=v,s[a]===u)return a/(h-1);const x=s[a],w=s[a+1]-x,A=(u-x)/w;return(a+A)/(h-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const a=this.getPoint(e),h=this.getPoint(s),u=new Et;return u.copy(h).sub(a).normalize(),u}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class Nn extends ss{constructor(t,e,s,a,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(u==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(u==5){const p=t;this.center=new Et(p.x,p.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(s)):St.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(a)):St.normalizeAngle(a)}else throw Ze.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const a=(at,Wt)=>({x:(at.x+Wt.x)/2,y:(at.y+Wt.y)/2}),h=(at,Wt)=>(Wt.y-at.y)/(Wt.x-at.x),u=at=>-1/at,p=a(t,e),v=a(e,s),f=h(t,e),x=h(e,s),w=u(f),A=u(x),k=(at,Wt,Kt,Xt)=>{const xt=(Xt-Wt)/(at-Kt),Bt=at*xt+Wt;return{x:xt,y:Bt}},L=p.y-w*p.x,C=v.y-A*v.x,V=k(w,L,A,C),z=Math.sqrt(Math.pow(t.x-V.x,2)+Math.pow(t.y-V.y,2)),st=(at,Wt)=>Math.atan2(at.y-Wt.y,at.x-Wt.x),_t=st(t,V),it=st(e,V),H=st(s,V),dt=H>_t&&H<it||_t>H&&_t<it||it>H&&it<_t;this.center=V,this.radius=z,this._clockwise=!dt,this._startAngle=_t,this._endAngle=H}createByStartEndPointsAndBulge(t,e,s){let a,h,u;s<0?(a=Math.atan(-s)*4,h=new te(t),u=new te(e)):(a=Math.atan(s)*4,h=new te(e),u=new te(t));const p=new te().subVectors(u,h),v=p.length(),f=new te().addVectors(h,p.multiplyScalar(.5)),x=Math.abs(v/2/Math.tan(a/2)),w=p.normalize();let A;if(a<Math.PI){const k=new te(w.x*Math.cos(Math.PI/2)-w.y*Math.sin(Math.PI/2),w.y*Math.cos(Math.PI/2)+w.x*Math.sin(Math.PI/2));A=f.add(k.multiplyScalar(-x))}else{const k=new te(w.x*Math.cos(Math.PI/2)-w.y*Math.sin(Math.PI/2),w.y*Math.cos(Math.PI/2)+w.x*Math.sin(Math.PI/2));A=f.add(k.multiplyScalar(x))}s<0?(this._startAngle=Math.atan2(h.y-A.y,h.x-A.x),this._endAngle=Math.atan2(u.y-A.y,u.x-A.x)):(this._startAngle=Math.atan2(u.y-A.y,u.x-A.x),this._endAngle=Math.atan2(h.y-A.y,h.x-A.x)),this._clockwise=s<0,this.center=A,this.radius=u.sub(A).length()}get center(){return this._center}set center(t){this._center=new Et(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(St.normalizeAngle(t)):St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const e=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(e):e,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return this.clockwise?St.normalizeAngle(t-e):St.normalizeAngle(e-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=St.normalizeAngle((t+e)/2),a=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(a)}get closed(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return Math.abs(e-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of e){const u=this._getInternalAngle(h);St.isBetweenAngle(u,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const s=t.map(h=>h.x),a=t.map(h=>h.y);return new ve(new Et(Math.min(...s),Math.min(...a)),new Et(Math.max(...s),Math.max(...a)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Nn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),s=this.center.x+this.radius*Math.cos(e),a=this.center.y+this.radius*Math.sin(e);return new Et(s,a)}getPoints(t=100){const e=[];let s=this.deltaAngle,a=this._getInternalAngle(this.startAngle);if(this.closed&&(s=Qt,a=0),this.clockwise)for(let h=0;h<=t;h++){const u=a-s*(h/t),p=this._clockwise?this._mirrorAngle(u):u,v=this.getPointAtAngle(p);e.push(new Et(v.x,v.y))}else for(let h=0;h<=t;h++){const u=a+s*(h/t),p=this._clockwise?this._mirrorAngle(u):u,v=this.getPointAtAngle(p);e.push(new Et(v.x,v.y))}return e}}class md extends Th{translate(t){return this.transform(new Ke().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class oi extends md{}let es=class Nh extends oi{constructor(t,e){super(),this._start=new G(t),this._end=new G(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new q().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new G((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(t){return this.project(t)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const s=this.delta(yn).normalize();return new G(this._start).addScaledVector(s,t)}else{const s=this.delta(yn).normalize();return new G(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=yn.subVectors(this._start,this._end).normalize();this._start=new G(this._start).addScaledVector(s,t)}else{const s=this.delta(yn).normalize();this._end=new G(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){kl.subVectors(t,this._start),fi.subVectors(this.endPoint,this.startPoint);const s=fi.dot(fi);let a=fi.dot(kl)/s;return e&&(a=St.clamp(a,0,1)),a}closestPointToPoint(t,e,s){const a=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(a).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=yn.subVectors(t,this.startPoint).dot(e);return new G().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,a=yn.subVectors(t,s).dot(e),h=yn.copy(e).multiplyScalar(a);return new G().addVectors(s,h)}calculateBoundingBox(){const t=new G(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new G(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 Nt(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Nh(this._start.clone(),this._end.clone())}};const yn=new q,kl=new q,fi=new q;let ao=class wi extends oi{static computeCenterPoint(t,e,s){const a=new q().addVectors(t,e).multiplyScalar(.5),h=new q().addVectors(t,s).multiplyScalar(.5),u=new q().subVectors(e,t),p=new q().subVectors(s,t),v=new q().crossVectors(u,p).normalize();if(v.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new q().crossVectors(u,v).normalize(),x=new q().crossVectors(p,v).normalize(),w=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),A=x.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),k=new es(a,a.clone().add(w)),L=new es(h,h.clone().add(A)),C=new q;return k.closestPointToPoint(L.startPoint,!0,C)?C:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const a=wi.computeCenterPoint(t,e,s);if(a){const h=a.distanceTo(t),u=new q().subVectors(t,a),p=new q().subVectors(e,a),v=Math.atan2(u.y,u.x),f=Math.atan2(p.y,p.x);return new wi(a,h,v,f,q.Z_AXIS)}}constructor(t,e,s,a,h,u=q.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=a,this.normal=h,this.refVec=u,(a-s)%Qt==0?(this.startAngle=0,this.endAngle=Qt):(this.startAngle=s,this.endAngle=a)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return St.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new q(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new q(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;this.closed&&(t=0,e=Qt);const s=t+e*.5;return this.getPointAtAngle(s)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const e=new q(t.x,t.y,t.z||0),s=this.center,a=this.normal,h=e.clone().sub(s).dot(a),u=e.clone().sub(a.clone().multiplyScalar(h)).clone().sub(s);if(u.lengthSq()===0)return this.startPoint.clone();u.normalize().multiplyScalar(this.radius);const p=s.clone().add(u),v=this.getAngle(p.clone()),f=this.startAngle,x=this.deltaAngle;let w=St.normalizeAngle(v-f);w<0&&(w=0),w>x&&(w=x);const A=this.getPointAtAngle(f+w),k=A.distanceTo(e),L=this.startPoint.distanceTo(e),C=this.endPoint.distanceTo(e);return L<k&&L<=C?this.startPoint.clone():C<k&&C<L?this.endPoint.clone():A}tangentPoints(t){const e=[],s=new q(t.x,t.y,t.z||0),a=this.center,h=this.normal,u=this.radius,p=s.clone().sub(a).dot(h),v=s.clone().sub(h.clone().multiplyScalar(p)),f=a.clone(),x=v.clone().sub(f).length();if(x<u)return e;const w=Math.acos(u/x),A=this.getAngle(v.clone()),k=[A+w,A-w];for(const L of k){const C=St.normalizeAngle(L-this.startAngle);C>=0&&C<=this.deltaAngle&&e.push(this.getPointAtAngle(this.startAngle+C))}return e}nearestTangentPoint(t){const e=this.tangentPoints(t);if(e.length===0)return null;const s=new G(t.x,t.y,t.z||0);return e.length===1||e[0].distanceTo(s)<e[1].distanceTo(s)?e[0]:e[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let v=0;v<2*Math.PI;v+=Math.PI/2)St.isBetweenAngle(v,this.startAngle,this.endAngle)&&t.push(v);let e=1/0,s=1/0,a=1/0,h=-1/0,u=-1/0,p=-1/0;for(const v of t){const f=this.getPointAtAngle(v);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>p&&(p=f.z)}return new Nt({x:e,y:s,z:a},{x:h,y:u,z:p})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,a=this.startAngle;this.closed&&(s=Qt,a=0);for(let h=0;h<=t;h++){const u=a+s*(h/t),p=this.getPointAtAngle(u);e.push(p)}return e}transform(t){const e=xa.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=xa.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),s.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new wi(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(xa.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,a={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},h=this.center,u=this.radius;return new G(h.x+u*(s.x*Math.cos(t)+a.x*Math.sin(t)),h.y+u*(s.y*Math.cos(t)+a.y*Math.sin(t)),h.z+u*(s.z*Math.cos(t)+a.z*Math.sin(t)))}get plane(){const t=new q(this.center).distanceTo(eo);return new ai(this.normal,t)}};const xa=new q;class li extends ss{constructor(t,e,s,a=0,h=Qt,u=!1,p=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(h-a)%Qt==0?(this.startAngle=0,this.endAngle=Qt):(this.startAngle=a,this.endAngle=h),this.clockwise=u,this.rotation=p}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return St.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,a=-1/0;for(let h=0;h<=100;h++){const u=this.getPoint(h/100);t=Math.min(t,u.x),e=Math.min(e,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y)}return new ve({x:t,y:e},{x:s,y:a})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(a?s=0:s=e),this.clockwise===!0&&!a&&(s===e?s=-e:s=s-e);const h=this.startAngle+t*s;let u=this.center.x+this.majorAxisRadius*Math.cos(h),p=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const v=Math.cos(this.rotation),f=Math.sin(this.rotation),x=u-this.center.x,w=p-this.center.y;u=x*v-w*f+this.center.x,p=x*f+w*v+this.center.y}return new Et(u,p)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new li(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class aa extends oi{constructor(t,e,s,a,h,u=0,p=Qt){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=a,this.minorAxisRadius=h;const v=Math.abs(p-u);Math.abs(v-Qt)<1e-10||Math.abs(v-2*Qt)<1e-10?(this.startAngle=0,this.endAngle=Qt):(this.startAngle=u,this.endAngle=p)}get center(){return this._center}set center(t){this._center=new G(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw Ze.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==Qt?t:St.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-Qt)<1e-10?Qt:St.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new q(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new q(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new q().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;(this.closed||Math.abs(e-Qt)<1e-10)&&(t=0,e=Qt);const s=t+e/2;return this.getPointAtAngle(s)}get isCircular(){return ro.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let s=0,a=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const u=this.startAngle+h*e,p=this.getPointAtAngle(u),v=p.x-a.x,f=p.y-a.y,x=p.z-a.z;s+=Math.sqrt(v*v+f*f+x*x),a=p}return s}get area(){const t=this.majorAxisRadius,e=this.minorAxisRadius,s=this.startAngle,a=s+this.deltaAngle;if(Math.abs(this.deltaAngle-Qt)<1e-10)return Math.PI*t*e;const h=t*e/2*(a-s-(Math.sin(a)*Math.cos(a)-Math.sin(s)*Math.cos(s)));return Math.abs(h)}calculateBoundingBox(){if(this.majorAxis.equals(q.X_AXIS)||this.majorAxis.equals(q.Y_AXIS)||this.majorAxis.isParallelTo(q.X_AXIS)||this.majorAxis.isParallelTo(q.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let v=0;v<2*Math.PI;v+=Math.PI/2)St.isBetweenAngle(v,this.startAngle,this.endAngle)&&t.push(v);let e=1/0,s=1/0,a=1/0,h=-1/0,u=-1/0,p=-1/0;for(const v of t){const f=this.getPointAtAngle(v);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<a&&(a=f.z),f.x>h&&(h=f.x),f.y>u&&(u=f.y),f.z>p&&(p=f.z)}return new Nt({x:e,y:s,z:a},{x:h,y:u,z:p})}else{let t=1/0,e=1/0,s=1/0,a=-1/0,h=-1/0,u=-1/0;for(let p=0;p<=100;p++){const v=this.startAngle+this.deltaAngle*(p/100),f=this.getPointAtAngle(v);t=Math.min(t,f.x),e=Math.min(e,f.y),s=Math.min(s,f.z),a=Math.max(a,f.x),h=Math.max(h,f.y),u=Math.max(u,f.z)}return new Nt({x:t,y:e,z:s},{x:a,y:h,z:u})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,a=this.startAngle;this.closed&&(s=Qt,a=0);for(let h=0;h<=t;h++){const u=a+s*(h/t),p=this.getPointAtAngle(u);e.push(p)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),a=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(a);return new G(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(t){const e=new q(t).sub(this.center),s=e.dot(this.majorAxis),a=e.dot(this.minorAxis),h=s/this.majorAxisRadius,u=a/this.minorAxisRadius;return h*h+u*u<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new aa(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new q(this.center).distanceTo(eo);return new ai(this.normal,t)}}class un extends ss{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new Et(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new Et(e.x,e.y)}else{const e=this._vertices[t-1];return new Et(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let s=0;s<e;++s){const a=this._vertices[s];let h=null;if(s<e-1?h=this._vertices[s+1]:s==e-1&&this.closed&&(h=this._vertices[0]),h)if(a.bulge){const u=new Nn(a,h,a.bulge);t+=u.length}else t+=new Et(a.x,a.y).distanceTo(h)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}removeVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error(`Index ${t} is out of bounds. Valid range is 0 to ${this._vertices.length-1}.`);this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0}reset(t,e){t?e!==void 0&&e>=0&&e<this._vertices.length&&(this._vertices=this._vertices.slice(0,e),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(t){const e=this._vertices[t];return new Et(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new ve().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(a=>s.push(new G().set(a.x,a.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let a=0;a<s;++a){const h=this._vertices[a];if(h.bulge){let u=null;if(a<s-1?u=this._vertices[a+1]:a==s-1&&this.closed&&(u=this._vertices[0]),u){const p=new Nn(h,u,h.bulge).getPoints(t),v=p.length;for(let f=0;f<v;++f){const x=p[f];e.push(new Et(x.x,x.y))}}}else e.push(new Et(h.x,h.y)),a==s-1&&this.closed&&e.push(e[0])}return e}}let ts=class Lh extends ss{constructor(t,e){super(),this._start=new Et(t),this._end=new Et(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new Et(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new Et(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new ve(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Lh(this._start.clone(),this._end.clone())}},oa=class extends ss{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new Et(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new ve;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(a=>{e.push(new Et(a.x,a.y))})}),e}};function gd(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Oh={exports:{}};(function(n,t){(function(e){n.exports=e()})(function(){var e={},s=this;new Function("try {return this===window;}catch(e){ return false;}");var a=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(a()&&h(),a()||h()){var u=s;if(h()){var p=function(v,f){var x=s;return v.split(".").forEach(function(w){x&&(x=x[w])}),x?x[f]:null};onmessage=function(v){if(!(!v.data.className||!v.data.methodName)){var f=p(v.data.className,v.data.methodName);if(!f)return console.error("could not find "+v.data.className+"."+v.data.methodName);postMessage({result:f.apply(null,v.data.args),id:v.data.id})}}}}return function(v,f,x){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var w={},A=function(){return Lt.__string_rec(this,"")};function k(r,i){function o(){}o.prototype=r;var l=new o;for(var c in i)l[c]=i[c];return i.toString!==Object.prototype.toString&&(l.toString=i.toString),l}var L=function(){};w.HxOverrides=L,L.__name__=["HxOverrides"],L.strDate=function(r){var i=r.length;switch(i){case 8:var o=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(o[0]),l.setUTCMinutes(o[1]),l.setUTCSeconds(o[2]),l;case 10:var c=r.split("-");return new Date(c[0],c[1]-1,c[2],0,0,0);case 19:var d=r.split(" "),g=d[0].split("-"),_=d[1].split(":");return new Date(g[0],g[1]-1,g[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},L.cca=function(r,i){var o=r.charCodeAt(i);if(o==o)return o},L.substr=function(r,i,o){return i!=null&&i!=0&&o!=null&&o<0?"":(o==null&&(o=r.length),i<0?(i=r.length+i,i<0&&(i=0)):o<0&&(o=r.length+o-i),r.substr(i,o))},L.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var C=function(){};w.Lambda=C,C.__name__=["Lambda"],C.fold=function(r,i,o){for(var l=sr(r)();l.hasNext();){var c=l.next();o=i(c,o)}return o};var V=function(){this.length=0};w.List=V,V.__name__=["List"],V.prototype={add:function(r){var i=[r];this.h==null?this.h=i:this.q[1]=i,this.q=i,this.length++},pop:function(){if(this.h==null)return null;var r=this.h[0];return this.h=this.h[1],this.h==null&&(this.q=null),this.length--,r},isEmpty:function(){return this.h==null},__class__:V},Math.__name__=["Math"];var z=function(){};w.Reflect=z,z.__name__=["Reflect"],z.field=function(r,i){try{return r[i]}catch(o){return o instanceof Q&&(o=o.val),null}},z.callMethod=function(r,i,o){return i.apply(r,o)},z.fields=function(r){var i=[];if(r!=null){var o=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&o.call(r,l)&&i.push(l)}return i},z.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},z.deleteField=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)?(delete r[i],!0):!1};var st=function(){};w.Std=st,st.__name__=["Std"],st.string=function(r){return Lt.__string_rec(r,"")},st.parseFloat=function(r){return parseFloat(r)};var _t=function(){this.b=""};w.StringBuf=_t,_t.__name__=["StringBuf"],_t.prototype={add:function(r){this.b+=st.string(r)},__class__:_t};var it=function(){};w.StringTools=it,it.__name__=["StringTools"],it.fastCodeAt=function(r,i){return r.charCodeAt(i)};var H=w.ValueType={__ename__:["ValueType"],__constructs__:["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]};H.TNull=["TNull",0],H.TNull.toString=A,H.TNull.__enum__=H,H.TInt=["TInt",1],H.TInt.toString=A,H.TInt.__enum__=H,H.TFloat=["TFloat",2],H.TFloat.toString=A,H.TFloat.__enum__=H,H.TBool=["TBool",3],H.TBool.toString=A,H.TBool.__enum__=H,H.TObject=["TObject",4],H.TObject.toString=A,H.TObject.__enum__=H,H.TFunction=["TFunction",5],H.TFunction.toString=A,H.TFunction.__enum__=H,H.TClass=function(r){var i=["TClass",6,r];return i.__enum__=H,i.toString=A,i},H.TEnum=function(r){var i=["TEnum",7,r];return i.__enum__=H,i.toString=A,i},H.TUnknown=["TUnknown",8],H.TUnknown.toString=A,H.TUnknown.__enum__=H;var dt=function(){};w.Type=dt,dt.__name__=["Type"],dt.getClassName=function(r){var i=r.__name__;return i==null?null:i.join(".")},dt.getEnumName=function(r){var i=r.__ename__;return i.join(".")},dt.resolveClass=function(r){var i=w[r];return i==null||!i.__name__?null:i},dt.resolveEnum=function(r){var i=w[r];return i==null||!i.__ename__?null:i},dt.createEmptyInstance=function(r){function i(){}return i.prototype=r.prototype,new i},dt.createEnum=function(r,i,o){var l=z.field(r,i);if(l==null)throw new Q("No such constructor "+i);if(z.isFunction(l)){if(o==null)throw new Q("Constructor "+i+" need parameters");return z.callMethod(r,l,o)}if(o!=null&&o.length!=0)throw new Q("Constructor "+i+" does not need parameters");return l},dt.getEnumConstructs=function(r){var i=r.__constructs__;return i.slice()},dt.typeof=function(r){var i=typeof r;switch(i){case"boolean":return H.TBool;case"string":return H.TClass(String);case"number":return Math.ceil(r)==r%2147483648?H.TInt:H.TFloat;case"object":if(r==null)return H.TNull;var o=r.__enum__;if(o!=null)return H.TEnum(o);var l=Lt.getClass(r);return l!=null?H.TClass(l):H.TObject;case"function":return r.__name__||r.__ename__?H.TObject:H.TFunction;case"undefined":return H.TNull;default:return H.TUnknown}};var at=function(){};w["haxe.IMap"]=at,at.__name__=["haxe","IMap"];var Wt=function(r,i){this.high=r,this.low=i};w["haxe._Int64.___Int64"]=Wt,Wt.__name__=["haxe","_Int64","___Int64"],Wt.prototype={__class__:Wt};var Kt=function(){this.buf=new _t,this.cache=[],this.useCache=Kt.USE_CACHE,this.useEnumIndex=Kt.USE_ENUM_INDEX,this.shash=new we,this.scount=0};w["haxe.Serializer"]=Kt,Kt.__name__=["haxe","Serializer"],Kt.prototype={toString:function(){return this.buf.b},serializeString:function(r){var i=this.shash.get(r);if(i!=null){this.buf.b+="R",i==null?this.buf.b+="null":this.buf.b+=""+i;return}this.shash.set(r,this.scount++),this.buf.b+="y",r=encodeURIComponent(r),r.length==null?this.buf.b+="null":this.buf.b+=""+r.length,this.buf.b+=":",r==null?this.buf.b+="null":this.buf.b+=""+r},serializeRef:function(r){for(var i=typeof r,o=0,l=this.cache.length;o<l;){var c=o++,d=this.cache[c];if(typeof d==i&&d==r)return this.buf.b+="r",c==null?this.buf.b+="null":this.buf.b+=""+c,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var i=0,o=z.fields(r);i<o.length;){var l=o[i];++i,this.serializeString(l),this.serialize(z.field(r,l))}this.buf.b+="g"},serialize:function(r){{var i=dt.typeof(r);switch(i[1]){case 0:this.buf.b+="n";break;case 1:var o=r;if(o==0){this.buf.b+="z";return}this.buf.b+="i",o==null?this.buf.b+="null":this.buf.b+=""+o;break;case 2:var l=r;isNaN(l)?this.buf.b+="k":isFinite(l)?(this.buf.b+="d",l==null?this.buf.b+="null":this.buf.b+=""+l):l<0?this.buf.b+="m":this.buf.b+="p";break;case 3:r?this.buf.b+="t":this.buf.b+="f";break;case 6:var c=i[2];if(c==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(c){case Array:var d=0;this.buf.b+="a";for(var g=r.length,_=0;_<g;){var y=_++;r[y]==null?d++:(d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d),d=0),this.serialize(r[y]))}d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d)),this.buf.b+="h";break;case V:this.buf.b+="l";for(var I=r,P=I.h,S=null;P!=null;){var E;S=P[0],P=P[1],E=S,this.serialize(E)}this.buf.b+="h";break;case Date:var M=r;this.buf.b+="v",this.buf.add(M.getTime());break;case we:this.buf.b+="b";for(var T=r,B=T.keys();B.hasNext();){var O=B.next();this.serializeString(O),this.serialize(da[O]!=null?T.getReserved(O):T.h[O])}this.buf.b+="h";break;case xt:this.buf.b+="q";for(var F=r,R=F.keys();R.hasNext();){var j=R.next();this.buf.b+=":",j==null?this.buf.b+="null":this.buf.b+=""+j,this.serialize(F.h[j])}this.buf.b+="h";break;case Bt:this.buf.b+="M";for(var D=r,X=D.keys();X.hasNext();){var J=X.next(),Y=z.field(J,"__id__");z.deleteField(J,"__id__"),this.serialize(J),J.__id__=Y,this.serialize(D.h[J.__id__])}this.buf.b+="h";break;case ze:for(var U=r,K=0,tt=U.length-2,et=new _t,ot=Kt.BASE64;K<tt;){var ct=U.get(K++),ht=U.get(K++),pt=U.get(K++);et.add(ot.charAt(ct>>2)),et.add(ot.charAt((ct<<4|ht>>4)&63)),et.add(ot.charAt((ht<<2|pt>>6)&63)),et.add(ot.charAt(pt&63))}if(K==tt){var nt=U.get(K++),mt=U.get(K++);et.add(ot.charAt(nt>>2)),et.add(ot.charAt((nt<<4|mt>>4)&63)),et.add(ot.charAt(mt<<2&63))}else if(K==tt+1){var $=U.get(K++);et.add(ot.charAt($>>2)),et.add(ot.charAt($<<4&63))}var ft=et.b;this.buf.b+="s",ft.length==null?this.buf.b+="null":this.buf.b+=""+ft.length,this.buf.b+=":",ft==null?this.buf.b+="null":this.buf.b+=""+ft;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(dt.getClassName(c)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(dt.getClassName(c)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Lt.__instanceof(r,il)){var kt=dt.getClassName(r);this.buf.b+="A",this.serializeString(kt)}else if(Lt.__instanceof(r,al))this.buf.b+="B",this.serializeString(dt.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Yt=i[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(dt.getEnumName(Yt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=st.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Zt=r.length;this.buf.b+=st.string(Zt-2);for(var Ut=2;Ut<Zt;){var Jt=Ut++;this.serialize(r[Jt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+st.string(r))}}},__class__:Kt};var Xt=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var i=Xt.DEFAULT_RESOLVER;i==null&&(i=dt,Xt.DEFAULT_RESOLVER=i),this.setResolver(i)};w["haxe.Unserializer"]=Xt,Xt.__name__=["haxe","Unserializer"],Xt.initCodes=function(){for(var r=[],i=0,o=Xt.BASE64.length;i<o;){var l=i++;r[Xt.BASE64.charCodeAt(l)]=l}return r},Xt.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(i){return null},resolveEnum:function(i){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,i=!1,o=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=o)break;i=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return i&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var i=this.buf.charCodeAt(this.pos);if(i>=43&&i<58||i==101||i==69)this.pos++;else break}return st.parseFloat(L.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var i=this.unserialize();if(typeof i!="string")throw new Q("Invalid object key");var o=this.unserialize();r[i]=o}this.pos++},unserializeEnum:function(r,i){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var o=this.readDigits();if(o==0)return dt.createEnum(r,i);for(var l=[];o-- >0;)l.push(this.unserialize());return dt.createEnum(r,i,l)},unserialize:function(){var r=this.get(this.pos++);switch(r){case 110:return null;case 116:return!0;case 102:return!1;case 122:return 0;case 105:return this.readDigits();case 100:return this.readFloat();case 121:var i=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<i)throw new Q("Invalid string length");var o=L.substr(this.buf,this.pos,i);return this.pos+=i,o=decodeURIComponent(o.split("+").join(" ")),this.scache.push(o),o;case 107:return NaN;case 109:return-1/0;case 112:return 1/0;case 97:this.buf;var l=[];for(this.cache.push(l);;){var c=this.buf.charCodeAt(this.pos);if(c==104){this.pos++;break}if(c==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var g={};return this.cache.push(g),this.unserializeObject(g),g;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var y=this.readDigits();if(y<0||y>=this.scache.length)throw new Q("Invalid string reference");return this.scache[y];case 120:throw new Q(this.unserialize());case 99:var I=this.unserialize(),P=this.resolver.resolveClass(I);if(P==null)throw new Q("Class not found "+I);var S=dt.createEmptyInstance(P);return this.cache.push(S),this.unserializeObject(S),S;case 119:var E=this.unserialize(),M=this.resolver.resolveEnum(E);if(M==null)throw new Q("Enum not found "+E);var T=this.unserializeEnum(M,this.unserialize());return this.cache.push(T),T;case 106:var B=this.unserialize(),O=this.resolver.resolveEnum(B);if(O==null)throw new Q("Enum not found "+B);this.pos++;var F=this.readDigits(),R=dt.getEnumConstructs(O)[F];if(R==null)throw new Q("Unknown enum index "+B+"@"+F);var j=this.unserializeEnum(O,R);return this.cache.push(j),j;case 108:var D=new V;for(this.cache.push(D),this.buf;this.buf.charCodeAt(this.pos)!=104;)D.add(this.unserialize());return this.pos++,D;case 98:var X=new we;for(this.cache.push(X),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();X.set(J,this.unserialize())}return this.pos++,X;case 113:var Y=new xt;this.cache.push(Y),this.buf;for(var U=this.get(this.pos++);U==58;){var K=this.readDigits();Y.set(K,this.unserialize()),U=this.get(this.pos++)}if(U!=104)throw new Q("Invalid IntMap format");return Y;case 77:var tt=new Bt;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var ot;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var ct=L.substr(this.buf,this.pos,19);ot=L.strDate(ct),this.pos+=19}else{var ht=this.readFloat(),pt=new Date;pt.setTime(ht),ot=pt}return this.cache.push(ot),ot;case 115:var nt=this.readDigits(),mt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var $=Xt.CODES;$==null&&($=Xt.initCodes(),Xt.CODES=$);var ft=this.pos,kt=nt&3,Yt;Yt=(nt>>2)*3+(kt>=2?kt-1:0);for(var Zt=ft+(nt-kt),Ut=ze.alloc(Yt),Jt=0;ft<Zt;){var Be=$[it.fastCodeAt(mt,ft++)],tr=$[it.fastCodeAt(mt,ft++)];Ut.set(Jt++,Be<<2|tr>>4);var Ae=$[it.fastCodeAt(mt,ft++)];Ut.set(Jt++,tr<<4|Ae>>2);var Ie=$[it.fastCodeAt(mt,ft++)];Ut.set(Jt++,Ae<<6|Ie)}if(kt>=2){var Re=$[it.fastCodeAt(mt,ft++)],Ue=$[it.fastCodeAt(mt,ft++)];if(Ut.set(Jt++,Re<<2|Ue>>4),kt==3){var ir=$[it.fastCodeAt(mt,ft++)];Ut.set(Jt++,Ue<<4|ir>>2)}}return this.pos+=nt,this.cache.push(Ut),Ut;case 67:var fr=this.unserialize(),ar=this.resolver.resolveClass(fr);if(ar==null)throw new Q("Class not found "+fr);var or=dt.createEmptyInstance(ar);if(this.cache.push(or),or.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return or;case 65:var lr=this.unserialize(),Sr=this.resolver.resolveClass(lr);if(Sr==null)throw new Q("Class not found "+lr);return Sr;case 66:var Yn=this.unserialize(),gn=this.resolver.resolveEnum(Yn);if(gn==null)throw new Q("Enum not found "+Yn);return gn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Xt};var xt=function(){this.h={}};w["haxe.ds.IntMap"]=xt,xt.__name__=["haxe","ds","IntMap"],xt.__interfaces__=[at],xt.prototype={set:function(r,i){this.h[r]=i},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var i in this.h)this.h.hasOwnProperty(i)&&r.push(i|0);return L.iter(r)},__class__:xt};var Bt=function(){this.h={},this.h.__keys__={}};w["haxe.ds.ObjectMap"]=Bt,Bt.__name__=["haxe","ds","ObjectMap"],Bt.__interfaces__=[at],Bt.prototype={set:function(r,i){var o=r.__id__||(r.__id__=++Bt.count);this.h[o]=i,this.h.__keys__[o]=r},keys:function(){var r=[];for(var i in this.h.__keys__)this.h.hasOwnProperty(i)&&r.push(this.h.__keys__[i]);return L.iter(r)},__class__:Bt};var be=w["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};be.Some=function(r){var i=["Some",0,r];return i.__enum__=be,i.toString=A,i},be.None=["None",1],be.None.toString=A,be.None.__enum__=be;var we=function(){this.h={}};w["haxe.ds.StringMap"]=we,we.__name__=["haxe","ds","StringMap"],we.__interfaces__=[at],we.prototype={set:function(r,i){da[r]!=null?this.setReserved(r,i):this.h[r]=i},get:function(r){return da[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,i){this.rh==null&&(this.rh={}),this.rh["$"+r]=i},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return L.iter(r)},arrayKeys:function(){var r=[];for(var i in this.h)this.h.hasOwnProperty(i)&&r.push(i);if(this.rh!=null)for(var i in this.rh)i.charCodeAt(0)==36&&r.push(i.substr(1));return r},__class__:we};var ze=function(r){this.length=r.byteLength,this.b=new pa(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};w["haxe.io.Bytes"]=ze,ze.__name__=["haxe","io","Bytes"],ze.alloc=function(r){return new ze(new mi(r))},ze.prototype={get:function(r){return this.b[r]},set:function(r,i){this.b[r]=i&255},__class__:ze};var se=w["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};se.Blocked=["Blocked",0],se.Blocked.toString=A,se.Blocked.__enum__=se,se.Overflow=["Overflow",1],se.Overflow.toString=A,se.Overflow.__enum__=se,se.OutsideBounds=["OutsideBounds",2],se.OutsideBounds.toString=A,se.OutsideBounds.__enum__=se,se.Custom=function(r){var i=["Custom",3,r];return i.__enum__=se,i.toString=A,i};var pe=function(){};w["haxe.io.FPHelper"]=pe,pe.__name__=["haxe","io","FPHelper"],pe.i32ToFloat=function(r){var i=1-(r>>>31<<1),o=r>>>23&255,l=r&8388607;return l==0&&o==0?0:i*(1+Math.pow(2,-23)*l)*Math.pow(2,o-127)},pe.floatToI32=function(r){if(r==0)return 0;var i;r<0?i=-r:i=r;var o=Math.floor(Math.log(i)/.6931471805599453);o<-127?o=-127:o>128&&(o=128);var l=Math.round((i/Math.pow(2,o)-1)*8388608)&8388607;return(r<0?-2147483648:0)|o+127<<23|l},pe.i64ToDouble=function(r,i){var o=1-(i>>>31<<1),l=(i>>20&2047)-1023,c=(i&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return c==0&&l==-1023?0:o*(1+Math.pow(2,-52)*c)*Math.pow(2,l)},pe.doubleToI64=function(r){var i=pe.i64tmp;if(r==0)i.low=0,i.high=0;else{var o;r<0?o=-r:o=r;var l=Math.floor(Math.log(o)/.6931471805599453),c,d=(o/Math.pow(2,l)-1)*4503599627370496;c=Math.round(d);var g=c|0,_=c/4294967296|0;i.low=g,i.high=(r<0?-2147483648:0)|l+1023<<20|_}return i};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};w["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=k(Error.prototype,{__class__:Q});var Lt=function(){};w["js.Boot"]=Lt,Lt.__name__=["js","Boot"],Lt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var i=r.__class__;if(i!=null)return i;var o=Lt.__nativeClassName(r);return o!=null?Lt.__resolveNativeClass(o):null},Lt.__string_rec=function(r,i){if(r==null)return"null";if(i.length>=5)return"<...>";var o=typeof r;switch(o=="function"&&(r.__name__||r.__ename__)&&(o="object"),o){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";i+=" ";for(var c=2,d=r.length;c<d;){var g=c++;g!=2?l+=","+Lt.__string_rec(r[g],i):l+=Lt.__string_rec(r[g],i)}return l+")"}var _=r.length,y="[";i+=" ";for(var I=0;I<_;){var P=I++;y+=(P>0?",":"")+Lt.__string_rec(r[P],i)}return y+="]",y}var S;try{S=r.toString}catch(O){return O instanceof Q&&(O=O.val),"???"}if(S!=null&&S!=Object.toString&&typeof S=="function"){var E=r.toString();if(E!="[object Object]")return E}var M=null,T=`{
|
|
4
4
|
`;i+=" ";var B=r.hasOwnProperty!=null;for(var M in r)B&&!r.hasOwnProperty(M)||M=="prototype"||M=="__class__"||M=="__super__"||M=="__interfaces__"||M=="__properties__"||(T.length!=2&&(T+=`,
|
|
5
5
|
`),T+=i+M+" : "+Lt.__string_rec(r[M],i));return i=i.substring(1),T+=`
|
|
6
|
-
`+i+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Lt.__interfLoop=function(r,i){if(r==null)return!1;if(r==i)return!0;var o=r.__interfaces__;if(o!=null)for(var l=0,c=o.length;l<c;){var d=l++,g=o[d];if(g==i||Lt.__interfLoop(g,i))return!0}return Lt.__interfLoop(r.__super__,i)},Lt.__instanceof=function(r,i){if(i==null)return!1;switch(i){case Cc:return(r|0)===r;case nl:return typeof r=="number";case sl:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case Bc:return!0;default:if(r!=null){if(typeof i=="function"){if(r instanceof i||Lt.__interfLoop(Lt.getClass(r),i))return!0}else if(typeof i=="object"&&Lt.__isNativeObj(i)&&r instanceof i)return!0}else return!1;return i==il&&r.__name__!=null||i==al&&r.__ename__!=null?!0:r.__enum__==i}},Lt.__nativeClassName=function(r){var i=Lt.__toStr.call(r).slice(8,-1);return i=="Object"||i=="Function"||i=="Math"||i=="JSON"?null:i},Lt.__isNativeObj=function(r){return Lt.__nativeClassName(r)!=null},Lt.__resolveNativeClass=function(r){return x[r]};var me=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var i=r;this.a=[];for(var o=0;o<i;){var l=o++;this.a[l]=0}this.byteLength=i}};w["js.html.compat.ArrayBuffer"]=me,me.__name__=["js","html","compat","ArrayBuffer"],me.sliceImpl=function(r,i){var o=new pa(this,r,i==null?null:i-r),l=new mi(o.byteLength),c=new pa(l);return c.set(o),l},me.prototype={slice:function(r,i){return new me(this.a.slice(r,i))},__class__:me};var wr=function(r,i,o){if(this.buf=r,i==null?this.offset=0:this.offset=i,o==null?this.length=r.byteLength-this.offset:this.length=o,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(se.OutsideBounds)};w["js.html.compat.DataView"]=wr,wr.__name__=["js","html","compat","DataView"],wr.prototype={getInt8:function(r){var i=this.buf.a[this.offset+r];return i>=128?i-256:i},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,i){var o=this.getUint16(r,i);return o>=32768?o-65536:o},getUint16:function(r,i){return i?this.buf.a[this.offset+r]|this.buf.a[this.offset+r+1]<<8:this.buf.a[this.offset+r]<<8|this.buf.a[this.offset+r+1]},getInt32:function(r,i){var o=this.offset+r,l=this.buf.a[o++],c=this.buf.a[o++],d=this.buf.a[o++],g=this.buf.a[o++];return i?l|c<<8|d<<16|g<<24:g|d<<8|c<<16|l<<24},getUint32:function(r,i){var o=this.getInt32(r,i);return o<0?o+4294967296:o},getFloat32:function(r,i){return pe.i32ToFloat(this.getInt32(r,i))},getFloat64:function(r,i){var o=this.getInt32(r,i),l=this.getInt32(r+4,i);return pe.i64ToDouble(i?o:l,i?l:o)},setInt8:function(r,i){i<0?this.buf.a[r+this.offset]=i+128&255:this.buf.a[r+this.offset]=i&255},setUint8:function(r,i){this.buf.a[r+this.offset]=i&255},setInt16:function(r,i,o){this.setUint16(r,i<0?i+65536:i,o)},setUint16:function(r,i,o){var l=r+this.offset;o?(this.buf.a[l]=i&255,this.buf.a[l++]=i>>8&255):(this.buf.a[l++]=i>>8&255,this.buf.a[l]=i&255)},setInt32:function(r,i,o){this.setUint32(r,i,o)},setUint32:function(r,i,o){var l=r+this.offset;o?(this.buf.a[l++]=i&255,this.buf.a[l++]=i>>8&255,this.buf.a[l++]=i>>16&255,this.buf.a[l++]=i>>>24):(this.buf.a[l++]=i>>>24,this.buf.a[l++]=i>>16&255,this.buf.a[l++]=i>>8&255,this.buf.a[l++]=i&255)},setFloat32:function(r,i,o){this.setUint32(r,pe.floatToI32(i),o)},setFloat64:function(r,i,o){var l=pe.doubleToI64(i);o?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:wr};var pr=function(){};w["js.html.compat.Uint8Array"]=pr,pr.__name__=["js","html","compat","Uint8Array"],pr._new=function(r,i,o){var l;if(typeof r=="number"){l=[];for(var c=0;c<r;){var d=c++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new me(l)}else if(Lt.__instanceof(r,me)){var g=r;i==null&&(i=0),o==null&&(o=g.byteLength-i),i==0?l=g.a:l=g.a.slice(i,i+o),l.byteLength=l.length,l.byteOffset=i,l.buffer=g}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new me(l);else throw new Q("TODO "+at.string(r));return l.subarray=pr._subarray,l.set=pr._set,l},pr._set=function(r,i){var o=this;if(Lt.__instanceof(r.buffer,me)){var l=r;if(r.byteLength+i>o.byteLength)throw new Q("set() outside of range");for(var c=0,d=r.byteLength;c<d;){var g=c++;o[g+i]=l[g]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+i>o.byteLength)throw new Q("set() outside of range");for(var y=0,I=_.length;y<I;){var P=y++;o[P+i]=_[P]}}else throw new Q("TODO")},pr._subarray=function(r,i){var o=this,l=pr._new(o.slice(r,i));return l.byteOffset=r,l};var Tt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&Tt.link(r,this,function(i){return i})};w["promhx.base.AsyncBase"]=Tt,Tt.__name__=["promhx","base","AsyncBase"],Tt.link=function(r,i,o){r._update.push({async:i,linkf:function(l){i.handleResolve(o(l))}}),Tt.immediateLinkUpdate(r,i,o)},Tt.immediateLinkUpdate=function(r,i,o){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&i.handleError(r._errorVal),r._resolved&&!r._pending)try{i.handleResolve(o(r._val))}catch(l){l instanceof Q&&(l=l.val),i.handleError(l)}},Tt.linkAll=function(r,i){for(var o=function(d,g,_){if(d.length==0||Tt.allFulfilled(d)){for(var y,I=[],P=sr(r)();P.hasNext();){var S=P.next();I.push(S==g?_:S._val)}y=I,i.handleResolve(y)}},l=sr(r)();l.hasNext();){var c=l.next();c._update.push({async:i,linkf:function(d,g,_){return function(y){d(g,_,y)}}(o,function(d){for(var g,_=[],y=sr(r)();y.hasNext();){var I=y.next();I!=c&&_.push(I)}return g=_,g}(),c)})}Tt.allFulfilled(r)&&i.handleResolve(function(d){for(var g,_=[],y=sr(r)();y.hasNext();){var I=y.next();_.push(I._val)}return g=_,g}())},Tt.pipeLink=function(r,i,o){var l=!1,c=function(d){if(!l){l=!0;var g=o(d);g._update.push({async:i,linkf:De(i,i.handleResolve)}),Tt.immediateLinkUpdate(g,i,function(_){return _})}};if(r._update.push({async:i,linkf:c}),r._resolved&&!r._pending)try{c(r._val)}catch(d){d instanceof Q&&(d=d.val),i.handleError(d)}},Tt.allResolved=function(r){for(var i=sr(r)();i.hasNext();){var o=i.next();if(!o._resolved)return!1}return!0},Tt.allFulfilled=function(r){for(var i=sr(r)();i.hasNext();){var o=i.next();if(!o._fulfilled)return!1}return!0},Tt.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,this},isResolved:function(){return this._resolved},isErrored:function(){return this._errored},isErrorHandled:function(){return this._error.length>0},isErrorPending:function(){return this._errorPending},isFulfilled:function(){return this._fulfilled},isPending:function(){return this._pending},handleResolve:function(r){this._resolve(r)},_resolve:function(r){var i=this;this._pending?At.enqueue(function(o,l){return function(){o(l)}}(De(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,At.queue.add(function(){i._val=r;for(var o=0,l=i._update;o<l.length;){var c=l[o];++o;try{c.linkf(r)}catch(d){d instanceof Q&&(d=d.val),c.async.handleError(d)}}i._fulfilled=!0,i._pending=!1}),At.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var i=this,o=function(l){if(i._error.length>0)for(var c=0,d=i._error;c<d.length;){var g=d[c];++c,g(l)}else if(i._update.length>0)for(var _=0,y=i._update;_<y.length;){var I=y[_];++_,I.async.handleError(l)}else throw new Q(l);i._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,At.queue.add(function(){if(i._errorMap!=null)try{i._resolve(i._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),o(l)}else o(r)}),At.continueOnNextLoop())},then:function(r){var i=new Tt(null);return Tt.link(this,i,r),i},unlink:function(r){var i=this;At.queue.add(function(){i._update=i._update.filter(function(o){return o.async!=r})}),At.continueOnNextLoop()},isLinked:function(r){for(var i=!1,o=0,l=this._update;o<l.length;){var c=l[o];if(++o,c.async==r)return!0}return i},__class__:Tt};var Bn=f.promhx.Deferred=function(){Tt.call(this)};w["promhx.Deferred"]=Bn,Bn.__name__=["promhx","Deferred"],Bn.__super__=Tt,Bn.prototype=k(Tt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new xe(this)},stream:function(){return new qt(this)},publicStream:function(){return new Yr(this)},__class__:Bn});var xe=f.promhx.Promise=function(r){Tt.call(this,r),this._rejected=!1};w["promhx.Promise"]=xe,xe.__name__=["promhx","Promise"],xe.whenAll=function(r){var i=new xe(null);return Tt.linkAll(r,i),i},xe.promise=function(r){var i=new xe;return i.handleResolve(r),i},xe.__super__=Tt,xe.prototype=k(Tt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var i="Promise has already been resolved";throw new Q(Rn.AlreadyResolved(i))}this._resolve(r)},then:function(r){var i=new xe(null);return Tt.link(this,i,r),i},unlink:function(r){var i=this;At.queue.add(function(){if(i._fulfilled)i._update=i._update.filter(function(l){return l.async!=r});else{var o="Downstream Promise is not fullfilled";i.handleError(Rn.DownstreamNotFullfilled(o))}}),At.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var i=new xe(null);return Tt.pipeLink(this,i,r),i},errorPipe:function(r){var i=new xe;return this.catchError(function(o){var l=r(o);l.then(De(i,i._resolve))}),this.then(De(i,i._resolve)),i},__class__:xe});var qt=f.promhx.Stream=function(r){Tt.call(this,r),this._end_promise=new xe};w["promhx.Stream"]=qt,qt.__name__=["promhx","Stream"],qt.foreach=function(r){for(var i=new qt(null),o=sr(r)();o.hasNext();){var l=o.next();i.handleResolve(l)}return i.end(),i},qt.wheneverAll=function(r){var i=new qt(null);return Tt.linkAll(r,i),i},qt.concatAll=function(r){for(var i=new qt(null),o=sr(r)();o.hasNext();){var l=o.next();i.concat(l)}return i},qt.mergeAll=function(r){for(var i=new qt(null),o=sr(r)();o.hasNext();){var l=o.next();i.merge(l)}return i},qt.stream=function(r){var i=new qt(null);return i.handleResolve(r),i},qt.__super__=Tt,qt.prototype=k(Tt.prototype,{then:function(r){var i=new qt(null);return Tt.link(this,i,r),this._end_promise._update.push({async:i._end_promise,linkf:function(o){i.end()}}),i},detachStream:function(r){for(var i=[],o=!1,l=0,c=this._update;l<c.length;){var d=c[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(g){return g.async!=r._end_promise}),o=!0):i.push(d)}return this._update=i,o},first:function(){var r=new xe(null);return this.then(function(i){r._resolved||r.handleResolve(i)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var i=new qt(null);return Tt.pipeLink(this,i,r),this._end_promise.then(function(o){i.end()}),i},errorPipe:function(r){var i=new qt(null);return this.catchError(function(o){var l=r(o);l.then(De(i,i._resolve)),l._end_promise.then((ca=i._end_promise,De(ca,ca._resolve)))}),this.then(De(i,i._resolve)),this._end_promise.then(function(o){i.end()}),i},handleEnd:function(){if(this._pending)At.queue.add(De(this,this.handleEnd)),At.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=be.Some(this._val):r=be.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return At.queue.add(De(this,this.handleEnd)),At.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var i=new qt(null);return this._update.push({async:i,linkf:function(o){r(o)&&i.handleResolve(o)}}),Tt.immediateLinkUpdate(this,i,function(o){return o}),i},concat:function(r){var i=new qt(null);return this._update.push({async:i,linkf:De(i,i.handleResolve)}),Tt.immediateLinkUpdate(this,i,function(o){return o}),this._end_promise.then(function(o){r.pipe(function(l){return i.handleResolve(l),i}),r._end_promise.then(function(l){i.end()})}),i},merge:function(r){var i=new qt(null);return this._update.push({async:i,linkf:De(i,i.handleResolve)}),r._update.push({async:i,linkf:De(i,i.handleResolve)}),Tt.immediateLinkUpdate(this,i,function(o){return o}),Tt.immediateLinkUpdate(r,i,function(o){return o}),i},__class__:qt});var Yr=f.promhx.PublicStream=function(r){qt.call(this,r)};w["promhx.PublicStream"]=Yr,Yr.__name__=["promhx","PublicStream"],Yr.publicstream=function(r){var i=new Yr(null);return i.handleResolve(r),i},Yr.__super__=qt,Yr.prototype=k(qt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Yr});var At=function(){};w["promhx.base.EventLoop"]=At,At.__name__=["promhx","base","EventLoop"],At.enqueue=function(r){At.queue.add(r),At.continueOnNextLoop()},At.set_nextLoop=function(r){if(At.nextLoop!=null)throw new Q("nextLoop has already been set");return At.nextLoop=r,At.nextLoop},At.queueEmpty=function(){return At.queue.isEmpty()},At.finish=function(r){r==null&&(r=1e3);for(var i=null;r-- >0&&(i=At.queue.pop())!=null;)i();return At.queue.isEmpty()},At.clear=function(){At.queue=new V},At.f=function(){var r=At.queue.pop();r!=null&&r(),At.queue.isEmpty()||At.continueOnNextLoop()},At.continueOnNextLoop=function(){At.nextLoop!=null?At.nextLoop(At.f):setImmediate(At.f)};var Rn=w["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};Rn.AlreadyResolved=function(r){var i=["AlreadyResolved",0,r];return i.__enum__=Rn,i.toString=A,i},Rn.DownstreamNotFullfilled=function(r){var i=["DownstreamNotFullfilled",1,r];return i.__enum__=Rn,i.toString=A,i};var di=function(){};w["verb.Verb"]=di,di.__name__=["verb","Verb"],di.main=function(){v.log("verb 2.1.0")};var Z=function(){};w["verb.core.ArrayExtensions"]=Z,Z.__name__=["verb","core","ArrayExtensions"],Z.alloc=function(r,i){if(!(i<0))for(;r.length<i;)r.push(null)},Z.reversed=function(r){var i=r.slice();return i.reverse(),i},Z.last=function(r){return r[r.length-1]},Z.first=function(r){return r[0]},Z.spliceAndInsert=function(r,i,o,l){r.splice(i,o),r.splice(i,0,l)},Z.left=function(r){if(r.length==0)return[];var i=Math.ceil(r.length/2);return r.slice(0,i)},Z.right=function(r){if(r.length==0)return[];var i=Math.ceil(r.length/2);return r.slice(i)},Z.rightWithPivot=function(r){if(r.length==0)return[];var i=Math.ceil(r.length/2);return r.slice(i-1)},Z.unique=function(r,i){if(r.length==0)return[];for(var o=[r.pop()];r.length>0;){for(var l=r.pop(),c=!0,d=0;d<o.length;){var g=o[d];if(++d,i(l,g)){c=!1;break}}c&&o.push(l)}return o};var Vt=function(){};w["verb.core.Binomial"]=Vt,Vt.__name__=["verb","core","Binomial"],Vt.get=function(r,i){if(i==0)return 1;if(r==0||i>r)return 0;if(i>r-i&&(i=r-i),Vt.memo_exists(r,i))return Vt.get_memo(r,i);for(var o=1,l=r,c=1,d=i+1;c<d;){var g=c++;if(Vt.memo_exists(l,g)){r--,o=Vt.get_memo(l,g);continue}o*=r--,o/=g,Vt.memoize(l,g,o)}return o},Vt.get_no_memo=function(r,i){if(i==0)return 1;if(r==0||i>r)return 0;i>r-i&&(i=r-i);for(var o=1,l=1,c=i+1;l<c;){var d=l++;o*=r--,o/=d}return o},Vt.memo_exists=function(r,i){return Vt.memo.h.hasOwnProperty(r)&&Vt.memo.h[r].h.hasOwnProperty(i)},Vt.get_memo=function(r,i){return Vt.memo.h[r].h[i]},Vt.memoize=function(r,i,o){Vt.memo.h.hasOwnProperty(r)||Vt.memo.set(r,new xt),Vt.memo.h[r].h[i]=o};var Ve=f.core.BoundingBox=function(r){this.max=null,this.min=null,this.dim=3,this.initialized=!1,r!=null&&this.addRange(r)};w["verb.core.BoundingBox"]=Ve,Ve.__name__=["verb","core","BoundingBox"],Ve.intervalsOverlap=function(r,i,o,l,c){c==null&&(c=-1);var d;c<-.5?d=rt.TOLERANCE:d=c;var g=Math.min(r,i)-d,_=Math.max(r,i)+d,y=Math.min(o,l)-d,I=Math.max(o,l)+d;return g>=y&&g<=I||_>=y&&_<=I||y>=g&&y<=_||I>=g&&I<=_},Ve.prototype={fromPoint:function(r){return new Ve([r])},add:function(r){if(!this.initialized)return this.dim=r.length,this.min=r.slice(0),this.max=r.slice(0),this.initialized=!0,this;for(var i=0,o=this.dim;i<o;){var l=i++;r[l]>this.max[l]&&(this.max[l]=r[l]),r[l]<this.min[l]&&(this.min[l]=r[l])}return this},addRange:function(r){for(var i=r.length,o=0;o<i;){var l=o++;this.add(r[l])}return this},contains:function(r,i){return i==null&&(i=-1),this.initialized?this.intersects(new Ve([r]),i):!1},intersects:function(r,i){if(i==null&&(i=-1),!this.initialized||!r.initialized)return!1;for(var o=this.min,l=this.max,c=r.min,d=r.max,g=0,_=this.dim;g<_;){var y=g++;if(!Ve.intervalsOverlap(o[y],l[y],c[y],d[y],i))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,i=0,o=0,l=this.dim;o<l;){var c=o++,d=this.getAxisLength(c);d>r&&(r=d,i=c)}return i},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,i){if(!this.initialized)return null;var o=this.min,l=this.max,c=r.min,d=r.max;if(!this.intersects(r,i))return null;for(var g=[],_=[],y=0,I=this.dim;y<I;){var P=y++;g.push(Math.min(l[P],d[P])),_.push(Math.max(o[P],c[P]))}return new Ve([_,g])},__class__:Ve};var rt=f.core.Constants=function(){};w["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var ee=f.core.SerializableBase=function(){};w["verb.core.SerializableBase"]=ee,ee.__name__=["verb","core","SerializableBase"],ee.prototype={serialize:function(){var r=new $t;return r.serialize(this),r.toString()},__class__:ee};var os=f.core.Plane=function(r,i){this.origin=r,this.normal=i};w["verb.core.Plane"]=os,os.__name__=["verb","core","Plane"],os.__super__=ee,os.prototype=k(ee.prototype,{__class__:os});var Fn=f.core.Ray=function(r,i){this.origin=r,this.dir=i};w["verb.core.Ray"]=Fn,Fn.__name__=["verb","core","Ray"],Fn.__super__=ee,Fn.prototype=k(ee.prototype,{__class__:Fn});var Ht=f.core.NurbsCurveData=function(r,i,o){this.degree=r,this.controlPoints=o,this.knots=i};w["verb.core.NurbsCurveData"]=Ht,Ht.__name__=["verb","core","NurbsCurveData"],Ht.__super__=ee,Ht.prototype=k(ee.prototype,{__class__:Ht});var ie=f.core.NurbsSurfaceData=function(r,i,o,l,c){this.degreeU=r,this.degreeV=i,this.knotsU=o,this.knotsV=l,this.controlPoints=c};w["verb.core.NurbsSurfaceData"]=ie,ie.__name__=["verb","core","NurbsSurfaceData"],ie.__super__=ee,ie.prototype=k(ee.prototype,{__class__:ie});var rr=f.core.MeshData=function(r,i,o,l){this.faces=r,this.points=i,this.normals=o,this.uvs=l};w["verb.core.MeshData"]=rr,rr.__name__=["verb","core","MeshData"],rr.empty=function(){return new rr([],[],[],[])},rr.__super__=ee,rr.prototype=k(ee.prototype,{__class__:rr});var ls=f.core.PolylineData=function(r,i){this.points=r,this.params=i};w["verb.core.PolylineData"]=ls,ls.__name__=["verb","core","PolylineData"],ls.__super__=ee,ls.prototype=k(ee.prototype,{__class__:ls});var hs=f.core.VolumeData=function(r,i,o,l,c,d,g){this.degreeU=r,this.degreeV=i,this.degreeW=o,this.knotsU=l,this.knotsV=c,this.knotsW=d,this.controlPoints=g};w["verb.core.VolumeData"]=hs,hs.__name__=["verb","core","VolumeData"],hs.__super__=ee,hs.prototype=k(ee.prototype,{__class__:hs});var ae=f.core.Pair=function(r,i){this.item0=r,this.item1=i};w["verb.core.Pair"]=ae,ae.__name__=["verb","core","Pair"],ae.prototype={__class__:ae};var Ce=f.core.Interval=function(r,i){this.min=r,this.max=i};w["verb.core.Interval"]=Ce,Ce.__name__=["verb","core","Interval"],Ce.prototype={__class__:Ce};var pn=f.core.CurveCurveIntersection=function(r,i,o,l){this.point0=r,this.point1=i,this.u0=o,this.u1=l};w["verb.core.CurveCurveIntersection"]=pn,pn.__name__=["verb","core","CurveCurveIntersection"],pn.prototype={__class__:pn};var us=f.core.CurveSurfaceIntersection=function(r,i,o,l){this.u=r,this.uv=i,this.curvePoint=o,this.surfacePoint=l};w["verb.core.CurveSurfaceIntersection"]=us,us.__name__=["verb","core","CurveSurfaceIntersection"],us.prototype={__class__:us};var Xr=f.core.MeshIntersectionPoint=function(r,i,o,l,c){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=i,this.point=o,this.faceIndex0,this.faceIndex1};w["verb.core.MeshIntersectionPoint"]=Xr,Xr.__name__=["verb","core","MeshIntersectionPoint"],Xr.prototype={__class__:Xr};var cs=f.core.PolylineMeshIntersection=function(r,i,o,l,c){this.point=r,this.u=i,this.uv=o,this.polylineIndex=l,this.faceIndex=c};w["verb.core.PolylineMeshIntersection"]=cs,cs.__name__=["verb","core","PolylineMeshIntersection"],cs.prototype={__class__:cs};var ds=f.core.SurfaceSurfaceIntersectionPoint=function(r,i,o,l){this.uv0=r,this.uv1=i,this.point=o,this.dist=l};w["verb.core.SurfaceSurfaceIntersectionPoint"]=ds,ds.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],ds.prototype={__class__:ds};var ps=f.core.TriSegmentIntersection=function(r,i,o,l){this.point=r,this.s=i,this.t=o,this.p=l};w["verb.core.TriSegmentIntersection"]=ps,ps.__name__=["verb","core","TriSegmentIntersection"],ps.prototype={__class__:ps};var zn=f.core.CurveTriPoint=function(r,i,o){this.u=r,this.point=i,this.uv=o};w["verb.core.CurveTriPoint"]=zn,zn.__name__=["verb","core","CurveTriPoint"],zn.prototype={__class__:zn};var Qe=function(r,i,o,l,c){c==null&&(c=!1),l==null&&(l=-1),this.uv=o,this.point=r,this.normal=i,this.id=l,this.degen=c};w["verb.core.SurfacePoint"]=Qe,Qe.__name__=["verb","core","SurfacePoint"],Qe.fromUv=function(r,i){return new Qe(null,null,[r,i])},Qe.prototype={__class__:Qe};var pi=f.core.CurvePoint=function(r,i){this.u=r,this.pt=i};w["verb.core.CurvePoint"]=pi,pi.__name__=["verb","core","CurvePoint"],pi.prototype={__class__:pi};var ms=f.core.KdTree=function(r,i){this.dim=3,this.points=r,this.distanceFunction=i,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};w["verb.core.KdTree"]=ms,ms.__name__=["verb","core","KdTree"],ms.prototype={buildTree:function(r,i,o){var l=i%this.dim,c,d;return r.length==0?null:r.length==1?new jn(r[0],l,o):(r.sort(function(g,_){var y=g.point[l]-_.point[l];return y==0?0:y>0?1:-1}),c=Math.floor(r.length/2),d=new jn(r[c],l,o),d.left=this.buildTree(r.slice(0,c),i+1,d),d.right=this.buildTree(r.slice(c+1),i+1,d),d)},nearest:function(r,i,o){var l=this,c=new gs(function(S){return-S.item1}),d,g=null;g=function(S){for(var E,M=S.dimension,T=l.distanceFunction(r,S.kdPoint.point),B,O=[],F=0,R=l.dim;F<R;)F++,O.push(0);B=O;for(var j,D,X=function($,tt){c.push(new ae($,tt)),c.size()>i&&c.pop()},J=0,Y=l.dim;J<Y;){var U=J++;U==S.dimension?B[U]=r[U]:B[U]=S.kdPoint.point[U]}if(j=l.distanceFunction(B,S.kdPoint.point),S.right==null&&S.left==null){(c.size()<i||T<c.peek().item1)&&X(S,T);return}S.right==null?E=S.left:S.left==null?E=S.right:r[M]<S.kdPoint.point[M]?E=S.left:E=S.right,g(E),(c.size()<i||T<c.peek().item1)&&X(S,T),(c.size()<i||Math.abs(j)<c.peek().item1)&&(E==S.left?D=S.right:D=S.left,D!=null&&g(D))},d=g;for(var _=0;_<i;)_++,c.push(new ae(null,o));d(this.root);for(var y=[],I=0;I<i;){var P=I++;c.content[P].item0!=null&&y.push(new ae(c.content[P].item0.kdPoint,c.content[P].item1))}return y},__class__:ms};var gs=function(r){this.content=[],this.scoreFunction=r};w["verb.core.BinaryHeap"]=gs,gs.__name__=["verb","core","BinaryHeap"],gs.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],i=this.content.pop();return this.content.length>0&&(this.content[0]=i,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var i=this.content.length,o=0;o<i;){var l=o++;if(this.content[l]==r){var c=this.content.pop();l!=i-1&&(this.content[l]=c,this.scoreFunction(c)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var i=this.content[r];r>0;){var o=Math.floor((r+1)/2)-1,l=this.content[o];if(this.scoreFunction(i)<this.scoreFunction(l))this.content[o]=i,this.content[r]=l,r=o;else break}},sinkDown:function(r){for(var i=this.content.length,o=this.content[r],l=this.scoreFunction(o);;){var c=(r+1)*2,d=c-1,g=-1,_=0;if(d<i){var y=this.content[d];_=this.scoreFunction(y),_<l&&(g=d)}if(c<i){var I=this.content[c],P=this.scoreFunction(I);P<(g==-1?l:_)&&(g=c)}if(g!=-1)this.content[r]=this.content[g],this.content[g]=o,r=g;else break}},__class__:gs};var Vn=f.core.KdPoint=function(r,i){this.point=r,this.obj=i};w["verb.core.KdPoint"]=Vn,Vn.__name__=["verb","core","KdPoint"],Vn.prototype={__class__:Vn};var jn=f.core.KdNode=function(r,i,o){this.kdPoint=r,this.left=null,this.right=null,this.parent=o,this.dimension=i};w["verb.core.KdNode"]=jn,jn.__name__=["verb","core","KdNode"],jn.prototype={__class__:jn};var xr=function(){};w["verb.eval.IBoundingBoxTree"]=xr,xr.__name__=["verb","eval","IBoundingBoxTree"],xr.prototype={__class__:xr};var mr=function(r,i){this._boundingBox=null,this._curve=r,i==null&&(i=m.domain(this._curve.knots)/64),this._knotTol=i};w["verb.core.LazyCurveBoundingBoxTree"]=mr,mr.__name__=["verb","core","LazyCurveBoundingBoxTree"],mr.__interfaces__=[xr],mr.prototype={split:function(){var r=Z.first(this._curve.knots),i=Z.last(this._curve.knots),o=i-r,l=ge.curveSplit(this._curve,(i+r)/2+o*.1*Math.random());return new ae(new mr(l[0],this._knotTol),new mr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ve(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:mr};var gr=function(r,i){if(this._boundingBox=null,this._mesh=r,i==null){for(var o=[],l=0,c=r.faces.length;l<c;){var d=l++;o.push(d)}i=o}this._faceIndices=i};w["verb.core.LazyMeshBoundingBoxTree"]=gr,gr.__name__=["verb","core","LazyMeshBoundingBoxTree"],gr.__interfaces__=[xr],gr.prototype={split:function(){var r=oe.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),i=Z.left(r),o=Z.right(r);return new ae(new gr(this._mesh,i),new gr(this._mesh,o))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=oe.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:gr};var _r=function(r,i){this._boundingBox=null,this._polyline=r,i==null&&(i=new Ce(0,r.points.length!=0?r.points.length-1:0)),this._interval=i};w["verb.core.LazyPolylineBoundingBoxTree"]=_r,_r.__name__=["verb","core","LazyPolylineBoundingBoxTree"],_r.__interfaces__=[xr],_r.prototype={split:function(){var r=this._interval.min,i=this._interval.max,o=r+Math.ceil((i-r)/2),l=new Ce(r,o),c=new Ce(o,i);return new ae(new _r(this._polyline,l),new _r(this._polyline,c))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ve(this._polyline.points)),this._boundingBox},yield:function(){return this._interval.min},indivisible:function(r){return this._interval.max-this._interval.min==1},empty:function(){return this._interval.max-this._interval.min==0},__class__:_r};var qr=function(r,i,o,l){i==null&&(i=!1),this._boundingBox=null,this._surface=r,this._splitV=i,o==null&&(o=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=o,this._knotTolV=l};w["verb.core.LazySurfaceBoundingBoxTree"]=qr,qr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],qr.__interfaces__=[xr],qr.prototype={split:function(){var r,i;this._splitV?(r=Z.first(this._surface.knotsV),i=Z.last(this._surface.knotsV)):(r=Z.first(this._surface.knotsU),i=Z.last(this._surface.knotsU));var o=(r+i)/2,l=ge.surfaceSplit(this._surface,o,this._splitV);return new ae(new qr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new qr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Ve;for(var r=0,i=this._surface.controlPoints;r<i.length;){var o=i[r];++r,this._boundingBox.addRange(N.dehomogenize1d(o))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:qr};var Ct=f.core.Mat=function(){};w["verb.core.Mat"]=Ct,Ct.__name__=["verb","core","Mat"],Ct.mul=function(r,i){for(var o=[],l=0,c=i.length;l<c;){var d=l++;o.push(m.mul(r,i[d]))}return o},Ct.mult=function(r,i){var o,l,c,d,g,_,y,I;o=r.length,l=i.length,c=i[0].length,d=[];for(var P=o-1,S=0,E=0;P>=0;){for(g=[],_=r[P],E=c-1;E>=0;){for(y=_[l-1]*i[l-1][E],S=l-2;S>=1;)I=S-1,y+=_[S]*i[S][E]+_[I]*i[I][E],S-=2;S==0&&(y+=_[0]*i[0][E]),g[E]=y,E--}d[P]=g,P--}return d},Ct.add=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.add(r[d],i[d]))}return o},Ct.div=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.div(r[d],i))}return o},Ct.sub=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.sub(r[d],i[d]))}return o},Ct.dot=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.dot(r[d],i))}return o},Ct.identity=function(r){for(var i=m.zeros2d(r,r),o=0;o<r;){var l=o++;i[l][l]=1}return i},Ct.transpose=function(r){if(r.length==0)return[];for(var i=[],o=0,l=r[0].length;o<l;){var c=o++;i.push(function(d){for(var g,_=[],y=0,I=r.length;y<I;){var P=y++;_.push(r[P][c])}return g=_,g}())}return i},Ct.solve=function(r,i){return Ct.LUsolve(Ct.LU(r),i)},Ct.LUsolve=function(r,i){var o,l,c=r.LU,d=c.length,g=i.slice(),_=r.P,y,I,P;for(o=d-1;o!=-1;)g[o]=i[o],--o;for(o=0;o<d;){for(y=_[o],_[o]!=o&&(P=g[o],g[o]=g[y],g[y]=P),I=c[o],l=0;l<o;)g[o]-=g[l]*I[l],++l;++o}for(o=d-1;o>=0;){for(I=c[o],l=o+1;l<d;)g[o]-=g[l]*I[l],++l;g[o]/=I[o],--o}return g},Ct.LU=function(r){for(var i,o,l,c,d,g,_,y,I,P=[],S=0,E=r.length;S<E;){var M=S++;P.push(r[M].slice())}r=P;var T=r.length,B=T-1,O=[];for(l=0;l<T;){for(_=l,g=r[l],I=Math.abs(g[l]),o=l+1;o<T;)c=Math.abs(r[o][l]),I<c&&(I=c,_=o),++o;for(O[l]=_,_!=l&&(r[l]=r[_],r[_]=g,g=r[l]),d=g[l],i=l+1;i<T;)r[i][l]/=d,++i;for(i=l+1;i<T;){for(y=r[i],o=l+1;o<B;)y[o]-=y[l]*g[o],++o,y[o]-=y[l]*g[o],++o;o==B&&(y[o]-=y[l]*g[o]),++i}++l}return new _s(r,O)};var _s=function(r,i){this.LU=r,this.P=i};w["verb.core._Mat.LUDecomp"]=_s,_s.__name__=["verb","core","_Mat","LUDecomp"],_s.prototype={__class__:_s};var oe=f.core.Mesh=function(){};w["verb.core.Mesh"]=oe,oe.__name__=["verb","core","Mesh"],oe.getTriangleNorm=function(r,i){var o=r[i[0]],l=r[i[1]],c=r[i[2]],d=m.sub(l,o),g=m.sub(c,o),_=m.cross(d,g);return m.mul(1/m.norm(_),_)},oe.makeMeshAabb=function(r,i){for(var o=new Ve,l=0;l<i.length;){var c=i[l];++l,o.add(r.points[r.faces[c][0]]),o.add(r.points[r.faces[c][1]]),o.add(r.points[r.faces[c][2]])}return o},oe.sortTrianglesOnLongestAxis=function(r,i,o){for(var l=r.getLongestAxis(),c=[],d=0;d<o.length;){var g=o[d];++d;var _=oe.getMinCoordOnAxis(i.points,i.faces[g],l);c.push(new ae(_,g))}c.sort(function(E,M){var T=E.item0,B=M.item0;return T==B?0:T>B?1:-1});for(var y=[],I=0,P=c.length;I<P;){var S=I++;y.push(c[S].item1)}return y},oe.getMinCoordOnAxis=function(r,i,o){for(var l=1/0,c=0;c<3;){var d=c++,g=r[i[d]][o];g<l&&(l=g)}return l},oe.getTriangleCentroid=function(r,i){for(var o=[0,0,0],l=0;l<3;)for(var c=l++,d=0;d<3;){var g=d++;o[g]+=r[i[c]][g]}for(var _=0;_<3;){var y=_++;o[y]/=3}return o},oe.triangleUVFromPoint=function(r,i,o){var l=r.faces[i],c=r.points[l[0]],d=r.points[l[1]],g=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],I=r.uvs[l[2]],P=m.sub(c,o),S=m.sub(d,o),E=m.sub(g,o),M=m.norm(m.cross(m.sub(c,d),m.sub(c,g))),T=m.norm(m.cross(S,E))/M,B=m.norm(m.cross(E,P))/M,O=m.norm(m.cross(P,S))/M;return m.add(m.mul(T,_),m.add(m.mul(B,y),m.mul(O,I)))};var Kr=function(r,i){if(this._empty=!1,this._face=-1,i==null){for(var o=[],l=0,c=r.faces.length;l<c;){var d=l++;o.push(d)}i=o}if(this._boundingBox=oe.makeMeshAabb(r,i),i.length<1){this._empty=!0;return}else if(i.length<2){this._face=i[0];return}var g=oe.sortTrianglesOnLongestAxis(this._boundingBox,r,i),_=Z.left(g),y=Z.right(g);this._children=new ae(new Kr(r,_),new Kr(r,y))};w["verb.core.MeshBoundingBoxTree"]=Kr,Kr.__name__=["verb","core","MeshBoundingBoxTree"],Kr.__interfaces__=[xr],Kr.prototype={split:function(){return this._children},boundingBox:function(){return this._boundingBox},yield:function(){return this._face},indivisible:function(r){return this._children==null},empty:function(){return this._empty},__class__:Kr};var nr=f.core.Minimizer=function(){};w["verb.core.Minimizer"]=nr,nr.__name__=["verb","core","Minimizer"],nr.uncmin=function(r,i,o,l,c){o==null&&(o=1e-8),l==null&&(l=function(J){return nr.numericalGradient(r,J)}),c==null&&(c=1e3),i=i.slice(0);var d=i.length,g=r(i),_=g,y;if(isNaN(g))throw new Q("uncmin: f(x0) is a NaN!");o=Math.max(o,rt.EPSILON);var I,P,S,E=Ct.identity(d),M=0,T=[],B,O,F,R,j,D,X="";for(P=l(i);M<c;){if(!m.all(m.finite(P))){X="Gradient has Infinity or NaN";break}if(I=m.neg(Ct.dot(E,P)),!m.all(m.finite(I))){X="Search direction has Infinity or NaN";break}if(D=m.norm(I),D<o){X="Newton step smaller than tol";break}for(j=1,y=m.dot(P,I),B=i;M<c&&!(j*D<o);){if(T=m.mul(j,I),B=m.add(i,T),_=r(B),_-g>=.1*j*y||isNaN(_)){j*=.5,++M;continue}break}if(j*D<o){X="Line search step size smaller than tol";break}if(M==c){X="maxit reached during line search";break}S=l(B),O=m.sub(S,P),R=m.dot(O,T),F=Ct.dot(E,O),E=Ct.sub(Ct.add(E,Ct.mul((R+m.dot(O,F))/(R*R),nr.tensor(T,T))),Ct.div(Ct.add(nr.tensor(F,T),nr.tensor(T,F)),R)),i=B,g=_,P=S,++M}return new fs(i,g,P,E,M,X)},nr.numericalGradient=function(r,i){var o=i.length,l=r(i);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var c=i.slice(0),d,g,_=[],y,I=.001,P,S,E,M=0,T,B,O,F=0;F<o;)for(var R=F++,j=Math.max(1e-6*l,1e-8);;){if(++M,M>20)throw new Q("Numerical gradient fails");if(c[R]=i[R]+j,d=r(c),c[R]=i[R]-j,g=r(c),c[R]=i[R],isNaN(d)||isNaN(g)){j/=16;continue}if(_[R]=(d-g)/(2*j),P=i[R]-j,S=i[R],E=i[R]+j,T=(d-l)/j,B=(l-g)/j,O=m.max([Math.abs(_[R]),Math.abs(l),Math.abs(d),Math.abs(g),Math.abs(P),Math.abs(S),Math.abs(E),1e-8]),y=Math.min(m.max([Math.abs(T-_[R]),Math.abs(B-_[R]),Math.abs(T-B)])/O,j/O),y>I)j/=16;else break}return _},nr.tensor=function(r,i){for(var o=r.length,l=i.length,c=[],d,g,_=o-1;_>=0;){d=[],g=r[_];for(var y=l-1;y>=3;)d[y]=g*i[y],--y,d[y]=g*i[y],--y,d[y]=g*i[y],--y,d[y]=g*i[y],--y;for(;y>=0;)d[y]=g*i[y],--y;c[_]=d,_--}return c};var fs=function(r,i,o,l,c,d){this.solution=r,this.value=i,this.gradient=o,this.invHessian=l,this.iterations=c,this.message=d};w["verb.core.MinimizationResult"]=fs,fs.__name__=["verb","core","MinimizationResult"],fs.prototype={__class__:fs};var Dn=function(){};w["verb.core.ISerializable"]=Dn,Dn.__name__=["verb","core","ISerializable"],Dn.prototype={__class__:Dn};var ua=f.core.Deserializer=function(){};w["verb.core.Deserializer"]=ua,ua.__name__=["verb","core","Deserializer"],ua.deserialize=function(r){var i=new Xt(r),o=i.unserialize();return o};var je=f.core.Trig=function(){};w["verb.core.Trig"]=je,je.__name__=["verb","core","Trig"],je.isPointInPlane=function(r,i,o){return Math.abs(m.dot(m.sub(r,i.origin),i.normal))<o},je.distToSegment=function(r,i,o){var l=je.segmentClosestPoint(i,r,o,0,1);return m.dist(i,l.pt)},je.rayClosestPoint=function(r,i,o){var l=m.sub(r,i),c=m.dot(l,o),d=m.add(i,m.mul(c,o));return d},je.distToRay=function(r,i,o){var l=je.rayClosestPoint(r,i,o),c=m.sub(l,r);return m.norm(c)},je.threePointsAreFlat=function(r,i,o,l){var c=m.sub(i,r),d=m.sub(o,r),g=m.cross(c,d),_=m.dot(g,g);return _<l},je.segmentClosestPoint=function(r,i,o,l,c){var d=m.sub(o,i),g=m.norm(d);if(g<rt.EPSILON)return{u:l,pt:i};var _=i,y=m.mul(1/g,d),I=m.sub(r,_),P=m.dot(I,y);return P<0?{u:l,pt:i}:P>g?{u:c,pt:o}:{u:l+(c-l)*P/g,pt:m.add(_,m.mul(P,y))}};var m=f.core.Vec=function(){};w["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,i){return Math.acos(m.dot(r,i)/(m.norm(r)*m.norm(i)))},m.positiveAngleBetween=function(r,i,o){var l=m.cross(r,i),c=m.norm(r),d=m.norm(i),g=c*d,_=m.dot(r,i),y=m.norm(l)/g,I=_/g,P=Math.atan2(y,I),S=m.dot(o,l);return Math.abs(S)<rt.EPSILON||S>0?P:-P},m.signedAngleBetween=function(r,i,o){var l=m.cross(r,i),c=m.norm(r),d=m.norm(i),g=c*d,_=m.dot(r,i),y=m.norm(l)/g,I=_/g,P=Math.atan2(y,I),S=m.dot(o,l);return S>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,i){var o=r[0]*i[1]-r[1]*i[0];return Math.atan2(o,m.dot(r,i))},m.domain=function(r){return Z.last(r)-Z.first(r)},m.range=function(r){for(var i=[],o=0,l=0;l<r;)l++,i.push(o),o+=1;return i},m.span=function(r,i,o){if(o==null)return[];if(o<rt.EPSILON)return[];if(r>i&&o>0)return[];if(i>r&&o<0)return[];for(var l=[],c=r;c<=i;)l.push(c),c+=o;return l},m.neg=function(r){return r.map(function(i){return-i})},m.min=function(r){return C.fold(r,function(i,o){return Math.min(i,o)},1/0)},m.max=function(r){return C.fold(r,function(i,o){return Math.max(i,o)},-1/0)},m.all=function(r){return C.fold(r,function(i,o){return o&&i},!0)},m.finite=function(r){return r.map(function(i){return isFinite(i)})},m.onRay=function(r,i,o){return m.add(r,m.mul(o,i))},m.lerp=function(r,i,o){return m.add(m.mul(r,i),m.mul(1-r,o))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,i){return[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]]},m.dist=function(r,i){return m.norm(m.sub(r,i))},m.distSquared=function(r,i){return m.normSquared(m.sub(r,i))},m.sum=function(r){return C.fold(r,function(i,o){return o+i},0)},m.addAll=function(r){var i=sr(r)();if(!i.hasNext())return null;var o=i.next().length;return C.fold(r,function(l,c){return m.add(c,l)},m.rep(o,0))},m.addAllMutate=function(r){for(var i=r[0],o=1,l=r.length;o<l;){var c=o++;m.addMutate(i,r[c])}},m.addMulMutate=function(r,i,o){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]+i*o[d]}},m.subMulMutate=function(r,i,o){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]-i*o[d]}},m.addMutate=function(r,i){for(var o=0,l=r.length;o<l;){var c=o++;r[c]=r[c]+i[c]}},m.subMutate=function(r,i){for(var o=0,l=r.length;o<l;){var c=o++;r[c]=r[c]-i[c]}},m.mulMutate=function(r,i){for(var o=0,l=i.length;o<l;){var c=o++;i[c]=i[c]*r}},m.norm=function(r){var i=m.normSquared(r);return i!=0?Math.sqrt(i):i},m.normSquared=function(r){return C.fold(r,function(i,o){return o+i*i},0)},m.rep=function(r,i){for(var o=[],l=0;l<r;)l++,o.push(i);return o},m.zeros1d=function(r){for(var i=[],o=0;o<r;)o++,i.push(0);return i},m.zeros2d=function(r,i){for(var o=[],l=0;l<r;)l++,o.push(m.zeros1d(i));return o},m.zeros3d=function(r,i,o){for(var l=[],c=0;c<r;)c++,l.push(m.zeros2d(i,o));return l},m.dot=function(r,i){for(var o=0,l=0,c=r.length;l<c;){var d=l++;o+=r[d]*i[d]}return o},m.add=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(r[d]+i[d])}return o},m.mul=function(r,i){for(var o=[],l=0,c=i.length;l<c;){var d=l++;o.push(r*i[d])}return o},m.div=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(r[d]/i)}return o},m.sub=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(r[d]-i[d])}return o},m.isZero=function(r){for(var i=0,o=r.length;i<o;){var l=i++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,i){for(var o=[],l=0,c=0;l<r.length||c<i.length;){if(l>=r.length){o.push(i[c]),c++;continue}else if(c>=i.length){o.push(r[l]),l++;continue}var d=r[l]-i[c];if(Math.abs(d)<rt.EPSILON){o.push(r[l]),l++,c++;continue}if(d>0){o.push(i[c]),c++;continue}o.push(r[l]),l++}return o},m.sortedSetSub=function(r,i){for(var o=[],l=0,c=0;l<r.length;){if(c>=i.length){o.push(r[l]),l++;continue}if(Math.abs(r[l]-i[c])<rt.EPSILON){l++,c++;continue}o.push(r[l]),l++}return o};var bt=f.eval.Analyze=function(){};w["verb.eval.Analyze"]=bt,bt.__name__=["verb","eval","Analyze"],bt.knotMultiplicities=function(r){for(var i=[new Un(r[0],0)],o=i[0],l=0;l<r.length;){var c=r[l];++l,Math.abs(c-o.knot)>rt.EPSILON&&(o=new Un(c,0),i.push(o)),o.inc()}return i},bt.isRationalSurfaceClosed=function(r,i){i==null&&(i=!0);var o;i?o=r.controlPoints:o=Ct.transpose(r.controlPoints);for(var l=0,c=o[0].length;l<c;){var d=l++,g=m.dist(Z.first(o)[d],Z.last(o)[d])<rt.EPSILON;if(!g)return!1}return!0},bt.rationalSurfaceClosestPoint=function(r,i){var o=bt.rationalSurfaceClosestParam(r,i);return N.rationalSurfacePoint(r,o[0],o[1])},bt.rationalSurfaceClosestParam=function(r,i){for(var o=5,l=0,c,d=1e-4,g=5e-4,_,y=r.knotsU[0],I=Z.last(r.knotsU),P=r.knotsV[0],S=Z.last(r.knotsV),E=bt.isRationalSurfaceClosed(r),M=bt.isRationalSurfaceClosed(r,!1),T,B=Rt.rationalSurfaceAdaptive(r,new $r),O=1/0,F=0,R=B.points.length;F<R;){var j=F++,D=B.points[j],X=m.normSquared(m.sub(i,D));X<O&&(O=X,T=B.uvs[j])}for(var J=function(Yt){return N.rationalSurfaceDerivatives(r,Yt[0],Yt[1],2)},Y=function(Yt,Zt,Ut){var Jt=Zt[1][0],Be=Zt[0][1],tr=Zt[2][0],Ae=Zt[0][2],Ie=Zt[1][1],Re=Zt[1][1],Ue=m.dot(Jt,Ut),ir=m.dot(Be,Ut),fr=[-Ue,-ir],ar=m.dot(Jt,Jt)+m.dot(tr,Ut),or=m.dot(Jt,Be)+m.dot(Ie,Ut),lr=m.dot(Jt,Be)+m.dot(Re,Ut),Sr=m.dot(Be,Be)+m.dot(Ae,Ut),Yn=[[ar,or],[lr,Sr]],gn=Ct.solve(Yn,fr);return m.add(gn,Yt)};l<o;){c=J(T),_=m.sub(c[0][0],i);var U=m.norm(_),$=m.dot(c[1][0],_),tt=m.norm(c[1][0])*U,et=m.dot(c[0][1],_),ot=m.norm(c[0][1])*U,ct=$/tt,ht=et/ot,pt=U<d,nt=ct<g,mt=ht<g;if(pt&&nt&&mt)return T;var K=Y(T,c,_);K[0]<y?E?K=[I-(K[0]-y),K[1]]:K=[y+rt.EPSILON,K[1]]:K[0]>I&&(E?K=[y+(K[0]-I),K[1]]:K=[I-rt.EPSILON,K[1]]),K[1]<P?M?K=[K[0],S-(K[1]-P)]:K=[K[0],P+rt.EPSILON]:K[1]>S&&(M?K=[K[0],P+(K[0]-S)]:K=[K[0],S-rt.EPSILON]);var ft=m.norm(m.mul(K[0]-T[0],c[1][0])),kt=m.norm(m.mul(K[1]-T[1],c[0][1]));if(ft+kt<d)return T;T=K,l++}return T},bt.rationalCurveClosestPoint=function(r,i){return N.rationalCurvePoint(r,bt.rationalCurveClosestParam(r,i))},bt.rationalCurveClosestParam=function(r,i){for(var o=1/0,l=0,c=Rt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,g=c.length-1;d<g;){var _=d++,y=c[_][0],I=c[_+1][0],P=c[_].slice(1),S=c[_+1].slice(1),E=je.segmentClosestPoint(i,P,S,y,I),M=m.norm(m.sub(i,E.pt));M<o&&(o=M,l=E.u)}for(var T=5,B=0,O,F=1e-4,R=5e-4,j,D=r.knots[0],X=Z.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],Z.last(r.controlPoints)))<rt.EPSILON,Y=l,U=function(K){return N.rationalCurveDerivatives(r,K,2)},$=function(K,ft,kt){var Yt=m.dot(ft[1],kt),Zt=m.dot(ft[2],kt),Ut=m.dot(ft[1],ft[1]),Jt=Zt+Ut;return K-Yt/Jt};B<T;){O=U(Y),j=m.sub(O[0],i);var tt=m.norm(j),et=m.dot(O[1],j),ot=m.norm(O[1])*tt,ct=et/ot,ht=tt<F,pt=Math.abs(ct)<R;if(ht&&pt)return Y;var nt=$(Y,O,j);nt<D?J?nt=X-(nt-D):nt=D:nt>X&&(J?nt=D+(nt-X):nt=X);var mt=m.norm(m.mul(nt-Y,O[1]));if(mt<F)return Y;Y=nt,B++}return Y},bt.rationalCurveParamAtArcLength=function(r,i,o,l,c){if(o==null&&(o=.001),i<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=yt.decomposeCurveIntoBeziers(r);var g=0;d[g];var _=-rt.EPSILON,y;for(c!=null?y=c:y=[];_<i&&g<d.length;){if(g<y.length?y[g]=y[g]:y[g]=bt.rationalBezierCurveArcLength(r),_+=y[g],i<_+rt.EPSILON)return bt.rationalBezierCurveParamAtArcLength(r,i,o,y[g]);g++}return-1},bt.rationalBezierCurveParamAtArcLength=function(r,i,o,l){if(i<0)return r.knots[0];var c;if(l!=null?c=l:c=bt.rationalBezierCurveArcLength(r),i>c)return Z.last(r.knots);var d=r.knots[0],g=0,_=Z.last(r.knots),y=c,I=0,P=0,S;for(o!=null?S=o:S=rt.TOLERANCE*2;y-g>S;)I=(d+_)/2,P=bt.rationalBezierCurveArcLength(r,I),P>i?(_=I,y=P):(d=I,g=P);return(d+_)/2},bt.rationalCurveArcLength=function(r,i,o){o==null&&(o=16),i==null?i=Z.last(r.knots):i=i;for(var l=yt.decomposeCurveIntoBeziers(r),c=0,d=l[0],g=0;c<l.length&&d.knots[0]+rt.EPSILON<i;){var _=Math.min(Z.last(d.knots),i);g+=bt.rationalBezierCurveArcLength(d,_,o),d=l[++c]}return g},bt.rationalBezierCurveArcLength=function(r,i,o){o==null&&(o=16);var l;i==null?l=Z.last(r.knots):l=i;for(var c=(l-r.knots[0])/2,d=0,g=r.degree+o,_,y,I=0;I<g;){var P=I++;_=c*bt.Tvalues[g][P]+c+r.knots[0],y=N.rationalCurveDerivatives(r,_,1),d+=bt.Cvalues[g][P]*m.norm(y[1])}return c*d};var Un=f.eval.KnotMultiplicity=function(r,i){this.knot=r,this.mult=i};w["verb.eval.KnotMultiplicity"]=Un,Un.__name__=["verb","eval","KnotMultiplicity"],Un.prototype={inc:function(){this.mult++},__class__:Un};var Je=f.eval.Check=function(){};w["verb.eval.Check"]=Je,Je.__name__=["verb","eval","Check"],Je.isValidKnotVector=function(r,i){if(r.length==0||r.length<(i+1)*2)return!1;for(var o=Z.first(r),l=0,c=i+1;l<c;){var d=l++;if(Math.abs(r[d]-o)>rt.EPSILON)return!1}o=Z.last(r);for(var g=r.length-i-1,_=r.length;g<_;){var y=g++;if(Math.abs(r[y]-o)>rt.EPSILON)return!1}return Je.isNonDecreasing(r)},Je.isNonDecreasing=function(r){for(var i=Z.first(r),o=0,l=r.length;o<l;){var c=o++;if(r[c]<i-rt.EPSILON)return!1;i=r[c]}return!0},Je.isValidNurbsCurveData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degree==null)throw new Q("Degree cannot be null!");if(r.degree<1)throw new Q("Degree must be greater than 1!");if(r.knots==null)throw new Q("Knots cannot be null!");if(r.knots.length!=r.controlPoints.length+r.degree+1)throw new Q("controlPoints.length + degree + 1 must equal knots.length!");if(!Je.isValidKnotVector(r.knots,r.degree))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r},Je.isValidNurbsSurfaceData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degreeU==null)throw new Q("DegreeU cannot be null!");if(r.degreeV==null)throw new Q("DegreeV cannot be null!");if(r.degreeU<1)throw new Q("DegreeU must be greater than 1!");if(r.degreeV<1)throw new Q("DegreeV must be greater than 1!");if(r.knotsU==null)throw new Q("KnotsU cannot be null!");if(r.knotsV==null)throw new Q("KnotsV cannot be null!");if(r.knotsU.length!=r.controlPoints.length+r.degreeU+1)throw new Q("controlPointsU.length + degreeU + 1 must equal knotsU.length!");if(r.knotsV.length!=r.controlPoints[0].length+r.degreeV+1)throw new Q("controlPointsV.length + degreeV + 1 must equal knotsV.length!");if(!Je.isValidKnotVector(r.knotsU,r.degreeU)||!Je.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var ge=f.eval.Divide=function(){};w["verb.eval.Divide"]=ge,ge.__name__=["verb","eval","Divide"],ge.surfaceSplit=function(r,i,o){o==null&&(o=!1);var l,c,d;o?(d=r.controlPoints,l=r.knotsV,c=r.degreeV):(d=Ct.transpose(r.controlPoints),l=r.knotsU,c=r.degreeU);for(var g,_=[],y=0,I=c+1;y<I;)y++,_.push(i);g=_;for(var P=[],S=[],E=N.knotSpan(c,i,l),M=null,T=0;T<d.length;){var B=d[T];++T,M=yt.curveKnotRefine(new Ht(c,l,B),g),P.push(M.controlPoints.slice(0,E+1)),S.push(M.controlPoints.slice(E+1))}var O=M.knots.slice(0,E+c+2),F=M.knots.slice(E+1);return o?[new ie(r.degreeU,c,r.knotsU.slice(),O,P),new ie(r.degreeU,c,r.knotsU.slice(),F,S)]:(P=Ct.transpose(P),S=Ct.transpose(S),[new ie(c,r.degreeV,O,r.knotsV.slice(),P),new ie(c,r.degreeV,F,r.knotsV.slice(),S)])},ge.curveSplit=function(r,i){var o=r.degree;r.controlPoints;for(var l=r.knots,c,d=[],g=0,_=o+1;g<_;)g++,d.push(i);c=d;var y=yt.curveKnotRefine(r,c),I=N.knotSpan(o,i,l),P=y.knots.slice(0,I+o+2),S=y.knots.slice(I+1),E=y.controlPoints.slice(0,I+1),M=y.controlPoints.slice(I+1);return[new Ht(o,P,E),new Ht(o,S,M)]},ge.rationalCurveByEqualArcLength=function(r,i){var o=bt.rationalCurveArcLength(r),l=o/i;return ge.rationalCurveByArcLength(r,l)},ge.rationalCurveByArcLength=function(r,i){var o=yt.decomposeCurveIntoBeziers(r),l=o.map(function(E){return bt.rationalBezierCurveArcLength(E)}),c=m.sum(l),d=[new Gn(r.knots[0],0)];if(i>c)return d;for(var g=i,_=0,y=g,I=0,P=0,S;_<o.length;){for(I+=l[_];y<I+rt.EPSILON;)S=bt.rationalBezierCurveParamAtArcLength(o[_],y-P,rt.TOLERANCE,l[_]),d.push(new Gn(S,y)),y+=g;P+=l[_],_++}return d};var Gn=f.eval.CurveLengthSample=function(r,i){this.u=r,this.len=i};w["verb.eval.CurveLengthSample"]=Gn,Gn.__name__=["verb","eval","CurveLengthSample"],Gn.prototype={__class__:Gn};var N=f.eval.Eval=function(){};w["verb.eval.Eval"]=N,N.__name__=["verb","eval","Eval"],N.rationalCurveTangent=function(r,i){var o=N.rationalCurveDerivatives(r,i,1);return o[1]},N.rationalSurfaceNormal=function(r,i,o){var l=N.rationalSurfaceDerivatives(r,i,o,1);return m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,i,o,l){l==null&&(l=1);for(var c=N.surfaceDerivatives(r,i,o,l),d=N.rational2d(c),g=N.weight2d(c),_=[],y=d[0][0].length,I=0,P=l+1;I<P;){var S=I++;_.push([]);for(var E=0,M=l-S+1;E<M;){for(var T=E++,B=d[S][T],O=1,F=T+1;O<F;){var R=O++;m.subMulMutate(B,Vt.get(T,R)*g[0][R],_[S][T-R])}for(var j=1,D=S+1;j<D;){var X=j++;m.subMulMutate(B,Vt.get(S,X)*g[X][0],_[S-X][T]);for(var J=m.zeros1d(y),Y=1,U=T+1;Y<U;){var $=Y++;m.addMulMutate(J,Vt.get(T,$)*g[X][$],_[S-X][T-$])}m.subMulMutate(B,Vt.get(S,X),J)}m.mulMutate(1/g[0][0],B),_[S].push(B)}}return _},N.rationalSurfacePoint=function(r,i,o){return N.dehomogenize(N.surfacePoint(r,i,o))},N.rationalCurveDerivatives=function(r,i,o){o==null&&(o=1);for(var l=N.curveDerivatives(r,i,o),c=N.rational1d(l),d=N.weight1d(l),g=[],_=0,y=o+1;_<y;){for(var I=_++,P=c[I],S=1,E=I+1;S<E;){var M=S++;m.subMulMutate(P,Vt.get(I,M)*d[M],g[I-M])}m.mulMutate(1/d[0],P),g.push(P)}return g},N.rationalCurvePoint=function(r,i){return N.dehomogenize(N.curvePoint(r,i))},N.surfaceDerivatives=function(r,i,o,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(c,d,r,i,o,l)},N.surfaceDerivativesGivenNM=function(r,i,o,l,c,d){var g=o.degreeU,_=o.degreeV,y=o.controlPoints,I=o.knotsU,P=o.knotsV;if(!N.areValidRelations(g,y.length,I.length)||!N.areValidRelations(_,y[0].length,P.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=y[0][0].length,E;d<g?E=d:E=g;var M;d<_?M=d:M=_;for(var T=m.zeros3d(d+1,d+1,S),B=N.knotSpanGivenN(r,g,l,I),O=N.knotSpanGivenN(i,_,c,P),F=N.derivativeBasisFunctionsGivenNI(B,l,g,r,I),R=N.derivativeBasisFunctionsGivenNI(O,c,_,i,P),j=m.zeros2d(_+1,S),D=0,X=0,J=E+1;X<J;){for(var Y=X++,U=0,$=_+1;U<$;){var tt=U++;j[tt]=m.zeros1d(S);for(var et=0,ot=g+1;et<ot;){var ct=et++;m.addMulMutate(j[tt],F[Y][ct],y[B-g+ct][O-_+tt])}}var ht=d-Y;ht<M?D=ht:D=M;for(var pt=0,nt=D+1;pt<nt;){var mt=pt++;T[Y][mt]=m.zeros1d(S);for(var K=0,ft=_+1;K<ft;){var kt=K++;m.addMulMutate(T[Y][mt],R[mt][kt],j[kt])}}}return T},N.surfacePoint=function(r,i,o){var l=r.knotsU.length-r.degreeU-2,c=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,c,r,i,o)},N.surfacePointGivenNM=function(r,i,o,l,c){var d=o.degreeU,g=o.degreeV,_=o.controlPoints,y=o.knotsU,I=o.knotsV;if(!N.areValidRelations(d,_.length,y.length)||!N.areValidRelations(g,_[0].length,I.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var P=_[0][0].length,S=N.knotSpanGivenN(r,d,l,y),E=N.knotSpanGivenN(i,g,c,I),M=N.basisFunctionsGivenKnotSpanIndex(S,l,d,y),T=N.basisFunctionsGivenKnotSpanIndex(E,c,g,I),B=S-d,O=E,F=m.zeros1d(P),R=m.zeros1d(P),j=0,D=g+1;j<D;){var X=j++;R=m.zeros1d(P),O=E-g+X;for(var J=0,Y=d+1;J<Y;){var U=J++;m.addMulMutate(R,M[U],_[B+U][O])}m.addMulMutate(F,T[X],R)}return F},N.curveRegularSamplePoints=function(r,i){for(var o=N.curveDerivatives(r,r.knots[0],r.degree),l=1/i,c=l*l,d=o[0],g=m.mul(l,o[1]),_=m.mul(c*.5,o[2]),y=m.mul(c*l*.5,o[3]),I=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),E=[],M=0,T=i+1;M<T;)M++,E.push(N.dehomogenize(d)),m.addAllMutate([d,g,_,S]),m.addAllMutate([g,I,y]),m.addAllMutate([I,P]),m.addAllMutate([_,y]);return E},N.curveRegularSamplePoints2=function(r,i){for(var o=N.curveDerivatives(r,r.knots[0],r.degree),l=1/i,c=l*l,d=o[0],g=m.mul(l,o[1]),_=m.mul(c*.5,o[2]),y=m.mul(c*l*.5,o[3]),I=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),E=[],M=0,T=i+1;M<T;)M++,E.push(N.dehomogenize(d)),m.addAllMutate([d,g,_,S]),m.addAllMutate([g,I,y]),m.addAllMutate([I,P]),m.addAllMutate([_,y]);return E},N.rationalSurfaceRegularSampleDerivatives=function(r,i,o,l){for(var c=N.surfaceRegularSampleDerivatives(r,i,o,l),d=[],g=i+1,_=o+1,y=l+1,I=0;I<g;){var P=I++,S=[];d.push(S);for(var E=0;E<_;){for(var M=E++,T=c[P][M],B=N.rational2d(T),O=N.weight2d(T),F=[],R=B[0][0].length,j=0;j<y;){var D=j++;F.push([]);for(var X=0,J=y-D;X<J;){for(var Y=X++,U=B[D][Y],$=1,tt=Y+1;$<tt;){var et=$++;m.subMulMutate(U,Vt.get(Y,et)*O[0][et],F[D][Y-et])}for(var ot=1,ct=D+1;ot<ct;){var ht=ot++;m.subMulMutate(U,Vt.get(D,ht)*O[ht][0],F[D-ht][Y]);for(var pt=m.zeros1d(R),nt=1,mt=Y+1;nt<mt;){var K=nt++;m.addMulMutate(pt,Vt.get(Y,K)*O[ht][K],F[D-ht][Y-K])}m.subMulMutate(U,Vt.get(D,ht),pt)}m.mulMutate(1/O[0][0],U),F[D].push(U)}}S.push(F)}}return d},N.surfaceRegularSampleDerivatives=function(r,i,o,l){var c=r.degreeU,d=r.degreeV,g=r.controlPoints,_=r.knotsU,y=r.knotsV,I=g[0][0].length;(Z.last(_)-_[0])/i,(Z.last(y)-y[0])/o;for(var P=N.regularlySpacedDerivativeBasisFunctions(c,_,i),S=P.item0,E=P.item1,M=N.regularlySpacedDerivativeBasisFunctions(d,y,o),T=M.item0,B=M.item1,O=[],F=i+1,R=o+1,j=0;j<F;){var D=j++,X=[];O.push(X);for(var J=0;J<R;){var Y=J++;X.push(N.surfaceDerivativesGivenBasesKnotSpans(c,d,g,S[D],T[Y],E[D],B[Y],I,l))}}return O},N.rationalSurfaceRegularSamplePoints=function(r,i,o){return N.dehomogenize2d(N.surfaceRegularSamplePoints(r,i,o))},N.surfaceRegularSamplePoints=function(r,i,o){var l=r.degreeU,c=r.degreeV,d=r.controlPoints,g=r.knotsU,_=r.knotsV,y=d[0][0].length;(Z.last(g)-g[0])/i,(Z.last(_)-_[0])/o;for(var I=N.regularlySpacedBasisFunctions(l,g,i),P=I.item0,S=I.item1,E=N.regularlySpacedBasisFunctions(c,_,o),M=E.item0,T=E.item1,B=[],O=i+1,F=o+1,R=0;R<O;){var j=R++,D=[];B.push(D);for(var X=0;X<F;){var J=X++;D.push(N.surfacePointGivenBasesKnotSpans(l,c,d,P[j],M[J],S[j],T[J],y))}}return B},N.regularlySpacedBasisFunctions=function(r,i,o){for(var l=i.length-r-2,c=(Z.last(i)-i[0])/o,d=[],g=[],_=i[0],y=N.knotSpanGivenN(l,r,_,i),I=o+1,P=0;P<I;){for(P++;_>=i[y+1];)y++;g.push(y),d.push(N.basisFunctionsGivenKnotSpanIndex(y,_,r,i)),_+=c}return new ae(g,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,i,o){for(var l=i.length-r-2,c=(Z.last(i)-i[0])/o,d=[],g=[],_=i[0],y=N.knotSpanGivenN(l,r,_,i),I=o+1,P=0;P<I;){for(P++;_>=i[y+1];)y++;g.push(y),d.push(N.derivativeBasisFunctionsGivenNI(y,_,r,l,i)),_+=c}return new ae(g,d)},N.surfacePointGivenBasesKnotSpans=function(r,i,o,l,c,d,g,_){for(var y=m.zeros1d(_),I,P=l-r,S=c-i,E=0,M=i+1;E<M;){var T=E++;I=m.zeros1d(_);for(var B=0,O=r+1;B<O;){var F=B++;m.addMulMutate(I,d[F],o[P+F][S])}S++,m.addMulMutate(y,g[T],I)}return y},N.surfaceDerivativesGivenBasesKnotSpans=function(r,i,o,l,c,d,g,_,y){var I=o[0][0].length,P;y<r?P=y:P=r;var S;y<i?S=y:S=i;for(var E=m.zeros3d(P+1,S+1,I),M=m.zeros2d(i+1,I),T=0,B=0,O=P+1;B<O;){for(var F=B++,R=0,j=i+1;R<j;){var D=R++;M[D]=m.zeros1d(I);for(var X=0,J=r+1;X<J;){var Y=X++;m.addMulMutate(M[D],d[F][Y],o[l-r+Y][c-i+D])}}var U=y-F;U<S?T=U:T=S;for(var $=0,tt=T+1;$<tt;){var et=$++;E[F][et]=m.zeros1d(I);for(var ot=0,ct=i+1;ot<ct;){var ht=ot++;m.addMulMutate(E[F][et],g[et][ht],M[ht])}}}return E},N.curveDerivatives=function(r,i,o){var l=r.knots.length-r.degree-2;return N.curveDerivativesGivenN(l,r,i,o)},N.curveDerivativesGivenN=function(r,i,o,l){var c=i.degree,d=i.controlPoints,g=i.knots;if(!N.areValidRelations(c,d.length,g.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<c?y=l:y=c;for(var I=m.zeros2d(l+1,_),P=N.knotSpanGivenN(r,c,o,g),S=N.derivativeBasisFunctionsGivenNI(P,o,c,y,g),E=0,M=y+1;E<M;)for(var T=E++,B=0,O=c+1;B<O;){var F=B++;m.addMulMutate(I[T],S[T][F],d[P-c+F])}return I},N.curvePoint=function(r,i){var o=r.knots.length-r.degree-2;return N.curvePointGivenN(o,r,i)},N.areValidRelations=function(r,i,o){return i+r+1-o==0},N.curvePointGivenN=function(r,i,o){var l=i.degree,c=i.controlPoints,d=i.knots;if(!N.areValidRelations(l,c.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var g=N.knotSpanGivenN(r,l,o,d),_=N.basisFunctionsGivenKnotSpanIndex(g,o,l,d),y=m.zeros1d(c[0].length),I=0,P=l+1;I<P;){var S=I++;m.addMulMutate(y,_[S],c[g-l+S])}return y},N.volumePoint=function(r,i,o,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,g=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,c,d,g,i,o,l)},N.volumePointGivenNML=function(r,i,o,l,c,d,g){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,y=r.degreeU,I=r.degreeV,P=r.degreeW,S=r.knotsU,E=r.knotsV,M=r.knotsW,T=_[0][0][0].length,B=N.knotSpanGivenN(i,y,c,S),O=N.knotSpanGivenN(o,I,d,E),F=N.knotSpanGivenN(l,P,g,M),R=N.basisFunctionsGivenKnotSpanIndex(B,c,y,S),j=N.basisFunctionsGivenKnotSpanIndex(O,d,I,E),D=N.basisFunctionsGivenKnotSpanIndex(F,g,P,M),X=B-y,J=m.zeros1d(T),Y=m.zeros1d(T),U=m.zeros1d(T),$=0,tt=P+1;$<tt;){var et=$++;U=m.zeros1d(T);for(var ot=F-P+et,ct=0,ht=I+1;ct<ht;){var pt=ct++;Y=m.zeros1d(T);for(var nt=O-I+pt,mt=0,K=y+1;mt<K;){var ft=mt++;m.addMulMutate(Y,R[ft],_[X+ft][nt][ot])}m.addMulMutate(U,j[pt],Y)}m.addMulMutate(J,D[et],U)}return J},N.derivativeBasisFunctions=function(r,i,o){var l=N.knotSpan(i,r,o),c=o.length-1,d=c-i-1;return N.derivativeBasisFunctionsGivenNI(l,r,i,d,o)},N.derivativeBasisFunctionsGivenNI=function(r,i,o,l,c){var d=m.zeros2d(o+1,o+1),g=m.zeros1d(o+1),_=m.zeros1d(o+1),y=0,I=0;d[0][0]=1;for(var P=1,S=o+1;P<S;){var E=P++;g[E]=i-c[r+1-E],_[E]=c[r+E]-i,y=0;for(var M=0;M<E;){var T=M++;d[E][T]=_[T+1]+g[E-T],I=d[T][E-1]/d[E][T],d[T][E]=y+_[T+1]*I,y=g[E-T]*I}d[E][E]=y}for(var B=m.zeros2d(l+1,o+1),O=m.zeros2d(2,o+1),F=0,R=1,j=0,D=0,X=0,J=0,Y=0,U=0,$=o+1;U<$;){var tt=U++;B[0][tt]=d[tt][o]}for(var et=0,ot=o+1;et<ot;){var ct=et++;F=0,R=1,O[0][0]=1;for(var ht=1,pt=l+1;ht<pt;){var nt=ht++;j=0,D=ct-nt,X=o-nt,ct>=nt&&(O[R][0]=O[F][0]/d[X+1][D],j=O[R][0]*d[D][X]),D>=-1?J=1:J=-D,ct-1<=X?Y=nt-1:Y=o-ct;for(var mt=J,K=Y+1;mt<K;){var ft=mt++;O[R][ft]=(O[F][ft]-O[F][ft-1])/d[X+1][D+ft],j+=O[R][ft]*d[D+ft][X]}ct<=X&&(O[R][nt]=-O[F][nt-1]/d[X+1][ct],j+=O[R][nt]*d[ct][X]),B[nt][ct]=j;var kt=F;F=R,R=kt}}for(var Yt=o,Zt=1,Ut=l+1;Zt<Ut;){for(var Jt=Zt++,Be=0,tr=o+1;Be<tr;){var Ae=Be++;B[Jt][Ae]*=Yt}Yt*=o-Jt}return B},N.basisFunctions=function(r,i,o){var l=N.knotSpan(i,r,o);return N.basisFunctionsGivenKnotSpanIndex(l,r,i,o)},N.basisFunctionsGivenKnotSpanIndex=function(r,i,o,l){var c=m.zeros1d(o+1),d=m.zeros1d(o+1),g=m.zeros1d(o+1),_=0,y=0;c[0]=1;for(var I=1,P=o+1;I<P;){var S=I++;d[S]=i-l[r+1-S],g[S]=l[r+S]-i,_=0;for(var E=0;E<S;){var M=E++;y=c[M]/(g[M+1]+d[S-M]),c[M]=_+g[M+1]*y,_=d[S-M]*y}c[S]=_}return c},N.knotSpan=function(r,i,o){return N.knotSpanGivenN(o.length-r-2,r,i,o)},N.knotSpanGivenN=function(r,i,o,l){if(o>l[r+1]-rt.EPSILON)return r;if(o<l[i]+rt.EPSILON)return i;for(var c=i,d=r+1,g=Math.floor((c+d)/2);o<l[g]||o>=l[g+1];)o<l[g]?d=g:c=g,g=Math.floor((c+d)/2);return g},N.dehomogenize=function(r){for(var i=r.length,o=[],l=r[i-1],c=r.length-1,d=0;d<c;){var g=d++;o.push(r[g]/l)}return o},N.rational1d=function(r){var i=r[0].length-1;return r.map(function(o){return o.slice(0,i)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var i=r[0].length-1;return r.map(function(o){return o[i]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,i){var o=r.length,l=r[0].length,c=[],d=0,g=[],_;i!=null?_=i:_=m.rep(r.length,1);for(var y=0;y<o;){var I=y++,P=[];g=r[I],d=_[I];for(var S=0;S<l;){var E=S++;P.push(g[E]*d)}P.push(d),c.push(P)}return c},N.homogenize2d=function(r,i){var o=r.length,l=[],c;if(i!=null)c=i;else{for(var d=[],g=0;g<o;)g++,d.push(m.rep(r[0].length,1));c=d}for(var _=0;_<o;){var y=_++;l.push(N.homogenize1d(r[y],c[y]))}return l};var ut=f.eval.Intersect=function(){};w["verb.eval.Intersect"]=ut,ut.__name__=["verb","eval","Intersect"],ut.surfaces=function(r,i,o){var l=Rt.rationalSurfaceAdaptive(r),c=Rt.rationalSurfaceAdaptive(i),d=ut.meshes(l,c),g=d.map(function(_){return _.map(function(y){return ut.surfacesAtPointWithEstimate(r,i,y.uv0,y.uv1,o)})});return g.map(function(_){return gt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},ut.surfacesAtPointWithEstimate=function(r,i,o,l,c){var d,g,_,y,I,P,S,E,M,T,B,O,F,R=5,j=0;do{if(d=N.rationalSurfaceDerivatives(r,o[0],o[1],1),g=d[0][0],y=d[1][0],I=d[0][1],_=m.normalized(m.cross(y,I)),P=m.dot(_,g),S=N.rationalSurfaceDerivatives(i,l[0],l[1],1),E=S[0][0],T=S[1][0],B=S[0][1],M=m.normalized(m.cross(T,B)),O=m.dot(M,E),F=m.distSquared(g,E),F<c*c)break;var D=m.normalized(m.cross(_,M)),X=m.dot(D,g),J=ut.threePlanes(_,P,M,O,D,X);if(J==null)throw new Q("panic!");var Y=m.sub(J,g),U=m.sub(J,E),$=m.cross(y,_),tt=m.cross(I,_),et=m.cross(T,M),ot=m.cross(B,M),ct=m.dot(tt,Y)/m.dot(tt,y),ht=m.dot($,Y)/m.dot($,I),pt=m.dot(ot,U)/m.dot(ot,T),nt=m.dot(et,U)/m.dot(et,B);o=m.add([ct,ht],o),l=m.add([pt,nt],l),j++}while(j<R);return new ds(o,l,g,F)},ut.meshes=function(r,i,o,l){o==null&&(o=new gr(r)),l==null&&(l=new gr(i));var c=ut.boundingBoxTrees(o,l,0),d=Z.unique(c.map(function(g){return ut.triangles(r,g.item0,i,g.item1)}).filter(function(g){return g!=null}).filter(function(g){return m.distSquared(g.min.point,g.max.point)>rt.EPSILON}),function(g,_){var y=m.sub(g.min.uv0,_.min.uv0),I=m.dot(y,y),P=m.sub(g.max.uv0,_.max.uv0),S=m.dot(P,P),E=m.sub(g.min.uv0,_.max.uv0),M=m.dot(E,E),T=m.sub(g.max.uv0,_.min.uv0),B=m.dot(T,T);return I<rt.EPSILON&&S<rt.EPSILON||M<rt.EPSILON&&B<rt.EPSILON});return ut.makeMeshIntersectionPolylines(d)},ut.meshSlices=function(r,i,o,l){for(var c=new Kr(r),d=c.boundingBox(),g=d.min[0],_=d.min[1],y=d.max[0],I=d.max[1],P=m.span(i,o,l),S=[],E=0;E<P.length;){var M=P[E];++E;var T=[[g,_,M],[y,_,M],[y,I,M],[g,I,M]],B=[[0,0],[1,0],[1,1],[0,1]],O=[[0,1,2],[0,2,3]],F=new rr(O,T,null,B);S.push(ut.meshes(r,F,c))}return S},ut.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var i=0;i<r.length;){var o=r[i];++i,o.max.opp=o.min,o.min.opp=o.max}for(var l=ut.kdTreeFromSegments(r),c=[],d=0;d<r.length;){var g=r[d];++d,c.push(g.min),c.push(g.max)}for(var _=0;_<c.length;){var y=c[_];if(++_,y.adj==null){var I=ut.lookupAdjacentSegment(y,l,r.length);I!=null&&I.adj==null&&(y.adj=I,I.adj=y)}}var P=c.filter(function(R){return R.adj==null});P.length==0&&(P=c);for(var S=[],E=0,M=!1;P.length!=0;){var T=P.pop();if(!T.visited){for(var B=[],O=T;O!=null&&!(O.visited||(O.visited=!0,O.opp.visited=!0,B.push(O),E+=2,O=O.opp.adj,O==T)););B.length>0&&(B.push(B[B.length-1].opp),S.push(B))}if(P.length==0&&c.length>0&&(M||E<c.length)){M=!0;var F=c.pop();P.push(F)}}return S},ut.kdTreeFromSegments=function(r){for(var i=[],o=0;o<r.length;){var l=r[o];++o,i.push(new Vn(l.min.point,l.min)),i.push(new Vn(l.max.point,l.max))}return new ms(i,m.distSquared)},ut.lookupAdjacentSegment=function(r,i,o){var l=i.nearest(r.point,o,rt.EPSILON).filter(function(c){return r!=c.item0.obj}).map(function(c){return c.item0.obj});return l.length==1?l[0]:null},ut.curveAndSurface=function(r,i,o,l,c){o==null&&(o=.001),l!=null?l=l:l=new mr(r),c!=null?c=c:c=new qr(i);var d=ut.boundingBoxTrees(l,c,o);return Z.unique(d.map(function(g){var _=g.item0,y=g.item1,I=Z.first(_.knots),P=Z.last(_.knots),S=(I+P)/2,E=Z.first(y.knotsU),M=Z.last(y.knotsU),T=Z.first(y.knotsV),B=Z.last(y.knotsV),O=[(E+M)/2,(T+B)/2];return ut.curveAndSurfaceWithEstimate(_,y,[S].concat(O),o)}).filter(function(g){return m.distSquared(g.curvePoint,g.surfacePoint)<o*o}),function(g,_){return Math.abs(g.u-_.u)<.5*o})},ut.curveAndSurfaceWithEstimate=function(r,i,o,l){l==null&&(l=.001);var c=function(y){var I=N.rationalCurvePoint(r,y[0]),P=N.rationalSurfacePoint(i,y[1],y[2]),S=m.sub(I,P);return m.dot(S,S)},d=function(y){var I=N.rationalCurveDerivatives(r,y[0],1),P=N.rationalSurfaceDerivatives(i,y[1],y[2],1),S=m.sub(P[0][0],I[0]),E=m.mul(-1,I[1]),M=P[1][0],T=P[0][1];return[2*m.dot(E,S),2*m.dot(M,S),2*m.dot(T,S)]},g=nr.uncmin(c,o,l*l,d),_=g.solution;return new us(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(i,_[1],_[2]))},ut.polylineAndMesh=function(r,i,o){for(var l=ut.boundingBoxTrees(new _r(r),new gr(i),o),c=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,I=ut.segmentWithTriangle(r.points[_],r.points[_+1],i.points,i.faces[y]);if(I!=null){var P=I.point,S=m.lerp(I.p,[r.params[_]],[r.params[_+1]])[0],E=oe.triangleUVFromPoint(i,y,P);c.push(new cs(P,S,E,_,y))}}return c},ut.boundingBoxTrees=function(r,i,o){o==null&&(o=1e-9);var l=[],c=[];l.push(r),c.push(i);for(var d=[];l.length>0;){var g=l.pop(),_=c.pop();if(!(g.empty()||_.empty())&&g.boundingBox().intersects(_.boundingBox(),o)){var y=g.indivisible(o),I=_.indivisible(o);if(y&&I){d.push(new ae(g.yield(),_.yield()));continue}else if(y&&!I){var P=_.split();l.push(g),c.push(P.item1),l.push(g),c.push(P.item0);continue}else if(!y&&I){var S=g.split();l.push(S.item1),c.push(_),l.push(S.item0),c.push(_);continue}var E=g.split(),M=_.split();l.push(E.item1),c.push(M.item1),l.push(E.item1),c.push(M.item0),l.push(E.item0),c.push(M.item1),l.push(E.item0),c.push(M.item0)}}return d},ut.curves=function(r,i,o){var l=ut.boundingBoxTrees(new mr(r),new mr(i),0);return Z.unique(l.map(function(c){return ut.curvesWithEstimate(r,i,Z.first(c.item0.knots),Z.first(c.item1.knots),o)}).filter(function(c){return m.distSquared(c.point0,c.point1)<o}),function(c,d){return Math.abs(c.u0-d.u0)<o*5})},ut.curvesWithEstimate=function(r,i,o,l,c){var d=function(E){var M=N.rationalCurvePoint(r,E[0]),T=N.rationalCurvePoint(i,E[1]),B=m.sub(M,T);return m.dot(B,B)},g=function(E){var M=N.rationalCurveDerivatives(r,E[0],1),T=N.rationalCurveDerivatives(i,E[1],1),B=m.sub(M[0],T[0]),O=M[1],F=m.mul(-1,T[1]);return[2*m.dot(O,B),2*m.dot(F,B)]},_=nr.uncmin(d,[o,l],c*c,g),y=_.solution[0],I=_.solution[1],P=N.rationalCurvePoint(r,y),S=N.rationalCurvePoint(i,I);return new pn(P,S,y,I)},ut.triangles=function(r,i,o,l){var c=r.faces[i],d=o.faces[l],g=oe.getTriangleNorm(r.points,c),_=oe.getTriangleNorm(o.points,d),y=r.points[c[0]],I=o.points[d[0]],P=ut.planes(y,g,I,_);if(P==null)return null;var S=ut.clipRayInCoplanarTriangle(P,r,i);if(S==null)return null;var E=ut.clipRayInCoplanarTriangle(P,o,l);if(E==null)return null;var M=ut.mergeTriangleClipIntervals(S,E,r,i,o,l);return M==null?null:new Ce(new Xr(M.min.uv0,M.min.uv1,M.min.point,i,l),new Xr(M.max.uv0,M.max.uv1,M.max.point,i,l))},ut.clipRayInCoplanarTriangle=function(r,i,o){for(var l=i.faces[o],c=[i.points[l[0]],i.points[l[1]],i.points[l[2]]],d=[i.uvs[l[0]],i.uvs[l[1]],i.uvs[l[2]]],g=[m.sub(d[1],d[0]),m.sub(d[2],d[1]),m.sub(d[0],d[2])],_=[m.sub(c[1],c[0]),m.sub(c[2],c[1]),m.sub(c[0],c[2])],y=_.map(m.normalized),I=_.map(m.norm),P=null,S=null,E=0;E<3;){var M=E++,T=c[M],B=y[M],O=ut.rays(T,B,r.origin,r.dir);if(O!=null){var F=O.u0,R=O.u1;F<-rt.EPSILON||F>I[M]+rt.EPSILON||((P==null||R<P.u)&&(P=new zn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[M],g[M],F/I[M]))),(S==null||R>S.u)&&(S=new zn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[M],g[M],F/I[M]))))}}return S==null||P==null?null:new Ce(P,S)},ut.mergeTriangleClipIntervals=function(r,i,o,l,c,d){if(i.min.u>r.max.u+rt.EPSILON||r.min.u>i.max.u+rt.EPSILON)return null;var g;r.min.u>i.min.u?g=new ae(r.min,0):g=new ae(i.min,1);var _;r.max.u<i.max.u?_=new ae(r.max,0):_=new ae(i.max,1);var y=new Ce(new Xr(null,null,g.item0.point,l,d),new Xr(null,null,_.item0.point,l,d));return g.item1==0?(y.min.uv0=g.item0.uv,y.min.uv1=oe.triangleUVFromPoint(c,d,g.item0.point)):(y.min.uv0=oe.triangleUVFromPoint(o,l,g.item0.point),y.min.uv1=g.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=oe.triangleUVFromPoint(c,d,_.item0.point)):(y.max.uv0=oe.triangleUVFromPoint(o,l,_.item0.point),y.max.uv1=_.item0.uv),y},ut.planes=function(r,i,o,l){var c=m.cross(i,l);if(m.dot(c,c)<rt.EPSILON)return null;var d=0,g=Math.abs(c[0]),_=Math.abs(c[1]),y=Math.abs(c[2]);_>g&&(d=1,g=_),y>g&&(d=2,g=y);var I,P,S,E;d==0?(I=i[1],P=i[2],S=l[1],E=l[2]):d==1?(I=i[0],P=i[2],S=l[0],E=l[2]):(I=i[0],P=i[1],S=l[0],E=l[1]);var M=-m.dot(r,i),T=-m.dot(o,l),B=I*E-P*S,O=(P*T-M*E)/B,F=(M*S-I*T)/B,R;return d==0?R=[0,O,F]:d==1?R=[O,0,F]:R=[O,F,0],new Fn(R,m.normalized(c))},ut.threePlanes=function(r,i,o,l,c,d){var g=m.cross(o,c),_=m.dot(r,g);if(Math.abs(_)<rt.EPSILON)return null;var y=m.sub(m.mul(d,o),m.mul(l,c)),I=m.add(m.mul(i,g),m.cross(r,y));return m.mul(1/_,I)},ut.polylines=function(r,i,o){for(var l=ut.boundingBoxTrees(new _r(r),new _r(i),o),c=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,I=ut.segments(r.points[_],r.points[_+1],i.points[y],i.points[y+1],o);I!=null&&(I.u0=m.lerp(I.u0,[r.params[_]],[r.params[_+1]])[0],I.u1=m.lerp(I.u1,[i.params[y]],[i.params[y+1]])[0],c.push(I))}return c},ut.segments=function(r,i,o,l,c){var d=m.sub(i,r),g=Math.sqrt(m.dot(d,d)),_=m.mul(1/g,d),y=m.sub(l,o),I=Math.sqrt(m.dot(y,y)),P=m.mul(1/I,y),S=ut.rays(r,_,o,P);if(S!=null){var E=Math.min(Math.max(0,S.u0/g),1),M=Math.min(Math.max(0,S.u1/I),1),T=m.onRay(r,d,E),B=m.onRay(o,y,M),O=m.distSquared(T,B);if(O<c*c)return new pn(T,B,E,M)}return null},ut.rays=function(r,i,o,l){var c=m.dot(i,l),d=m.dot(i,o),g=m.dot(i,r),_=m.dot(l,o),y=m.dot(l,r),I=m.dot(i,i),P=m.dot(l,l),S=I*P-c*c;if(Math.abs(S)<rt.EPSILON)return null;var E=c*(d-g)-I*(_-y),M=E/S,T=(d-g+M*c)/I,B=m.onRay(r,i,T),O=m.onRay(o,l,M);return new pn(B,O,T,M)},ut.segmentWithTriangle=function(r,i,o,l){var c=o[l[0]],d=o[l[1]],g=o[l[2]],_=m.sub(d,c),y=m.sub(g,c),I=m.cross(_,y),P=m.sub(i,r),S=m.sub(r,c),E=-m.dot(I,S),M=m.dot(I,P);if(Math.abs(M)<rt.EPSILON)return null;var T=E/M;if(T<0||T>1)return null;var B=m.add(r,m.mul(T,P)),O=m.dot(_,y),F=m.dot(_,_),R=m.dot(y,y),j=m.sub(B,c),D=m.dot(j,_),X=m.dot(j,y),J=O*O-F*R;if(Math.abs(J)<rt.EPSILON)return null;var Y=(O*X-R*D)/J,U=(O*D-F*X)/J;return Y>1+rt.EPSILON||U>1+rt.EPSILON||U<-rt.EPSILON||Y<-rt.EPSILON||Y+U>1+rt.EPSILON?null:new ps(B,Y,U,T)},ut.segmentAndPlane=function(r,i,o,l){var c=m.dot(l,m.sub(i,r));if(Math.abs(c)<rt.EPSILON)return null;var d=m.dot(l,m.sub(o,r)),g=d/c;return g>1+rt.EPSILON||g<-rt.EPSILON?null:{p:g}};var gt=f.eval.Make=function(){};w["verb.eval.Make"]=gt,gt.__name__=["verb","eval","Make"],gt.rationalTranslationalSurface=function(r,i){for(var o=N.rationalCurvePoint(i,Z.first(i.knots)),l=Z.first(i.knots),c=Z.last(i.knots),d=2*i.controlPoints.length,g=(c-l)/(d-1),_=[],y=0;y<d;){var I=y++,P=m.sub(N.rationalCurvePoint(i,l+I*g),o),S=yt.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(S)}return gt.loftedSurface(_)},gt.surfaceBoundaryCurves=function(r){var i=gt.surfaceIsocurve(r,Z.first(r.knotsU),!1),o=gt.surfaceIsocurve(r,Z.last(r.knotsU),!1),l=gt.surfaceIsocurve(r,Z.first(r.knotsV),!0),c=gt.surfaceIsocurve(r,Z.last(r.knotsV),!0);return[i,o,l,c]},gt.surfaceIsocurve=function(r,i,o){o==null&&(o=!1);var l;o?l=r.knotsV:l=r.knotsU;var c;o?c=r.degreeV:c=r.degreeU;for(var d=bt.knotMultiplicities(l),g=-1,_=0,y=d.length;_<y;){var I=_++;if(Math.abs(i-d[I].knot)<rt.EPSILON){g=I;break}}var P=c+1;g>=0&&(P=P-d[g].mult);var S;P>0?S=yt.surfaceKnotRefine(r,m.rep(P,i),o):S=r;var E=N.knotSpan(c,i,l);return Math.abs(i-Z.first(l))<rt.EPSILON?E=0:Math.abs(i-Z.last(l))<rt.EPSILON&&(E=(o?S.controlPoints[0].length:S.controlPoints.length)-1),o?new Ht(S.degreeU,S.knotsU,function(M){for(var T,B=[],O=0,F=S.controlPoints;O<F.length;){var R=F[O];++O,B.push(R[E])}return T=B,T}()):new Ht(S.degreeV,S.knotsV,S.controlPoints[E])},gt.loftedSurface=function(r,i){r=yt.unifyCurveKnotVectors(r);var o=r[0].degree;i==null&&(i=3),i>r.length-1&&(i=r.length-1);for(var l=r[0].knots,c=[],d=[],g=0,_=r[0].controlPoints.length;g<_;){var y=[g++],I=r.map(function(S){return function(E){return E.controlPoints[S[0]]}}(y)),P=gt.rationalInterpCurve(I,i,!0);d.push(P.controlPoints),c=P.knots}return new ie(o,i,l,c,d)},gt.clonedCurve=function(r){return new Ht(r.degree,r.knots.slice(),r.controlPoints.map(function(i){return i.slice()}))},gt.rationalBezierCurve=function(r,i){for(var o=r.length-1,l=[],c=0,d=o+1;c<d;)c++,l.push(0);for(var g=0,_=o+1;g<_;)g++,l.push(1);return i==null&&(i=m.rep(r.length,1)),new Ht(o,l,N.homogenize1d(r,i))},gt.fourPointSurface=function(r,i,o,l,c){c==null&&(c=3);for(var d=c,g=[],_=0,y=c+1;_<y;){for(var I=_++,P=[],S=0,E=c+1;S<E;){var M=S++,T=1-I/d,B=m.lerp(T,r,i),O=m.lerp(T,l,o),F=m.lerp(1-M/d,B,O);F.push(1),P.push(F)}g.push(P)}var R=m.rep(c+1,0),j=m.rep(c+1,1);return new ie(c,c,R.concat(j),R.concat(j),g)},gt.ellipseArc=function(r,i,o,l,c){var d=m.norm(i),g=m.norm(o);i=m.normalized(i),o=m.normalized(o),c<l&&(c=2*Math.PI+l);var _=c-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var I=_/y,P=Math.cos(I/2),S=m.add(r,m.add(m.mul(d*Math.cos(l),i),m.mul(g*Math.sin(l),o))),E=m.sub(m.mul(Math.cos(l),o),m.mul(Math.sin(l),i)),M=[],T=m.zeros1d(2*y+3),B=0,O=l,F=m.zeros1d(y*2);M[0]=S,F[0]=1;for(var R=1,j=y+1;R<j;){var D=R++;O+=I;var X=m.add(r,m.add(m.mul(d*Math.cos(O),i),m.mul(g*Math.sin(O),o)));F[B+2]=1,M[B+2]=X;var J=m.sub(m.mul(Math.cos(O),o),m.mul(Math.sin(O),i)),Y=ut.rays(S,m.mul(1/m.norm(E),E),X,m.mul(1/m.norm(J),J)),U=m.add(S,m.mul(Y.u0,E));F[B+1]=P,M[B+1]=U,B+=2,D<y&&(S=X,E=J)}for(var $=2*y+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+$]=1}switch(y){case 2:T[3]=T[4]=.5;break;case 3:T[3]=T[4]=.3333333333333333,T[5]=T[6]=.6666666666666666;break;case 4:T[3]=T[4]=.25,T[5]=T[6]=.5,T[7]=T[8]=.75;break}return new Ht(2,T,N.homogenize1d(M,F))},gt.arc=function(r,i,o,l,c,d){return gt.ellipseArc(r,m.mul(l,m.normalized(i)),m.mul(l,m.normalized(o)),c,d)},gt.polyline=function(r){for(var i=[0,0],o=0,l=0,c=r.length-1;l<c;){var d=l++;o+=m.dist(r[d],r[d+1]),i.push(o)}i.push(o),i=m.mul(1/o,i);for(var g,_=[],y=0,I=r.length;y<I;)y++,_.push(1);return g=_,new Ht(1,i,N.homogenize1d(r.slice(0),g))},gt.extrudedSurface=function(r,i,o){for(var l=[[],[],[]],c=[[],[],[]],d=N.dehomogenize1d(o.controlPoints),g=N.weight1d(o.controlPoints),_=m.mul(i,r),y=m.mul(.5*i,r),I=0,P=d.length;I<P;){var S=I++;l[2][S]=d[S],l[1][S]=m.add(y,d[S]),l[0][S]=m.add(_,d[S]),c[0][S]=g[S],c[1][S]=g[S],c[2][S]=g[S]}return new ie(2,o.degree,[0,0,0,1,1,1],o.knots,N.homogenize2d(l,c))},gt.cylindricalSurface=function(r,i,o,l,c){var d=m.cross(r,i),g=gt.arc(o,i,d,c,0,2*Math.PI);return gt.extrudedSurface(r,l,g)},gt.revolvedSurface=function(r,i,o,l){var c=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),g,_;l<=Math.PI/2?(g=1,_=m.zeros1d(6+2*(g-1))):l<=Math.PI?(g=2,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(g=3,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(g=4,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/g,I=3+2*(g-1),P=0;P<3;){var S=P++;_[S]=0,_[I+S]=1}for(var E=Math.cos(y/2),M=0,T=m.zeros1d(g+1),B=m.zeros1d(g+1),O=m.zeros3d(2*g+1,c.length,3),F=m.zeros2d(2*g+1,c.length),R=1,j=g+1;R<j;){var D=R++;M+=y,B[D]=Math.cos(M),T[D]=Math.sin(M)}for(var X=0,J=c.length;X<J;){var Y=X++,U=je.rayClosestPoint(c[Y],i,o),$=m.sub(c[Y],U),tt=m.norm($),et=m.cross(o,$);tt>rt.EPSILON&&($=m.mul(1/tt,$),et=m.mul(1/tt,et)),O[0][Y]=c[Y];var ot=c[Y];F[0][Y]=d[Y];for(var ct=et,ht=0,pt=1,nt=g+1;pt<nt;){var mt=pt++,K;tt==0?K=U:K=m.add(U,m.add(m.mul(tt*B[mt],$),m.mul(tt*T[mt],et))),O[ht+2][Y]=K,F[ht+2][Y]=d[Y];var ft=m.sub(m.mul(B[mt],et),m.mul(T[mt],$));if(tt==0)O[ht+1][Y]=U;else{var kt=ut.rays(ot,m.mul(1/m.norm(ct),ct),K,m.mul(1/m.norm(ft),ft)),Yt=m.add(ot,m.mul(kt.u0,ct));O[ht+1][Y]=Yt}F[ht+1][Y]=E*d[Y],ht+=2,mt<g&&(ot=K,ct=ft)}}return new ie(2,r.degree,_,r.knots,N.homogenize2d(O,F))},gt.sphericalSurface=function(r,i,o,l){var c=gt.arc(r,m.mul(-1,i),o,l,0,Math.PI);return gt.revolvedSurface(c,r,i,2*Math.PI)},gt.conicalSurface=function(r,i,o,l,c){var d=2*Math.PI,g=1,_=[m.add(o,m.mul(l,r)),m.add(o,m.mul(c,i))],y=[0,0,1,1],I=[1,1],P=new Ht(g,y,N.homogenize1d(_,I));return gt.revolvedSurface(P,o,r,d)},gt.rationalInterpCurve=function(r,i,o,l,c){if(o==null&&(o=!1),i==null&&(i=3),r.length<i+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],g=1,_=r.length;g<_;){var y=g++,I=m.norm(m.sub(r[y],r[y-1])),P=d[d.length-1];d.push(P+I)}for(var S=d[d.length-1],E=0,M=d.length;E<M;){var T=E++;d[T]=d[T]/S}var B=m.rep(i+1,0),O=l!=null&&c!=null,F;O?F=0:F=1;var R;O?R=d.length-i+1:R=d.length-i;for(var j=F;j<R;){for(var D=j++,X=0,J=0;J<i;){var Y=J++;X+=d[D+Y]}B.push(1/i*X)}var U=B.concat(m.rep(i+1,1)),$=[],tt;O?tt=r.length+1:tt=r.length-1;var et;O?et=r.length-(i-1):et=r.length-(i+1);for(var ot=0;ot<d.length;){var ct=d[ot];++ot;var ht=N.knotSpanGivenN(tt,i,ct,U),pt=N.basisFunctionsGivenKnotSpanIndex(ht,ct,i,U),nt=ht-i,mt=m.zeros1d(nt),K=m.zeros1d(et-nt);$.push(mt.concat(pt).concat(K))}if(O){var ft=$[0].length-2,kt=[-1,1].concat(m.zeros1d(ft)),Yt=m.zeros1d(ft).concat([-1,1]);Z.spliceAndInsert($,1,0,kt),Z.spliceAndInsert($,$.length-1,0,Yt)}for(var Zt=r[0].length,Ut=[],Jt=(1-U[U.length-i-2])/i,Be=U[i+1]/i,tr=0;tr<Zt;){var Ae=[tr++],Ie;if(!O)Ie=r.map(function(lr){return function(Sr){return Sr[lr[0]]}}(Ae));else{Ie=[r[0][Ae[0]]],Ie.push(Be*l[Ae[0]]);for(var Re=1,Ue=r.length-1;Re<Ue;){var ir=Re++;Ie.push(r[ir][Ae[0]])}Ie.push(Jt*c[Ae[0]]),Ie.push(Z.last(r)[Ae[0]])}var fr=Ct.solve($,Ie);Ut.push(fr)}var ar=Ct.transpose(Ut);if(!o){var or=m.rep(ar.length,1);ar=N.homogenize1d(ar,or)}return new Ht(i,U,ar)};var yt=f.eval.Modify=function(){};w["verb.eval.Modify"]=yt,yt.__name__=["verb","eval","Modify"],yt.curveReverse=function(r){return new Ht(r.degree,yt.knotsReverse(r.knots),Z.reversed(r.controlPoints))},yt.surfaceReverse=function(r,i){return i==null&&(i=!1),i?new ie(r.degreeU,r.degreeV,r.knotsU,yt.knotsReverse(r.knotsV),function(o){for(var l,c=[],d=0,g=r.controlPoints;d<g.length;){var _=g[d];++d,c.push(Z.reversed(_))}return l=c,l}()):new ie(r.degreeU,r.degreeV,yt.knotsReverse(r.knotsU),r.knotsV,Z.reversed(r.controlPoints))},yt.knotsReverse=function(r){var i=Z.first(r);Z.last(r);for(var o=[i],l=r.length,c=1;c<l;){var d=c++;o.push(o[d-1]+(r[l-d]-r[l-d-1]))}return o},yt.unifyCurveKnotVectors=function(r){r=r.map(gt.clonedCurve);for(var i=C.fold(r,function(U,$){return yt.imax(U.degree,$)},0),o=0,l=r.length;o<l;){var c=o++;r[c].degree<i&&(r[c]=yt.curveElevateDegree(r[c],i))}for(var d,g=[],_=0;_<r.length;){var y=r[_];++_,g.push(new Ce(Z.first(y.knots),Z.last(y.knots)))}d=g;for(var I=0,P=r.length;I<P;){var S=I++,E=[d[S].min];r[S].knots=r[S].knots.map(function(U){return function($){return $-U[0]}}(E))}for(var M=d.map(function(U){return U.max-U.min}),T=C.fold(M,function(U,$){return Math.max(U,$)},0),B=0,O=r.length;B<O;){var F=B++,R=[T/M[F]];r[F].knots=r[F].knots.map(function(U){return function($){return $*U[0]}}(R))}for(var j=C.fold(r,function(U,$){return m.sortedSetUnion(U.knots,$)},[]),D=0,X=r.length;D<X;){var J=D++,Y=m.sortedSetSub(j,r[J].knots);Y.length==0&&(r[J]=r[J]),r[J]=yt.curveKnotRefine(r[J],Y)}return r},yt.imin=function(r,i){return r<i?r:i},yt.imax=function(r,i){return r>i?r:i},yt.curveElevateDegree=function(r,i){if(i<=r.degree)return r;var o=r.knots.length-r.degree-2,l=r.degree,c=r.knots,d=r.controlPoints,g=i-r.degree,_=r.controlPoints[0].length,y=m.zeros2d(l+g+1,l+1),I=[],P=[],S=[],E=o+l+1,M=i,T=Math.floor(M/2),B=[],O=[];y[0][0]=1,y[M][l]=1;for(var F=1,R=T+1;F<R;)for(var j=F++,D=1/Vt.get(M,j),X=yt.imin(l,j),J=yt.imax(0,j-g),Y=X+1;J<Y;){var U=J++;y[j][U]=D*Vt.get(l,U)*Vt.get(g,j-U)}for(var $=T+1;$<M;)for(var tt=$++,et=yt.imin(l,tt),ot=yt.imax(0,tt-g),ct=et+1;ot<ct;){var ht=ot++;y[tt][ht]=y[M-tt][l-ht]}var pt=M+1,nt=-1,mt=l,K=l+1,ft=1,kt=c[0];B[0]=d[0];for(var Yt=0,Zt=M+1;Yt<Zt;){var Ut=Yt++;O[Ut]=kt}for(var Jt=0,Be=l+1;Jt<Be;){var tr=Jt++;I[tr]=d[tr]}for(;K<E;){for(var Ae=K;K<E&&c[K]==c[K+1];)K=K+1;var Ie=K-Ae+1,Re=c[K],Ue=nt;nt=l-Ie;var ir;Ue>0?ir=Math.floor((Ue+2)/2):ir=1;var fr;if(nt>0?fr=Math.floor(M-(nt+1)/2):fr=M,nt>0){for(var ar=Re-kt,or=[],lr=l;lr>Ie;)or[lr-Ie-1]=ar/(c[mt+lr]-kt),lr--;for(var Sr=1,Yn=nt+1;Sr<Yn;){for(var gn=Sr++,Rc=nt-gn,ma=Ie+gn,_n=l;_n>=ma;)I[_n]=m.add(m.mul(or[_n-ma],I[_n]),m.mul(1-or[_n-ma],I[_n-1])),_n--;S[Rc]=I[l]}}for(var ol=ir,Fc=M+1;ol<Fc;){var Xn=ol++;P[Xn]=m.zeros1d(_);for(var zc=yt.imin(l,Xn),ll=yt.imax(0,Xn-g),Vc=zc+1;ll<Vc;){var hl=ll++;P[Xn]=m.add(P[Xn],m.mul(y[Xn][hl],I[hl]))}}if(Ue>1)for(var ga=pt-2,_a=pt,ul=Re-kt,jc=(Re-O[pt-1])/ul,cl=1;cl<Ue;){for(var fa=cl++,Pr=ga,fn=_a,en=fn-pt+1;fn-Pr>fa;){if(Pr<ft){var Dc=(Re-O[Pr])/(kt-O[Pr]);B[Pr]=m.lerp(Dc,B[Pr],B[Pr-1])}if(fn>=ir){if(fn-fa<=pt-M+Ue){var Uc=(Re-O[fn-fa])/ul;P[en]=m.lerp(Uc,P[en],P[en+1])}}else P[en]=m.lerp(jc,P[en],P[en+1]);Pr=Pr+1,fn=fn-1,en=en-1}ga=ga-1,_a=_a+1}if(mt!=l)for(var dl=0,Gc=M-Ue;dl<Gc;)dl++,O[pt]=kt,pt=pt+1;for(var pl=ir,Wc=fr+1;pl<Wc;){var Hc=pl++;B[ft]=P[Hc],ft=ft+1}if(K<E){for(var ml=0;ml<nt;){var gl=ml++;I[gl]=S[gl]}for(var _l=nt,Yc=l+1;_l<Yc;){var fl=_l++;I[fl]=d[K-l+fl]}mt=K,K=K+1,kt=Re}else for(var yl=0,Xc=M+1;yl<Xc;){var qc=yl++;O[pt+qc]=Re}}return new Ht(i,O,B)},yt.rationalSurfaceTransform=function(r,i){for(var o=N.dehomogenize2d(r.controlPoints),l=0,c=o.length;l<c;)for(var d=l++,g=0,_=o[d].length;g<_;){var y=g++,I=o[d][y];I.push(1),o[d][y]=Ct.dot(i,I).slice(0,I.length-1)}return new ie(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(o,N.weight2d(r.controlPoints)))},yt.rationalCurveTransform=function(r,i){for(var o=N.dehomogenize1d(r.controlPoints),l=0,c=o.length;l<c;){var d=l++,g=o[d];g.push(1),o[d]=Ct.dot(i,g).slice(0,g.length-1)}return new Ht(r.degree,r.knots.slice(),N.homogenize1d(o,N.weight1d(r.controlPoints)))},yt.surfaceKnotRefine=function(r,i,o){var l=[],c,d,g;o?(g=r.controlPoints,c=r.knotsV,d=r.degreeV):(g=Ct.transpose(r.controlPoints),c=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<g.length;){var I=g[y];++y,_=yt.curveKnotRefine(new Ht(d,c,I),i),l.push(_.controlPoints)}var P=_.knots;return o?new ie(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Ct.transpose(l),new ie(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},yt.decomposeCurveIntoBeziers=function(r){for(var i=r.degree,o=r.controlPoints,l=r.knots,c=bt.knotMultiplicities(l),d=i+1,g=0;g<c.length;){var _=c[g];if(++g,_.mult<d){var y=m.rep(d-_.mult,_.knot),I=yt.curveKnotRefine(new Ht(i,l,o),y);l=I.knots,o=I.controlPoints}}l.length/d-1;for(var P=d*2,S=[],E=0;E<o.length;){var M=l.slice(E,E+P),T=o.slice(E,E+d);S.push(new Ht(i,M,T)),E+=d}return S},yt.curveKnotRefine=function(r,i){if(i.length==0)return gt.clonedCurve(r);for(var o=r.degree,l=r.controlPoints,c=r.knots,d=l.length-1,g=d+o+1,_=i.length-1,y=N.knotSpan(o,i[0],c),I=N.knotSpan(o,i[_],c),P=[],S=[],E=0,M=y-o+1;E<M;){var T=E++;P[T]=l[T]}for(var B=I-1,O=d+1;B<O;){var F=B++;P[F+_+1]=l[F]}for(var R=0,j=y+1;R<j;){var D=R++;S[D]=c[D]}for(var X=I+o,J=g+1;X<J;){var Y=X++;S[Y+_+1]=c[Y]}for(var U=I+o-1,$=I+o+_,tt=_;tt>=0;){for(;i[tt]<=c[U]&&U>y;)P[$-o-1]=l[U-o-1],S[$]=c[U],$=$-1,U=U-1;P[$-o-1]=P[$-o];for(var et=1,ot=o+1;et<ot;){var ct=et++,ht=$-o+ct,pt=S[$+ct]-i[tt];Math.abs(pt)<rt.EPSILON?P[ht-1]=P[ht]:(pt=pt/(S[$+ct]-c[U-o+ct]),P[ht-1]=m.add(m.mul(pt,P[ht-1]),m.mul(1-pt,P[ht])))}S[$]=i[tt],$=$-1,tt--}return new Ht(o,S,P)},yt.curveKnotInsert=function(r,i,o){for(var l=r.degree,c=r.controlPoints,d=r.knots,g=0,_=c.length,y=N.knotSpan(l,i,d),I=[],P=[],S=[],E=1,M=y+1;E<M;){var T=E++;P[T]=d[T]}for(var B=1,O=o+1;B<O;){var F=B++;P[y+F]=i}for(var R=y+1,j=d.length;R<j;){var D=R++;P[D+o]=d[D]}for(var X=0,J=y-l+1;X<J;){var Y=X++;S[Y]=c[Y]}for(var U=y-g;U<_;){var $=U++;S[$+o]=c[$]}for(var tt=0,et=l-g+1;tt<et;){var ot=tt++;I[ot]=c[y-l+ot]}for(var ct=0,ht=0,pt=1,nt=o+1;pt<nt;){var mt=pt++;ct=y-l+mt;for(var K=0,ft=l-mt-g+1;K<ft;){var kt=K++;ht=(i-d[ct+kt])/(d[kt+y+1]-d[ct+kt]),I[kt]=m.add(m.mul(ht,I[kt+1]),m.mul(1-ht,I[kt]))}S[ct]=I[0],S[y+o-mt-g]=I[l-mt-g]}for(var Yt=ct+1,Zt=y-g;Yt<Zt;){var Ut=Yt++;S[Ut]=I[Ut-ct]}return new Ht(l,P,S)};var Rt=f.eval.Tess=function(){};w["verb.eval.Tess"]=Rt,Rt.__name__=["verb","eval","Tess"],Rt.rationalCurveRegularSample=function(r,i,o){return Rt.rationalCurveRegularSampleRange(r,r.knots[0],Z.last(r.knots),i,o)},Rt.rationalCurveRegularSampleRange=function(r,i,o,l,c){l<1&&(l=2);for(var d=[],g=(o-i)/(l-1),_=0,y=0;y<l;){var I=y++;_=i+g*I,c?d.push([_].concat(N.rationalCurvePoint(r,_))):d.push(N.rationalCurvePoint(r,_))}return d},Rt.rationalCurveAdaptiveSample=function(r,i,o){if(o==null&&(o=!1),i==null&&(i=1e-6),r.degree==1)if(o){for(var l=[],c=0,d=r.controlPoints.length;c<d;){var g=c++;l.push([r.knots[g+1]].concat(N.dehomogenize(r.controlPoints[g])))}return l}else return r.controlPoints.map(N.dehomogenize);return Rt.rationalCurveAdaptiveSampleRange(r,r.knots[0],Z.last(r.knots),i,o)},Rt.rationalCurveAdaptiveSampleRange=function(r,i,o,l,c){var d=N.rationalCurvePoint(r,i),g=N.rationalCurvePoint(r,o),_=.5+.2*Math.random(),y=i+(o-i)*_,I=N.rationalCurvePoint(r,y),P=m.sub(d,g),S=m.sub(d,I);if(m.dot(P,P)<l&&m.dot(S,S)>l||!je.threePointsAreFlat(d,I,g,l)){var E=i+(o-i)*.5,M=Rt.rationalCurveAdaptiveSampleRange(r,i,E,l,c),T=Rt.rationalCurveAdaptiveSampleRange(r,E,o,l,c);return M.slice(0,-1).concat(T)}else return c?[[i].concat(d),[o].concat(g)]:[d,g]},Rt.rationalSurfaceNaive=function(r,i,o){i<1&&(i=1),o<1&&(o=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,c=r.knotsV,d=Z.last(l)-l[0],g=Z.last(c)-c[0],_=d/i,y=g/o,I=[],P=[],S=[],E=0,M=i+1;E<M;)for(var T=E++,B=0,O=o+1;B<O;){var F=B++,R=T*_,j=F*y;P.push([R,j]);var D=N.rationalSurfaceDerivatives(r,R,j,1),X=D[0][0];I.push(X);var J=m.normalized(m.cross(D[1][0],D[0][1]));S.push(J)}for(var Y=[],U=0;U<i;)for(var $=U++,tt=0;tt<o;){var et=tt++,ot=$*(o+1)+et,ct=($+1)*(o+1)+et,ht=ct+1,pt=ot+1,nt=[ot,ct,ht],mt=[ot,ht,pt];Y.push(nt),Y.push(mt)}return new rr(Y,I,S,P)},Rt.divideRationalSurfaceAdaptive=function(r,i){i==null&&(i=new $r),i.minDivsU!=null?i.minDivsU=i.minDivsU:i.minDivsU=1,i.minDivsV!=null?i.minDivsU=i.minDivsV:i.minDivsU=1,i.refine!=null?i.refine=i.refine:i.refine=!0;var o=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,c;i.minDivsU>o?c=i.minDivsU=i.minDivsU:c=i.minDivsU=o;var d;i.minDivsV>l?d=i.minDivsV=i.minDivsV:d=i.minDivsV=l;for(var g=Z.last(r.knotsU),_=r.knotsU[0],y=Z.last(r.knotsV),I=r.knotsV[0],P=(g-_)/c,S=(y-I)/d,E=[],M=[],T=0,B=d+1;T<B;){for(var O=T++,F=[],R=0,j=c+1;R<j;){var D=R++,X=_+P*D,J=I+S*O,Y=N.rationalSurfaceDerivatives(r,X,J,1),U=m.normalized(m.cross(Y[0][1],Y[1][0]));F.push(new Qe(Y[0][0],U,[X,J],-1,m.isZero(U)))}M.push(F)}for(var $=0;$<d;)for(var tt=$++,et=0;et<c;){var ot=et++,ct=[M[d-tt-1][ot],M[d-tt-1][ot+1],M[d-tt][ot+1],M[d-tt][ot]];E.push(new Ir(r,ct))}if(!i.refine)return E;for(var ht=0;ht<d;)for(var pt=ht++,nt=0;nt<c;){var mt=nt++,K=pt*c+mt,ft=Rt.north(K,pt,mt,c,d,E),kt=Rt.east(K,pt,mt,c,d,E),Yt=Rt.south(K,pt,mt,c,d,E),Zt=Rt.west(K,pt,mt,c,d,E);E[K].neighbors=[Yt,kt,ft,Zt],E[K].divide(i)}return E},Rt.north=function(r,i,o,l,c,d){return i==0?null:d[r-l]},Rt.south=function(r,i,o,l,c,d){return i==c-1?null:d[r+l]},Rt.east=function(r,i,o,l,c,d){return o==l-1?null:d[r+1]},Rt.west=function(r,i,o,l,c,d){return o==0?null:d[r-1]},Rt.triangulateAdaptiveRefinementNodeTree=function(r){for(var i=rr.empty(),o=0;o<r.length;){var l=r[o];++o,l.triangulate(i)}return i},Rt.rationalSurfaceAdaptive=function(r,i){i!=null?i=i:i=new $r;var o=Rt.divideRationalSurfaceAdaptive(r,i);return Rt.triangulateAdaptiveRefinementNodeTree(o)};var $r=f.core.AdaptiveRefinementOptions=function(){this.minDivsV=1,this.minDivsU=1,this.refine=!0,this.maxDepth=10,this.minDepth=0,this.normTol=.025};w["verb.eval.AdaptiveRefinementOptions"]=$r,$r.__name__=["verb","eval","AdaptiveRefinementOptions"],$r.prototype={__class__:$r};var Ir=f.core.AdaptiveRefinementNode=function(r,i,o){if(this.srf=r,o==null?this.neighbors=[null,null,null,null]:this.neighbors=o,this.corners=i,this.corners==null){var l=r.knotsU[0],c=Z.last(r.knotsU),d=r.knotsV[0],g=Z.last(r.knotsV);this.corners=[Qe.fromUv(l,d),Qe.fromUv(c,d),Qe.fromUv(c,g),Qe.fromUv(l,g)]}};w["verb.eval.AdaptiveRefinementNode"]=Ir,Ir.__name__=["verb","eval","AdaptiveRefinementNode"],Ir.prototype={isLeaf:function(){return this.children==null},center:function(){return this.centerPoint!=null?this.centerPoint:this.evalSrf(this.u05,this.v05)},evalCorners:function(){this.u05=(this.corners[0].uv[0]+this.corners[2].uv[0])/2,this.v05=(this.corners[0].uv[1]+this.corners[2].uv[1])/2;for(var r=0;r<4;){var i=r++;if(this.corners[i].point==null){var o=this.corners[i];this.evalSrf(o.uv[0],o.uv[1],o)}}},evalSrf:function(r,i,o){var l=N.rationalSurfaceDerivatives(this.srf,r,i,1),c=l[0][0],d=m.cross(l[0][1],l[1][0]),g=m.isZero(d);return g||(d=m.normalized(d)),o!=null?(o.degen=g,o.point=c,o.normal=d,o):new Qe(c,d,[r,i],-1,g)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){case 0:return this.children[0].getEdgeCorners(0);case 1:return this.children[0].getEdgeCorners(1).concat(this.children[1].getEdgeCorners(1));case 2:return this.children[1].getEdgeCorners(2);case 3:return this.children[1].getEdgeCorners(3).concat(this.children[0].getEdgeCorners(3))}switch(r){case 0:return this.children[0].getEdgeCorners(0).concat(this.children[1].getEdgeCorners(0));case 1:return this.children[1].getEdgeCorners(1);case 2:return this.children[1].getEdgeCorners(2).concat(this.children[0].getEdgeCorners(2));case 3:return this.children[0].getEdgeCorners(3)}return null},getAllCorners:function(r){var i=[this.corners[r]];if(this.neighbors[r]==null)return i;var o=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,c=rt.EPSILON,d=this,g=[function(y){return y.uv[0]>d.corners[0].uv[0]+c&&y.uv[0]<d.corners[2].uv[0]-c},function(y){return y.uv[1]>d.corners[0].uv[1]+c&&y.uv[1]<d.corners[2].uv[1]-c}],_=o.filter(g[l]);return _.reverse(),i.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){case 0:this.midPoints[0]=this.evalSrf(this.u05,this.corners[0].uv[1]);break;case 1:this.midPoints[1]=this.evalSrf(this.corners[1].uv[0],this.v05);break;case 2:this.midPoints[2]=this.evalSrf(this.u05,this.corners[2].uv[1]);break;case 3:this.midPoints[3]=this.evalSrf(this.corners[0].uv[0],this.v05);break}return this.midPoints[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,i=0;i<r;){var o=i++;if(this.corners[o],this.corners[o].degen){var l=this.corners[(o+1)%r],c=this.corners[(o+3)%r];l.degen?this.corners[o].normal=c.normal:this.corners[o].normal=l.normal}}},shouldDivide:function(r,i){if(i<r.minDepth)return!0;if(i>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=m.normSquared(m.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var o=this.center();return m.normSquared(m.sub(o.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(o.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(o.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(o.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new $r),r.normTol==null&&(r.normTol=.085),r.minDepth==null&&(r.minDepth=0),r.maxDepth==null&&(r.maxDepth=10),this._divide(r,0,!0)},_divide:function(r,i,o){if(this.evalCorners(),!!this.shouldDivide(r,i)){if(i++,this.splitVert&&!this.splitHoriz?o=!1:!this.splitVert&&this.splitHoriz&&(o=!0),this.horizontal=o,this.horizontal){var l=[this.corners[0],this.corners[1],this.midpoint(1),this.midpoint(3)],c=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new Ir(this.srf,l),new Ir(this.srf,c)],this.children[0].neighbors=[this.neighbors[0],this.neighbors[1],this.children[1],this.neighbors[3]],this.children[1].neighbors=[this.children[0],this.neighbors[1],this.neighbors[2],this.neighbors[3]]}else{var d=[this.corners[0],this.midpoint(0),this.midpoint(2),this.corners[3]],g=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new Ir(this.srf,d),new Ir(this.srf,g)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var I=y[_];++_,I._divide(r,i,!o)}}},triangulate:function(r){if(r==null&&(r=rr.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var i=0,o=this.children;i<o.length;){var l=o[i];if(++i,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var i=r.points.length,o=[],l=[],c=0,d=0;d<4;){var g=d++,_=this.getAllCorners(g);_.length==2&&(c=g+1);for(var y=0,I=_.length;y<I;){var P=y++;o.push(_[P])}}for(var S=0;S<o.length;){var E=o[S];if(++S,E.id!=-1){l.push(E.id);continue}r.uvs.push(E.uv),r.points.push(E.point),r.normals.push(E.normal),E.id=i,l.push(i),i++}if(o.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(o.length==5){var M=l.length;return r.faces.push([l[c],l[(c+2)%M],l[(c+1)%M]]),r.faces.push([l[(c+4)%M],l[(c+3)%M],l[c]]),r.faces.push([l[c],l[(c+3)%M],l[(c+2)%M]]),r}var T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var B=r.points.length-1,O=0,F=o.length-1;O<o.length;)r.faces.push([B,l[O],l[F]]),F=O++;return r},__class__:Ir};var It=f.exe.Dispatcher=function(){};w["verb.exe.Dispatcher"]=It,It.__name__=["verb","exe","Dispatcher"],It.init=function(){It._init||(It._workerPool=new Zr(It.THREADS),It._init=!0)},It.dispatchMethod=function(r,i,o){It.init();var l=new Bn,c=function(d){l.resolve(d)};return It._workerPool.addWork(dt.getClassName(r),i,o,c),new xe(l)};var Zr=f.exe.WorkerPool=function(r,i){i==null&&(i="verb.js"),r==null&&(r=1),this._callbacks=new xt,this._working=new xt,this._pool=[],this._queue=[];for(var o=0;o<r;){o++;var l;try{l=new Worker(Zr.basePath+i)}catch(c){c instanceof Q&&(c=c.val),l=new Worker(Zr.basePath+i.substring(0,-3)+".min.js")}this._pool.push(l)}};w["verb.exe.WorkerPool"]=Zr,Zr.__name__=["verb","exe","WorkerPool"],Zr.prototype={addWork:function(r,i,o,l){var c=new mn(r,i,o);this._callbacks.set(c.id,l),this._queue.push(c),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var i=this._queue.shift(),o=[i.id],l=[this._pool.shift()];this._working.h[o[0]]=l[0],l[0].onmessage=function(c,d){return function(g){r._working.remove(d[0]),r._pool.push(c[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](g.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),v.log(_)}r.processQueue()}}(l,o),l[0].postMessage(i)}},__class__:Zr};var mn=function(r,i,o){this.className=r,this.methodName=i,this.args=o,this.id=mn.uuid++};w["verb.exe._WorkerPool.Work"]=mn,mn.__name__=["verb","exe","_WorkerPool","Work"],mn.prototype={__class__:mn};var Wn=function(){};w["verb.geom.ICurve"]=Wn,Wn.__name__=["verb","geom","ICurve"],Wn.__interfaces__=[Dn],Wn.prototype={__class__:Wn};var Ot=f.geom.NurbsCurve=function(r){this._data=Je.isValidNurbsCurveData(r)};w["verb.geom.NurbsCurve"]=Ot,Ot.__name__=["verb","geom","NurbsCurve"],Ot.__interfaces__=[Wn],Ot.byKnotsControlPointsWeights=function(r,i,o,l){return new Ot(new Ht(r,i.slice(),N.homogenize1d(o,l)))},Ot.byPoints=function(r,i){return i==null&&(i=3),new Ot(gt.rationalInterpCurve(r,i))},Ot.__super__=ee,Ot.prototype=k(ee.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new Ht(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ot(this._data)},domain:function(){return new Ce(Z.first(this._data.knots),Z.last(this._data.knots))},transform:function(r){return new Ot(yt.rationalCurveTransform(this._data,r))},transformAsync:function(r){return It.dispatchMethod(yt,"rationalCurveTransform",[this._data,r]).then(function(i){return new Ot(i)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return It.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return It.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,i){return i==null&&(i=1),N.rationalCurveDerivatives(this._data,r,i)},derivativesAsync:function(r,i){return i==null&&(i=1),It.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,i])},closestPoint:function(r){return bt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return It.dispatchMethod(bt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return bt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return It.dispatchMethod(bt,"rationalCurveClosestParam",[this._data,r])},length:function(){return bt.rationalCurveArcLength(this._data)},lengthAsync:function(){return It.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return bt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return It.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,i){return bt.rationalCurveParamAtArcLength(this._data,r,i)},paramAtLengthAsync:function(r,i){return It.dispatchMethod(bt,"rationalCurveParamAtArcLength",[this._data,r,i])},divideByEqualArcLength:function(r){return ge.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return It.dispatchMethod(ge,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return ge.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return It.dispatchMethod(ge,"rationalCurveByArcLength",[this._data,r])},split:function(r){return ge.curveSplit(this._data,r).map(function(i){return new Ot(i)})},splitAsync:function(r){return It.dispatchMethod(ge,"curveSplit",[this._data,r]).then(function(i){return i.map(function(o){return new Ot(o)})})},reverse:function(){return new Ot(yt.curveReverse(this._data))},reverseAsync:function(){return It.dispatchMethod(yt,"curveReverse",[this._data]).then(function(r){return new Ot(r)})},tessellate:function(r){return Rt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return It.dispatchMethod(Rt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ot});var Qr=f.geom.Arc=function(r,i,o,l,c,d){Ot.call(this,gt.arc(r,i,o,l,c,d)),this._center=r,this._xaxis=i,this._yaxis=o,this._radius=l,this._minAngle=c,this._maxAngle=d};w["verb.geom.Arc"]=Qr,Qr.__name__=["verb","geom","Arc"],Qr.__super__=Ot,Qr.prototype=k(Ot.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},radius:function(){return this._radius},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Qr});var ys=f.geom.BezierCurve=function(r,i){Ot.call(this,gt.rationalBezierCurve(r,i))};w["verb.geom.BezierCurve"]=ys,ys.__name__=["verb","geom","BezierCurve"],ys.__super__=Ot,ys.prototype=k(Ot.prototype,{__class__:ys});var vs=f.geom.Circle=function(r,i,o,l){Qr.call(this,r,i,o,l,0,Math.PI*2)};w["verb.geom.Circle"]=vs,vs.__name__=["verb","geom","Circle"],vs.__super__=Qr,vs.prototype=k(Qr.prototype,{__class__:vs});var Hn=function(){};w["verb.geom.ISurface"]=Hn,Hn.__name__=["verb","geom","ISurface"],Hn.__interfaces__=[Dn],Hn.prototype={__class__:Hn};var Mt=f.geom.NurbsSurface=function(r){this._data=Je.isValidNurbsSurfaceData(r)};w["verb.geom.NurbsSurface"]=Mt,Mt.__name__=["verb","geom","NurbsSurface"],Mt.__interfaces__=[Hn],Mt.byKnotsControlPointsWeights=function(r,i,o,l,c,d){return new Mt(new ie(r,i,o,l,N.homogenize2d(c,d)))},Mt.byCorners=function(r,i,o,l){return new Mt(gt.fourPointSurface(r,i,o,l))},Mt.byLoftingCurves=function(r,i){return new Mt(gt.loftedSurface(function(o){for(var l,c=[],d=0;d<r.length;){var g=r[d];++d,c.push(g.asNurbs())}return l=c,l}(),i))},Mt.__super__=ee,Mt.prototype=k(ee.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new ie(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Mt(this.asNurbs())},domainU:function(){return new Ce(Z.first(this._data.knotsU),Z.last(this._data.knotsU))},domainV:function(){return new Ce(Z.first(this._data.knotsV),Z.last(this._data.knotsV))},point:function(r,i){return N.rationalSurfacePoint(this._data,r,i)},pointAsync:function(r,i){return It.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,i])},normal:function(r,i){return N.rationalSurfaceNormal(this._data,r,i)},normalAsync:function(r,i){return It.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,i])},derivatives:function(r,i,o){return o==null&&(o=1),N.rationalSurfaceDerivatives(this._data,r,i,o)},derivativesAsync:function(r,i,o){return o==null&&(o=1),It.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,i,o])},closestParam:function(r){return bt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return It.dispatchMethod(bt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return bt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return It.dispatchMethod(bt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,i){return i==null&&(i=!1),ge.surfaceSplit(this._data,r,i).map(function(o){return new Mt(o)})},splitAsync:function(r,i){return i==null&&(i=!1),It.dispatchMethod(ge,"surfaceSplit",[this._data,r,i]).then(function(o){return o.map(function(l){return new Mt(l)})})},reverse:function(r){return r==null&&(r=!1),new Mt(yt.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),It.dispatchMethod(yt,"surfaceReverse",[this._data,r]).then(function(i){return new Mt(i)})},isocurve:function(r,i){return i==null&&(i=!1),new Ot(gt.surfaceIsocurve(this._data,r,i))},isocurveAsync:function(r,i){return i==null&&(i=!1),It.dispatchMethod(gt,"surfaceIsocurve",[this._data,r,i]).then(function(o){return new Ot(o)})},boundaries:function(r){return gt.surfaceBoundaryCurves(this._data).map(function(i){return new Ot(i)})},boundariesAsync:function(r){return It.dispatchMethod(gt,"surfaceBoundaryCurves",[this._data]).then(function(i){return i.map(function(o){return new Ot(o)})})},tessellate:function(r){return Rt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return It.dispatchMethod(Rt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Mt(yt.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return It.dispatchMethod(yt,"rationalSurfaceTransform",[this._data,r]).then(function(i){return new Mt(i)})},__class__:Mt});var bs=f.geom.ConicalSurface=function(r,i,o,l,c){Mt.call(this,gt.conicalSurface(r,i,o,l,c)),this._axis=r,this._xaxis=i,this._base=o,this._height=l,this._radius=c};w["verb.geom.ConicalSurface"]=bs,bs.__name__=["verb","geom","ConicalSurface"],bs.__super__=Mt,bs.prototype=k(Mt.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:bs});var ws=f.geom.CylindricalSurface=function(r,i,o,l,c){Mt.call(this,gt.cylindricalSurface(r,i,o,l,c)),this._axis=r,this._xaxis=i,this._base=o,this._height=l,this._radius=c};w["verb.geom.CylindricalSurface"]=ws,ws.__name__=["verb","geom","CylindricalSurface"],ws.__super__=Mt,ws.prototype=k(Mt.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:ws});var Jr=f.geom.EllipseArc=function(r,i,o,l,c){Ot.call(this,gt.ellipseArc(r,i,o,l,c)),this._center=r,this._xaxis=i,this._yaxis=o,this._minAngle=l,this._maxAngle=c};w["verb.geom.EllipseArc"]=Jr,Jr.__name__=["verb","geom","EllipseArc"],Jr.__super__=Ot,Jr.prototype=k(Ot.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Jr});var xs=f.geom.Ellipse=function(r,i,o){Jr.call(this,r,i,o,0,Math.PI*2)};w["verb.geom.Ellipse"]=xs,xs.__name__=["verb","geom","Ellipse"],xs.__super__=Jr,xs.prototype=k(Jr.prototype,{__class__:xs});var Is=f.geom.ExtrudedSurface=function(r,i){Mt.call(this,gt.extrudedSurface(m.normalized(i),m.norm(i),r.asNurbs())),this._profile=r,this._direction=i};w["verb.geom.ExtrudedSurface"]=Is,Is.__name__=["verb","geom","ExtrudedSurface"],Is.__super__=Mt,Is.prototype=k(Mt.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:Is});var tn=f.geom.Intersect=function(){};w["verb.geom.Intersect"]=tn,tn.__name__=["verb","geom","Intersect"],tn.curves=function(r,i,o){return o==null&&(o=.001),ut.curves(r.asNurbs(),i.asNurbs(),o)},tn.curvesAsync=function(r,i,o){return o==null&&(o=.001),It.dispatchMethod(ut,"curves",[r.asNurbs(),i.asNurbs(),o])},tn.curveAndSurface=function(r,i,o){return o==null&&(o=.001),ut.curveAndSurface(r.asNurbs(),i.asNurbs(),o)},tn.curveAndSurfaceAsync=function(r,i,o){return o==null&&(o=.001),It.dispatchMethod(ut,"curveAndSurface",[r.asNurbs(),i.asNurbs(),o])},tn.surfaces=function(r,i,o){return o==null&&(o=.001),ut.surfaces(r.asNurbs(),i.asNurbs(),o).map(function(l){return new Ot(l)})},tn.surfacesAsync=function(r,i,o){return o==null&&(o=.001),It.dispatchMethod(ut,"surfaces",[r.asNurbs(),i.asNurbs(),o]).then(function(l){return l.map(function(c){return new Ot(c)})})};var Ss=f.geom.Line=function(r,i){Ot.call(this,gt.polyline([r,i])),this._start=r,this._end=i};w["verb.geom.Line"]=Ss,Ss.__name__=["verb","geom","Line"],Ss.__super__=Ot,Ss.prototype=k(Ot.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:Ss});var Ps=f.geom.RevolvedSurface=function(r,i,o,l){Mt.call(this,gt.revolvedSurface(r.asNurbs(),i,o,l)),this._profile=r,this._center=i,this._axis=o,this._angle=l};w["verb.geom.RevolvedSurface"]=Ps,Ps.__name__=["verb","geom","RevolvedSurface"],Ps.__super__=Mt,Ps.prototype=k(Mt.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:Ps});var As=f.geom.SphericalSurface=function(r,i){Mt.call(this,gt.sphericalSurface(r,[0,0,1],[1,0,0],i)),this._center=r,this._radius=i};w["verb.geom.SphericalSurface"]=As,As.__name__=["verb","geom","SphericalSurface"],As.__super__=Mt,As.prototype=k(Mt.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:As});var Es=f.geom.SweptSurface=function(r,i){Mt.call(this,gt.rationalTranslationalSurface(r.asNurbs(),i.asNurbs())),this._profile=r,this._rail=i};w["verb.geom.SweptSurface"]=Es,Es.__name__=["verb","geom","SweptSurface"],Es.__super__=Mt,Es.prototype=k(Mt.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:Es});function sr(r){return r instanceof Array?function(){return L.iter(r)}:typeof r.iterator=="function"?De(r,r.iterator):r.iterator}var ca,Oc=0;function De(r,i){if(i==null)return null;i.__id__==null&&(i.__id__=Oc++);var o;return r.hx__closures__==null?r.hx__closures__={}:o=r.hx__closures__[i.__id__],o==null&&(o=function(){return o.method.apply(o.scope,arguments)},o.scope=r,o.method=i,r.hx__closures__[i.__id__]=o),o}w.Math=Math,String.prototype.__class__=w.String=String,String.__name__=["String"],w.Array=Array,Array.__name__=["Array"],Date.prototype.__class__=w.Date=Date,Date.__name__=["Date"];var Cc=w.Int={__name__:["Int"]},Bc=w.Dynamic={__name__:["Dynamic"]},nl=w.Float=Number;nl.__name__=["Float"];var sl=w.Bool=Boolean;sl.__ename__=["Bool"];var il=w.Class={__name__:["Class"]},al={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var i=[],o=0,l=this.length;o<l;){var c=o++;i[c]=r(this[c])}return i}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var i=[],o=0,l=this.length;o<l;){var c=o++,d=this[c];r(d)&&i.push(d)}return i});var da={},mi=x.ArrayBuffer||me;mi.prototype.slice==null&&(mi.prototype.slice=me.sliceImpl),x.DataView;var pa=x.Uint8Array||pr._new;(function(r,i){if(r.setImmediate)return;var o=1,l={},c=!1,d=r.document,g;function _(R){return l[o]=y.apply(i,R),o++}function y(R){var j=[].slice.call(arguments,1);return function(){typeof R=="function"?R.apply(i,j):new Function(""+R)()}}function I(R){if(c)setTimeout(y(I,R),0);else{var j=l[R];if(j){c=!0;try{j()}finally{P(R),c=!1}}}}function P(R){delete l[R]}function S(){g=function(){var R=_(arguments);return process.nextTick(y(I,R)),R}}function E(){if(r.postMessage&&!r.importScripts){var R=!0,j=r.onmessage;return r.onmessage=function(){R=!1},r.postMessage("","*"),r.onmessage=j,R}}function M(){var R="setImmediate$"+Math.random()+"$",j=function(D){D.source===r&&typeof D.data=="string"&&D.data.indexOf(R)===0&&I(+D.data.slice(R.length))};r.addEventListener?r.addEventListener("message",j,!1):r.attachEvent("onmessage",j),g=function(){var D=_(arguments);return r.postMessage(R+D,"*"),D}}function T(){var R=new MessageChannel;R.port1.onmessage=function(j){var D=j.data;I(D)},g=function(){var j=_(arguments);return R.port2.postMessage(j),j}}function B(){var R=d.documentElement;g=function(){var j=_(arguments),D=d.createElement("script");return D.onreadystatechange=function(){I(j),D.onreadystatechange=null,R.removeChild(D),D=null},R.appendChild(D),j}}function O(){g=function(){var R=_(arguments);return setTimeout(y(I,R),0),R}}var F=Object.getPrototypeOf&&Object.getPrototypeOf(r);F=F&&F.setTimeout?F:r,{}.toString.call(r.process)==="[object process]"?S():E()?M():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?B():O(),F.setImmediate=g,F.clearImmediate=P})(new Function("return this")()),$t.USE_CACHE=!1,$t.USE_ENUM_INDEX=!1,$t.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Xt.DEFAULT_RESOLVER=dt,Xt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Bt.count=0,pe.i64tmp=function(r){var i,o=new Wt(0,0);return i=o,i}(),Lt.__toStr={}.toString,pr.BYTES_PER_ELEMENT=1,At.queue=new V,Vt.memo=new xt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",bt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],bt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],It.THREADS=1,It._init=!1,Zr.basePath="",mn.uuid=0,di.main()}(typeof console<"u"?console:{log:function(){}},e,typeof u<"u"?u:typeof s<"u"?s:typeof self<"u"?self:this),e})})(Oh);var _d=Oh.exports;const Kn=gd(_d);class Ia{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,a){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-a,this.c3=2*t-2*e+s+a}initCatmullRom(t,e,s,a,h){this.init(e,s,h*(s-t),h*(a-e))}initNonuniformCatmullRom(t,e,s,a,h,u,p){let v=(e-t)/h-(s-t)/(h+u)+(s-e)/u,f=(s-e)/u-(a-e)/(u+p)+(a-s)/p;v*=u,f*=u,this.init(e,s,v,f)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}let Ch=class extends oi{constructor(t=[],e=!1,s="centripetal",a=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new q,this._px=new Ia,this._py=new Ia,this._pz=new Ia,this._points=t.map(h=>new G(h)),this._closed=e,this._curveType=s,this._tension=a}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new G}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new G}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new G){const s=e,a=this._points,h=a.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(a[0]);const u=(h-(this._closed?0:1))*t;let p=Math.floor(u),v=u-p;this._closed?p+=p>0?0:(Math.floor(Math.abs(p)/h)+1)*h:v===0&&p===h-1&&(p=h-2,v=1);let f,x;this._closed||p>0?f=a[(p-1)%h]:(this._tmp.subVectors(a[0],a[1]).add(a[0]),f=new G(this._tmp.x,this._tmp.y,this._tmp.z));const w=a[p%h],A=a[(p+1)%h];if(this._closed||p+2<h?x=a[(p+2)%h]:(this._tmp.subVectors(a[h-1],a[h-2]).add(a[h-1]),x=new G(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const k=this._curveType==="chordal"?.5:.25;let L=Math.pow(f.distanceToSquared(w),k),C=Math.pow(w.distanceToSquared(A),k),V=Math.pow(A.distanceToSquared(x),k);C<1e-4&&(C=1),L<1e-4&&(L=C),V<1e-4&&(V=C),this._px.initNonuniformCatmullRom(f.x,w.x,A.x,x.x,L,C,V),this._py.initNonuniformCatmullRom(f.y,w.y,A.y,x.y,L,C,V),this._pz.initNonuniformCatmullRom(f.z,w.z,A.z,x.z,L,C,V)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,w.x,A.x,x.x,this._tension),this._py.initCatmullRom(f.y,w.y,A.y,x.y,this._tension),this._pz.initCatmullRom(f.z,w.z,A.z,x.z,this._tension));return s.set(this._px.calc(v),this._py.calc(v),this._pz.calc(v)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new G(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const s=new G;return s.copy(e),s.applyMatrix4(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Nt;const t=new Nt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}};class Mn{constructor(t,e,s,a){this._degree=t,this._knots=[...e],this._controlPoints=s.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=a?[...a]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return Ks(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Ah(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,a){return new Mn(t,e,s,a)}static byPoints(t,e,s="Uniform"){let a;switch(s){case"Chord":a=Sh(e,t);break;case"SqrtChord":a=Ph(e,t);break;case"Uniform":default:a=Ih(e,t.length);break}const h=t.map(p=>({x:p[0],y:p[1],z:p[2]})),u=new Array(h.length).fill(1);return new Mn(e,a,h,u)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:a}=this.getParameterRange();for(let h=0;h<=t;h++){const u=s+(a-s)*(h/t);e.push(this.point(u))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),a=this.point(e),h=this.point(s),u=a[0]-h[0],p=a[1]-h[1],v=a[2]-h[2];return Math.sqrt(u*u+p*p+v*v)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new Ch(t,!0,"centripetal"),s=Math.max(50,t.length*2);return e.getPoints(s)}static createClosedCurve(t,e,s="Chord"){const a=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return Mn.byPoints(a,e,s)}}class Gr extends oi{constructor(t,e,s,a,h){super();const u=arguments.length;if(u<2||u>5)throw Ze.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let p,v=3,f=!1;if(u>=3&&(Array.isArray(s)?(p=s,u>=4&&(v=a||3),u>=5&&(f=h)):s!==void 0&&(v=s||3,u>=4&&(f=a))),s===void 0&&u>=4&&(v=a||3,u>=5&&(f=h)),this._degree=v,this._closed=f,this._controlPoints.length<this._degree+1)throw Ze.ILLEGAL_PARAMETERS;const x=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Kn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,x,p)}else{if(this._fitPoints=t,this._knotParameterization=e,u>=3&&(this._degree=s||3),u>=4&&(this._closed=a),this._fitPoints.length<this._degree+1)throw Ze.ILLEGAL_PARAMETERS;const p=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Kn.geom.NurbsCurve.byPoints(p,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=Mn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Kn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Kn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=Mn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Kn.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Kn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,s,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0}))}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(e=>({x:e.x,y:e.y,z:e.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],a=this._nurbsCurve.point(s);return new G(a[0],a[1],a[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],a=this._nurbsCurve.point(s);return new G(a[0],a[1],a[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,a=this._fitPoints[s];return{x:a.x,y:a.y,z:a.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],a=e.knots(),h=this._nurbsCurve.degree(),u=a[h],p=a[a.length-h-1],v=(p-u)/(t-1);for(let f=0;f<t;f++){const x=f===t-1?p:u+f*v,w=e.point(x);s.push(new G(w[0],w[1],w[2]))}return s}getCurvePoints(t,e){const s=[],a=t.knots(),h=a[3],u=(a[a.length-4]-h)/(e-1);for(let p=0;p<e;p++){const v=h+p*u;s.push(t.point(v))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Nt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,a)=>{e[a]=[s.x,s.y,s.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((s,a)=>{e[a]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,a)=>{e[a]={x:s[0],y:s[1],z:s[2]}}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Gr(t,e,s,!0)}}var oo=(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))(oo||{});class is{static get instance(){return this._instance||(this._instance=new is),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,a=[],h=!0,u,p){var f;const v=[];if(e!=null){const x=this.createKey(e.name,s);let w;if(this.has(x))w=this.get(x);else{const A=(f=t.basePoint)==null?void 0:f.clone();t.basePoint=void 0;const k=e.newIterator();let L=!0;for(const C of k)if(C.color.isByBlock&&s?(Ml.copy(C.color),C.color.setRGBValue(s),this.addEntity(C,v,t),C.color.copy(Ml)):this.addEntity(C,v,t),L&&v.length>0){const V=v[0];t.basePoint=V.basePoint,L=!1}w=t.group(v),w&&h&&ue.name&&!ue.name.startsWith("*U")&&this.set(x,w),t.basePoint=A}return w&&u&&(w.applyMatrix(u),p&&(p.x!=0||p.y!=0||p.z!=1)&&(u.setFromExtrusionDirection(p),w.applyMatrix(u))),w&&a&&a.length>0&&(w.bakeTransformToChildren(),a.forEach(A=>w.addChild(A))),w}else return t.group(v)}addEntity(t,e,s){const a=t.worldDraw(s);a&&(this.attachEntityInfo(a,t),e.push(a))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const Ml=new ce;var lo=(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))(lo||{});const fd=["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"],Bh=n=>fd[n],Ti="Continuous",ne="Standard",xi="ByLayer",Rh="ByBlock";var Fh=(n=>(n[n.kInches=0]="kInches",n[n.kMillimeters=1]="kMillimeters",n[n.kPixels=2]="kPixels",n))(Fh||{}),zh=(n=>(n[n.k0degrees=0]="k0degrees",n[n.k90degrees=1]="k90degrees",n[n.k180degrees=2]="k180degrees",n[n.k270degrees=3]="k270degrees",n))(zh||{}),Vh=(n=>(n[n.kDisplay=0]="kDisplay",n[n.kExtents=1]="kExtents",n[n.kLimits=2]="kLimits",n[n.kView=3]="kView",n[n.kWindow=4]="kWindow",n[n.kLayout=5]="kLayout",n))(Vh||{}),sn=(n=>(n[n.kDraft=0]="kDraft",n[n.kPreview=1]="kPreview",n[n.kNormal=2]="kNormal",n[n.kPresentation=3]="kPresentation",n[n.kMaximum=4]="kMaximum",n[n.kCustom=5]="kCustom",n))(sn||{}),Zn=(n=>(n[n.kAsDisplayed=0]="kAsDisplayed",n[n.kWireframe=1]="kWireframe",n[n.kHidden=2]="kHidden",n[n.kRendered=3]="kRendered",n[n.kVisualStyle=4]="kVisualStyle",n[n.kRenderPreset=5]="kRenderPreset",n))(Zn||{}),jh=(n=>(n[n.kScaleToFit=0]="kScaleToFit",n[n.k1_128in_1ft=1]="k1_128in_1ft",n[n.k1_64in_1ft=2]="k1_64in_1ft",n[n.k1_32in_1ft=3]="k1_32in_1ft",n[n.k1_16in_1ft=4]="k1_16in_1ft",n[n.k3_32in_1ft=5]="k3_32in_1ft",n[n.k1_8in_1ft=6]="k1_8in_1ft",n[n.k3_16in_1ft=7]="k3_16in_1ft",n[n.k1_4in_1ft=8]="k1_4in_1ft",n[n.k3_8in_1ft=9]="k3_8in_1ft",n[n.k1_2in_1ft=10]="k1_2in_1ft",n[n.k3_4in_1ft=11]="k3_4in_1ft",n[n.k1in_1ft=12]="k1in_1ft",n[n.k3in_1ft=13]="k3in_1ft",n[n.k6in_1ft=14]="k6in_1ft",n[n.k1ft_1ft=15]="k1ft_1ft",n[n.k1_1=16]="k1_1",n[n.k1_2=17]="k1_2",n[n.k1_4=18]="k1_4",n[n.k1_5=19]="k1_5",n[n.k1_8=20]="k1_8",n[n.k1_10=21]="k1_10",n[n.k1_16=22]="k1_16",n[n.k1_20=23]="k1_20",n[n.k1_30=24]="k1_30",n[n.k1_40=25]="k1_40",n[n.k1_50=26]="k1_50",n[n.k1_100=27]="k1_100",n[n.k2_1=28]="k2_1",n[n.k4_1=29]="k4_1",n[n.k8_1=30]="k8_1",n[n.k10_1=31]="k10_1",n[n.k100_1=32]="k100_1",n[n.k1000_1=33]="k1000_1",n[n.k1and1_2in_1ft=34]="k1and1_2in_1ft",n))(jh||{});const yd={0:0,1:1/1536,2:1/768,3:1/384,4:1/192,5:1/128,6:1/96,7:1/64,8:1/48,9:1/32,10:1/24,11:1/16,12:1/12,13:1/4,14:1/2,15:1,16:1,17:1/2,18:1/4,19:1/5,20:1/8,21:1/10,22:1/16,23:1/20,24:1/30,25:1/40,26:1/50,27:1/100,28:2,29:4,30:8,31:10,32:100,33:1e3,34:1/8};class Dh extends Hr{constructor(t=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new Et,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new Et,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._plotWindowArea=new ve,this._modelType=t,this._plotCentered=!1,this._plotHidden=!1,this._plotPaperUnits=1,this._plotPlotStyles=!0,this._plotRotation=0,this._plotType=5,this._plotViewportBorders=!1,this._printLineweights=!0,this._scaleLineweights=!1,this._drawViewportsFirst=!1,this._showPlotStyles=!0,this._shadePlotType=0,this._shadePlotResLevel=2,this._shadePlotCustomDpi=300,this._shadePlotId=void 0,this._stdScaleType=0,this._useStandardScale=!0}get plotSettingsName(){return this._plotSettingsName}set plotSettingsName(t){this._plotSettingsName=t}getPlotSettingsName(){return this._plotSettingsName}setPlotSettingsName(t){this._plotSettingsName=t}get plotCfgName(){return this._plotCfgName}set plotCfgName(t){this._plotCfgName=t}getPlotCfgName(){return this._plotCfgName}get canonicalMediaName(){return this._canonicalMediaName}set canonicalMediaName(t){this._canonicalMediaName=t}getCanonicalMediaName(){return this._canonicalMediaName}get currentStyleSheet(){return this._currentStyleSheet}set currentStyleSheet(t){this._currentStyleSheet=t}getCurrentStyleSheet(){return this._currentStyleSheet}get plotOrigin(){return this._plotOrigin}set plotOrigin(t){this._plotOrigin=t}getPlotOrigin(){return this._plotOrigin}get customPrintScale(){return this._customPrintScale}set customPrintScale(t){this._customPrintScale=t}getCustomPrintScale(){return this._customPrintScale}get plotPaperSize(){return this._plotPaperSize}set plotPaperSize(t){this._plotPaperSize=t}getPlotPaperSize(){return this._plotPaperSize}get plotPaperMargins(){return this._plotPaperMargins}set plotPaperMargins(t){this._plotPaperMargins=t}getPlotPaperMargins(){return this._plotPaperMargins}get plotViewName(){return this._plotViewName}set plotViewName(t){this._plotViewName=t}getPlotViewName(){return this._plotViewName}get plotWindowArea(){return this._plotWindowArea}set plotWindowArea(t){this._plotWindowArea=t}getPlotWindowArea(){return this._plotWindowArea}get modelType(){return this._modelType}set modelType(t){this._modelType=t}getModelType(){return this._modelType}setModelType(t){this._modelType=t}get drawViewportsFirst(){return this._drawViewportsFirst}set drawViewportsFirst(t){this._drawViewportsFirst=t}setDrawViewportsFirst(t){this._drawViewportsFirst=t}get plotCentered(){return this._plotCentered}set plotCentered(t){this._plotCentered=t}setPlotCentered(t){this._plotCentered=t}get plotHidden(){return this._plotHidden}set plotHidden(t){this._plotHidden=t}setPlotHidden(t){this._plotHidden=t}get plotPaperUnits(){return this._plotPaperUnits}set plotPaperUnits(t){this._plotPaperUnits=t}get plotPlotStyles(){return this._plotPlotStyles}set plotPlotStyles(t){this._plotPlotStyles=t}setPlotPlotStyles(t){this._plotPlotStyles=t}get plotRotation(){return this._plotRotation}set plotRotation(t){this._plotRotation=t}get plotType(){return this._plotType}set plotType(t){this._plotType=t}get plotViewportBorders(){return this._plotViewportBorders}set plotViewportBorders(t){this._plotViewportBorders=t}setPlotViewportBorders(t){this._plotViewportBorders=t}get printLineweights(){return this._printLineweights}set printLineweights(t){this._printLineweights=t}setPrintLineweights(t){this._printLineweights=t}get scaleLineweights(){return this._scaleLineweights}set scaleLineweights(t){this._scaleLineweights=t}setScaleLineweights(t){this._scaleLineweights=t}get showPlotStyles(){return this._showPlotStyles}set showPlotStyles(t){this._showPlotStyles=t}setShowPlotStyles(t){this._showPlotStyles=t}get shadePlot(){return this._shadePlotType}set shadePlot(t){this._shadePlotType=t}setShadePlot(t){this._shadePlotType=t}get shadePlotResLevel(){return this._shadePlotResLevel}set shadePlotResLevel(t){this._shadePlotResLevel=t}setShadePlotResLevel(t){this._shadePlotResLevel=t}get shadePlotCustomDPI(){return this._shadePlotCustomDpi}set shadePlotCustomDPI(t){this._shadePlotCustomDpi=t}setShadePlotCustomDPI(t){this._shadePlotCustomDpi=t}get shadePlotId(){return this._shadePlotId}set shadePlotId(t){this._shadePlotId=t}get plotWireframe(){return this._shadePlotType===1}get plotAsRaster(){return this._shadePlotType===3||this._shadePlotType===4||this._shadePlotType===5}get stdScaleType(){return this._stdScaleType}set stdScaleType(t){this._stdScaleType=t}get stdScale(){return yd[this._stdScaleType]??1}get useStandardScale(){return this._useStandardScale}set useStandardScale(t){this._useStandardScale=t}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPlotSettings"),t.writeString(1,this.plotSettingsName),t.writeString(2,this.plotCfgName),t.writeString(4,this.canonicalMediaName),t.writeString(6,this.plotViewName),t.writeDouble(40,this.plotPaperMargins.left),t.writeDouble(41,this.plotPaperMargins.bottom),t.writeDouble(42,this.plotPaperMargins.right),t.writeDouble(43,this.plotPaperMargins.top),t.writeDouble(44,this.plotPaperSize.x),t.writeDouble(45,this.plotPaperSize.y),t.writeDouble(46,this.plotOrigin.x),t.writeDouble(47,this.plotOrigin.y),t.writeDouble(48,this.plotWindowArea.min.x),t.writeDouble(49,this.plotWindowArea.min.y),t.writeDouble(140,this.plotWindowArea.max.x),t.writeDouble(141,this.plotWindowArea.max.y),t.writeDouble(142,this.customPrintScale.numerator),t.writeDouble(143,this.customPrintScale.denominator);let e=0;return this.plotViewportBorders&&(e|=1),this.showPlotStyles&&(e|=2),this.plotCentered&&(e|=4),this.plotHidden&&(e|=8),this.useStandardScale&&(e|=16),this.plotPlotStyles&&(e|=32),this.scaleLineweights&&(e|=64),this.printLineweights&&(e|=128),this.drawViewportsFirst&&(e|=512),this.modelType&&(e|=1024),t.writeInt16(70,e),t.writeInt16(72,this.plotPaperUnits),t.writeInt16(73,this.plotRotation),t.writeInt16(74,this.plotType),t.writeString(7,this.currentStyleSheet),t.writeInt16(75,this.stdScaleType),t.writeInt16(76,this.shadePlot),t.writeInt16(77,this.shadePlotResLevel),t.writeInt16(78,this.shadePlotCustomDPI),t.writeDouble(147,this.stdScale),t.writeObjectId(333,this.shadePlotId),this}}class hi extends Dh{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new ve,this._extents=new Nt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayout"),t.writeString(1,this.layoutName),t.writeInt16(70,this.tabSelected?1:0),t.writeInt16(71,this.tabOrder),t.writeObjectId(330,this.blockTableRecordId),t.writePoint2d(10,this.limits.min),t.writePoint2d(11,this.limits.max),t.writePoint3d(14,this.extents.min),t.writePoint3d(15,this.extents.max),this}}class ui{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}class $s extends Hr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,e.ownerId=this.objectId,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e),this.database.events.dictObjetSet.dispatch({database:this.database,object:e,key:t})}remove(t){const e=this.getAt(t);return e?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t}),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,a)=>{s===e&&(this._recordsByName.delete(a),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:a}))}),!0):!1}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new ui(this._recordsByName)}entries(){return this._recordsByName.entries()}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(281,1);for(const[e,s]of this._recordsByName)t.writeString(3,e),t.writeObjectId(350,s.objectId);return this}}class Uh extends $s{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class cn extends Hr{constructor(t,e){t=t||{},ns(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTableRecord"),this}}const on=class on extends cn{static isModelSapceName(t){return t.toLowerCase()==on.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(on.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new G,this._layoutId="",this._entities=new Map}get isModelSapce(){return on.isModelSapceName(this.name)}get isPaperSapce(){return on.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(t){this._origin.copy(t)}get layoutId(){return this._layoutId}set layoutId(t){this._layoutId=t}appendEntity(t){if(Array.isArray(t))for(let e=0;e<t.length;++e){const s=t[e];s.database=this.database,s.ownerId=this.objectId,s.resolveEffectiveProperties(),this._entities.set(s.objectId,s)}else t.database=this.database,t.ownerId=this.objectId,t.resolveEffectiveProperties(),this._entities.set(t.objectId,t);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}removeEntity(t){const e=Array.isArray(t)?t:[t],s=[];return e.forEach(a=>{const h=this._entities.get(a);h&&s.push(h),this._entities.delete(a)}),s.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:s}),s.length>0}newIterator(){return new ui(this._entities)}getIdAt(t){return this._entities.get(t)}dxfOutBlockRecord(t){return t.writeStart("BLOCK_RECORD"),this.dxfOut(t),this}dxfOutBlockBegin(t){return t.writeStart("BLOCK"),t.writeHandle(5,`BLOCK:${this.objectId}`),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbBlockBegin"),t.writeString(8,"0"),t.writeString(2,this.name),t.writeInt16(70,0),t.writePoint3d(10,this.origin),t.writeString(3,this.name),this}dxfOutBlockEnd(t){return t.writeStart("ENDBLK"),t.writeHandle(5,`ENDBLK:${this.objectId}`),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbBlockEnd"),this}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeObjectId(340,this.layoutId),this}};on.MODEL_SPACE_NAME="*Model_Space",on.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let ue=on;class Gh{constructor(){this.events={layoutCreated:new he,layoutRemoved:new he,layoutRenamed:new he,layoutSwitched:new he}}countLayouts(t){return this.getWorkingDatabase(t).objects.layout.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).objects.layout.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),a=s.objects.layout.getIdAt(t);return this.setCurrentLayoutInternal(a,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),a=s.objects.layout.getBtrIdAt(t);return this.setCurrentLayoutInternal(a,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),a=s.objects.layout.getAt(t);return this.setCurrentLayoutInternal(a,s)}renameLayout(t,e,s){const h=this.getWorkingDatabase(s).objects.layout.getAt(t);return h?(h.layoutName=e,this.events.layoutRenamed.dispatch({layout:h,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).objects.layout.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).objects.layout,a=s.getAt(t);let h=!1;return a&&(h=s.remove(t),h&&this.events.layoutRemoved.dispatch({layout:a})),h}createLayout(t,e){const s=this.getWorkingDatabase(e),a=new hi;a.layoutName=t,a.tabOrder=s.objects.layout.maxTabOrder;const h=new ue;return h.name=`*Paper_Space${a.tabOrder}`,s.tables.blockTable.add(h),s.objects.layout.setAt(t,a),this.events.layoutCreated.dispatch({layout:a}),{layout:a,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.objects.layout.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Xa().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}Ql(()=>new Gh);class Wh extends Hr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImageDef"),t.writeString(1,this.sourceFileName),t.writeInt16(280,1),t.writeInt16(281,0),this}}var Hh=(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))(Hh||{});class ho extends Hr{constructor(){super(...arguments),this._data=null}get data(){return this._data}set data(t){this._data=t}clear(){var t;(t=this._data)==null||t.clear()}clone(){var e;const t=new ho;return t._data=((e=this._data)==null?void 0:e.clone())??null,t}getDuplicateRecordCloning(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXrecord"),t.writeInt16(280,1),t.writeResultBuffer(this.data),this}}class Yh{constructor(t){this.db=t}createDefaultLayer(){const t=new ce;return t.colorIndex=7,this.db.tables.layerTable.add(new ci({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new ln({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ln({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ln({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new la({name:ne,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new On({name:ne,dimtxsty:ne}))}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 ei;e.patternName="SOLID";const s=new oa;s.add(new ts({x:0,y:0},{x:-1,y:.125})),s.add(new ts({x:-1,y:.125},{x:-1,y:-.125})),s.add(new ts({x:-1,y:-.125},{x:0,y:0})),e.add(s);const a=new ue;a.name="_CAXARROW",a.appendEntity(e),this.db.tables.blockTable.add(a)}}}var Xh=(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))(Xh||{}),zt=(n=>(n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(zt||{});function vd(n){let t=0;for(const e of n)t|=1<<e-1;return t}function bd(n){const t=[];for(const e of Object.values(zt)){if(typeof e!="number")continue;const s=1<<e-1;n&s&&t.push(e)}return t}function wd(n,t){return n^1<<t-1}function xd(n,t){return(n&1<<t-1)!==0}function Id(n,t){return n|1<<t-1}function Sd(n,t){return n&~(1<<t-1)}var uo=(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))(uo||{});function Pd(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function Ad(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}var co=(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))(co||{}),hn=(n=>(n[n.ByBlock=-2]="ByBlock",n[n.ByDIPs=-4]="ByDIPs",n[n.ByLayer=-1]="ByLayer",n[n.ByLineWeightDefault=-3]="ByLineWeightDefault",n[n.LineWeight000=0]="LineWeight000",n[n.LineWeight005=5]="LineWeight005",n[n.LineWeight009=9]="LineWeight009",n[n.LineWeight013=13]="LineWeight013",n[n.LineWeight015=15]="LineWeight015",n[n.LineWeight018=18]="LineWeight018",n[n.LineWeight020=20]="LineWeight020",n[n.LineWeight025=25]="LineWeight025",n[n.LineWeight030=30]="LineWeight030",n[n.LineWeight035=35]="LineWeight035",n[n.LineWeight040=40]="LineWeight040",n[n.LineWeight050=50]="LineWeight050",n[n.LineWeight053=53]="LineWeight053",n[n.LineWeight060=60]="LineWeight060",n[n.LineWeight070=70]="LineWeight070",n[n.LineWeight080=80]="LineWeight080",n[n.LineWeight090=90]="LineWeight090",n[n.LineWeight100=100]="LineWeight100",n[n.LineWeight106=106]="LineWeight106",n[n.LineWeight120=120]="LineWeight120",n[n.LineWeight140=140]="LineWeight140",n[n.LineWeight158=158]="LineWeight158",n[n.LineWeight200=200]="LineWeight200",n[n.LineWeight211=211]="LineWeight211",n))(hn||{}),Ur=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(Ur||{}),Pe=(n=>(n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n))(Pe||{}),po=(n=>(n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",n))(po||{}),mo=(n=>(n[n.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",n[n.TOP=1]="TOP",n[n.BOTTOM=2]="BOTTOM",n[n.FRONT=3]="FRONT",n[n.BACK=4]="BACK",n[n.LEFT=5]="LEFT",n[n.RIGHT=6]="RIGHT",n))(mo||{}),go=(n=>(n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",n))(go||{});let qh=class Kh{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new ve;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new ve;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Kh;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}};const xo=class xo extends Hr{constructor(){super(...arguments),this._lineType=xi,this._visibility=!0,this._transparency=new na}get type(){return this.constructor.typeName}get dxfEntityTypeName(){switch(this.type){case"BlockReference":return"INSERT";case"Polyline":return"LWPOLYLINE";case"2dPolyline":case"3dPolyline":return"POLYLINE";case"2dVertex":case"3dVertex":return"VERTEX";case"Face":return"3DFACE";case"RasterImage":return"IMAGE";case"Table":return"ACAD_TABLE";case"AlignedDimension":case"RadialDimension":case"DiametricDimension":case"OrdinateDimension":case"3PointAngularDimension":case"ArcDimension":return"DIMENSION";default:return this.type.toUpperCase()}}get layer(){return this._layer==null&&(this._layer=this.database.clayer??"0"),this._layer}set layer(t){this._layer=t}get color(){return this._color==null&&(this._color=new ce,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._color}set color(t){this._color==null&&(this._color=new ce),this._color.copy(t)}get resolvedColor(){let t=this.color;if(t.isByLayer){const e=this.getLayerColor();e&&e.RGB!=null&&(t=e)}else t.isByBlock;return t}get rgbColor(){const e=this.resolvedColor.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||xi}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??hn.ByLayer),this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t.clone()}dxfOutFields(t){t.writeSubclassMarker("AcDbEntity"),t.writeString(8,this.layer),t.writeString(6,this.lineType),t.writeDouble(48,this.linetypeScale),t.writeInt16(60,this.visibility?0:1),t.writeCmColor(this.color),t.writeInt16(370,this.lineWeight),t.writeTransparency(this.transparency);const e=this.database.tables.blockTable.getIdAt(this.ownerId);return e!=null&&e.isPaperSapce&&t.writeInt16(67,1),this}resolveEffectiveProperties(){this._layer==null&&(this._layer=this.database.clayer??"0"),this._color==null&&(this._color=new ce,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??hn.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,a,h){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){const s=t.subEntityTraits;s.color=this.resolvedColor,s.rgbColor=this.rgbColor,s.lineType=this.lineStyle,s.lineTypeScale=this.linetypeScale,s.lineWeight=this.lineWeight,s.transparency=this.transparency,s.layer=this.layer,"thickness"in this&&(s.thickness=this.thickness);const a=this.subWorldDraw(t,e);return this.attachEntityInfo(a),a}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:t=>{this.color.copy(t)}}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:t=>{this.layer=t}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:()=>this.lineType,set:t=>{this.lineType=t}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:()=>this.linetypeScale,set:t=>{this.linetypeScale=t}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:()=>this.lineWeight,set:t=>{this.lineWeight=t}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:()=>this.transparency,set:t=>{this.transparency=t}}}]}}get lineStyle(){var a;const{type:t,name:e}=this.getLineType(),s=(a=this.database)==null?void 0:a.tables.linetypeTable.getAt(e);return s?{type:t,...s.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==xi){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Rh?{type:"ByBlock",name:Ti}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:Ti}}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}attachEntityInfo(t){t&&(t.objectId=this.objectId,this.attrs.has("ownerId")&&(t.ownerId=this.ownerId),t.layerName=this.layer,t.visible=this.visibility)}};xo.typeName="Entity";let Le=xo;const Io=class Io extends Le{};Io.typeName="Curve";let Oe=Io;var Qn=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.FitCurvePoly=1]="FitCurvePoly",n[n.QuadSplinePoly=2]="QuadSplinePoly",n[n.CubicSplinePoly=3]="CubicSplinePoly",n))(Qn||{});const So=class So extends Oe{constructor(t,e,s=0,a=!1,h=0,u=0,p=null){super(),this._polyType=t,this._elevation=s;const v=p&&(p==null?void 0:p.length)===e.length,f=e.map((x,w)=>({x:x.x,y:x.y,bulge:v?p[w]:void 0}));this._geo=new un(f,a)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){return this._geo.getPointAt(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const s=this._geo.getPointAt(e);t.push(new G(s.x,s.y,0))}return t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const u=this._geo.getPointAt(h);a.push(new G(u.x,u.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}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(38,this.elevation),this}};So.typeName="2dPolyline";let Js=So;var $h=(n=>(n[n.Vertex=0]="Vertex",n[n.CurveFitVertex=1]="CurveFitVertex",n[n.SplineFitVertex=8]="SplineFitVertex",n[n.SplineCtlVertex=9]="SplineCtlVertex",n))($h||{});const Po=class Po extends Le{constructor(){super(),this._position=new G,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 Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,s,a){a.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.writePoint3d(10,this.position),t.writeDouble(40,this.startWidth),t.writeDouble(41,this.endWidth),t.writeDouble(42,this.bulge),t.writeInt16(70,this.vertexType),this}};Po.typeName="2dVertex";let ja=Po;var Zs=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.QuadSplinePoly=1]="QuadSplinePoly",n[n.CubicSplinePoly=2]="CubicSplinePoly",n))(Zs||{});const Ao=class Ao extends Oe{constructor(t,e,s=!1){super(),this._polyType=t,this._geo=new un(e,s)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){return this._geo.getPointAt(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const s=this._geo.getPointAt(e);t.push(new G(s.x,s.y,0))}return t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const u=this._geo.getPointAt(h);a.push(new G(u.x,u.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,0))),t.lines(e)}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}};Ao.typeName="3dPolyline";let ti=Ao;var Zh=(n=>(n[n.SimpleVertex=0]="SimpleVertex",n[n.ControlVertex=1]="ControlVertex",n[n.FitVertex=2]="FitVertex",n))(Zh||{});const Eo=class Eo extends Le{constructor(){super(),this._position=new G,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 Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,s,a){a.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}};Eo.typeName="3dVertex";let Da=Eo;const ko=class ko extends Oe{constructor(t,e,s,a,h=q.Z_AXIS){super(),this._geo=new ao(t,e,s,a,h,q.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"arcLength",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"totalAngle",type:"float",editable:!1,accessor:{get:()=>St.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,a){const h=this.startPoint,u=this.endPoint;switch(t){case zt.EndPoint:a.push(h),a.push(u);break;case zt.MidPoint:a.push(this.midPoint);break;case zt.Nearest:{const p=this._geo.nearestPoint(e);a.push(p)}break;case zt.Perpendicular:break;case zt.Tangent:{const p=this._geo.tangentPoints(e);a.push(...p);break}}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbArc"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeAngle(50,this.startAngle),t.writeAngle(51,this.endAngle),t.writeVector3d(210,this.normal),this}};ko.typeName="Arc";let Ni=ko;var Qh=(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))(Qh||{}),Jh=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Jh||{});const Mo=class Mo extends Le{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new G,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new Nt}subGetOsnapPoints(t,e,s,a){zt.Insertion===t&&a.push(this._position)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt(ne)||t.getAt(ne)),e.textStyle}subWorldDraw(t,e){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Ur.BOTTOM_TO_TOP,attachmentPoint:Pe.BottomLeft};return t.mtext(s,this.getTextStyle(),e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbText"),t.writePoint3d(10,this.position),t.writeDouble(39,this.thickness),t.writeDouble(40,this.height),t.writeString(1,this.textString),t.writeAngle(50,this.rotation),t.writeDouble(41,this.widthFactor),t.writeAngle(51,this.oblique),t.writeString(7,this.styleName),t.writeInt16(72,this.horizontalMode),t.writeInt16(73,this.verticalMode),t.writePoint3d(11,this.position),this}};Mo.typeName="Text";let rs=Mo;var de=(n=>(n[n.Invisible=1]="Invisible",n[n.Const=2]="Const",n[n.Verifiable=4]="Verifiable",n[n.Preset=8]="Preset",n))(de||{}),br=(n=>(n[n.MultiLine=2]="MultiLine",n[n.ConstMultiLine=4]="ConstMultiLine",n))(br||{});const To=class To extends rs{constructor(){super(),this._flags=0,this._prompt="",this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&1)!==0}set isInvisible(t){t?this._flags|=1:this._flags&=-2}get prompt(){return this._prompt}set prompt(t){this._prompt=t}get isConst(){return(this._flags&2)!==0}set isConst(t){t?this._flags|=2:this._flags&=-3}get isVerifiable(){return(this._flags&4)!==0}set isVerifiable(t){t?this._flags|=4:this._flags&=-5}get isPreset(){return(this._flags&8)!==0}set isPreset(t){t?this._flags|=8:this._flags&=-9}get isMTextAttribute(){return(this._mtextFlag&2)!==0}set isMTextAttribute(t){t?this._mtextFlag|=2:this._mtextFlag&=-3}get isConstMTextAttribute(){return(this._mtextFlag&4)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=4:this._mtextFlag&=-5}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}subWorldDraw(t){}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttributeDefinition"),t.writeString(3,this.prompt),t.writeString(2,this.tag),t.writeInt16(70,this.isInvisible?1:0),t.writeInt16(73,this.fieldLength),t.writeInt16(74,this.isReallyLocked?1:0),this}};To.typeName="AttDef";let Li=To;const No=class No extends rs{constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&de.Invisible)!==0}set isInvisible(t){t?this._flags|=de.Invisible:this._flags&=~de.Invisible}get isConst(){return(this._flags&de.Const)!==0}set isConst(t){t?this._flags|=de.Const:this._flags&=~de.Const}get isVerifiable(){return(this._flags&de.Verifiable)!==0}set isVerifiable(t){t?this._flags|=de.Verifiable:this._flags&=~de.Verifiable}get isPreset(){return(this._flags&de.Preset)!==0}set isPreset(t){t?this._flags|=de.Preset:this._flags&=~de.Preset}get isMTextAttribute(){return(this._mtextFlag&br.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=br.MultiLine:this._mtextFlag&=~br.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&br.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=br.ConstMultiLine:this._mtextFlag&=~br.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}};No.typeName="Attrib";let Oi=No;const Lo=class Lo extends Le{constructor(t){super(),this._blockName=t,this._position=new G,this._rotation=0,this._normal=new q(0,0,1),this._scaleFactors=new G(1,1,1),this._attribs=new Map}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockName(){return this._blockName}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId}attributeIterator(){return new ui(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??G.ORIGIN,s=new $e().makeTranslation(-e.x,-e.y,-e.z),a=new $e().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),h=new Cn().setFromAxisAngle(q.Z_AXIS,this._rotation),u=new $e().makeRotationFromQuaternion(h),p=new $e().makeTranslation(this._position.x,this._position.y,this._position.z);return new $e().multiplyMatrices(p,u).multiply(a).multiply(s)}subGetOsnapPoints(t,e,s,a,h){zt.Insertion===t?a.push(this._position):h&&this.subEntityGetOsnapPoints(t,e,s,a,h)}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(s=>{e.properties.push({name:s.tag,type:"string",editable:!s.isConst,skipTranslation:!0,accessor:{get:()=>s.textString,set:a=>{s.textString=a}}})})}return t}get geometricExtents(){const t=new Nt,e=this.blockTableRecord;if(e!=null){const a=e.newIterator();for(const h of a)t.union(h.geometricExtents)}const s=this.blockTransform;return t.applyMatrix4(s),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const s=this.blockTransform,a=[];return this._attribs.forEach(u=>{if(!u.isInvisible){const p=u.worldDraw(t);p&&a.push(p)}}),is.instance.draw(t,e,this.rgbColor,a,!0,s,this._normal)}else return t.group([])}subEntityGetOsnapPoints(t,e,s,a,h){var p;if(h===this.objectId)return;const u=(p=this.database)==null?void 0:p.tables.blockTable;if(u!=null){const v=u.getEntityById(h);if(v){const f=[];v.subGetOsnapPoints(t,e,s,f,h);const x=this.blockTransform;f.forEach(w=>{const A=w.clone().applyMatrix4(x);a.push(A)})}}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockReference"),t.writePoint3d(10,this.position),t.writeString(2,this.blockName),t.writeDouble(41,this.scaleFactors.x),t.writeDouble(42,this.scaleFactors.y),t.writeDouble(43,this.scaleFactors.z),t.writeAngle(50,this.rotation),t.writeVector3d(210,this.normal),this}};Lo.typeName="BlockReference";let Ln=Lo;const Oo=class Oo extends Oe{constructor(t,e,s=q.Z_AXIS){super(),this._geo=new ao(t,e,0,Qt,s,q.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,s,a){switch(t){case zt.Center:case zt.Centroid:a.push(this._geo.center);break;case zt.Quadrant:a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case zt.Nearest:{const h=this._geo.nearestPoint(e);a.push(h)}break;case zt.Tangent:{const h=this._geo.tangentPoints(e);a.push(...h);break}}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"diameter",type:"float",editable:!1,accessor:{get:()=>this._geo.radius*2}},{name:"perimeter",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeVector3d(210,this.normal),this}};Oo.typeName="Circle";let Ci=Oo;const Co=class Co extends Oe{constructor(t,e,s,a,h,u,p){super(),this._geo=new aa(t,e,s,a,h,u,p)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:this.closed||(a.push(this._geo.startPoint),a.push(this._geo.endPoint));break;case zt.MidPoint:this.closed||a.push(this._geo.midPoint);break;case zt.Quadrant:this.closed&&(a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3)));break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){return t.ellipticalArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbEllipse"),t.writePoint3d(10,this.center),t.writePoint3d(11,{x:this.majorAxisRadius,y:0,z:0}),t.writeVector3d(210,this.normal),t.writeDouble(40,this.minorAxisRadius/this.majorAxisRadius),t.writeDouble(41,this.startAngle),t.writeDouble(42,this.endAngle),this}};Co.typeName="Ellipse";let Bi=Co;const Bo=class Bo extends Le{constructor(){super(),this._vertices=[new G,new G,new G],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 G),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 Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=this._vertices.length,s=new Float32Array(e*3),a=new Uint16Array(e*2);for(let h=0;h<e;h++)s[h*3]=this._vertices[h].x,s[h*3+1]=this._vertices[h].y,s[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(a[h*2]=h,a[h*2+1]=(h+1)%4);return t.lineSegments(s,3,a)}dxfOutFields(t){super.dxfOutFields(t);const e=this.getVertexAt(0),s=this.getVertexAt(1),a=this.getVertexAt(2),h=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,s),t.writePoint3d(12,a),t.writePoint3d(13,h);let u=0;for(let p=0;p<4;++p)this.isEdgeVisibleAt(p)||(u|=1<<p);return t.writeInt16(70,u),this}};Bo.typeName="Face";let Ri=Bo;var Qs=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(Qs||{}),tu=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(tu||{});const Ro=class Ro extends Le{constructor(){super(),this._elevation=0,this._geo=new ia,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(t){this._isSolidFill=t}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:Qs[0],value:0},{label:Qs[1],value:1},{label:Qs[2],value:2}],accessor:{get:()=>this.patternType,set:t=>{this.patternType=t}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:t=>{this.patternName=t}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:t=>{this.patternAngle=t}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:t=>{this.patternScale=t}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){const e=t.subEntityTraits;return e.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,definitionLines:this.definitionLines},t.area(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=this._geo.loops;return t.writeSubclassMarker("AcDbHatch"),t.writePoint3d(10,{x:0,y:0,z:this.elevation}),t.writeVector3d(210,{x:0,y:0,z:1}),t.writeString(2,this.patternName||(this.isSolidFill?"SOLID":"USER")),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,0),t.writeInt16(91,e.length),e.forEach((s,a)=>{const h=a===0;if(s instanceof un){const u=s.vertices,p=u.some(f=>(f.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,p?1:0),t.writeInt16(73,s.closed?1:0),t.writeInt16(93,u.length);for(const f of u)t.writePoint2d(10,f),p&&t.writeDouble(42,f.bulge??0);t.writeInt16(97,0);return}if(s instanceof oa){const u=h?1:0;t.writeInt16(92,u),t.writeInt16(93,s.numberOfEdges);for(const p of s.curves){if(p instanceof ts){t.writeInt16(72,1),t.writePoint2d(10,p.startPoint),t.writePoint2d(11,p.endPoint);continue}if(p instanceof Nn){t.writeInt16(72,2),t.writePoint2d(10,p.center),t.writeDouble(40,p.radius),t.writeAngle(50,p.startAngle),t.writeAngle(51,p.endAngle),t.writeInt16(73,p.clockwise?0:1);continue}if(p instanceof li){t.writeInt16(72,3),t.writePoint2d(10,p.center);const v=new Et(p.majorAxisRadius*Math.cos(p.rotation),p.majorAxisRadius*Math.sin(p.rotation));t.writePoint2d(11,v);const f=p.majorAxisRadius===0?0:p.minorAxisRadius/p.majorAxisRadius;t.writeDouble(40,f),t.writeAngle(50,p.startAngle),t.writeAngle(51,p.endAngle),t.writeInt16(73,p.clockwise?0:1);continue}if(p instanceof Gr){const v=p.knots,f=p.controlPoints,x=p.weights,w=p.fitPoints,A=x.some(k=>k!==1);t.writeInt16(72,4),t.writeInt16(94,p.degree),t.writeInt16(73,A?1:0),t.writeInt16(74,p.closed?1:0),t.writeInt16(95,v.length),t.writeInt16(96,f.length),v.forEach(k=>t.writeDouble(40,k)),f.forEach((k,L)=>{t.writePoint2d(10,k),A&&t.writeDouble(42,x[L]??1)}),t.writeInt16(97,(w==null?void 0:w.length)??0),w==null||w.forEach(k=>t.writePoint2d(11,k))}}t.writeInt16(97,0)}}),t.writeInt16(75,this.hatchStyle),t.writeInt16(76,this.patternType),t.writeAngle(52,this.patternAngle),t.writeDouble(41,this.patternScale),t.writeInt16(77,0),t.writeInt16(78,this.definitionLines.length),this.definitionLines.forEach(s=>{t.writeAngle(53,s.angle),t.writePoint2d(43,s.base),t.writePoint2d(45,s.offset),t.writeInt16(79,s.dashLengths.length),s.dashLengths.forEach(a=>t.writeDouble(49,a))}),t.writeInt16(98,0),this}};Ro.typeName="Hatch";let ei=Ro;var eu=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(eu||{});const Fo=class Fo extends Oe{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get vertices(){return this._vertices.map(t=>t.clone())}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new G().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Nt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}subWorldDraw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e)}else return t.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Gr(this._vertices,"Uniform"),this._updated=!1)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLeader"),t.writeString(3,this.dimensionStyle),t.writeInt16(71,this.hasArrowHead?1:0),t.writeInt16(72,this.annoType),t.writeInt16(73,this.hasHookLine?1:0),t.writeInt16(74,this.isSplined?1:0),t.writeInt16(76,this.numVertices);for(const e of this.vertices)t.writePoint3d(10,e);return this}};Fo.typeName="Leader";let Fi=Fo;const zo=class zo extends Oe{constructor(t,e){super(),this._geo=new es(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,a){const h=this.startPoint,u=this.endPoint;switch(t){case zt.EndPoint:a.push(h),a.push(u);break;case zt.MidPoint:a.push(this.midPoint);break;case zt.Nearest:{const p=this._geo.project(e);a.push(p)}break;case zt.Perpendicular:{const p=this._geo.perpPoint(e);a.push(p)}break;case zt.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,s=this.endPoint,a=[new G(e.x,e.y,0),new G(s.x,s.y,0)];return t.lines(a)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),t.writePoint3d(10,this.startPoint),t.writePoint3d(11,this.endPoint),this}};zo.typeName="Line";let ri=zo;const Vo=class Vo extends Le{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new G,this._attachmentPoint=Pe.TopLeft,this._direction=new q(1,0,0),this._drawingDirection=Ur.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Nt}subGetOsnapPoints(t,e,s,a){zt.Insertion===t&&a.push(this._location)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:Pe[1],value:1},{label:Pe[2],value:2},{label:Pe[3],value:3},{label:Pe[4],value:4},{label:Pe[5],value:5},{label:Pe[6],value:6},{label:Pe[7],value:7},{label:Pe[8],value:8},{label:Pe[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Ur[1],value:1},{label:Ur[2],value:2},{label:Ur[3],value:3},{label:Ur[4],value:4},{label:Ur[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt(ne)||t.getAt(ne)),e.textStyle}subWorldDraw(t,e){const s={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor};return t.mtext(s,this.getTextStyle(),e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMText"),t.writePoint3d(10,this.location),t.writeDouble(40,this.height),t.writeDouble(41,this.width),t.writeString(1,this.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}};Vo.typeName="MText";let ni=Vo;const jo=class jo extends Oe{constructor(t,e,s,a,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(u<2||u>5)throw Ze.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Gr(t,e,s,a):this._geo=new Gr(t,e,s,a,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(this._geo.startPoint),a.push(this._geo.endPoint);break}}subWorldDraw(t){const e=this._geo.getPoints(100);return t.lines(e)}dxfOutFields(t){var s;const e=this._geo;super.dxfOutFields(t),t.writeSubclassMarker("AcDbSpline"),t.writeInt16(70,this.closed?1:0),t.writeInt16(71,e.degree),t.writeInt16(72,e.knots.length),t.writeInt16(73,e.controlPoints.length),t.writeInt16(74,((s=e.fitPoints)==null?void 0:s.length)??0);for(const a of e.knots)t.writeDouble(40,a);for(const a of e.weights)t.writeDouble(41,a);for(const a of e.controlPoints)t.writePoint3d(10,a);for(const a of e.fitPoints??[])t.writePoint3d(11,a);return this}};jo.typeName="Spline";let si=jo;const Ed=new q,Do=class Do extends Ln{constructor(t,e,s){super(t),this._attachmentPoint=Pe.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Nt}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){let e=0,s=0;const a=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let u=0;for(let A=0;A<=this.numRows;A++){e-=A>0?this.rowHeight(A-1):0,s=0;for(let k=0;k<=this.numColumns;k++)s+=k>0?this.columnWidth(k-1):0,h[u++]=s,h[u++]=e,h[u++]=0}const p=[],v=new Array(this.numRows*this.numColumns).fill(!1);s=0,u=0;let f=0;for(let A=0;A<this.numColumns;A++){s+=A>0?this.columnWidth(A-1):0,e=0;for(let k=0;k<this.numRows;k++){e+=k>0?this.rowHeight(k-1):0;const L=this.cell(k*this.numColumns+A);if(f=k*this.numColumns+A,L&&!v[f]){const C=L.borderWidth??1,V=L.borderHeight??1;this.fillVisited(v,f,this.numColumns,C,V),a[u++]=A+k*(this.numColumns+1),a[u++]=A+k*(this.numColumns+1)+C;const z=h[a[u-1]*3]-s,at=A+(k+V)*(this.numColumns+1)+C;A+C==this.numColumns&&(a[u++]=A+k*(this.numColumns+1)+C,a[u++]=at);const _t=-h[at*3+1]-e;if(k+V==this.numRows&&(a[u++]=A+(k+V)*(this.numColumns+1)+V,a[u++]=A+(k+V)*(this.numColumns+1)),a[u++]=A+(k+V)*(this.numColumns+1),a[u++]=A+k*(this.numColumns+1),L.text){const st=L.attachmentPoint||this.attachmentPoint||Pe.MiddleCenter,H=this.getTableTextOffset(st,z,_t),dt={text:L.text,height:L.textHeight,width:z,position:Ed.set(s,-e,0).clone().add(H),rotation:this.rotation,attachmentPoint:st},it=this.getTextStyle(L);p.push(t.mtext(dt,it))}}}}p.push(t.lineSegments(h,3,a));const x=t.group(p),w=new Cn;return w.setFromAxisAngle(q.Z_AXIS,this.rotation),Tl.compose(this.position,w,this.scaleFactors),x.applyMatrix(Tl),x}fillVisited(t,e,s,a,h){if(h==1&&a==1)t[e]=!0;else for(let u=0;u<a;++u)for(let p=0;p<h;++p)t[e+u+p*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let s;return t.textStyle&&(s=e.getAt(t.textStyle)),s||(s=e.getAt(ne)||e.getAt(ne)),s.textStyle}getTableTextOffset(t,e,s){const a=new q;switch(t){case 1:break;case 2:a.setX(e/2);break;case 3:a.setX(e);break;case 4:a.setY(-s/2);break;case 5:a.set(e/2,-s/2,0);break;case 6:a.set(e,-s/2,0);break;case 7:a.setY(-s);break;case 8:a.set(e/2,-s,0);break;case 9:a.set(e,-s,0);break}return a}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable"),t.writeInt16(71,this.attachmentPoint),t.writeInt32(91,this.numRows),t.writeInt32(92,this.numColumns);for(let e=0;e<this.numRows;++e)t.writeDouble(141,this.rowHeight(e));for(let e=0;e<this.numColumns;++e)t.writeDouble(142,this.columnWidth(e));return this}};Do.typeName="Table";let zi=Do;const Tl=new $e,Uo=class Uo extends Oe{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new G,new G,new G,new G]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=new un(this._vertices,!0),s=new ia;s.add(e);const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(s)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTrace"),t.writeDouble(38,this.elevation),t.writeDouble(39,this.thickness),t.writePoint3d(10,this.getPointAt(0)),t.writePoint3d(11,this.getPointAt(1)),t.writePoint3d(12,this.getPointAt(2)),t.writePoint3d(13,this.getPointAt(3)),this}};Uo.typeName="Trace";let Vi=Uo;const Go=class Go extends Oe{constructor(){super(),this._elevation=0,this._geo=new un}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,a=-1,h=-1){const u=a<0?void 0:a,p=h<0?void 0:h,v={x:e.x,y:e.y,bulge:s,startWidth:u,endWidth:p};this._geo.addVertexAt(t,v)}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 G(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}subGetOsnapPoints(t,e,s,a){const h=new Array;for(let u=0;u<this.numberOfVertices;++u)h.push(this.getPoint3dAt(u));switch(t){case zt.EndPoint:a.push(...h);break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyline"),t.writeInt32(90,this.numberOfVertices),t.writeInt16(70,this.closed?1:0),t.writeDouble(38,this.elevation);for(let e=0;e<this.numberOfVertices;++e)t.writePoint2d(10,this.getPoint2dAt(e));return this}};Go.typeName="Polyline";let ji=Go;const Wo=class Wo extends Le{constructor(){super(),this._geo=new G}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Nt().expandByPoint(this._geo)}subGetOsnapPoints(t,e,s,a){zt.Node===t&&a.push(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}subWorldDraw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbPoint"),t.writePoint3d(10,this.position),this}};Wo.typeName="Point";let Di=Wo;var ru=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(ru||{}),nu=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(nu||{});const Ho=class Ho extends Le{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new G,this._scale=new te(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.objects.imageDefinition.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Nt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}subWorldDraw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,a=new ve;a.setFromPoints(this._clipBoundary);const h=new Et;h.setX(this._position.x-a.min.x*e),h.setY(this._position.y-a.min.y*s),this._clipBoundary.forEach(u=>{const p=u.x*e+h.x,v=u.y*s+h.y;t.push(new G(p,v,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){Nl.copy(t[1]);for(let e=1;e<4;e++)yi.copy(t[e]),yi.rotateAround(Nl,this._rotation),t[e].setX(yi.x),t[e].setY(yi.y)}t.push(t[0])}return t}dxfOutFields(t){if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImage"),t.writePoint3d(10,this.position),t.writePoint3d(11,{x:this.width*this.scale.x,y:0,z:0}),t.writePoint3d(12,{x:0,y:this.height*this.scale.y,z:0}),t.writeObjectId(340,this.imageDefId),t.writeInt16(70,this.isImageShown?1:0),t.writeInt16(280,this.clipBoundaryType),t.writeInt16(281,this.isClipped?1:0),t.writeInt16(282,this.isImageTransparent?1:0),t.writeInt16(283,this.brightness),t.writeInt16(360,this.contrast),t.writeInt16(361,this.fade),this.isClipped){t.writeInt16(91,this.clipBoundary.length);for(const e of this.clipBoundary)t.writePoint2d(14,e)}return this}};Ho.typeName="RasterImage";let ii=Ho;const Nl=new Et,yi=new Et,Yo=class Yo extends Oe{constructor(){super(),this._basePoint=new G,this._unitDir=new q}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(this.basePoint);break}}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRay"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}};Yo.typeName="Ray";let Ui=Yo;const Xo=class Xo extends Le{constructor(){super(),this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new Nt}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 qh;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),s.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),s}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewport"),t.writePoint3d(10,this.centerPoint),t.writeDouble(40,this.height),t.writeDouble(41,this.width),t.writePoint3d(12,this.viewCenter),t.writeDouble(45,this.viewHeight),t.writeInt32(69,this.number),this}};Xo.typeName="Viewport";let Gi=Xo;const qo=class qo extends ii{subWorldDraw(t){const e=this.boundaryPath(),s=new ia;return s.add(new un(e)),t.area(s)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbWipeout"),this}};qo.typeName="Wipeout";let Wi=qo;const Ko=class Ko extends Oe{constructor(){super(),this._basePoint=new G,this._unitDir=new q}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subWorldDraw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXline"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}};Ko.typeName="Xline";let Hi=Ko;var su=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(su||{});const $o=class $o extends Le{constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new G,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new G,this._textRotation=0,this._normal=new q(0,0,1)}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(t)}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new On),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}subWorldDraw(t){if(this.dimBlockId){const s=this.database.tables.blockTable.getAt(this.dimBlockId);if(s){const a=this.computeDimBlockTransform();return is.instance.draw(t,s,this.rgbColor,[],!1,a,this._normal)}}return t.group([])}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,s){const a=new G().subVectors(e,t).normalize();return new G(e).addScaledVector(a,s)}findPointOnLine2(t,e,s){const a=t.x+s*Math.cos(e),h=t.y+s*Math.sin(e);return{x:a,y:h}}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():co.Closed}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??G.ORIGIN,s=new $e().makeTranslation(-e.x,-e.y,-e.z),a=new $e().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new $e().multiplyMatrices(a,s)}dxfOutFields(t){super.dxfOutFields(t);const e=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return t.writeSubclassMarker("AcDbDimension"),t.writeString(3,this.dimensionStyleName??this.dimensionStyle.name),t.writePoint3d(10,this.dimBlockPosition),t.writeString(1,this.dimensionText??""),t.writeAngle(53,this.textRotation),t.writePoint3d(11,this.textPosition),t.writeInt16(70,0),t.writeVector3d(210,this.normal),t.writeObjectId(340,e==null?void 0:e.objectId),this}};$o.typeName="Dimension";let Wr=$o;const Zo=class Zo extends Wr{constructor(t,e,s,a,h=null,u=null){super(),this._centerPoint=new G().copy(t),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(s),this._arcPoint=new G().copy(a),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Nt}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}};Zo.typeName="3PointAngularDimension";let Yi=Zo;const Qo=class Qo extends Wr{constructor(t,e,s,a=null,h=null){super(),this._dimLinePoint=new G().copy(s),this._xLine1Point=new G().copy(t),this._xLine2Point=new G().copy(e),this._oblique=0,this._rotation=0,this.calculateRotation(),a?this.dimensionText=a:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new Nt}get isAppendArrow(){return!1}createDimBlock(t){const e=new ue;e.name=t;const s=this.createLines();s.forEach(p=>e.appendEntity(new ri(p.startPoint,p.endPoint))),this.createArrows(s[0]).forEach(p=>e.appendEntity(p));const h=s[0].midPoint,u=this.createMText(h,this._rotation);return u&&e.appendEntity(u),e}createMText(t,e){const s=a=>({x:Math.cos(a),y:Math.sin(a),z:0});if(this.dimensionText){const a=new ni;return a.attachmentPoint=Pe.MiddleLeft,a.layer="0",a.color=new ce(lt.ByBlock),a.location=t,a.contents=this.dimensionText??"",a.height=10,a.direction=s(e),a.styleName=this.dimensionStyle.dimtxsty,a}}createArrows(t){const e=[];return e.push(this.createArrow(t.startPoint,this.rotation+Math.PI,10)),e.push(this.createArrow(t.endPoint,this.rotation,10)),e}createArrow(t,e,s){const a="_CAXARROW",h=new Ln(a);return h.position=t,h.rotation=e,h.scaleFactors={x:s,y:s,z:s},h}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),a=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),u=new es(a,h);return t.push(u),e.endPoint=a,this.adjustExtensionLine(e),t.push(e),s.endPoint=h,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new es(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,a=t.endPoint,h=new q().subVectors(a,s).normalize(),p=new q().subVectors(e,s).dot(h),v=new q().copy(h).multiplyScalar(p);return new q().addVectors(s,v)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,s=e.x-t.x,a=e.y-t.y;this._rotation=Math.atan2(a,s)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAlignedDimension"),t.writePoint3d(13,this.xLine1Point),t.writePoint3d(14,this.xLine2Point),t.writePoint3d(15,this.dimLinePoint),t.writeAngle(50,this.rotation),t.writeAngle(52,this.oblique),this}};Qo.typeName="AlignedDimension";let Xi=Qo;const Jo=class Jo extends Wr{constructor(t,e,s,a,h=null,u=null){super(),this._arcPoint=new G().copy(a),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(s),this._centerPoint=new G().copy(t),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Nt}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}};Jo.typeName="ArcDimension";let Ua=Jo;const tl=class tl extends Wr{constructor(t,e,s=0,a=null,h=null){super(),this._chordPoint=new G().copy(t),this._farChordPoint=new G().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=a,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Nt}drawLines(t,e){const s=[],a=e.length;return a==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):a==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{s.push(this.drawLine(t,h))}),s}drawLine(t,e,s){if(s){const a=[e.startPoint,e.endPoint];return t.lines(a)}else return e.worldDraw(t)}sortLines(t){const e=(s,a)=>s.x!==a.x?s.x-a.x:s.y!==a.y?s.y-a.y:s.z-a.z;t.sort((s,a)=>{const h=e(s.startPoint,a.startPoint);return h!==0?h:e(s.endPoint,a.endPoint)})}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbDiametricDimension"),t.writePoint3d(15,this.chordPoint),t.writePoint3d(16,this.farChordPoint),t.writeDouble(40,this.leaderLength),t.writeAngle(52,this.extArcStartAngle),t.writeAngle(53,this.extArcEndAngle),this}};tl.typeName="DiametricDimension";let qi=tl;const el=class el extends Wr{constructor(t,e,s=null,a=null){super(),this._definingPoint=new G().copy(t),this._leaderEndPoint=new G().copy(e),this.dimensionText=s,this.dimensionStyleName=a}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new Nt}get arrowLineCount(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbOrdinateDimension"),t.writePoint3d(13,this.definingPoint),t.writePoint3d(14,this.leaderEndPoint),this}};el.typeName="OrdinateDimension";let Ki=el;const rl=class rl extends Wr{constructor(t,e,s,a=null,h=null){super(),this._center=new G().copy(t),this._chordPoint=new G().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=a,this.dimensionStyleName=h}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new Nt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRadialDimension"),t.writePoint3d(15,this.center),t.writePoint3d(13,this.chordPoint),t.writeDouble(40,this.leaderLength),t.writeAngle(52,this.extArcStartAngle),t.writeAngle(53,this.extArcEndAngle),this}};rl.typeName="RadialDimension";let $i=rl;class dn extends Hr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}add(t){t.database=this.database,t.ownerId=this.objectId;const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),s=this._recordsByName.get(e);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this._recordsById.has(t)}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new ui(this._recordsByName)}normalizeName(t){return t}}class iu extends dn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(ue.MODEL_SPACE_NAME);return t||(t=new ue,t.name=ue.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){for(const e of this.database.tables.blockTable.newIterator()){const s=e.getIdAt(t);if(s)return s}}removeEntity(t){let e=!1;for(const s of this.database.tables.blockTable.newIterator())if(s.removeEntity(t)){e=!0;break}return e}normalizeName(t){let e=t;if(ue.isModelSapceName(t))e=ue.MODEL_SPACE_NAME;else if(ue.isPaperSapceName(t)){const s=ue.PAPER_SPACE_NAME_PREFIX,a=t.substring(s.length);e=s+a}return e}}class au extends dn{constructor(t){super(t)}}var ou=(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))(ou||{}),lu=(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))(lu||{}),hu=(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))(hu||{}),uu=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(uu||{}),cu=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(cu||{});const ta=class ta extends cn{constructor(t,e){t=t||{},ns(t,ta.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}dxfOutFields(t){super.dxfOutFields(t);const e=this.database.tables.textStyleTable.getAt(this.dimtxsty),s=this.database.tables.blockTable.getAt(this.dimldrblk),a=this.database.tables.blockTable.getAt(this.dimblk),h=this.database.tables.blockTable.getAt(this.dimblk1),u=this.database.tables.blockTable.getAt(this.dimblk2);return t.writeSubclassMarker("AcDbDimStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeString(3,this.dimpost),t.writeString(4,this.dimapost),t.writeDouble(40,this.dimscale),t.writeDouble(41,this.dimasz),t.writeDouble(42,this.dimexo),t.writeDouble(43,this.dimdli),t.writeDouble(44,this.dimexe),t.writeDouble(140,this.dimtxt),t.writeDouble(147,this.dimgap),t.writeInt16(170,this.dimalt),t.writeInt16(171,this.dimtol),t.writeInt16(172,this.dimlim),t.writeInt16(173,this.dimtih),t.writeInt16(174,this.dimtoh),t.writeObjectId(340,e==null?void 0:e.objectId),t.writeObjectId(341,s==null?void 0:s.objectId),t.writeObjectId(342,a==null?void 0:a.objectId),t.writeObjectId(343,h==null?void 0:h.objectId),t.writeObjectId(344,u==null?void 0:u.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}};ta.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:ne,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let On=ta;class ci extends cn{constructor(t,e){t=t||{},ns(t,{color:new ce,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new na,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeCmColor(this.color),t.writeString(6,this.linetype),t.writeInt16(290,this.isPlottable?1:0),t.writeInt16(370,this.lineWeight),t.writeTransparency(this.transparency),this.description&&t.writeString(4,this.description),this}}class du extends dn{constructor(t){super(t);const e=new ce,s=new ci({name:"0",standardFlags:0,linetype:Ti,lineWeight:hn.ByLineWeightDefault,isOff:!1,color:e,isPlottable:!0});this.add(s)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class pu extends dn{constructor(t){super(t)}}class ln extends cn{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLinetypeTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.linetype.standardFlag),t.writeString(3,this.comments),t.writeInt16(72,65),t.writeInt16(73,this.numDashes),t.writeDouble(40,this.patternLength);for(const e of this.linetype.pattern??[])t.writeDouble(49,e.elementLength),t.writeInt16(74,e.elementTypeFlag);return this}}class mu extends dn{constructor(t){super(t)}get fonts(){const t=new Set,e=a=>{if(a){const h=a.lastIndexOf(".");if(h>=0){const u=a.substring(0,h).toLowerCase();t.add(u)}else t.add(a.toLowerCase())}},s=this.newIterator();for(const a of s)e(a.fileName),e(a.bigFontFileName);return Array.from(t)}}class la extends cn{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTextStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.textStyle.standardFlag),t.writeDouble(40,this.textSize),t.writeDouble(41,this.xScale),t.writeAngle(50,this.obliquingAngle),t.writeInt16(71,this.isVertical?4:this.textStyle.textGenerationFlag),t.writeDouble(42,this.priorSize),t.writeString(3,this.fileName),t.writeString(4,this.bigFontFileName),this}}class gu extends dn{constructor(t){super(t)}}const kd={center:new Et,viewDirectionFromTarget:new G(0,0,1),viewTarget:new G(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:po.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new G(0,0,0),ucsXAxis:new G(1,0,0),ucsYAxis:new G(0,1,0),orthographicType:mo.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:go.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class _o extends cn{constructor(){super(),this._circleSides=100,this._center=new Et,this._lowerLeftCorner=new Et(0,0),this._upperRightCorner=new Et(1,1),this._snapBase=new Et(0,0),this._snapAngle=0,this._snapSpacing=new Et(0,0),this._standardFlag=0,this._gridSpacing=new Et,this._gridMajor=10,this._gsView=kd}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewportTableRecord"),t.writeString(2,this.name),t.writeDouble(45,this.gsView.viewHeight),t.writePoint2d(10,this.lowerLeftCorner),t.writePoint2d(11,this.upperRightCorner),t.writePoint2d(12,this.center),t.writePoint2d(13,this.snapBase),t.writePoint2d(14,this.snapIncrements),t.writePoint2d(15,this.gridIncrements),t.writeInt16(70,this.standardFlag),t.writeInt16(71,this.circleSides),t.writeDouble(42,this.gsView.lensLength),t.writePoint3d(16,this.gsView.viewDirectionFromTarget),t.writePoint3d(17,this.gsView.viewTarget),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.gsView.viewTwistAngle),t.writeInt16(61,this.gridMajor),t.writeInt16(281,this.backgroundObjectId?1:0),t.writeObjectId(332,this.backgroundObjectId),this}}class _u extends dn{constructor(t){super(t)}}class fu extends cn{constructor(t){super(),this.name=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRegAppTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),this}}const jt={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",CECOLOR:"CECOLOR",CELTSCALE:"CELTSCALE",CELWEIGHT:"CELWEIGHT",CLAYER:"CLAYER",COLORTHEME:"COLORTHEME",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",INSUNITS:"INSUNITS",LTSCALE:"LTSCALE",LWDISPLAY:"LWDISPLAY",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",OSMODE:"OSMODE",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",TEXTSTYLE:"TEXTSTYLE",WHITEBKCOLOR:"WHITEBKCOLOR"},Md=Object.freeze(Object.values(jt)),ea=class ea{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new he},this.registerVar({name:jt.CECOLOR,type:"color",isDbVar:!0,defaultValue:new ce(lt.ByLayer)}),this.registerVar({name:jt.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:jt.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:hn.ByLayer}),this.registerVar({name:jt.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:jt.COLORTHEME,type:"number",isDbVar:!1,defaultValue:"0"}),this.registerVar({name:jt.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:jt.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new ce(lt.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:jt.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:jt.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:jt.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:ne}),this.registerVar({name:jt.WHITEBKCOLOR,type:"boolean",isDbVar:!1,defaultValue:!1})}static instance(){return this._instance||(this._instance=new ea),this._instance}registerVar(t){const e=this.normalizeName(t.name);this.registry.set(e,{...t,name:e}),t.isDbVar||this.cache.set(e,t.defaultValue)}registerMany(t){t.forEach(e=>this.registerVar(e))}getVar(t,e){t=this.normalizeName(t);const s=this.getDescriptor(t);if(s){if(s.isDbVar)return e[t.toLowerCase()];if(this.cache.has(t))return this.cache.get(t)}}setVar(t,e,s){t=this.normalizeName(t);const a=this.getDescriptor(t);if(a){const h=this.getVar(t,s);if(a.type!=="string"&&(typeof e=="string"||e instanceof String)){if(a.type==="number"){const u=Number(e);if(Number.isNaN(u))throw new Error("Invalid number input!");e=u}else if(a.type==="boolean")e=this.parseBoolean(e);else if(a.type==="color"){const u=ce.fromString(e);if(u==null)throw new Error("Invalid color value!");e=u}}a.isDbVar?s[t.toLowerCase()]=e:(this.cache.set(t,e),this.hasValueChanged(h,e)&&this.events.sysVarChanged.dispatch({database:s,name:t,newVal:e,oldVal:h}))}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(this.normalizeName(t))}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),s=new Set(["true","t","1","yes","y"]),a=new Set(["false","f","0","no","n"]);return s.has(e)?!0:(a.has(e),!1)}hasValueChanged(t,e){return t instanceof ce&&e instanceof ce?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};ea._instance=null;let Zi=ea;const ra=class ra extends Hr{constructor(){super(),this.events={dictObjetSet:new he,dictObjectErased:new he,entityAppended:new he,entityModified:new he,entityErased:new he,layerAppended:new he,layerModified:new he,layerErased:new he,openProgress:new he},this._version=new er("AC1014"),this._angBase=0,this._angDir=0,this._aunits=oo.DecimalDegrees,this._celtscale=1,this._cecolor=new ce,this._celweight=hn.ByLayer,this._clayer="0",this._textstyle=ne,this._extents=new Nt,this._insunits=uo.Millimeters,this._ltscale=1,this._lwdisplay=!0,this._pdmode=0,this._pdsize=0,this._osmode=0,this._tables={appIdTable:new _u(this),blockTable:new iu(this),dimStyleTable:new au(this),linetypeTable:new pu(this),textStyleTable:new mu(this),layerTable:new du(this),viewportTable:new gu(this)},this._objects={dictionary:new $s(this),imageDefinition:new $s(this),layout:new Uh(this),xrecord:new $s(this)},this._tables.appIdTable.add(new fu(ra.MLIGHTCAD_APPID))}get tables(){return this._tables}get objects(){return this._objects}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(jt.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get version(){return this._version}set version(t){this.updateSysVar(jt.ACADVER,this._version,new er(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(jt.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(jt.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}set lwdisplay(t){this.updateSysVar(jt.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(jt.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(jt.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(jt.CELWEIGHT,this._celweight,t??hn.ByLayer,e=>{this._celweight=e})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(jt.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(jt.TEXTSTYLE,this._textstyle,t??ne,e=>{this._textstyle=e})}get angBase(){return this._angBase}set angBase(t){this.updateSysVar(jt.ANGBASE,this._angBase,t??0,e=>{this._angBase=e})}get angDir(){return this._angDir}set angDir(t){this.updateSysVar(jt.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(jt.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(jt.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(jt.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(jt.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(jt.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}async read(t,e,s=Xs.DXF){const a=vr.instance.get(s);if(a==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await a.read(t,this,e&&e.minimumChunkSize||10,async(h,u,p,v)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:u,subStageStatus:p,data:v}),e&&e.fontLoader&&u=="FONT"&&p=="END"){const f=v||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}},e==null?void 0:e.timeout)}async openUri(t,e){var k;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const s=await fetch(t);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${s.status}'!`);const a=s.headers.get("content-length"),h=a?parseInt(a,10):null;let u=0;const p=(k=s.body)==null?void 0:k.getReader();if(!p)throw new Error("Failed to get response reader");const v=[];for(;;){const{done:L,value:C}=await p.read();if(L)break;if(v.push(C),u+=C.length,h!==null){const V=Math.round(u/h*100);this.events.openProgress.dispatch({database:this,percentage:V,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(u);let x=0;for(const L of v)f.set(L,x),x+=L.length;const A=this.getFileNameFromUri(t).toLowerCase().split(".").pop();A==="dwg"?await this.read(f.buffer,e,Xs.DWG):A==="dxf"?await this.read(f.buffer,e,Xs.DXF):await this.read(f.buffer,e,A),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(t,e=16,s=this.version.name,a=!1){this.ensureDxfExportDefaults();const h=s instanceof er?s:new er(s),u=new Vl({database:this,precision:e,version:h});return this.writeDxfHeaderSection(u),this.writeDxfTablesSection(u,h),this.writeDxfBlocksSection(u),this.writeDxfEntitiesSection(u),this.writeDxfObjectsSection(u),u.writeStart("EOF"),u.toString()}async regen(){await new Lc(this).read(null,this,500,async(e,s,a,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:s,subStageStatus:a,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Yh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureDxfExportDefaults(){if(!this.tables.layerTable.has("0")){const e=new ce;e.colorIndex=7,this.tables.layerTable.add(new ci({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has("ByBlock")||this.tables.linetypeTable.add(new ln({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has("ByLayer")||this.tables.linetypeTable.add(new ln({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has("Continuous")||this.tables.linetypeTable.add(new ln({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0})),this.tables.textStyleTable.has(ne)||this.tables.textStyleTable.add(new la({name:ne,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),this.tables.dimStyleTable.has(ne)||this.tables.dimStyleTable.add(new On({name:ne,dimtxsty:ne})),!this.tables.viewportTable.has("*ACTIVE")){const e=new _o;e.name="*ACTIVE",this.tables.viewportTable.add(e)}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}}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,"$INSUNITS"),t.writeInt16(70,this.insunits),t.writeString(9,"$LTSCALE"),t.writeDouble(40,this.ltscale),t.writeString(9,"$LWDISPLAY"),t.writeInt16(70,this.lwdisplay?1:0),t.writeString(9,"$CLAYER"),t.writeString(8,this.clayer),t.writeString(9,"$TEXTSTYLE"),t.writeString(7,this.textstyle),t.writeString(9,"$ANGBASE"),t.writeAngle(50,this.angBase),t.writeString(9,"$ANGDIR"),t.writeInt16(70,this.angDir),t.writeString(9,"$EXTMIN"),t.writePoint3d(10,this.extmin),t.writeString(9,"$EXTMAX"),t.writePoint3d(10,this.extmax),t.writeString(9,"$PDMODE"),t.writeInt32(70,this.pdmode),t.writeString(9,"$PDSIZE"),t.writeDouble(40,this.pdsize),t.writeString(9,"$OSMODE"),t.writeInt32(70,this.osmode),t.endSection()}writeDxfTablesSection(t,e){t.startSection("TABLES"),this.writeDxfTable(t,"VPORT",this.tables.viewportTable.newIterator(),"VPORT"),this.writeDxfTable(t,"LTYPE",this.tables.linetypeTable.newIterator(),"LTYPE"),this.writeDxfTable(t,"LAYER",this.tables.layerTable.newIterator(),"LAYER"),this.writeDxfTable(t,"STYLE",this.tables.textStyleTable.newIterator(),"STYLE"),this.writeDxfTable(t,"APPID",this.tables.appIdTable.newIterator(),"APPID"),this.writeDxfTable(t,"DIMSTYLE",this.tables.dimStyleTable.newIterator(),"DIMSTYLE"),e.value>=19&&this.writeDxfTable(t,"BLOCK_RECORD",this.tables.blockTable.newIterator(),"BLOCK_RECORD"),t.endSection()}writeDxfBlocksSection(t){t.startSection("BLOCKS");for(const e of this.tables.blockTable.newIterator()){if(e.dxfOutBlockBegin(t),!e.isModelSapce&&!e.isPaperSapce)for(const s of e.newIterator())this.writeDxfEntity(t,s);e.dxfOutBlockEnd(t)}t.endSection()}writeDxfEntitiesSection(t){t.startSection("ENTITIES");for(const e of this.tables.blockTable.newIterator())if(!(!e.isModelSapce&&!e.isPaperSapce))for(const s of e.newIterator())this.writeDxfEntity(t,s);t.endSection()}writeDxfObjectsSection(t){t.startSection("OBJECTS"),this.objects.layout.ownerId=this.objects.dictionary.objectId,this.objects.imageDefinition.ownerId=this.objects.dictionary.objectId,this.objects.xrecord.ownerId=this.objects.dictionary.objectId,t.writeStart("DICTIONARY"),t.writeHandle(5,this.objects.dictionary.objectId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(281,1),t.writeString(3,"ACAD_LAYOUT"),t.writeObjectId(350,this.objects.layout.objectId),this.objects.imageDefinition.numEntries>0&&(t.writeString(3,"ISM_RASTER_IMAGE_DICT"),t.writeObjectId(350,this.objects.imageDefinition.objectId)),this.objects.xrecord.numEntries>0&&(t.writeString(3,"MLIGHT_XRECORD"),t.writeObjectId(350,this.objects.xrecord.objectId)),t.writeStart("DICTIONARY"),this.objects.layout.dxfOut(t),this.objects.imageDefinition.numEntries>0&&(t.writeStart("DICTIONARY"),this.objects.imageDefinition.dxfOut(t)),this.objects.xrecord.numEntries>0&&(t.writeStart("DICTIONARY"),this.objects.xrecord.dxfOut(t));for(const e of this.objects.layout.newIterator())t.writeStart("LAYOUT"),e.dxfOut(t);for(const e of this.objects.imageDefinition.newIterator())t.writeStart("IMAGEDEF"),e.dxfOut(t);for(const e of this.objects.xrecord.newIterator())t.writeStart("XRECORD"),e.dxfOut(t);t.endSection()}writeDxfTable(t,e,s,a){const h=[...s];t.startTable(e,h.length);for(const u of h){if(a==="BLOCK_RECORD"&&u instanceof ue){u.dxfOutBlockRecord(t);continue}t.writeStart(a),u.dxfOut(t)}t.endTable()}writeDxfEntity(t,e){if(t.writeStart(e.dxfEntityTypeName),e.dxfOut(t),e instanceof Js){for(let s=0;s<e.numberOfVertices;++s)t.writeStart("VERTEX"),t.writeHandle(5,`VERTEX:${e.objectId}:${s}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint3d(10,{x:e.getPointAt(s).x,y:e.getPointAt(s).y,z:e.elevation}),t.writeInt16(70,0);t.writeStart("SEQEND"),t.writeHandle(5,`SEQEND:${e.objectId}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity");return}if(e instanceof ti){for(let s=0;s<e.numberOfVertices;++s){const a=e.getPointAt(s);t.writeStart("VERTEX"),t.writeHandle(5,`VERTEX:${e.objectId}:${s}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb3dPolylineVertex"),t.writePoint3d(10,{x:a.x,y:a.y,z:0}),t.writeInt16(70,32)}t.writeStart("SEQEND"),t.writeHandle(5,`SEQEND:${e.objectId}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity");return}if(e instanceof Ln){let s=!1;for(const a of e.attributeIterator())s=!0,t.writeStart("ATTRIB"),a.dxfOut(t);s&&(t.writeStart("SEQEND"),t.writeHandle(5,`SEQEND:${e.objectId}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity"))}}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._objects.layout.removeAll(),this._currentSpace=void 0,this._extents.makeEmpty()}updateSysVar(t,e,s,a){this.hasSysVarValueChanged(e,s)&&(a(s),this.triggerSysVarChangedEvent(t,e,s))}hasSysVarValueChanged(t,e){return t instanceof ce&&e instanceof ce?!t.equals(e):t instanceof er&&e instanceof er?t.value!==e.value:!Object.is(t,e)}triggerSysVarChangedEvent(t,e,s){const a=Zi.instance(),h=t.toLowerCase();a.getDescriptor(h)!=null&&a.events.sysVarChanged.dispatch({database:this,name:h,oldVal:e,newVal:s})}getFileNameFromUri(t){try{const s=new URL(t).pathname.split("/");return s[s.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}};ra.MLIGHTCAD_APPID="mlightcad";let Ga=ra;const yu="Load Database",Ll=3e4,Td=12e4,Nd=1024*1024;class Fe extends Yl{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Ya.getInstance().getEntry(yu),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const a=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",a?a.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-s),a}}class fo{constructor(t={}){this.config=t}async read(t,e,s,a,h){const u={name:yu,data:{total:0},format(){let x="";return Object.keys(this.data).forEach(w=>{w!=="total"&&(x+=`- ${w}: ${this.data[w]} ms
|
|
7
|
-
`)}),x+=`- total: ${this.data.total} ms`,x}};Ya.getInstance().collect(u),this.progress=a;const p={value:0},v=new Xl;v.setCompleteCallback(()=>this.onFinished()),v.setErrorCallback(x=>this.onError(x)),v.addTask(new Fe({stage:"START",step:1,progress:p,task:async x=>x},a)),v.addTask(new Fe({stage:"PARSE",step:5,progress:p,task:async x=>await this.parse(x,h)},a)),v.addTask(new Fe({stage:"FONT",step:5,progress:p,task:async x=>{const w=this.getFonts(x.model);return{model:x.model,data:w}}},a)),v.addTask(new Fe({stage:"LTYPE",step:1,progress:p,task:async x=>(this.processLineTypes(x.model,e),x)},a)),v.addTask(new Fe({stage:"STYLE",step:1,progress:p,task:async x=>(this.processTextStyles(x.model,e),x)},a)),v.addTask(new Fe({stage:"DIMSTYLE",step:1,progress:p,task:async x=>(this.processDimStyles(x.model,e),x)},a)),v.addTask(new Fe({stage:"LAYER",step:1,progress:p,task:async x=>(this.processLayers(x.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),x)},a)),v.addTask(new Fe({stage:"VPORT",step:1,progress:p,task:async x=>(this.processViewports(x.model,e),x)},a)),v.addTask(new Fe({stage:"HEADER",step:1,progress:p,task:async x=>(this.processHeader(x.model,e),x)},a)),v.addTask(new Fe({stage:"BLOCK_RECORD",step:5,progress:p,task:async x=>(this.processBlockTables(x.model,e),x)},a)),v.addTask(new Fe({stage:"OBJECT",step:5,progress:p,task:async x=>(this.processObjects(x.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),x)},a)),v.addTask(new Fe({stage:"BLOCK",step:5,progress:p,task:async x=>(await this.processBlocks(x.model,e),x)},a)),v.addTask(new Fe({stage:"ENTITY",step:100,progress:p,task:async x=>(await this.processEntities(x.model,e,s,p,a),x)},a)),v.addTask(new Fe({stage:"END",step:0,progress:p,task:async x=>x},a));const f=Date.now();await v.run(t),u.data.total=Date.now()-f}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return console.error(`Error occurred in conversion stage '${t.task.name}': `,t.error),t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),is.instance.clear())}getParserWorkerTimeout(t,e){const s=e??this.config.timeout;if(s!=null)return s;const a=Math.ceil(t.byteLength/Nd),h=Ll+a*1e3;return Math.min(Td,Math.max(Ll,h))}async parse(t,e){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,a,h){throw new Error("Not impelemented yet!")}}var _e,ks,re,le,Ms,ur,Ee,Er,cr,vn,Ts,Ns,bn,wn,Ls,Os,Cs,We,kr,Kt,xn,Bs,vt,ke,Rs,Me,Fs,Mr,Tr,dr,zs,In,He,Nr,Sn,Sa,Pa,Lr,Or,Vs,js,Cr,Ds,Aa,Ea,fe,Br,ye,Ye,ka,Ma,Ta,Na,Rr,Xe,Pn,Us,An,qe,Fr,Ke,zr;(_e={})[_e.None=0]="None",_e[_e.Anonymous=1]="Anonymous",_e[_e.NonConstant=2]="NonConstant",_e[_e.Xref=4]="Xref",_e[_e.XrefOverlay=8]="XrefOverlay",_e[_e.ExternallyDependent=16]="ExternallyDependent",_e[_e.ResolvedOrDependent=32]="ResolvedOrDependent",_e[_e.ReferencedXref=64]="ReferencedXref";(ks={})[ks.BYBLOCK=0]="BYBLOCK",ks[ks.BYLAYER=256]="BYLAYER";(re={})[re.Rotated=0]="Rotated",re[re.Aligned=1]="Aligned",re[re.Angular=2]="Angular",re[re.Diameter=3]="Diameter",re[re.Radius=4]="Radius",re[re.Angular3Point=5]="Angular3Point",re[re.Ordinate=6]="Ordinate",re[re.ReferenceIsExclusive=32]="ReferenceIsExclusive",re[re.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",re[re.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(le={})[le.TopLeft=1]="TopLeft",le[le.TopCenter=2]="TopCenter",le[le.TopRight=3]="TopRight",le[le.MiddleLeft=4]="MiddleLeft",le[le.MiddleCenter=5]="MiddleCenter",le[le.MiddleRight=6]="MiddleRight",le[le.BottomLeft=7]="BottomLeft",le[le.BottomCenter=8]="BottomCenter",le[le.BottomRight=9]="BottomRight";(Ms={})[Ms.AtLeast=1]="AtLeast",Ms[Ms.Exact=2]="Exact";var Ol=((ur={})[ur.Center=0]="Center",ur[ur.Above=1]="Above",ur[ur.Outside=2]="Outside",ur[ur.JIS=3]="JIS",ur[ur.Below=4]="Below",ur),$n=((Ee={})[Ee.Feet=0]="Feet",Ee[Ee.None=1]="None",Ee[Ee.Inch=2]="Inch",Ee[Ee.FeetAndInch=3]="FeetAndInch",Ee[Ee.Leading=4]="Leading",Ee[Ee.Trailing=8]="Trailing",Ee[Ee.LeadingAndTrailing=12]="LeadingAndTrailing",Ee),Ld=((Er={})[Er.None=0]="None",Er[Er.Leading=1]="Leading",Er[Er.Trailing=2]="Trailing",Er[Er.LeadingAndTrailing=3]="LeadingAndTrailing",Er),Od=((cr={})[cr.Center=0]="Center",cr[cr.Left=1]="Left",cr[cr.Right=2]="Right",cr[cr.OverFirst=3]="OverFirst",cr[cr.OverSecond=4]="OverSecond",cr),Cd=((vn={})[vn.Bottom=0]="Bottom",vn[vn.Center=1]="Center",vn[vn.Top=2]="Top",vn),Bd=((Ts={})[Ts.PatternFill=0]="PatternFill",Ts[Ts.SolidFill=1]="SolidFill",Ts);(Ns={})[Ns.NonAssociative=0]="NonAssociative",Ns[Ns.Associative=1]="Associative";(bn={})[bn.Normal=0]="Normal",bn[bn.Outer=1]="Outer",bn[bn.Ignore=2]="Ignore";(wn={})[wn.UserDefined=0]="UserDefined",wn[wn.Predefined=1]="Predefined",wn[wn.Custom=2]="Custom";(Ls={})[Ls.NotAnnotated=0]="NotAnnotated",Ls[Ls.Annotated=1]="Annotated";(Os={})[Os.Solid=0]="Solid",Os[Os.Gradient=1]="Gradient";(Cs={})[Cs.TwoColor=0]="TwoColor",Cs[Cs.OneColor=1]="OneColor";var Rd=((We={})[We.Default=0]="Default",We[We.External=1]="External",We[We.Polyline=2]="Polyline",We[We.Derived=4]="Derived",We[We.Textbox=8]="Textbox",We[We.Outermost=16]="Outermost",We),vi=((kr={})[kr.Line=1]="Line",kr[kr.Circular=2]="Circular",kr[kr.Elliptic=3]="Elliptic",kr[kr.Spline=4]="Spline",kr),Fd=((Kt={})[Kt.Off=0]="Off",Kt[Kt.Solid=1]="Solid",Kt[Kt.Dashed=2]="Dashed",Kt[Kt.Dotted=3]="Dotted",Kt[Kt.ShotDash=4]="ShotDash",Kt[Kt.MediumDash=5]="MediumDash",Kt[Kt.LongDash=6]="LongDash",Kt[Kt.DoubleShortDash=7]="DoubleShortDash",Kt[Kt.DoubleMediumDash=8]="DoubleMediumDash",Kt[Kt.DoubleLongDash=9]="DoubleLongDash",Kt[Kt.DoubleMediumLongDash=10]="DoubleMediumLongDash",Kt[Kt.SparseDot=11]="SparseDot",Kt);Fd.Off;(xn={})[xn.Standard=-3]="Standard",xn[xn.ByLayer=-2]="ByLayer",xn[xn.ByBlock=-1]="ByBlock";(Bs={})[Bs.English=0]="English",Bs[Bs.Metric=1]="Metric";(vt={})[vt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",vt[vt.FRONT_CLIPPING=2]="FRONT_CLIPPING",vt[vt.BACK_CLIPPING=4]="BACK_CLIPPING",vt[vt.UCS_FOLLOW=8]="UCS_FOLLOW",vt[vt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",vt[vt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",vt[vt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",vt[vt.FAST_ZOOM=128]="FAST_ZOOM",vt[vt.SNAP_MODE=256]="SNAP_MODE",vt[vt.GRID_MODE=512]="GRID_MODE",vt[vt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",vt[vt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",vt[vt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",vt[vt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",vt[vt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",vt[vt.UNUSED=32768]="UNUSED",vt[vt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",vt[vt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",vt[vt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",vt[vt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",vt[vt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",vt[vt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(ke={})[ke.OPTIMIZED_2D=0]="OPTIMIZED_2D",ke[ke.WIREFRAME=1]="WIREFRAME",ke[ke.HIDDEN_LINE=2]="HIDDEN_LINE",ke[ke.FLAT_SHADED=3]="FLAT_SHADED",ke[ke.GOURAUD_SHADED=4]="GOURAUD_SHADED",ke[ke.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",ke[ke.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(Rs={})[Rs.UCS_UNCHANGED=0]="UCS_UNCHANGED",Rs[Rs.HAS_OWN_UCS=1]="HAS_OWN_UCS";(Me={})[Me.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",Me[Me.TOP=1]="TOP",Me[Me.BOTTOM=2]="BOTTOM",Me[Me.FRONT=3]="FRONT",Me[Me.BACK=4]="BACK",Me[Me.LEFT=5]="LEFT",Me[Me.RIGHT=6]="RIGHT";(Fs={})[Fs.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Fs[Fs.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Mr={})[Mr.ByLayer=0]="ByLayer",Mr[Mr.ByBlock=1]="ByBlock",Mr[Mr.ByDictionaryDefault=2]="ByDictionaryDefault",Mr[Mr.ByObject=3]="ByObject";function Pt(n,t,e){return n.code===t&&(e==null||n.value===e)}function Ft(n){let t={};n.rewind();let e=n.next(),s=e.code;if(t.x=e.value,(e=n.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=n.next()).code!==s+20?n.rewind():t.z=e.value,t}let yo=Symbol();function wt(n,t){return(e,s,a)=>{let h=function(v,f=!1){return v.reduce((x,w)=>{w.pushContext&&x.push({});let A=x[x.length-1];for(let k of typeof w.code=="number"?[w.code]:w.code){let L=A[k]??(A[k]=[]);w.isMultiple&&L.length&&f&&console.warn(`Snippet ${L[L.length-1].name} for code(${k}) is shadowed by ${w.name}`),L.push(w)}return x},[{}])}(n,s.debug),u=!1,p=h.length-1;for(;!Pt(e,0,"EOF");){let v=function(V,z,at){return V.find((_t,st)=>{var H;return st>=at&&((H=_t[z])==null?void 0:H.length)})}(h,e.code,p),f=v==null?void 0:v[e.code],x=f==null?void 0:f[f.length-1];if(!v||!x){s.rewind();break}x.isMultiple||v[e.code].pop();let{name:w,parser:A,isMultiple:k,isReducible:L}=x,C=A==null?void 0:A(e,s,a);if(C===yo){s.rewind();break}if(w){let[V,z]=function(at,_t){let st=_t.split(".");if(!st.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let H=at;for(let dt=0;dt<st.length-1;++dt){let it=La(st[dt]),Wt=La(st[dt+1]);Object.prototype.hasOwnProperty.call(H,it)||(typeof Wt=="number"?H[it]=[]:H[it]={}),H=H[it]}return[H,La(st[st.length-1])]}(a,w);k&&!L?(Object.prototype.hasOwnProperty.call(V,z)||(V[z]=[]),V[z].push(C)):V[z]=C}x.pushContext&&(p-=1),u=!0,e=s.next()}return t&&Object.setPrototypeOf(a,t),u}}function La(n){let t=Number.parseInt(n);return Number.isNaN(t)?n:t}function b({value:n}){return n}function W(n,t){return Ft(t)}function Dt({value:n}){return!!n}let zd=[{code:1001,name:"xdata",parser:vu}];function vu(n,t){var a;if(!Pt(n,1001))throw Error("XData must starts with code 1001");let e={appName:n.value,value:[]};n=t.next();let s=[e.value];for(;!Pt(n,0,"EOF")&&n.code>=1e3;){let h=s[s.length-1];switch(n.code){case 1002:n.value==="{"?s.push([]):(s.pop(),(a=s[s.length-1])==null||a.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Vr(n.code),value:n.value});break;case 1003:h.push({name:"layer",type:Vr(n.code),value:n.value});break;case 1005:h.push({name:"handle",type:Vr(n.code),value:n.value});break;case 1010:h.push({type:Vr(n.code),value:Ft(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Vr(n.code),value:Ft(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Vr(n.code),value:Ft(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Vr(n.code),value:Ft(t)});break;case 1041:h.push({name:"distance",type:Vr(n.code),value:n.value});break;case 1042:h.push({name:"scale",type:Vr(n.code),value:n.value})}n=t.next()}return t.rewind(),e}function Vr(n){switch(n){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function Tn(n,t,e){for(;Pt(n,102);){var s;let a=n.value;if(n=t.next(),!a.startsWith("{")){t.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${a}`),function(u,p){for(;!Pt(u,102)&&!Pt(u,0,"EOF");)u=p.next()}(n,t),n=t.next();continue}let h=a.slice(1).trim();e.extensions??(e.extensions={}),(s=e.extensions)[h]??(s[h]=[]),function(u,p,v){for(;!Pt(u,102,"}")&&!Pt(u,0,"EOF");)v.push(u),u=p.next()}(n,t,e.extensions[h]),n=t.next()}t.rewind()}let Vd=0;function bu(n){if(!n)throw TypeError("entity cannot be undefined or null");n.handle||(n.handle=Vd++)}var jd=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function wu(n){return jd[n]}(Tr={})[Tr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Tr[Tr.CAST=1]="CAST",Tr[Tr.RECEIVE=2]="RECEIVE",Tr[Tr.IGNORE=3]="IGNORE";let Gt=[...zd,{code:284,name:"shadowMode",parser:b},{code:390,name:"plotStyleHardId",parser:b},{code:380,name:"plotStyleType",parser:b},{code:440,name:"transparency",parser:b},{code:430,name:"colorName",parser:b},{code:420,name:"color",parser:b},{code:310,name:"proxyEntity",isMultiple:!0,parser:b},{code:92,name:"proxyByte",parser:b},{code:60,name:"isVisible",parser:Dt},{code:48,name:"lineTypeScale",parser:b},{code:370,name:"lineweight",parser:b},{code:62,name:"colorIndex",parser(n,t,e){let s=n.value;return s>0&&s<256&&(e.color=wu(Math.abs(s))),s}},{code:347,name:"materialObjectHardId",parser:b},{code:6,name:"lineType",parser:b},{code:8,name:"layer",parser:b},{code:410,name:"layoutTabName",parser:b},{code:67,name:"isInPaperSpace",parser:Dt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:b},{code:102,parser:Tn},{code:102,parser:Tn},{code:102,parser:Tn},{code:5,name:"handle",parser:b}];function ha(n){return[{code:3,name:n,parser:(t,e,s)=>(s._code3text=(s._code3text??"")+t.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:n,parser:(t,e,s)=>(s._code1text=t.value,(s._code3text??"")+s._code1text)}]}function xu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Dd={extrusionDirection:{x:0,y:0,z:1}},Ud=[{code:210,name:"extrusionDirection",parser:W},{code:51,name:"endAngle",parser:b},{code:50,name:"startAngle",parser:b},{code:100,name:"subclassMarker",parser:b},{code:40,name:"radius",parser:b},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:b},{code:100},...Gt];class Iu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){xu(this,"parser",wt(Ud,Dd))}}xu(Iu,"ForEntityName","ARC");(dr={})[dr.NONE=0]="NONE",dr[dr.INVISIBLE=1]="INVISIBLE",dr[dr.CONSTANT=2]="CONSTANT",dr[dr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",dr[dr.PRESET=8]="PRESET";(zs={})[zs.MULTILINE=2]="MULTILINE",zs[zs.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(In={})[In.NONE=0]="NONE",In[In.MIRRORED_X=2]="MIRRORED_X",In[In.MIRRORED_Y=4]="MIRRORED_Y";var Gd=((He={})[He.LEFT=0]="LEFT",He[He.CENTER=1]="CENTER",He[He.RIGHT=2]="RIGHT",He[He.ALIGNED=3]="ALIGNED",He[He.MIDDLE=4]="MIDDLE",He[He.FIT=5]="FIT",He),Wd=((Nr={})[Nr.BASELINE=0]="BASELINE",Nr[Nr.BOTTOM=1]="BOTTOM",Nr[Nr.MIDDLE=2]="MIDDLE",Nr[Nr.TOP=3]="TOP",Nr);function Su(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Pu={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Gd.LEFT,valign:Wd.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Au=[{code:73,name:"valign",parser:b},{code:100},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:72,name:"valign",parser:b},{code:72,name:"halign",parser:b},{code:71,name:"generationFlag",parser:b},{code:7,name:"styleName",parser:b},{code:51,name:"obliqueAngle",parser:b},{code:41,name:"xScale",parser:b},{code:50,name:"rotation",parser:b},{code:1,name:"text",parser:b},{code:40,name:"textHeight",parser:b},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Eu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Su(this,"parser",wt(Au,Pu))}}function ku(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Su(Eu,"ForEntityName","TEXT");let Hd={...Pu},Yd=[{code:2},{code:40,name:"annotationScale",parser:b},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:b},{code:70,name:"numberOfSecondaryAttributes",parser:b},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:b},{code:280,name:"isDuplicatedRecord",parser:Dt},{code:100},{code:280,name:"isLocked",parser:Dt},{code:74,name:"valign",parser:b},{code:73},{code:70,name:"attributeFlag",parser:b},{code:2,name:"tag",parser:b},{code:3,name:"prompt",parser:b},{code:280},{code:100,name:"subclassMarker",parser:b},...Au.slice(2)];class Mu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ku(this,"parser",wt(Yd,Hd))}}ku(Mu,"ForEntityName","ATTDEF");(Sn={})[Sn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Sn[Sn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Sn[Sn.BY_STYLE=5]="BY_STYLE";function Xd(n,t){let e={};for(let s of n){let a=t(s);a!=null&&(e[a]??(e[a]=[]),e[a].push(s))}return e}function*Qi(n,t=1/0,e=1){for(let s=n;s!==t;s+=e)yield s}function an(n){return{x:n.x??0,y:n.y??0,z:n.z??0}}function vo(n,t,e){if(Pt(t,102))return Tn(t,e,n),!0;switch(t.code){case 0:n.type=t.value;break;case 5:n.handle=t.value;break;case 330:n.ownerBlockRecordSoftId=t.value;break;case 67:n.isInPaperSpace=!!t.value;break;case 8:n.layer=t.value;break;case 6:n.lineType=t.value;break;case 347:n.materialObjectHardId=t.value;break;case 62:n.colorIndex=t.value,n.color=wu(Math.abs(t.value));break;case 370:n.lineweight=t.value;break;case 48:n.lineTypeScale=t.value;break;case 60:n.isVisible=!!t.value;break;case 92:n.proxyByte=t.value;break;case 310:n.proxyEntity=t.value;break;case 100:break;case 420:n.color=t.value;break;case 430:n.transparency=t.value;break;case 390:n.plotStyleHardId=t.value;break;case 284:n.shadowMode=t.value;break;case 1001:n.xdata=vu(t,e);break;default:return!1}return!0}function Tu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let qd={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Ii=[{code:46,name:"annotationHeight",parser:b},{code:101,parser(n,t){(function(e){e.rewind();let s=e.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=e.next();while(s.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:b},{code:49,name:"columnGutter",parser:b},{code:48,name:"columnWidth",parser:b},{code:79,name:"columnAutoHeight",parser:b},{code:78,name:"columnFlowReversed",parser:b},{code:76,name:"columnCount",parser:b},{code:75,name:"columnType",parser:b},{code:441,name:"backgroundFillTransparency",parser:b},{code:63,name:"backgroundFillColor",parser:b},{code:45,name:"fillBoxScale",parser:b},{code:[...Qi(430,440)],name:"backgroundColor",parser:b},{code:[...Qi(420,430)],name:"backgroundColor",parser:b},{code:90,name:"backgroundFill",parser:b},{code:44,name:"lineSpacing",parser:b},{code:73,name:"lineSpacingStyle",parser:b},{code:50,name:"rotation",parser:b},{code:43},{code:42},{code:11,name:"direction",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:7,name:"styleName",parser:b},...ha("text"),{code:72,name:"drawingDirection",parser:b},{code:71,name:"attachmentPoint",parser:b},{code:41,name:"width",parser:b},{code:40,name:"height",parser:b},{code:10,name:"insertionPoint",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Nu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Tu(this,"parser",wt(Ii,qd))}}function Lu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Tu(Nu,"ForEntityName","MTEXT");let Kd={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},$d=[...Ii.slice(Ii.findIndex(({name:n})=>n==="columnType"),Ii.findIndex(({name:n})=>n==="subclassMarker")+1),{code:100},{code:0,parser(n){if(!Pt(n,0,"MTEXT"))return yo}},{code:2,name:"definitionTag",parser:b},{code:40,name:"annotationScale",parser:b},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardId",parser:b},{code:70,name:"numberOfSecondaryAttributes",parser:b},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:b},{code:280,name:"isDuplicatedEntriesKeep",parser:Dt},{code:100},{code:280,name:"lockPositionFlag",parser:Dt},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"alignmentPoint",parser:W},{code:74,name:"verticalJustification",parser:b},{code:72,name:"horizontalJustification",parser:b},{code:71,name:"textGenerationFlag",parser:b},{code:7,name:"textStyle",parser:b},{code:51,name:"obliqueAngle",parser:b},{code:41,name:"scale",parser:b},{code:50,name:"rotation",parser:b},{code:73},{code:70,name:"attributeFlag",parser:b},{code:2,name:"tag",parser:b},{code:280},{code:100,name:"subclassMarker",parser:b},{code:1,name:"text",parser:b},{code:40,name:"textHeight",parser:b},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:b},{code:100},...Gt];class Ou{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Lu(this,"parser",wt($d,Kd))}}function Cu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Lu(Ou,"ForEntityName","ATTRIB");let Zd=[...ha("data"),{code:70,name:"version",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Bu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Cu(this,"parser",wt(Zd))}}function Ru(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Cu(Bu,"ForEntityName","BODY");let Qd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Jd=[{code:210,name:"extrusionDirection",parser:W},{code:40,name:"radius",parser:b},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Fu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ru(this,"parser",wt(Jd,Qd))}}Ru(Fu,"ForEntityName","CIRCLE");class Si{parseEntity(t,e){let s={};for(;!Pt(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(a,h,u){switch(h.code){case 100:a.subclassMarker=h.value;break;case 280:a.version=h.value;break;case 2:a.name=h.value;break;case 10:a.definitionPoint=Ft(u);break;case 11:a.textPoint=Ft(u);break;case 12:a.insertionPoint=Ft(u);break;case 13:a.subDefinitionPoint1=Ft(u);break;case 14:a.subDefinitionPoint2=Ft(u);break;case 15:a.centerPoint=Ft(u);break;case 16:a.arcPoint=Ft(u);break;case 70:a.dimensionType=h.value;break;case 71:a.attachmentPoint=h.value;break;case 72:a.textLineSpacingStyle=h.value;break;case 40:a.leaderLength=h.value;break;case 41:a.textLineSpacingFactor=h.value;break;case 42:a.measurement=h.value;break;case 1:a.text=h.value;break;case 50:a.rotationAngle=h.value;break;case 52:a.obliqueAngle=h.value;break;case 53:a.textRotation=h.value;break;case 51:a.ocsRotation=h.value;break;case 210:a.extrusionDirection=Ft(u);break;case 3:a.styleName=h.value;break;default:vo(a,h,u)}})(s,e,t),e=t.next()}return s}}function zu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Pa="DIMENSION",(Sa="ForEntityName")in Si?Object.defineProperty(Si,Sa,{value:Pa,enumerable:!0,configurable:!0,writable:!0}):Si[Sa]=Pa;let t0={extrusionDirection:{x:0,y:0,z:1}},e0=[{code:42,name:"endAngle",parser:b},{code:41,name:"startAngle",parser:b},{code:40,name:"axisRatio",parser:b},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"majorAxisEndPoint",parser:W},{code:10,name:"center",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Vu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){zu(this,"parser",wt(e0,t0))}}zu(Vu,"ForEntityName","ELLIPSE");(Lr={})[Lr.First=1]="First",Lr[Lr.Second=2]="Second",Lr[Lr.Third=4]="Third",Lr[Lr.Fourth=8]="Fourth";function ju(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let r0=[{code:13,name:"vertices.3",parser:W},{code:12,name:"vertices.2",parser:W},{code:11,name:"vertices.1",parser:W},{code:10,name:"vertices.0",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Du{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ju(this,"parser",wt(r0))}}ju(Du,"ForEntityName","3DFACE");let Uu=[{code:330,name:"sourceBoundaryObjects",parser:b,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:b}],n0=[{code:11,name:"end",parser:W},{code:10,name:"start",parser:W}],s0=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:b},{code:50,name:"startAngle",parser:b},{code:40,name:"radius",parser:b},{code:10,name:"center",parser:W}],i0=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:b},{code:50,name:"startAngle",parser:b},{code:40,name:"lengthOfMinorAxis",parser:b},{code:11,name:"end",parser:W},{code:10,name:"center",parser:W}],a0=[{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:11,name:"fitDatum",isMultiple:!0,parser:W},{code:97,name:"numberOfFitData",parser:b},{code:10,name:"controlPoints",isMultiple:!0,parser(n,t){let e={...Ft(t),weight:1};return(n=t.next()).code===42?e.weight=n.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:b},{code:96,name:"numberOfControlPoints",parser:b},{code:95,name:"numberOfKnots",parser:b},{code:74,name:"isPeriodic",parser:Dt},{code:73,name:"splineFlag",parser:b},{code:94,name:"degree",parser:b}],o0={[vi.Line]:n0,[vi.Circular]:s0,[vi.Elliptic]:i0,[vi.Spline]:a0},l0=[...Uu,{code:72,name:"edges",parser(n,t){let e={type:n.value},s=wt(o0[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(n=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:b}],h0=[...Uu,{code:10,name:"vertices",parser(n,t){let e={...Ft(t),bulge:0};return(n=t.next()).code===42?e.bulge=n.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:b},{code:73,name:"isClosed",parser:Dt},{code:72,name:"hasBulge",parser:Dt}],u0=[{code:49,name:"dashLengths",parser:b,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:b},{code:45,name:"offset",parser:Cl},{code:43,name:"base",parser:Cl},{code:53,name:"angle",parser:b}];function Cl(n,t){let e=n.code+1,s={x:n.value,y:1};return(n=t.next()).code===e?s.y=n.value:t.rewind(),s}function Gu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let c0={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},d0=[{code:470},{code:463},{code:462,name:"colorTint",parser:b},{code:461,name:"gradientDefinition",parser:b},{code:460,name:"gradientRotation",parser:b},{code:453,name:"numberOfColors",parser:b},{code:452,name:"gradientColorFlag",parser:b},{code:451},{code:450,name:"gradientFlag",parser:b},{code:10,name:"seedPoints",parser:W,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:W},{code:98,name:"numberOfSeedPoints",parser:b},{code:47,name:"pixelSize",parser:b},{code:53,name:"definitionLines",parser:function(n,t){let e={};return wt(u0)(n,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:b},{code:77,name:"isDouble",parser:Dt},{code:73,name:"isAnnotated",parser:Dt},{code:41,name:"patternScale",parser:b},{code:52,name:"patternAngle",parser:b},{code:76,name:"patternType",parser:b},{code:75,name:"hatchStyle",parser:b},{code:92,name:"boundaryPaths",parser:function(n,t){let e={boundaryPathTypeFlag:n.value},s=e.boundaryPathTypeFlag&Rd.Polyline;return n=t.next(),s?wt(h0)(n,t,e):wt(l0)(n,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:b},{code:71,name:"associativity",parser:b},{code:63,name:"patternFillColor",parser:b},{code:70,name:"solidFill",parser:b},{code:2,name:"patternName",parser:b},{code:210,name:"extrusionDirection",parser:W},{code:10,name:"elevationPoint",parser:W},{code:100,name:"subclassMarker",parser:b,pushContext:!0},...Gt];class Wu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gu(this,"parser",wt(d0,c0))}}Gu(Wu,"ForEntityName","HATCH");(Or={})[Or.ShowImage=1]="ShowImage",Or[Or.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",Or[Or.UseClippingBoundary=4]="UseClippingBoundary",Or[Or.TransparencyIsOn=8]="TransparencyIsOn";(Vs={})[Vs.Rectangular=1]="Rectangular",Vs[Vs.Polygonal=2]="Polygonal";(js={})[js.Outside=0]="Outside",js[js.Inside=1]="Inside";function Hu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let p0={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},m0=[{code:290,name:"clipMode",parser:b},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:W},{code:91,name:"countBoundaryPoints",parser:b},{code:71,name:"clippingBoundaryType",parser:b},{code:360,name:"imageDefReactorHandle",parser:b},{code:283,name:"fade",parser:b},{code:282,name:"contrast",parser:b},{code:281,name:"brightness",parser:b},{code:280,name:"isClipped",parser:Dt},{code:70,name:"flags",parser:b},{code:340,name:"imageDefHandle",parser:b},{code:13,name:"imageSize",parser:W},{code:12,name:"vPixel",parser:W},{code:11,name:"uPixel",parser:W},{code:10,name:"position",parser:W},{code:90,name:"version",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Yu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Hu(this,"parser",wt(m0,p0))}}function Xu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Hu(Yu,"ForEntityName","IMAGE");let g0={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},_0=[{code:210,name:"extrusionDirection",parser:W},{code:45,name:"rowSpacing",parser:b},{code:44,name:"columnSpacing",parser:b},{code:71,name:"rowCount",parser:b},{code:70,name:"columnCount",parser:b},{code:50,name:"rotation",parser:b},{code:43,name:"zScale",parser:b},{code:42,name:"yScale",parser:b},{code:41,name:"xScale",parser:b},{code:10,name:"insertionPoint",parser:W},{code:2,name:"name",parser:b},{code:66,name:"isVariableAttributes",parser:Dt},{code:100,name:"subclassMarker",parser:b},...Gt];class qu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Xu(this,"parser",wt(_0,g0))}}function Ku(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Xu(qu,"ForEntityName","INSERT");let f0={isArrowheadEnabled:!0},y0=[{code:213,name:"offsetFromAnnotation",parser:W},{code:212,name:"offsetFromBlock",parser:W},{code:211,name:"horizontalDirection",parser:W},{code:210,name:"normal",parser:W},{code:340,name:"associatedAnnotation",parser:b},{code:77,name:"byBlockColor",parser:b},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:76,name:"numberOfVertices",parser:b},{code:41,name:"textWidth",parser:b},{code:40,name:"textHeight",parser:b},{code:75,name:"isHooklineExists",parser:Dt},{code:74,name:"isHooklineSameDirection",parser:Dt},{code:73,name:"leaderCreationFlag",parser:b},{code:72,name:"isSpline",parser:Dt},{code:71,name:"isArrowheadEnabled",parser:Dt},{code:3,name:"styleName",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class $u{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ku(this,"parser",wt(y0,f0))}}Ku($u,"ForEntityName","LEADER");(Cr={})[Cr.TextAnnotation=0]="TextAnnotation",Cr[Cr.ToleranceAnnotation=1]="ToleranceAnnotation",Cr[Cr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Cr[Cr.NoAnnotation=3]="NoAnnotation";function Zu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let v0={thickness:0,extrusionDirection:{x:0,y:0,z:1}},b0=[{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Qu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zu(this,"parser",wt(b0,v0))}}Zu(Qu,"ForEntityName","LINE");(Ds={})[Ds.IS_CLOSED=1]="IS_CLOSED",Ds[Ds.PLINE_GEN=128]="PLINE_GEN";let w0={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},x0={bulge:0},I0=[{code:42,name:"bulge",parser:b},{code:41,name:"endWidth",parser:b},{code:40,name:"startWidth",parser:b},{code:91,name:"id",parser:b},{code:20,name:"y",parser:b},{code:10,name:"x",parser:b}],S0=[{code:210,name:"extrusionDirection",parser:W},{code:10,name:"vertices",isMultiple:!0,parser(n,t){let e={};return wt(I0,x0)(n,t,e),e}},{code:39,name:"thickness",parser:b},{code:38,name:"elevation",parser:b},{code:43,name:"constantWidth",parser:b},{code:70,name:"flag",parser:b},{code:90,name:"numberOfVertices",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Pi{parseEntity(t,e){let s={};return wt(S0,w0)(e,t,s),s}}function Ju(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ea="LWPOLYLINE",(Aa="ForEntityName")in Pi?Object.defineProperty(Pi,Aa,{value:Ea,enumerable:!0,configurable:!0,writable:!0}):Pi[Aa]=Ea;let P0=[{code:90,name:"overridenSubEntityCount",parser:b},{code:140,name:"edgeCreaseWeights",parser:b,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:b},{code:94,parser(n,t,e){e.edgeCount=n.value,e.edgeIndices=[];for(let s=0;s<e.edgeCount;++s){let a=[];n=t.next(),a[0]=n.value,n=t.next(),a[1]=n.value,e.edgeIndices.push(a)}}},{code:93,parser(n,t,e){e.totalFaceIndices=n.value,e.faceIndices=[];let s=[];for(let h=0;h<e.totalFaceIndices&&!Pt(n,0);++h)n=t.next(),s.push(n.value);let a=0;for(;a<s.length;){let h=s[a++],u=[];for(let p=0;p<h;++p)u.push(s[a++]);e.faceIndices.push(u)}}},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:92,name:"verticesCount",parser:b},{code:91,name:"subdivisionLevel",parser:b},{code:40,name:"blendCrease",parser:b},{code:72,name:"isBlendCreased",parser:Dt},{code:71,name:"version",parser:b},{code:100,name:"subclassMarker",parser:function({value:n}){return n.trim()},pushContext:!0},...Gt];class tc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ju(this,"parser",wt(P0))}}function ec(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ju(tc,"ForEntityName","MESH");let A0={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},E0=[{code:50,name:"angle",parser:b},{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:b},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class rc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ec(this,"parser",wt(E0,A0))}}ec(rc,"ForEntityName","POINT");(fe={})[fe.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",fe[fe.CURVE_FIT=2]="CURVE_FIT",fe[fe.SPLINE_FIT=4]="SPLINE_FIT",fe[fe.POLYLINE_3D=8]="POLYLINE_3D",fe[fe.POLYGON_3D=16]="POLYGON_3D",fe[fe.CLOSED_POLYGON=32]="CLOSED_POLYGON",fe[fe.POLYFACE=64]="POLYFACE",fe[fe.CONTINUOUS=128]="CONTINUOUS";var bi=((Br={})[Br.NONE=0]="NONE",Br[Br.QUADRATIC=5]="QUADRATIC",Br[Br.CUBIC=6]="CUBIC",Br[Br.BEZIER=8]="BEZIER",Br),k0=((ye={})[ye.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ye[ye.TANGENT_DEFINED=2]="TANGENT_DEFINED",ye[ye.NOT_USED=4]="NOT_USED",ye[ye.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ye[ye.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ye[ye.FOR_POLYLINE=32]="FOR_POLYLINE",ye[ye.FOR_POLYGON=64]="FOR_POLYGON",ye[ye.POLYFACE=128]="POLYFACE",ye);function nc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let M0={startWidth:0,endWidth:0,bulge:0},T0=[{code:91,name:"id",parser:b},{code:[...Qi(71,75)],name:"faces",isMultiple:!0,parser:b},{code:50,name:"tangentDirection",parser:b},{code:70,name:"flag",parser:b},{code:42,name:"bulge",parser:b},{code:41,name:"endWidth",parser:b},{code:40,name:"startWidth",parser:b},{code:30,name:"z",parser:b},{code:20,name:"y",parser:b},{code:10,name:"x",parser:b},{code:100,name:"subclassMarker",parser:b},{code:100},...Gt];class bo{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nc(this,"parser",wt(T0,M0))}}function sc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}nc(bo,"ForEntityName","VERTEX");let N0={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},L0=[{code:0,name:"vertices",isMultiple:!0,parser:(n,t)=>Pt(n,0,"VERTEX")?(n=t.next(),new bo().parseEntity(t,n)):yo},{code:210,name:"extrusionDirection",parser:W},{code:75,name:"smoothType",parser:b},{code:74,name:"surfaceNDensity",parser:b},{code:73,name:"surfaceMDensity",parser:b},{code:72,name:"meshNVertexCount",parser:b},{code:71,name:"meshMVertexCount",parser:b},{code:41,name:"endWidth",parser:b},{code:40,name:"startWidth",parser:b},{code:70,name:"flag",parser:b},{code:39,name:"thickness",parser:b},{code:30,name:"elevation",parser:b},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:b},...Gt];class ic{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){sc(this,"parser",wt(L0,N0))}}function ac(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}sc(ic,"ForEntityName","POLYLINE");let O0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class oc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ac(this,"parser",wt(O0))}}function lc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ac(oc,"ForEntityName","RAY");let C0=[...ha("data"),{code:70,name:"version",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class hc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){lc(this,"parser",wt(C0))}}function uc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}lc(hc,"ForEntityName","REGION");let B0={vertices:[],backLineVertices:[]},R0=[{code:360,name:"geometrySettingHardId",parser:b},{code:12,name:"backLineVertices",isMultiple:!0,parser:W},{code:93,name:"numberOfBackLineVertices",parser:b},{code:11,name:"vertices",isMultiple:!0,parser:W},{code:92,name:"verticesCount",parser:b},{code:[63,411],name:"indicatorColor",parser:b},{code:70,name:"indicatorTransparency",parser:b},{code:41,name:"bottomHeight",parser:b},{code:40,name:"topHeight",parser:b},{code:10,name:"verticalDirection",parser:W},{code:1,name:"name",parser:b},{code:91,name:"flag",parser:b},{code:90,name:"state",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class cc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){uc(this,"parser",wt(R0,B0))}}function dc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}uc(cc,"ForEntityName","SECTION");let F0={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},z0=[{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:b},{code:[...Qi(10,14)],name:"points",isMultiple:!0,parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class pc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dc(this,"parser",wt(z0,F0))}}function mc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}dc(pc,"ForEntityName","SOLID");let V0=[{code:350,name:"historyObjectSoftId",parser:b},{code:100,name:"subclassMarker",parser:b},...ha("data"),{code:70,name:"version",parser:b},{code:100},...Gt];class gc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){mc(this,"parser",wt(V0))}}mc(gc,"ForEntityName","3DSOLID");(Ye={})[Ye.NONE=0]="NONE",Ye[Ye.CLOSED=1]="CLOSED",Ye[Ye.PERIODIC=2]="PERIODIC",Ye[Ye.RATIONAL=4]="RATIONAL",Ye[Ye.PLANAR=8]="PLANAR",Ye[Ye.LINEAR=16]="LINEAR";function _c(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let j0={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},D0=[{code:11,name:"fitPoints",isMultiple:!0,parser:W},{code:10,name:"controlPoints",isMultiple:!0,parser:W},{code:41,name:"weights",isMultiple:!0,parser:b},{code:40,name:"knots",isMultiple:!0,parser:b},{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:44,name:"fitTolerance",parser:b},{code:43,name:"controlTolerance",parser:b},{code:42,name:"knotTolerance",parser:b},{code:74,name:"numberOfFitPoints",parser:b},{code:73,name:"numberOfControlPoints",parser:b},{code:72,name:"numberOfKnots",parser:b},{code:71,name:"degree",parser:b},{code:70,name:"flag",parser:b},{code:210,name:"normal",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class fc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){_c(this,"parser",wt(D0,j0))}}_c(fc,"ForEntityName","SPLINE");class Ai{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=an(Ft(t)),e=t.lastReadGroup;break;case 11:s.directionVector=an(Ft(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerDictionaryId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(a,h){let u=!1,p=!1,v={};for(;!a.isEOF()&&h.code!==0&&!p;)switch(h.code){case 171:if(u){p=!0;continue}v.cellType=h.value,u=!0,h=a.next();break;case 172:v.flagValue=h.value,h=a.next();break;case 173:v.mergedValue=h.value,h=a.next();break;case 174:v.autoFit=h.value,h=a.next();break;case 175:v.borderWidth=h.value,h=a.next();break;case 176:v.borderHeight=h.value,h=a.next();break;case 91:v.overrideFlag=h.value,h=a.next();break;case 178:v.virtualEdgeFlag=h.value,h=a.next();break;case 145:v.rotation=h.value,h=a.next();break;case 345:v.fieldObjetId=h.value,h=a.next();break;case 340:v.blockTableRecordId=h.value,h=a.next();break;case 146:v.blockScale=h.value,h=a.next();break;case 177:v.blockAttrNum=h.value,h=a.next();break;case 7:v.textStyle=h.value,h=a.next();break;case 140:v.textHeight=h.value,h=a.next();break;case 170:v.attachmentPoint=h.value,h=a.next();break;case 92:v.extendedCellFlags=h.value,h=a.next();break;case 285:v.rightBorderVisibility=!!(h.value??!0),h=a.next();break;case 286:v.bottomBorderVisibility=!!(h.value??!0),h=a.next();break;case 288:v.leftBorderVisibility=!!(h.value??!0),h=a.next();break;case 289:v.topBorderVisibility=!!(h.value??!0),h=a.next();break;case 301:(function(f,x,w){for(;w.code!==304;)switch(w.code){case 301:case 93:case 90:case 94:w=x.next();break;case 1:f.text=w.value,w=x.next();break;case 300:f.attrText=w.value,w=x.next();break;case 302:f.text=w.value?w.value:f.text,w=x.next();break;default:console.log(`Ignore code: ${w.code}, value: ${w.value}`),w=x.next()}})(v,a,h),h=a.next();break;default:return v}return u=!1,p=!1,v}(t,e)),e=t.lastReadGroup;break;default:vo(s,e,t),e=t.next()}}return s}}function yc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ma="ACAD_TABLE",(ka="ForEntityName")in Ai?Object.defineProperty(Ai,ka,{value:Ma,enumerable:!0,configurable:!0,writable:!0}):Ai[ka]=Ma;let U0=[{code:11,name:"xAxisDirection",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:1,name:"text",parser:b},{code:10,name:"position",parser:W},{code:3,name:"styleName",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class vc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){yc(this,"parser",wt(U0))}}yc(vc,"ForEntityName","TOLERANCE");class Ei{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(a,h,u){if(u==="EOF")return!1;switch(u.code){case 0:return!1;case 8:a.layer=u.value;break;case 100:a.subclassMarker=u.value;break;case 10:a.viewportCenter=an(Ft(h));break;case 40:a.width=u.value;break;case 41:a.height=u.value;break;case 68:a.status=u.value;break;case 69:a.viewportId=u.value;break;case 12:a.displayCenter=Ft(h);break;case 13:a.snapBase=Ft(h);break;case 14:a.snapSpacing=Ft(h);break;case 15:a.gridSpacing=Ft(h);break;case 16:a.viewDirection=an(Ft(h));break;case 17:a.targetPoint=an(Ft(h));break;case 42:a.perspectiveLensLength=u.value;break;case 43:a.frontClipZ=u.value;break;case 44:a.backClipZ=u.value;break;case 45:a.viewHeight=u.value;break;case 50:a.snapAngle=u.value;break;case 51:a.viewTwistAngle=u.value;break;case 72:a.circleZoomPercent=u.value;break;case 331:a.frozenLayerIds??(a.frozenLayerIds=[]),a.frozenLayerIds.push(u.value);break;case 90:a.statusBitFlags=u.value;break;case 340:a.clippingBoundaryId=u.value;break;case 1:a.sheetName=u.value;break;case 281:a.renderMode=u.value;break;case 71:a.ucsPerViewport=u.value;break;case 110:a.ucsOrigin=an(Ft(h));break;case 111:a.ucsXAxis=an(Ft(h));break;case 112:a.ucsYAxis=an(Ft(h));break;case 345:a.ucsId=u.value;break;case 346:a.ucsBaseId=u.value;break;case 79:a.orthographicType=u.value;break;case 146:a.elevation=u.value;break;case 170:a.shadePlotMode=u.value;break;case 61:a.majorGridFrequency=u.value;break;case 332:a.backgroundId=u.value;break;case 333:a.shadePlotId=u.value;break;case 348:a.visualStyleId=u.value;break;case 292:a.isDefaultLighting=!!u.value;break;case 282:a.defaultLightingType=u.value;break;case 141:a.brightness=u.value;break;case 142:a.contrast=u.value;break;case 63:case 421:case 431:a.ambientLightColor=u.value;break;case 361:a.sunId=u.value;break;case 335:case 343:case 344:case 91:a.softPointer=u.value}return!0}(s,t,e)&&vo(s,e,t),e=t.next()}return s}}Na="VIEWPORT",(Ta="ForEntityName")in Ei?Object.defineProperty(Ei,Ta,{value:Na,enumerable:!0,configurable:!0,writable:!0}):Ei[Ta]=Na;(Rr={})[Rr.ShowImage=1]="ShowImage",Rr[Rr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Rr[Rr.UseClippingBoundary=4]="UseClippingBoundary",Rr[Rr.Transparency=8]="Transparency";function bc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let G0={brightness:50,constrast:50,fade:0},W0=[{code:14,name:"boundary",isMultiple:!0,parser:W},{code:91,name:"numberOfVertices",parser:b},{code:71,name:"boundaryType",parser:b},{code:360,name:"imageDefReactorHardId",parser:b},{code:283,name:"fade",parser:b},{code:282,name:"contrast",parser:b},{code:281,name:"brightness",parser:b},{code:280,name:"isClipping",parser:Dt},{code:70,name:"displayFlag",parser:b},{code:340,name:"imageDefHardId",parser:b},{code:13,name:"imageSize",parser:W},{code:12,name:"vDirection",parser:W},{code:11,name:"uDirection",parser:W},{code:10,name:"position",parser:W},{code:90,name:"classVersion",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class wc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){bc(this,"parser",wt(W0,G0))}}function xc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}bc(wc,"ForEntityName","WIPEOUT");let H0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Ic{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){xc(this,"parser",wt(H0))}}function Sc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}xc(Ic,"ForEntityName","XLINE");let Y0={},X0=[{code:170,name:"multileaderType",parser:b},{code:291,name:"doglegEnabled",parser:Dt},{code:40,name:"doglegLength",parser:b},{code:172,name:"contentType",parser:b},{code:3,name:"textContent",parser:b},{code:12,name:"textAnchor",parser:W},{code:344,name:"blockHandle",parser:b},{code:15,name:"blockPosition",parser:W},{code:302,name:"leaderSections",parser:function(n,t,e){let s,a={leaderLines:[]};for(;t.hasNext()&&(s=t.next()).code!==303;)switch(s.code){case 10:a.landingPoint=(s.value,Ft(t));break;case 11:a.doglegVector=(s.value,Ft(t));break;case 40:a.doglegLength=s.value;break;case 304:a.leaderLines.push(function(h,u,p){let v,f={vertices:[]};for(;u.hasNext()&&(v=u.next()).code!==305;)v.code===10&&f.vertices.push((v.value,Ft(u)));return f}(0,t))}return a},isMultiple:!0},...Gt];class Pc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sc(this,"parser",wt(X0,Y0))}}Sc(Pc,"ForEntityName","MULTILEADER");let q0=Object.fromEntries([Iu,Mu,Ou,Bu,Fu,Si,Vu,Du,Yu,qu,$u,Qu,Pi,tc,Nu,Pc,rc,ic,oc,hc,cc,pc,gc,fc,Ai,Eu,vc,Wu,bo,Ei,wc,Ic].map(n=>[n.ForEntityName,new n]));function Ac(n,t){let e=[];for(;!Pt(n,0,"EOF");){if(n.code===0){if(n.value==="ENDBLK"||n.value==="ENDSEC"){t.rewind();break}let s=q0[n.value];if(s){let a=n.value;n=t.next();let h=s.parseEntity(t,n);h.type=a,bu(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${n.value}`)}n=t.next()}return e}function K0(n,t){let e={};for(;!Pt(n,0,"EOF")&&!Pt(n,0,"ENDSEC");){if(Pt(n,0,"BLOCK")){let s=$0(n=t.next(),t);bu(s),s.name&&(e[s.name]=s)}n=t.next()}return e}function $0(n,t){let e={};for(;!Pt(n,0,"EOF");){if(Pt(n,0,"ENDBLK")){for(n=t.next();!Pt(n,0,"EOF");){if(Pt(n,100,"AcDbBlockEnd"))return e;n=t.next()}break}switch(n.code){case 1:e.xrefPath=n.value;break;case 2:e.name=n.value;break;case 3:e.name2=n.value;break;case 5:e.handle=n.value;break;case 8:e.layer=n.value;break;case 10:e.position=Ft(t);break;case 67:e.paperSpace=!!n.value&&n.value==1;break;case 70:n.value!==0&&(e.type=n.value);break;case 100:break;case 330:e.ownerHandle=n.value;break;case 0:e.entities=Ac(n,t)}n=t.next()}return e}function Z0(n,t){let e=null,s={};for(;!Pt(n,0,"EOF")&&!Pt(n,0,"ENDSEC");)n.code===9?e=n.value:n.code===10?s[e]=Ft(t):s[e]=n.value,n=t.next();return s}(Xe={})[Xe.NOT_APPLICABLE=0]="NOT_APPLICABLE",Xe[Xe.KEEP_EXISTING=1]="KEEP_EXISTING",Xe[Xe.USE_CLONE=2]="USE_CLONE",Xe[Xe.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Xe[Xe.VALUE_NAME=4]="VALUE_NAME",Xe[Xe.UNMANGLE_NAME=5]="UNMANGLE_NAME";let wo=[{code:330,name:"ownerObjectId",parser:b},{code:102,parser:Tn},{code:102,parser:Tn},{code:102,parser:Tn},{code:5,name:"handle",parser:b}],Q0=[{code:3,name:"entries",parser:(n,t)=>{let e={name:n.value};return(n=t.next()).code===350?e.objectSoftId=n.value:n.code===360?e.objectHardId=n.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:b},{code:280,name:"isHardOwned",parser:Dt},{code:100,name:"subclassMarker",parser:b},...wo],J0=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:b},{code:90,name:"version",parser:b},{code:1,name:"fileName",parser:b},{code:10,name:"size",parser:W},{code:11,name:"sizeOfOnePixel",parser:W},{code:280,name:"isLoaded",parser:b},{code:281,name:"resolutionUnits",parser:b},{code:100,name:"subclassMarker",parser:b}];(Pn={})[Pn.NOUNIT=0]="NOUNIT",Pn[Pn.CENTIMETERS=2]="CENTIMETERS",Pn[Pn.INCH=5]="INCH";(Us={})[Us.PSLTSCALE=1]="PSLTSCALE",Us[Us.LIMCHECK=2]="LIMCHECK";(An={})[An.INCHES=0]="INCHES",An[An.MILLIMETERS=1]="MILLIMETERS",An[An.PIXELS=2]="PIXELS";(qe={})[qe.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",qe[qe.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",qe[qe.DRAWING_LIMITS=2]="DRAWING_LIMITS",qe[qe.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",qe[qe.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",qe[qe.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Fr={})[Fr.AS_DISPLAYED=0]="AS_DISPLAYED",Fr[Fr.WIREFRAME=1]="WIREFRAME",Fr[Fr.HIDDEN=2]="HIDDEN",Fr[Fr.RENDERED=3]="RENDERED";(Ke={})[Ke.DRAFT=0]="DRAFT",Ke[Ke.PREVIEW=1]="PREVIEW",Ke[Ke.NORMAL=2]="NORMAL",Ke[Ke.PRESENTATION=3]="PRESENTATION",Ke[Ke.MAXIMUM=4]="MAXIMUM",Ke[Ke.CUSTOM=5]="CUSTOM";let Ec=[{code:333,name:"shadePlotId",parser:b},{code:149,name:"imageOriginY",parser:b},{code:148,name:"imageOriginX",parser:b},{code:147,name:"scaleFactor",parser:b},{code:78,name:"shadePlotCustomDPI",parser:b},{code:77,name:"shadePlotResolution",parser:b},{code:76,name:"shadePlotMode",parser:b},{code:75,name:"standardScaleType",parser:b},{code:7,name:"currentStyleSheet",parser:b},{code:74,name:"plotType",parser:b},{code:73,name:"plotRotation",parser:b},{code:72,name:"plotPaperUnit",parser:b},{code:70,name:"layoutFlag",parser:b},{code:143,name:"printScaleDenominator",parser:b},{code:142,name:"printScaleNumerator",parser:b},{code:141,name:"windowAreaYMax",parser:b},{code:140,name:"windowAreaXMax",parser:b},{code:49,name:"windowAreaYMin",parser:b},{code:48,name:"windowAreaXMin",parser:b},{code:47,name:"plotOriginY",parser:b},{code:46,name:"plotOriginX",parser:b},{code:45,name:"paperHeight",parser:b},{code:44,name:"paperWidth",parser:b},{code:43,name:"marginTop",parser:b},{code:42,name:"marginRight",parser:b},{code:41,name:"marginBottom",parser:b},{code:40,name:"marginLeft",parser:b},{code:6,name:"plotViewName",parser:b},{code:4,name:"paperSize",parser:b},{code:2,name:"configName",parser:b},{code:1,name:"pageSetupName",parser:b},{code:100,name:"subclassMarker",parser:b},...wo],tp=[{code:346,name:"orthographicUcsId",parser:b},{code:345,name:"namedUcsId",parser:b},{code:331,name:"viewportId",parser:b},{code:330,name:"paperSpaceTableId",parser:b},{code:76,name:"orthographicType",parser:b},{code:17,name:"ucsYAxis",parser:W},{code:16,name:"ucsXAxis",parser:W},{code:13,name:"ucsOrigin",parser:W},{code:146,name:"elevation",parser:b},{code:15,name:"maxExtent",parser:W},{code:14,name:"minExtent",parser:W},{code:12,name:"insertionPoint",parser:W},{code:11,name:"maxLimit",parser:W},{code:10,name:"minLimit",parser:W},{code:71,name:"tabOrder",parser:b},{code:70,name:"controlFlag",parser:b},{code:1,name:"layoutName",parser:b},{code:100,name:"subclassMarker",parser:b},...Ec],ep=[{code:40,name:"wcsToOCSTransform",parser:Bl},{code:40,name:"ocsToWCSTransform",parser:Bl},{code:41,name:"backClippingDistance",parser:b},{code:73,name:"isBackClipping",parser:Dt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:b},{code:72,name:"isFrontClipping",parser:Dt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Dt},{code:11,name:"position",parser:W},{code:210,name:"normal",parser:W},{code:10,name:"boundaryVertices",parser:W,isMultiple:!0},{code:70,name:"boundaryCount",parser:b},{code:100,name:"subclassMarker",parser:b},{code:100},...wo];function Bl(n,t){let e=[];for(let s=0;s<3&&Pt(n,40);++s){let a=[];for(let h=0;h<4&&Pt(n,40);++h)a.push(n.value),n=t.next();e.push(a)}return t.rewind(),e}let rp={LAYOUT:tp,PLOTSETTINGS:Ec,DICTIONARY:Q0,SPATIAL_FILTER:ep,IMAGEDEF:J0};function np(n,t){let e=[];for(;n.code!==0||!["EOF","ENDSEC"].includes(n.value);){let s=n.value,a=rp[s];if(n.code===0&&(a!=null&&a.length)){let h=wt(a),u={name:s};h(n=t.next(),t,u)?(e.push(u),n=t.peek()):n=t.next()}else n=t.next()}return{byName:Xd(e,({name:s})=>s)}}let as=[{code:100,name:"subclassMarker",parser:b},{code:330,name:"ownerObjectId",parser:b},{code:102,parser(n,t){for(;!Pt(n,0,"EOF")&&!Pt(n,102,"}");)n=t.next()}},{code:5,name:"handle",parser:b}],sp=wt([{code:310,name:"bmpPreview",parser:b},{code:281,name:"scalability",parser:b},{code:280,name:"explodability",parser:b},{code:70,name:"insertionUnits",parser:b},{code:340,name:"layoutObjects",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),ip=[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:Ol.Above,defaultValueImperial:Ol.Center},{name:"DIMZIN",code:78,defaultValue:$n.Trailing,defaultValueImperial:$n.Feet},{name:"DIMAZIN",code:79,defaultValue:Ld.None},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:2,defaultValueImperial:4},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:",",defaultValueImperial:"."},{name:"DIMJUST",code:280,defaultValue:Od.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Cd.Center},{name:"DIMTZIN",code:284,defaultValue:$n.Trailing,defaultValueImperial:$n.Feet},{name:"DIMALTZ",code:285,defaultValue:$n.Trailing},{name:"DIMALTTZ",code:286,defaultValue:$n.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}],ap=wt([...ip.map(n=>({...n,parser:b})),{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},{code:105,name:"handle",parser:b},...as.filter(n=>n.code!==5)]),op=wt([{code:347,name:"materialObjectId",parser:b},{code:390,name:"plotStyleNameObjectId",parser:b},{code:370,name:"lineweight",parser:b},{code:290,name:"isPlotting",parser:Dt},{code:6,name:"lineType",parser:b},{code:62,name:"colorIndex",parser:b},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]);(zr={})[zr.NONE=0]="NONE",zr[zr.AbsoluteRotation=1]="AbsoluteRotation",zr[zr.TextEmbedded=2]="TextEmbedded",zr[zr.ShapeEmbedded=4]="ShapeEmbedded";let lp=wt([{code:9,name:"text",parser:b},{code:45,name:"offsetY",parser:b},{code:44,name:"offsetX",parser:b},{code:50,name:"rotation",parser:b},{code:46,name:"scale",parser:b},{code:340,name:"styleObjectId",parser:b},{code:75,name:"shapeNumber",parser:b},{code:74,name:"elementTypeFlag",parser:b},{code:49,name:"elementLength",parser:b}],{elementTypeFlag:0,elementLength:0}),hp=wt([{code:49,name:"pattern",parser(n,t){let e={};return lp(n,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:b},{code:73,name:"numberOfLineTypes",parser:b},{code:72,parser:b},{code:3,name:"description",parser:b},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),up=wt([{code:1e3,name:"extendedFont",parser:b},{code:1001},{code:4,name:"bigFont",parser:b},{code:3,name:"font",parser:b},{code:42,name:"lastHeight",parser:b},{code:71,name:"textGenerationFlag",parser:b},{code:50,name:"obliqueAngle",parser:b},{code:41,name:"widthFactor",parser:b},{code:40,name:"fixedTextHeight",parser:b},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),cp=wt([{code:[63,421,431],name:"ambientColor",parser:b},{code:142,name:"contrast",parser:b},{code:141,name:"brightness",parser:b},{code:282,name:"defaultLightingType",parser:b},{code:292,name:"isDefaultLightingOn",parser:Dt},{code:348,name:"visualStyleObjectId",parser:b},{code:333,name:"shadePlotObjectId",parser:b},{code:332,name:"backgroundObjectId",parser:b},{code:61,name:"majorGridLines",parser:b},{code:170,name:"shadePlotSetting",parser:b},{code:146,name:"elevation",parser:b},{code:79,name:"orthographicType",parser:b},{code:112,name:"ucsYAxis",parser:W},{code:111,name:"ucsXAxis",parser:W},{code:110,name:"ucsOrigin",parser:W},{code:74,name:"ucsIconSetting",parser:b},{code:71,name:"viewMode",parser:b},{code:281,name:"renderMode",parser:b},{code:1,name:"styleSheet",parser:b},{code:[331,441],name:"frozenLayers",parser:b,isMultiple:!0},{code:72,name:"circleSides",parser:b},{code:51,name:"viewTwistAngle",parser:b},{code:50,name:"snapRotationAngle",parser:b},{code:45,name:"viewHeight",parser:b},{code:44,name:"backClippingPlane",parser:b},{code:43,name:"frontClippingPlane",parser:b},{code:42,name:"lensLength",parser:b},{code:17,name:"viewTarget",parser:W},{code:16,name:"viewDirectionFromTarget",parser:W},{code:15,name:"gridSpacing",parser:W},{code:14,name:"snapSpacing",parser:W},{code:13,name:"snapBasePoint",parser:W},{code:12,name:"center",parser:W},{code:11,name:"upperRightCorner",parser:W},{code:10,name:"lowerLeftCorner",parser:W},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),dp={BLOCK_RECORD:sp,DIMSTYLE:ap,LAYER:op,LTYPE:hp,STYLE:up,VPORT:cp},pp=wt([{code:70,name:"maxNumberOfEntries",parser:b},{code:100,name:"subclassMarker",parser:b},{code:330,name:"ownerObjectId",parser:b},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:b},{code:2,name:"name",parser:b}]);function mp(n,t){var s;let e={};for(;!Pt(n,0,"EOF")&&!Pt(n,0,"ENDSEC");){if(Pt(n,0,"TABLE")){n=t.next();let a={entries:[]};pp(n,t,a),e[a.name]=a}if(Pt(n,0)&&!Pt(n,0,"ENDTAB")){let a=n.value;n=t.next();let h=dp[a];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${a}'`),n=t.next();continue}let u={};h(n,t,u),(s=e[a])==null||s.entries.push(u)}n=t.next()}return e}function Gs(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}class Rl{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=Fl(t,this._data[this._pointer++],this.debug),s={code:t,value:e};return Pt(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=Fl(t.code,this._data[this._pointer+1],this.debug),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t,e=!1){Gs(this,"_data",void 0),Gs(this,"debug",void 0),Gs(this,"_pointer",void 0),Gs(this,"_eof",void 0),Gs(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Fl(n,t,e=!1){return n<=9?t:n>=10&&n<=59?parseFloat(t.trim()):n>=60&&n<=99?parseInt(t.trim()):n>=100&&n<=109?t:n>=110&&n<=149?parseFloat(t.trim()):n>=160&&n<=179?parseInt(t.trim()):n>=210&&n<=239?parseFloat(t.trim()):n>=270&&n<=289?parseInt(t.trim()):n>=290&&n<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(t.trim()):n>=300&&n<=369?t:n>=370&&n<=389?parseInt(t.trim()):n>=390&&n<=399?t:n>=400&&n<=409?parseInt(t.trim()):n>=410&&n<=419?t:n>=420&&n<=429?parseInt(t.trim()):n>=430&&n<=439?t:n>=440&&n<=459?parseInt(t.trim()):n>=460&&n<=469?parseFloat(t.trim()):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?t:n>=1010&&n<=1059?parseFloat(t.trim()):n>=1060&&n<=1071?parseInt(t.trim()):(e&&console.warn("WARNING: Group code does not have a defined type: %j",{code:n,value:t}),t)}function Wa(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}class gp{constructor(){Wa(this,"encoding","utf-8"),Wa(this,"encodingFailureFatal",!1)}}class _p extends EventTarget{parseSync(t,e=!1){let s=new Rl(t.split(/\r\n|\r|\n/g),e);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(t){let e="",s=this;return new Promise((a,h)=>{t.on("data",u=>{e+=u}),t.on("end",()=>{try{let u=e.split(/\r\n|\r|\n/g),p=new Rl(u);if(!p.hasNext())throw Error("Empty file");a(s.parseAll(p))}catch(u){h(u)}}),t.on("error",u=>{h(u)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let a=s.body.getReader(),h="";for(;;){let{done:u,value:p}=await a.read();if(u){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(p,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!Pt(s,0,"EOF");)Pt(s,0,"SECTION")&&(Pt(s=t.next(),2,"HEADER")?(s=t.next(),e.header=Z0(s,t)):Pt(s,2,"BLOCKS")?(s=t.next(),e.blocks=K0(s,t)):Pt(s,2,"ENTITIES")?(s=t.next(),e.entities=Ac(s,t)):Pt(s,2,"TABLES")?(s=t.next(),e.tables=mp(s,t)):Pt(s,2,"OBJECTS")&&(s=t.next(),e.objects=np(s,t))),s=t.next();return e}constructor(t=new gp){super(),Wa(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}class fp{parse(t){const e=new _p,s=this.getDxfInfoFromBuffer(t);let a="";return s.version&&s.version.value<=23&&s.encoding?a=new TextDecoder(s.encoding).decode(t):a=new TextDecoder().decode(t),e.parseSync(a)}getDxfInfoFromBuffer(t){var f,x,w;const s=new TextDecoder("utf-8");let a=0,h="",u=null,p=null,v=!1;for(;a<t.byteLength;){const A=Math.min(a+65536,t.byteLength),k=t.slice(a,A);a=A;const C=(h+s.decode(k,{stream:!0})).split(/\r?\n/);h=C.pop()??"";for(let V=0;V<C.length;V++){const z=C[V].trim();if(z==="SECTION"&&((f=C[V+2])==null?void 0:f.trim())==="HEADER")v=!0;else if(z==="ENDSEC"&&v)return{version:u,encoding:p};if(v&&z==="$ACADVER"){const at=(x=C[V+2])==null?void 0:x.trim();at&&(u=new er(at))}else if(v&&z==="$DWGCODEPAGE"){const at=(w=C[V+2])==null?void 0:w.trim();if(at){const _t=lo[at];p=Bh(_t)}}if(u&&p)return{version:u,encoding:p}}}return{version:u,encoding:p}}}class zl{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):t.type=="ARC"?this.convertArc(t):t.type=="ATTDEF"?this.convertAttributeDefinition(t):t.type=="ATTRIB"?this.convertAttribute(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertFace(t){const e=new Ri;return t.vertices.forEach((s,a)=>e.setVertexAt(a,s)),e}convertArc(t){return new Ni(t.center,t.radius,St.degToRad(t.startAngle),St.degToRad(t.endAngle),t.extrusionDirection??q.Z_AXIS)}convertAttributeCommon(t,e){e.textString=t.text,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=t.rotation,e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.tag=t.tag,e.fieldLength=0,e.isInvisible=(t.attributeFlag&de.Invisible)!==0,e.isConst=(t.attributeFlag&de.Const)!==0,e.isVerifiable=(t.attributeFlag&de.Verifiable)!==0,e.isPreset=(t.attributeFlag&de.Preset)!==0,e.isReallyLocked=!!t.isReallyLocked,e.isMTextAttribute=(t.mtextFlag&br.MultiLine)!==0,e.isConstMTextAttribute=(t.mtextFlag&br.ConstMultiLine)!==0}convertAttribute(t){const e=new Oi;return this.convertAttributeCommon(t,e),e.styleName=t.textStyle,e.horizontalMode=t.horizontalJustification,e.verticalMode=t.verticalJustification,e.widthFactor=t.scale??1,e.lockPositionInBlock=t.lockPositionFlag,e}convertAttributeDefinition(t){const e=new Li;return this.convertAttributeCommon(t,e),e.styleName=t.styleName,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e.prompt=t.prompt,e}convertCirle(t){return new Ci(t.center,t.radius,t.extrusionDirection??q.Z_AXIS)}convertEllipse(t){const e=new q(t.majorAxisEndPoint),s=e.length();return new Bi(t.center,t.extrusionDirection??q.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new ri(new G(e.x,e.y,e.z||0),new G(s.x,s.y,s.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new si(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new si(e,"Uniform",t.degree,!!(t.flag&1))}}catch(e){console.log(`Failed to convert spline with error: ${e}`)}return null}convertPoint(t){const e=new Di;return e.position=t.position,e}convertSolid(t){const e=new Vi;return t.points.forEach((s,a)=>e.setPointAt(a,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),s=!!(t.flag&8),a=[],h=[];if(t.vertices.map(u=>{u.flag&k0.SPLINE_CONTROL_POINT||(a.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0))}),s){let u=Zs.SimplePoly;return t.flag&4&&(t.smoothType==bi.CUBIC?u=Zs.CubicSplinePoly:t.smoothType==bi.QUADRATIC&&(u=Zs.QuadSplinePoly)),new ti(u,a,e)}else{let u=Qn.SimplePoly;return t.flag&2?u=Qn.FitCurvePoly:t.flag&4&&(t.smoothType==bi.CUBIC?u=Qn.CubicSplinePoly:t.smoothType==bi.QUADRATIC&&(u=Qn.QuadSplinePoly)),new Js(u,a,0,e,t.startWidth,t.endWidth,h)}}convertLWPolyline(t){const e=new ji;return e.closed=!!(t.flag&1),t.vertices.forEach((s,a)=>{e.addVertexAt(a,new Et(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var a;const e=new ei;return(a=t.definitionLines)==null||a.forEach(h=>{e.definitionLines.push({angle:h.angle,base:h.base,offset:h.offset,dashLengths:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.isSolidFill=t.solidFill==Bd.SolidFill,e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const p=h,v=new un;v.closed=p.isClosed,p.vertices.forEach((f,x)=>{v.addVertexAt(x,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(v)}else{const p=h,v=new oa;p.edges.forEach(f=>{if(f.type==1){const x=f;v.add(new ts(x.start,x.end))}else if(f.type==2){const x=f;v.add(new Nn(x.center,x.radius,St.degToRad(x.startAngle||0),St.degToRad(x.endAngle||0),!x.isCCW))}else if(f.type==3){const x=f;new te().subVectors(x.end,x.center);const A=Math.sqrt(Math.pow(x.end.x,2)+Math.pow(x.end.y,2)),k=A*x.lengthOfMinorAxis;let L=St.degToRad(x.startAngle||0),C=St.degToRad(x.endAngle||0);const V=Math.atan2(x.end.y,x.end.x);x.isCCW||(L=Math.PI*2-L,C=Math.PI*2-C),v.add(new li({...x.center,z:0},A,k,L,C,!x.isCCW,V))}else if(f.type==4){const x=f;if(x.numberOfControlPoints>0&&x.numberOfKnots>0){const w=x.controlPoints.map(L=>({x:L.x,y:L.y,z:0}));let A=!0;const k=x.controlPoints.map(L=>(L.weight==null&&(A=!1),L.weight||1));v.add(new Gr(w,x.knots,A?k:void 0))}else if(x.numberOfFitData>0){const w=x.fitDatum.map(A=>({x:A.x,y:A.y,z:0}));v.add(new Gr(w,"Uniform"))}}}),e.add(v)}}),e}convertTable(t){const e=new zi(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,a)=>e.setColumnWidth(a,s)),t.rowHeightArr.forEach((s,a)=>e.setRowHeight(a,s)),t.cells.forEach((s,a)=>{e.setCell(a,s)}),e}convertText(t){const e=new rs;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=St.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new ni;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=St.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new q(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new Fi;return t.vertices.forEach(s=>{e.appendVertex(s)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new Xi(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(s.dimBlockPosition={...e.insertionPoint,z:0}),s.rotation=St.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new Yi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new Ki(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new $i(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new qi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,e.imageDefId=t.imageDefHandle,e.isClipped=t.isClipped,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new Et(s))}),e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new ii;return this.processImage(t,e),e.clipBoundaryType=t.clippingBoundaryType,e}processWipeout(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.displayFlag|4)>0,e.isImageShown=(t.displayFlag|3)>0,e.isImageTransparent=(t.displayFlag|8)>0,e.imageDefId=t.imageDefHardId,e.isClipped=t.isClipping,t.boundary.forEach(s=>{e.clipBoundary.push(new Et(s))}),e.clipBoundaryType=t.boundaryType,e.width=Math.sqrt(t.uDirection.x**2+t.uDirection.y**2+t.uDirection.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vDirection.x**2+t.vDirection.y**2+t.vDirection.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uDirection.y,t.uDirection.x)}convertWipeout(t){const e=new Wi;return this.processWipeout(t,e),e}convertViewport(t){const e=new Gi;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new Ui;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Hi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Ln(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?St.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&e.color.setRGBValue(t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=na.deserialize(t.transparency))}numberArrayToPointArray(t,e){const s=t.length;let a=0;if(s/2==e?a=2:s/3==e&&(a=3),a==0)return;const h=[];for(let u=0,p=s/a;u<p;++u)h.push({x:t[u*a],y:t[u*a+1],z:a==3?t[u*a+2]:0});return h}}class yp{convertLayout(t,e){var h,u;const s=new hi;s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,s.plotSettingsName=t.pageSetupName,s.plotCfgName=t.configName,s.canonicalMediaName=t.paperSize,s.plotViewName=t.plotViewName,s.currentStyleSheet=t.currentStyleSheet,s.plotPaperMargins={left:t.marginLeft,right:t.marginRight,top:t.marginTop,bottom:t.marginBottom},s.plotPaperSize.copy({x:t.paperWidth,y:t.paperHeight}),s.plotOrigin.copy({x:t.plotOriginX,y:t.plotOriginY}),s.plotWindowArea.min.copy({x:t.windowAreaXMin,y:t.windowAreaYMin}),s.plotWindowArea.max.copy({x:t.windowAreaXMax,y:t.windowAreaYMax}),s.customPrintScale={numerator:t.printScaleNumerator,denominator:t.printScaleDenominator},s.plotPaperUnits=t.plotPaperUnit,s.plotRotation=t.plotRotation,s.plotType=t.plotType,s.stdScaleType=t.standardScaleType,s.shadePlot=(()=>{switch(t.shadePlotMode){case 1:return Zn.kWireframe;case 2:return Zn.kHidden;case 3:return Zn.kRendered;default:return Zn.kAsDisplayed}})(),s.shadePlotResLevel=(()=>{switch(t.shadePlotResolution){case 1:return sn.kPreview;case 2:return sn.kNormal;case 3:return sn.kPresentation;case 4:return sn.kMaximum;case 5:return sn.kCustom;default:return sn.kDraft}})(),t.shadePlotCustomDPI!=null&&(s.shadePlotCustomDPI=t.shadePlotCustomDPI),t.shadePlotId&&(s.shadePlotId=t.shadePlotId);const a=t.layoutFlag??0;if(s.plotViewportBorders=(a&1)!==0,s.showPlotStyles=(a&2)!==0,s.plotCentered=(a&4)!==0,s.plotHidden=(a&8)!==0,s.useStandardScale=(a&16)!==0,s.plotPlotStyles=(a&32)!==0,s.scaleLineweights=(a&64)!==0,s.printLineweights=(a&128)!==0,s.drawViewportsFirst=(a&512)!==0,s.modelType=(a&1024)!==0,t.layoutName==="Model"){const p=ue.MODEL_SPACE_NAME;(h=e.tables.BLOCK_RECORD)==null||h.entries.some(v=>v.name.toUpperCase()===p?(s.blockTableRecordId=v.handle,!0):!1)}else(u=e.tables.BLOCK_RECORD)==null||u.entries.some(p=>p.layoutObjects===t.handle?(s.blockTableRecordId=p.handle,!0):!1),s.blockTableRecordId||(s.blockTableRecordId=t.paperSpaceTableId);return s.limits.min.copy(t.minLimit),s.limits.max.copy(t.maxLimit),s.extents.min.copy(t.minExtent),s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new Wh;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class kc{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),a=this.generateTaskId();try{return await this.executeInWorker(a,t,e||this.config.workerUrl)}catch(h){const u=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:u}}}async executeInWorker(t,e,s){const a=Date.now();return new Promise((h,u)=>{const p=this.getAvailableWorker(s),v=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(p),u(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:w=>{clearTimeout(v),this.releaseWorker(p),h(w)},reject:w=>{clearTimeout(v),this.releaseWorker(p),u(w)},timeout:v});const f=w=>{const{id:A,success:k,data:L,error:C}=w.data;if(A!==t)return;this.cleanupTask(t);const V=Date.now()-a;h(k?{success:!0,data:L,duration:V}:{success:!1,error:C,duration:V})},x=w=>{this.cleanupTask(t),u(new Error(`Worker error: ${w.message}`))};p.addEventListener("message",f),p.addEventListener("error",x),p.postMessage({id:t,input:e})})}cleanupTask(t){const e=this.pendingTasks.get(t);e&&(clearTimeout(e.timeout),this.pendingTasks.delete(t))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(t){for(const[s,a]of this.workers)if(!a.isBusy)return a.isBusy=!0,a.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const s=new Worker(t,{type:"module"}),a=this.generateWorkerId(),h={worker:s,isBusy:!0,id:a,createdAt:new Date};return this.workers.set(a,h),s}const e=Array.from(this.workers.values()).sort((s,a)=>s.createdAt.getTime()-a.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,s]of this.workers)if(s.worker===t){s.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(t=>t.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[t,e]of this.pendingTasks)clearTimeout(e.timeout),e.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[t,e]of this.workers)e.worker.terminate();this.workers.clear()}}class Mc{constructor(t){this.framework=new kc(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Tc(n){return new Mc(n)}class vp{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:s}=t.data;try{const a=await this.executeTask(s);this.sendResponse(e,!0,a)}catch(a){this.sendResponse(e,!1,void 0,a instanceof Error?a.message:String(a))}}}sendResponse(t,e,s,a){const h={id:t,success:e,data:s,error:a};self.postMessage(h)}}class Nc extends fo{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t,e){const s=this.config,a=this.getParserWorkerTimeout(t,e);if(s.useWorker&&s.parserWorkerUrl){const h=Tc({workerUrl:s.parserWorkerUrl,timeout:a,maxConcurrentWorkers:1}),u=await h.execute(t);if(h.destroy(),u.success)return{model:u.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${u.error}'`)}else return{model:new fp().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,s=u=>{if(u){const p=u.lastIndexOf(".");return p>=0?u.substring(0,p).toLowerCase():u.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(u=>{const p=[];if(u.font){const v=s(u.font);v&&p.push(v)}if(u.bigFont){const v=s(u.bigFont);v&&p.push(v)}if(u.extendedFont){const v=s(u.extendedFont);v&&p.push(v)}e.set(u.name,p)});const a=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,a),Array.from(a)}getFontsInBlock(t,e,s,a){const h=/\\f(.*?)\|/g;t.forEach(u=>{if(u.type=="MTEXT"){const p=u;[...p.text.matchAll(h)].forEach(x=>{a.add(x[1].toLowerCase())});const f=s.get(p.styleName);f==null||f.forEach(x=>a.add(x))}else if(u.type=="TEXT"){const p=u,v=s.get(p.styleName);v==null||v.forEach(f=>a.add(f))}else if(u.type=="INSERT"){const v=e[u.name];v&&v.entities&&this.getFontsInBlock(v.entities,e,s,a)}})}async processEntities(t,e,s,a,h){const u=new zl;let p=t.entities;const v=p.length,f=new Ka(v,100-a.value,s);this.config.convertByEntityType&&(p=this.groupAndFlattenByType(p));const x=new Map;for(let A=0;A<v;A++){const k=p[A];if(k.type==="ATTRIB"){const L=u.convert(k);if(L&&L.ownerId&&L.ownerId!=="0"){let C=x.get(L==null?void 0:L.ownerId);C==null&&(C=[],x.set(L.ownerId,C)),C.push(L)}}}const w=e.tables.blockTable.modelSpace;await f.processChunk(async(A,k)=>{let L=[],C=A<k?p[A].type:"";for(let z=A;z<k;z++){const at=p[z];if(at.type!=="ATTRIB"){const _t=u.convert(at);if(_t){if(this.config.convertByEntityType&&at.type!==C&&(w.appendEntity(L),L=[],C=at.type),at.type==="INSERT"){const st=x.get(_t.objectId);st&&st.length>0&&st.forEach(H=>{_t.appendAttributes(H)})}L.push(_t)}}}w.appendEntity(L);let V=a.value+k/v*(100-a.value);V>100&&(V=100),h&&await h(V,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(t,e,s=!1){const a=new zl,h=t.length,u=[],p=e.objectId,v=[];for(let f=0;f<h;f++){const x=t[f],w=a.convert(x);w&&(x.type==="ATTRIB"?v.push(w):(!s||x.ownerBlockRecordSoftId===p)&&u.push(w))}v.forEach(f=>{const x=e.getIdAt(f.ownerId);x&&x.appendAttributes(f)}),e.appendEntity(u)}processBlocks(t,e){const s=t.blocks;for(const[a,h]of Object.entries(s)){let u=e.tables.blockTable.getAt(h.name);u||(u=new ue,u.objectId=h.handle,u.name=a,u.origin.copy(h.position),e.tables.blockTable.add(u)),h.entities?this.processEntitiesInBlock(h.entities,u):u.isPaperSapce&&this.processEntitiesInBlock(t.entities,u,!0)}}processHeader(t,e){const s=t.header;s.$ACADVER&&(e.version=s.$ACADVER),e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,s.$AUNITS!=null&&(e.aunits=s.$AUNITS),e.celtscale=s.$CELTSCALE||1,e.ltscale=s.$LTSCALE||1,s.$EXTMAX&&(e.extmax=s.$EXTMAX),s.$EXTMIN&&(e.extmin=s.$EXTMIN),s.$INSUNITS!=null&&(e.insunits=s.$INSUNITS),e.osmode=s.$OSMODE||0,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0,e.textstyle=s.$TEXTSTYLE||ne}processBlockTables(t,e){var a;const s=(a=t.tables.BLOCK_RECORD)==null?void 0:a.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(h=>{const u=new ue;u.objectId=h.handle,u.name=h.name,u.layoutId=h.layoutObjects,e.tables.blockTable.add(u)}))}processObjects(t,e){const s=t.objects.byName,a=new yp;if("LAYOUT"in s){const h=e.objects.layout;s.LAYOUT.forEach(u=>{const p=a.convertLayout(u,t);h.setAt(p.layoutName,p)})}if("IMAGEDEF"in s){const h=e.objects.imageDefinition;s.IMAGEDEF.forEach(u=>{const p=a.convertImageDef(u);h.setAt(p.objectId,p)})}}processViewports(t,e){var a,h;const s=(h=(a=t.tables)==null?void 0:a.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const p=new _o;this.processCommonTableEntryAttrs(u,p),u.circleSides&&(p.circleSides=u.circleSides),p.standardFlag=u.standardFlag,p.center.copy(u.center),p.lowerLeftCorner.copy(u.lowerLeftCorner),p.upperRightCorner.copy(u.upperRightCorner),u.snapBasePoint&&p.snapBase.copy(u.snapBasePoint),u.snapRotationAngle&&(p.snapAngle=u.snapRotationAngle),u.snapSpacing&&p.snapIncrements.copy(u.snapSpacing),u.majorGridLines&&(p.gridMajor=u.majorGridLines),u.gridSpacing&&p.gridIncrements.copy(u.gridSpacing),u.backgroundObjectId&&(p.backgroundObjectId=u.backgroundObjectId),p.gsView.center.copy(u.center),p.gsView.viewDirectionFromTarget.copy(u.viewDirectionFromTarget),p.gsView.viewTarget.copy(u.viewTarget),u.lensLength&&(p.gsView.lensLength=u.lensLength),u.frontClippingPlane&&(p.gsView.frontClippingPlane=u.frontClippingPlane),u.backClippingPlane&&(p.gsView.backClippingPlane=u.backClippingPlane),u.viewHeight&&(p.gsView.viewHeight=u.viewHeight),u.viewTwistAngle&&(p.gsView.viewTwistAngle=u.viewTwistAngle),u.frozenLayers&&(p.gsView.frozenLayers=u.frozenLayers),u.styleSheet&&(p.gsView.styleSheet=u.styleSheet),u.renderMode&&(p.gsView.renderMode=u.renderMode),u.viewMode&&(p.gsView.viewMode=u.viewMode),u.ucsIconSetting&&(p.gsView.ucsIconSetting=u.ucsIconSetting),u.ucsOrigin&&p.gsView.ucsOrigin.copy(u.ucsOrigin),u.ucsXAxis&&p.gsView.ucsXAxis.copy(u.ucsXAxis),u.ucsYAxis&&p.gsView.ucsYAxis.copy(u.ucsYAxis),u.orthographicType&&(p.gsView.orthographicType=u.orthographicType),u.shadePlotSetting&&(p.gsView.shadePlotSetting=u.shadePlotSetting),u.shadePlotObjectId&&(p.gsView.shadePlotObjectId=u.shadePlotObjectId),u.visualStyleObjectId&&(p.gsView.visualStyleObjectId=u.visualStyleObjectId),u.isDefaultLightingOn&&(p.gsView.isDefaultLightingOn=u.isDefaultLightingOn),u.defaultLightingType&&(p.gsView.defaultLightingType=u.defaultLightingType),u.brightness&&(p.gsView.brightness=u.brightness),u.contrast&&(p.gsView.contrast=u.contrast),u.ambientColor&&(p.gsView.ambientColor=u.ambientColor),e.tables.viewportTable.add(p)})}processLayers(t,e){var a,h;const s=(h=(a=t.tables)==null?void 0:a.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const p=new ce;p.colorIndex=u.colorIndex;const v=new ci({name:u.name,standardFlags:u.standardFlag,linetype:u.lineType,lineWeight:u.lineweight,isOff:u.colorIndex<0,color:p,isPlottable:u.isPlotting});this.processCommonTableEntryAttrs(u,v),e.tables.layerTable.add(v)})}processLineTypes(t,e){var a,h;const s=(h=(a=t.tables)==null?void 0:a.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const p=new ln(u);this.processCommonTableEntryAttrs(u,p),p.name=u.name,e.tables.linetypeTable.add(p)})}processTextStyles(t,e){var a;const s=(a=t.tables.STYLE)==null?void 0:a.entries;s&&s.length>0&&s.forEach(h=>{const u=new la(h);this.processCommonTableEntryAttrs(h,u),e.tables.textStyleTable.add(u)})}processDimStyles(t,e){var a;const s=(a=t.tables.DIMSTYLE)==null?void 0:a.entries;s&&s.length>0&&s.forEach(h=>{const u={name:h.name,ownerId:h.ownerObjectId,dimpost:h.DIMPOST||"",dimapost:h.DIMAPOST||"",dimscale:h.DIMSCALE,dimasz:h.DIMASZ,dimexo:h.DIMEXO,dimdli:h.DIMDLI,dimexe:h.DIMEXE,dimrnd:h.DIMRND,dimdle:h.DIMDLE,dimtp:h.DIMTP,dimtm:h.DIMTM,dimtxt:h.DIMTXT,dimcen:h.DIMCEN,dimtsz:h.DIMTSZ,dimaltf:h.DIMALTF,dimlfac:h.DIMLFAC,dimtvp:h.DIMTVP,dimtfac:h.DIMTFAC,dimgap:h.DIMGAP,dimaltrnd:h.DIMALTRND,dimtol:h.DIMTOL==null||h.DIMTOL==0?0:1,dimlim:h.DIMLIM==null||h.DIMLIM==0?0:1,dimtih:h.DIMTIH==null||h.DIMTIH==0?0:1,dimtoh:h.DIMTOH==null||h.DIMTOH==0?0:1,dimse1:h.DIMSE1==null||h.DIMSE1==0?0:1,dimse2:h.DIMSE2==null||h.DIMSE2==0?0:1,dimtad:h.DIMTAD,dimzin:h.DIMZIN,dimazin:h.DIMAZIN,dimalt:h.DIMALT,dimaltd:h.DIMALTD,dimtofl:h.DIMTOFL,dimsah:h.DIMSAH,dimtix:h.DIMTIX,dimsoxd:h.DIMSOXD,dimclrd:h.DIMCLRD,dimclre:h.DIMCLRE,dimclrt:h.DIMCLRT,dimadec:h.DIMADEC||0,dimunit:h.DIMUNIT||2,dimdec:h.DIMDEC,dimtdec:h.DIMTDEC,dimaltu:h.DIMALTU,dimalttd:h.DIMALTTD,dimaunit:h.DIMAUNIT,dimfrac:h.DIMFRAC,dimlunit:h.DIMLUNIT,dimdsep:h.DIMDSEP,dimtmove:h.DIMTMOVE||0,dimjust:h.DIMJUST,dimsd1:h.DIMSD1,dimsd2:h.DIMSD2,dimtolj:h.DIMTOLJ,dimtzin:h.DIMTZIN,dimaltz:h.DIMALTZ,dimalttz:h.DIMALTTZ,dimfit:h.DIMFIT||0,dimupt:h.DIMUPT,dimatfit:h.DIMATFIT,dimtxsty:h.DIMTXSTY||ne,dimldrblk:h.DIMLDRBLK||"",dimblk:h.DIMBLK||"",dimblk1:h.DIMBLK1||"",dimblk2:h.DIMBLK2||"",dimlwd:h.DIMLWD,dimlwe:h.DIMLWE},p=new On(u);this.processCommonTableEntryAttrs(h,p),e.tables.dimStyleTable.add(p)})}processCommonTableEntryAttrs(t,e){e.name=t.name,t.handle!=null&&(e.objectId=t.handle),e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},s=[];for(const a of t)e[a.type]||(e[a.type]=[],s.push(a.type)),e[a.type].push(a);return s.flatMap(a=>e[a])}}class Lc extends fo{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,s,a,h){let u=t.tables.blockTable.modelSpace.newIterator().toArray();const p=u.length,v=new Ka(p,100-a.value,s);this.config.convertByEntityType&&(u=this.groupAndFlattenByType(u));const f=e.tables.blockTable.modelSpace;await v.processChunk(async(x,w)=>{let A=[],k=x<w?u[x].type:"";for(let L=x;L<w;L++){const C=u[L];this.config.convertByEntityType&&C.type!==k&&(this.triggerEvents(f,A),A=[],k=C.type),A.push(C)}if(this.triggerEvents(f,A),h){let L=a.value+w/p*(100-a.value);L>100&&(L=100),await h(L,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const s=e.newIterator().toArray();this.triggerEvents(e,s)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const s of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const s of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},s=[];for(const a of t)e[a.type]||(e[a.type]=[],s.push(a.type)),e[a.type].push(a);return s.flatMap(a=>e[a])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}exports.AC_DB_SYSTEM_VARIABLE_NAMES=Md;exports.AcCmColor=ce;exports.AcCmColorMethod=lt;exports.AcCmColorUtil=nn;exports.AcCmEntityColor=$c;exports.AcCmErrors=Ze;exports.AcCmEventDispatcher=Zc;exports.AcCmEventManager=he;exports.AcCmLoader=id;exports.AcCmLoadingManager=ql;exports.AcCmObject=Wl;exports.AcCmPerformanceCollector=Ya;exports.AcCmTask=Yl;exports.AcCmTaskScheduler=Xl;exports.AcCmTransparency=na;exports.AcCmTransparencyMethod=Ne;exports.AcDb2dPolyline=Js;exports.AcDb2dVertex=ja;exports.AcDb2dVertexType=$h;exports.AcDb3PointAngularDimension=Yi;exports.AcDb3dPolyline=ti;exports.AcDb3dVertex=Da;exports.AcDb3dVertexType=Zh;exports.AcDbAlignedDimension=Xi;exports.AcDbAngleUnits=oo;exports.AcDbArc=Ni;exports.AcDbArcDimension=Ua;exports.AcDbAttribute=Oi;exports.AcDbAttributeDefinition=Li;exports.AcDbAttributeFlags=de;exports.AcDbAttributeMTextFlag=br;exports.AcDbBaseWorker=vp;exports.AcDbBatchProcessing=Ka;exports.AcDbBlockReference=Ln;exports.AcDbBlockTable=iu;exports.AcDbBlockTableRecord=ue;exports.AcDbCircle=Ci;exports.AcDbCodePage=lo;exports.AcDbCurve=Oe;exports.AcDbDataGenerator=Yh;exports.AcDbDatabase=Ga;exports.AcDbDatabaseConverter=fo;exports.AcDbDatabaseConverterManager=vr;exports.AcDbDiametricDimension=qi;exports.AcDbDictionary=$s;exports.AcDbDimArrowType=Xh;exports.AcDbDimStyleTable=au;exports.AcDbDimStyleTableRecord=On;exports.AcDbDimTextHorizontal=ou;exports.AcDbDimTextVertical=lu;exports.AcDbDimVerticalJustification=cu;exports.AcDbDimZeroSuppression=hu;exports.AcDbDimZeroSuppressionAngular=uu;exports.AcDbDimension=Wr;exports.AcDbDuplicateRecordCloning=Hh;exports.AcDbDwgVersion=er;exports.AcDbDxfCode=Ha;exports.AcDbDxfConverter=Nc;exports.AcDbDxfFiler=Vl;exports.AcDbEllipse=Bi;exports.AcDbEntity=Le;exports.AcDbFace=Ri;exports.AcDbFileType=Xs;exports.AcDbHatch=ei;exports.AcDbHatchPatternType=Qs;exports.AcDbHatchStyle=tu;exports.AcDbHostApplicationServices=ki;exports.AcDbLayerTable=du;exports.AcDbLayerTableRecord=ci;exports.AcDbLayout=hi;exports.AcDbLayoutDictionary=Uh;exports.AcDbLayoutManager=Gh;exports.AcDbLeader=Fi;exports.AcDbLeaderAnnotationType=eu;exports.AcDbLine=ri;exports.AcDbLineSpacingStyle=su;exports.AcDbLinetypeTable=pu;exports.AcDbLinetypeTableRecord=ln;exports.AcDbMText=ni;exports.AcDbObject=Hr;exports.AcDbObjectIterator=ui;exports.AcDbOpenMode=Jl;exports.AcDbOrdinateDimension=Ki;exports.AcDbOsnapMode=zt;exports.AcDbPlotPaperUnits=Fh;exports.AcDbPlotRotation=zh;exports.AcDbPlotSettings=Dh;exports.AcDbPlotShadePlotResLevel=sn;exports.AcDbPlotShadePlotType=Zn;exports.AcDbPlotStdScaleType=jh;exports.AcDbPlotType=Vh;exports.AcDbPoint=Di;exports.AcDbPoly2dType=Qn;exports.AcDbPoly3dType=Zs;exports.AcDbPolyline=ji;exports.AcDbRadialDimension=$i;exports.AcDbRasterImage=ii;exports.AcDbRasterImageClipBoundaryType=ru;exports.AcDbRasterImageDef=Wh;exports.AcDbRasterImageImageDisplayOpt=nu;exports.AcDbRay=Ui;exports.AcDbRegAppTable=_u;exports.AcDbRegAppTableRecord=fu;exports.AcDbRegenerator=Lc;exports.AcDbRenderingCache=is;exports.AcDbResultBuffer=qa;exports.AcDbSpline=si;exports.AcDbSymbolTable=dn;exports.AcDbSymbolTableRecord=cn;exports.AcDbSysVarManager=Zi;exports.AcDbSystemVariables=jt;exports.AcDbTable=zi;exports.AcDbText=rs;exports.AcDbTextHorizontalMode=Qh;exports.AcDbTextStyleTable=mu;exports.AcDbTextStyleTableRecord=la;exports.AcDbTextVerticalMode=Jh;exports.AcDbTrace=Vi;exports.AcDbUnitsValue=uo;exports.AcDbViewport=Gi;exports.AcDbViewportTable=gu;exports.AcDbViewportTableRecord=_o;exports.AcDbWipeout=Wi;exports.AcDbWorkerApi=Mc;exports.AcDbWorkerManager=kc;exports.AcDbXline=Hi;exports.AcDbXrecord=ho;exports.AcGeArea2d=ia;exports.AcGeBox2d=ve;exports.AcGeBox3d=Nt;exports.AcGeCatmullRomCurve3d=Ch;exports.AcGeCircArc2d=Nn;exports.AcGeCircArc3d=ao;exports.AcGeCurve2d=ss;exports.AcGeEllipseArc2d=li;exports.AcGeEllipseArc3d=aa;exports.AcGeEuler=pd;exports.AcGeGeometryUtil=xh;exports.AcGeLine2d=ts;exports.AcGeLine3d=es;exports.AcGeLoop2d=oa;exports.AcGeMathUtil=St;exports.AcGeMatrix2d=sa;exports.AcGeMatrix3d=$e;exports.AcGeNurbsCurve=Mn;exports.AcGePlane=ai;exports.AcGePoint2d=Et;exports.AcGePoint3d=G;exports.AcGePolyline2d=un;exports.AcGeQuaternion=Cn;exports.AcGeShape2d=io;exports.AcGeSpline3d=Gr;exports.AcGeTol=ro;exports.AcGeVector2d=te;exports.AcGeVector3d=q;exports.AcGiArrowType=co;exports.AcGiDefaultLightingType=go;exports.AcGiLineWeight=hn;exports.AcGiMTextAttachmentPoint=Pe;exports.AcGiMTextFlowDirection=Ur;exports.AcGiOrthographicType=mo;exports.AcGiRenderMode=po;exports.AcGiViewport=qh;exports.AcTrStringUtil=sd;exports.ByBlock=Rh;exports.ByLayer=xi;exports.DEBUG_MODE=rd;exports.DEFAULT_LINE_TYPE=Ti;exports.DEFAULT_TEXT_STYLE=ne;exports.DEFAULT_TOL=no;exports.DEG2RAD=$a;exports.DefaultLoadingManager=Kl;exports.FLOAT_TOL=En;exports.ORIGIN_POINT_2D=od;exports.ORIGIN_POINT_3D=eo;exports.RAD2DEG=Za;exports.TAU=Qt;exports.acdbDisableOsnapMode=Sd;exports.acdbEnableOsnapMode=Id;exports.acdbHasOsnapMode=xd;exports.acdbHostApplicationServices=Xa;exports.acdbMaskToOsnapModes=bd;exports.acdbOsnapModesToMask=vd;exports.acdbToggleOsnapMode=wd;exports.basisFunction=Mi;exports.calculateCurveLength=Ah;exports.ceilPowerOfTwo=mh;exports.clamp=Dr;exports.clone=Ws;exports.createWorkerApi=Tc;exports.damp=nh;exports.deepClone=Oa;exports.defaults=ns;exports.degToRad=ch;exports.dwgCodePageToEncoding=Bh;exports.euclideanModulo=Qa;exports.evaluateNurbsPoint=Ks;exports.floorPowerOfTwo=gh;exports.generateChordKnots=Sh;exports.generateSqrtChordKnots=Ph;exports.generateUUID=th;exports.generateUniformKnots=Ih;exports.has=jl;exports.intPartLength=to;exports.interpolateControlPoints=ld;exports.inverseLerp=rh;exports.isBetween=_h;exports.isBetweenAngle=fh;exports.isEmpty=Dl;exports.isEqual=Jn;exports.isImperialUnits=Ad;exports.isMetricUnits=Pd;exports.isPointInPolygon=so;exports.isPolygonIntersect=wh;exports.isPowerOfTwo=ph;exports.lerp=Ja;exports.log=Ys;exports.mapLinear=eh;exports.normalizeAngle=qs;exports.pingpong=sh;exports.radToDeg=dh;exports.randFloat=lh;exports.randFloatSpread=hh;exports.randInt=oh;exports.relativeEps=yh;exports.seededRandom=uh;exports.setAcDbHostApplicationServicesProvider=Zl;exports.setAcDbLayoutManagerFactory=Ql;exports.setLogLevel=nd;exports.smootherstep=ah;exports.smoothstep=ih;
|
|
6
|
+
`+i+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Lt.__interfLoop=function(r,i){if(r==null)return!1;if(r==i)return!0;var o=r.__interfaces__;if(o!=null)for(var l=0,c=o.length;l<c;){var d=l++,g=o[d];if(g==i||Lt.__interfLoop(g,i))return!0}return Lt.__interfLoop(r.__super__,i)},Lt.__instanceof=function(r,i){if(i==null)return!1;switch(i){case Cc:return(r|0)===r;case nl:return typeof r=="number";case sl:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case Bc:return!0;default:if(r!=null){if(typeof i=="function"){if(r instanceof i||Lt.__interfLoop(Lt.getClass(r),i))return!0}else if(typeof i=="object"&&Lt.__isNativeObj(i)&&r instanceof i)return!0}else return!1;return i==il&&r.__name__!=null||i==al&&r.__ename__!=null?!0:r.__enum__==i}},Lt.__nativeClassName=function(r){var i=Lt.__toStr.call(r).slice(8,-1);return i=="Object"||i=="Function"||i=="Math"||i=="JSON"?null:i},Lt.__isNativeObj=function(r){return Lt.__nativeClassName(r)!=null},Lt.__resolveNativeClass=function(r){return x[r]};var me=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var i=r;this.a=[];for(var o=0;o<i;){var l=o++;this.a[l]=0}this.byteLength=i}};w["js.html.compat.ArrayBuffer"]=me,me.__name__=["js","html","compat","ArrayBuffer"],me.sliceImpl=function(r,i){var o=new pa(this,r,i==null?null:i-r),l=new mi(o.byteLength),c=new pa(l);return c.set(o),l},me.prototype={slice:function(r,i){return new me(this.a.slice(r,i))},__class__:me};var wr=function(r,i,o){if(this.buf=r,i==null?this.offset=0:this.offset=i,o==null?this.length=r.byteLength-this.offset:this.length=o,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(se.OutsideBounds)};w["js.html.compat.DataView"]=wr,wr.__name__=["js","html","compat","DataView"],wr.prototype={getInt8:function(r){var i=this.buf.a[this.offset+r];return i>=128?i-256:i},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,i){var o=this.getUint16(r,i);return o>=32768?o-65536:o},getUint16:function(r,i){return i?this.buf.a[this.offset+r]|this.buf.a[this.offset+r+1]<<8:this.buf.a[this.offset+r]<<8|this.buf.a[this.offset+r+1]},getInt32:function(r,i){var o=this.offset+r,l=this.buf.a[o++],c=this.buf.a[o++],d=this.buf.a[o++],g=this.buf.a[o++];return i?l|c<<8|d<<16|g<<24:g|d<<8|c<<16|l<<24},getUint32:function(r,i){var o=this.getInt32(r,i);return o<0?o+4294967296:o},getFloat32:function(r,i){return pe.i32ToFloat(this.getInt32(r,i))},getFloat64:function(r,i){var o=this.getInt32(r,i),l=this.getInt32(r+4,i);return pe.i64ToDouble(i?o:l,i?l:o)},setInt8:function(r,i){i<0?this.buf.a[r+this.offset]=i+128&255:this.buf.a[r+this.offset]=i&255},setUint8:function(r,i){this.buf.a[r+this.offset]=i&255},setInt16:function(r,i,o){this.setUint16(r,i<0?i+65536:i,o)},setUint16:function(r,i,o){var l=r+this.offset;o?(this.buf.a[l]=i&255,this.buf.a[l++]=i>>8&255):(this.buf.a[l++]=i>>8&255,this.buf.a[l]=i&255)},setInt32:function(r,i,o){this.setUint32(r,i,o)},setUint32:function(r,i,o){var l=r+this.offset;o?(this.buf.a[l++]=i&255,this.buf.a[l++]=i>>8&255,this.buf.a[l++]=i>>16&255,this.buf.a[l++]=i>>>24):(this.buf.a[l++]=i>>>24,this.buf.a[l++]=i>>16&255,this.buf.a[l++]=i>>8&255,this.buf.a[l++]=i&255)},setFloat32:function(r,i,o){this.setUint32(r,pe.floatToI32(i),o)},setFloat64:function(r,i,o){var l=pe.doubleToI64(i);o?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:wr};var pr=function(){};w["js.html.compat.Uint8Array"]=pr,pr.__name__=["js","html","compat","Uint8Array"],pr._new=function(r,i,o){var l;if(typeof r=="number"){l=[];for(var c=0;c<r;){var d=c++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new me(l)}else if(Lt.__instanceof(r,me)){var g=r;i==null&&(i=0),o==null&&(o=g.byteLength-i),i==0?l=g.a:l=g.a.slice(i,i+o),l.byteLength=l.length,l.byteOffset=i,l.buffer=g}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new me(l);else throw new Q("TODO "+st.string(r));return l.subarray=pr._subarray,l.set=pr._set,l},pr._set=function(r,i){var o=this;if(Lt.__instanceof(r.buffer,me)){var l=r;if(r.byteLength+i>o.byteLength)throw new Q("set() outside of range");for(var c=0,d=r.byteLength;c<d;){var g=c++;o[g+i]=l[g]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+i>o.byteLength)throw new Q("set() outside of range");for(var y=0,I=_.length;y<I;){var P=y++;o[P+i]=_[P]}}else throw new Q("TODO")},pr._subarray=function(r,i){var o=this,l=pr._new(o.slice(r,i));return l.byteOffset=r,l};var Tt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&Tt.link(r,this,function(i){return i})};w["promhx.base.AsyncBase"]=Tt,Tt.__name__=["promhx","base","AsyncBase"],Tt.link=function(r,i,o){r._update.push({async:i,linkf:function(l){i.handleResolve(o(l))}}),Tt.immediateLinkUpdate(r,i,o)},Tt.immediateLinkUpdate=function(r,i,o){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&i.handleError(r._errorVal),r._resolved&&!r._pending)try{i.handleResolve(o(r._val))}catch(l){l instanceof Q&&(l=l.val),i.handleError(l)}},Tt.linkAll=function(r,i){for(var o=function(d,g,_){if(d.length==0||Tt.allFulfilled(d)){for(var y,I=[],P=sr(r)();P.hasNext();){var S=P.next();I.push(S==g?_:S._val)}y=I,i.handleResolve(y)}},l=sr(r)();l.hasNext();){var c=l.next();c._update.push({async:i,linkf:function(d,g,_){return function(y){d(g,_,y)}}(o,function(d){for(var g,_=[],y=sr(r)();y.hasNext();){var I=y.next();I!=c&&_.push(I)}return g=_,g}(),c)})}Tt.allFulfilled(r)&&i.handleResolve(function(d){for(var g,_=[],y=sr(r)();y.hasNext();){var I=y.next();_.push(I._val)}return g=_,g}())},Tt.pipeLink=function(r,i,o){var l=!1,c=function(d){if(!l){l=!0;var g=o(d);g._update.push({async:i,linkf:De(i,i.handleResolve)}),Tt.immediateLinkUpdate(g,i,function(_){return _})}};if(r._update.push({async:i,linkf:c}),r._resolved&&!r._pending)try{c(r._val)}catch(d){d instanceof Q&&(d=d.val),i.handleError(d)}},Tt.allResolved=function(r){for(var i=sr(r)();i.hasNext();){var o=i.next();if(!o._resolved)return!1}return!0},Tt.allFulfilled=function(r){for(var i=sr(r)();i.hasNext();){var o=i.next();if(!o._fulfilled)return!1}return!0},Tt.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,this},isResolved:function(){return this._resolved},isErrored:function(){return this._errored},isErrorHandled:function(){return this._error.length>0},isErrorPending:function(){return this._errorPending},isFulfilled:function(){return this._fulfilled},isPending:function(){return this._pending},handleResolve:function(r){this._resolve(r)},_resolve:function(r){var i=this;this._pending?At.enqueue(function(o,l){return function(){o(l)}}(De(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,At.queue.add(function(){i._val=r;for(var o=0,l=i._update;o<l.length;){var c=l[o];++o;try{c.linkf(r)}catch(d){d instanceof Q&&(d=d.val),c.async.handleError(d)}}i._fulfilled=!0,i._pending=!1}),At.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var i=this,o=function(l){if(i._error.length>0)for(var c=0,d=i._error;c<d.length;){var g=d[c];++c,g(l)}else if(i._update.length>0)for(var _=0,y=i._update;_<y.length;){var I=y[_];++_,I.async.handleError(l)}else throw new Q(l);i._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,At.queue.add(function(){if(i._errorMap!=null)try{i._resolve(i._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),o(l)}else o(r)}),At.continueOnNextLoop())},then:function(r){var i=new Tt(null);return Tt.link(this,i,r),i},unlink:function(r){var i=this;At.queue.add(function(){i._update=i._update.filter(function(o){return o.async!=r})}),At.continueOnNextLoop()},isLinked:function(r){for(var i=!1,o=0,l=this._update;o<l.length;){var c=l[o];if(++o,c.async==r)return!0}return i},__class__:Tt};var Bn=f.promhx.Deferred=function(){Tt.call(this)};w["promhx.Deferred"]=Bn,Bn.__name__=["promhx","Deferred"],Bn.__super__=Tt,Bn.prototype=k(Tt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new xe(this)},stream:function(){return new qt(this)},publicStream:function(){return new Yr(this)},__class__:Bn});var xe=f.promhx.Promise=function(r){Tt.call(this,r),this._rejected=!1};w["promhx.Promise"]=xe,xe.__name__=["promhx","Promise"],xe.whenAll=function(r){var i=new xe(null);return Tt.linkAll(r,i),i},xe.promise=function(r){var i=new xe;return i.handleResolve(r),i},xe.__super__=Tt,xe.prototype=k(Tt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var i="Promise has already been resolved";throw new Q(Rn.AlreadyResolved(i))}this._resolve(r)},then:function(r){var i=new xe(null);return Tt.link(this,i,r),i},unlink:function(r){var i=this;At.queue.add(function(){if(i._fulfilled)i._update=i._update.filter(function(l){return l.async!=r});else{var o="Downstream Promise is not fullfilled";i.handleError(Rn.DownstreamNotFullfilled(o))}}),At.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var i=new xe(null);return Tt.pipeLink(this,i,r),i},errorPipe:function(r){var i=new xe;return this.catchError(function(o){var l=r(o);l.then(De(i,i._resolve))}),this.then(De(i,i._resolve)),i},__class__:xe});var qt=f.promhx.Stream=function(r){Tt.call(this,r),this._end_promise=new xe};w["promhx.Stream"]=qt,qt.__name__=["promhx","Stream"],qt.foreach=function(r){for(var i=new qt(null),o=sr(r)();o.hasNext();){var l=o.next();i.handleResolve(l)}return i.end(),i},qt.wheneverAll=function(r){var i=new qt(null);return Tt.linkAll(r,i),i},qt.concatAll=function(r){for(var i=new qt(null),o=sr(r)();o.hasNext();){var l=o.next();i.concat(l)}return i},qt.mergeAll=function(r){for(var i=new qt(null),o=sr(r)();o.hasNext();){var l=o.next();i.merge(l)}return i},qt.stream=function(r){var i=new qt(null);return i.handleResolve(r),i},qt.__super__=Tt,qt.prototype=k(Tt.prototype,{then:function(r){var i=new qt(null);return Tt.link(this,i,r),this._end_promise._update.push({async:i._end_promise,linkf:function(o){i.end()}}),i},detachStream:function(r){for(var i=[],o=!1,l=0,c=this._update;l<c.length;){var d=c[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(g){return g.async!=r._end_promise}),o=!0):i.push(d)}return this._update=i,o},first:function(){var r=new xe(null);return this.then(function(i){r._resolved||r.handleResolve(i)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var i=new qt(null);return Tt.pipeLink(this,i,r),this._end_promise.then(function(o){i.end()}),i},errorPipe:function(r){var i=new qt(null);return this.catchError(function(o){var l=r(o);l.then(De(i,i._resolve)),l._end_promise.then((ca=i._end_promise,De(ca,ca._resolve)))}),this.then(De(i,i._resolve)),this._end_promise.then(function(o){i.end()}),i},handleEnd:function(){if(this._pending)At.queue.add(De(this,this.handleEnd)),At.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=be.Some(this._val):r=be.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return At.queue.add(De(this,this.handleEnd)),At.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var i=new qt(null);return this._update.push({async:i,linkf:function(o){r(o)&&i.handleResolve(o)}}),Tt.immediateLinkUpdate(this,i,function(o){return o}),i},concat:function(r){var i=new qt(null);return this._update.push({async:i,linkf:De(i,i.handleResolve)}),Tt.immediateLinkUpdate(this,i,function(o){return o}),this._end_promise.then(function(o){r.pipe(function(l){return i.handleResolve(l),i}),r._end_promise.then(function(l){i.end()})}),i},merge:function(r){var i=new qt(null);return this._update.push({async:i,linkf:De(i,i.handleResolve)}),r._update.push({async:i,linkf:De(i,i.handleResolve)}),Tt.immediateLinkUpdate(this,i,function(o){return o}),Tt.immediateLinkUpdate(r,i,function(o){return o}),i},__class__:qt});var Yr=f.promhx.PublicStream=function(r){qt.call(this,r)};w["promhx.PublicStream"]=Yr,Yr.__name__=["promhx","PublicStream"],Yr.publicstream=function(r){var i=new Yr(null);return i.handleResolve(r),i},Yr.__super__=qt,Yr.prototype=k(qt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Yr});var At=function(){};w["promhx.base.EventLoop"]=At,At.__name__=["promhx","base","EventLoop"],At.enqueue=function(r){At.queue.add(r),At.continueOnNextLoop()},At.set_nextLoop=function(r){if(At.nextLoop!=null)throw new Q("nextLoop has already been set");return At.nextLoop=r,At.nextLoop},At.queueEmpty=function(){return At.queue.isEmpty()},At.finish=function(r){r==null&&(r=1e3);for(var i=null;r-- >0&&(i=At.queue.pop())!=null;)i();return At.queue.isEmpty()},At.clear=function(){At.queue=new V},At.f=function(){var r=At.queue.pop();r!=null&&r(),At.queue.isEmpty()||At.continueOnNextLoop()},At.continueOnNextLoop=function(){At.nextLoop!=null?At.nextLoop(At.f):setImmediate(At.f)};var Rn=w["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};Rn.AlreadyResolved=function(r){var i=["AlreadyResolved",0,r];return i.__enum__=Rn,i.toString=A,i},Rn.DownstreamNotFullfilled=function(r){var i=["DownstreamNotFullfilled",1,r];return i.__enum__=Rn,i.toString=A,i};var di=function(){};w["verb.Verb"]=di,di.__name__=["verb","Verb"],di.main=function(){v.log("verb 2.1.0")};var Z=function(){};w["verb.core.ArrayExtensions"]=Z,Z.__name__=["verb","core","ArrayExtensions"],Z.alloc=function(r,i){if(!(i<0))for(;r.length<i;)r.push(null)},Z.reversed=function(r){var i=r.slice();return i.reverse(),i},Z.last=function(r){return r[r.length-1]},Z.first=function(r){return r[0]},Z.spliceAndInsert=function(r,i,o,l){r.splice(i,o),r.splice(i,0,l)},Z.left=function(r){if(r.length==0)return[];var i=Math.ceil(r.length/2);return r.slice(0,i)},Z.right=function(r){if(r.length==0)return[];var i=Math.ceil(r.length/2);return r.slice(i)},Z.rightWithPivot=function(r){if(r.length==0)return[];var i=Math.ceil(r.length/2);return r.slice(i-1)},Z.unique=function(r,i){if(r.length==0)return[];for(var o=[r.pop()];r.length>0;){for(var l=r.pop(),c=!0,d=0;d<o.length;){var g=o[d];if(++d,i(l,g)){c=!1;break}}c&&o.push(l)}return o};var Vt=function(){};w["verb.core.Binomial"]=Vt,Vt.__name__=["verb","core","Binomial"],Vt.get=function(r,i){if(i==0)return 1;if(r==0||i>r)return 0;if(i>r-i&&(i=r-i),Vt.memo_exists(r,i))return Vt.get_memo(r,i);for(var o=1,l=r,c=1,d=i+1;c<d;){var g=c++;if(Vt.memo_exists(l,g)){r--,o=Vt.get_memo(l,g);continue}o*=r--,o/=g,Vt.memoize(l,g,o)}return o},Vt.get_no_memo=function(r,i){if(i==0)return 1;if(r==0||i>r)return 0;i>r-i&&(i=r-i);for(var o=1,l=1,c=i+1;l<c;){var d=l++;o*=r--,o/=d}return o},Vt.memo_exists=function(r,i){return Vt.memo.h.hasOwnProperty(r)&&Vt.memo.h[r].h.hasOwnProperty(i)},Vt.get_memo=function(r,i){return Vt.memo.h[r].h[i]},Vt.memoize=function(r,i,o){Vt.memo.h.hasOwnProperty(r)||Vt.memo.set(r,new xt),Vt.memo.h[r].h[i]=o};var Ve=f.core.BoundingBox=function(r){this.max=null,this.min=null,this.dim=3,this.initialized=!1,r!=null&&this.addRange(r)};w["verb.core.BoundingBox"]=Ve,Ve.__name__=["verb","core","BoundingBox"],Ve.intervalsOverlap=function(r,i,o,l,c){c==null&&(c=-1);var d;c<-.5?d=rt.TOLERANCE:d=c;var g=Math.min(r,i)-d,_=Math.max(r,i)+d,y=Math.min(o,l)-d,I=Math.max(o,l)+d;return g>=y&&g<=I||_>=y&&_<=I||y>=g&&y<=_||I>=g&&I<=_},Ve.prototype={fromPoint:function(r){return new Ve([r])},add:function(r){if(!this.initialized)return this.dim=r.length,this.min=r.slice(0),this.max=r.slice(0),this.initialized=!0,this;for(var i=0,o=this.dim;i<o;){var l=i++;r[l]>this.max[l]&&(this.max[l]=r[l]),r[l]<this.min[l]&&(this.min[l]=r[l])}return this},addRange:function(r){for(var i=r.length,o=0;o<i;){var l=o++;this.add(r[l])}return this},contains:function(r,i){return i==null&&(i=-1),this.initialized?this.intersects(new Ve([r]),i):!1},intersects:function(r,i){if(i==null&&(i=-1),!this.initialized||!r.initialized)return!1;for(var o=this.min,l=this.max,c=r.min,d=r.max,g=0,_=this.dim;g<_;){var y=g++;if(!Ve.intervalsOverlap(o[y],l[y],c[y],d[y],i))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,i=0,o=0,l=this.dim;o<l;){var c=o++,d=this.getAxisLength(c);d>r&&(r=d,i=c)}return i},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,i){if(!this.initialized)return null;var o=this.min,l=this.max,c=r.min,d=r.max;if(!this.intersects(r,i))return null;for(var g=[],_=[],y=0,I=this.dim;y<I;){var P=y++;g.push(Math.min(l[P],d[P])),_.push(Math.max(o[P],c[P]))}return new Ve([_,g])},__class__:Ve};var rt=f.core.Constants=function(){};w["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var ee=f.core.SerializableBase=function(){};w["verb.core.SerializableBase"]=ee,ee.__name__=["verb","core","SerializableBase"],ee.prototype={serialize:function(){var r=new Kt;return r.serialize(this),r.toString()},__class__:ee};var os=f.core.Plane=function(r,i){this.origin=r,this.normal=i};w["verb.core.Plane"]=os,os.__name__=["verb","core","Plane"],os.__super__=ee,os.prototype=k(ee.prototype,{__class__:os});var Fn=f.core.Ray=function(r,i){this.origin=r,this.dir=i};w["verb.core.Ray"]=Fn,Fn.__name__=["verb","core","Ray"],Fn.__super__=ee,Fn.prototype=k(ee.prototype,{__class__:Fn});var Ht=f.core.NurbsCurveData=function(r,i,o){this.degree=r,this.controlPoints=o,this.knots=i};w["verb.core.NurbsCurveData"]=Ht,Ht.__name__=["verb","core","NurbsCurveData"],Ht.__super__=ee,Ht.prototype=k(ee.prototype,{__class__:Ht});var ie=f.core.NurbsSurfaceData=function(r,i,o,l,c){this.degreeU=r,this.degreeV=i,this.knotsU=o,this.knotsV=l,this.controlPoints=c};w["verb.core.NurbsSurfaceData"]=ie,ie.__name__=["verb","core","NurbsSurfaceData"],ie.__super__=ee,ie.prototype=k(ee.prototype,{__class__:ie});var rr=f.core.MeshData=function(r,i,o,l){this.faces=r,this.points=i,this.normals=o,this.uvs=l};w["verb.core.MeshData"]=rr,rr.__name__=["verb","core","MeshData"],rr.empty=function(){return new rr([],[],[],[])},rr.__super__=ee,rr.prototype=k(ee.prototype,{__class__:rr});var ls=f.core.PolylineData=function(r,i){this.points=r,this.params=i};w["verb.core.PolylineData"]=ls,ls.__name__=["verb","core","PolylineData"],ls.__super__=ee,ls.prototype=k(ee.prototype,{__class__:ls});var hs=f.core.VolumeData=function(r,i,o,l,c,d,g){this.degreeU=r,this.degreeV=i,this.degreeW=o,this.knotsU=l,this.knotsV=c,this.knotsW=d,this.controlPoints=g};w["verb.core.VolumeData"]=hs,hs.__name__=["verb","core","VolumeData"],hs.__super__=ee,hs.prototype=k(ee.prototype,{__class__:hs});var ae=f.core.Pair=function(r,i){this.item0=r,this.item1=i};w["verb.core.Pair"]=ae,ae.__name__=["verb","core","Pair"],ae.prototype={__class__:ae};var Ce=f.core.Interval=function(r,i){this.min=r,this.max=i};w["verb.core.Interval"]=Ce,Ce.__name__=["verb","core","Interval"],Ce.prototype={__class__:Ce};var pn=f.core.CurveCurveIntersection=function(r,i,o,l){this.point0=r,this.point1=i,this.u0=o,this.u1=l};w["verb.core.CurveCurveIntersection"]=pn,pn.__name__=["verb","core","CurveCurveIntersection"],pn.prototype={__class__:pn};var us=f.core.CurveSurfaceIntersection=function(r,i,o,l){this.u=r,this.uv=i,this.curvePoint=o,this.surfacePoint=l};w["verb.core.CurveSurfaceIntersection"]=us,us.__name__=["verb","core","CurveSurfaceIntersection"],us.prototype={__class__:us};var Xr=f.core.MeshIntersectionPoint=function(r,i,o,l,c){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=i,this.point=o,this.faceIndex0,this.faceIndex1};w["verb.core.MeshIntersectionPoint"]=Xr,Xr.__name__=["verb","core","MeshIntersectionPoint"],Xr.prototype={__class__:Xr};var cs=f.core.PolylineMeshIntersection=function(r,i,o,l,c){this.point=r,this.u=i,this.uv=o,this.polylineIndex=l,this.faceIndex=c};w["verb.core.PolylineMeshIntersection"]=cs,cs.__name__=["verb","core","PolylineMeshIntersection"],cs.prototype={__class__:cs};var ds=f.core.SurfaceSurfaceIntersectionPoint=function(r,i,o,l){this.uv0=r,this.uv1=i,this.point=o,this.dist=l};w["verb.core.SurfaceSurfaceIntersectionPoint"]=ds,ds.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],ds.prototype={__class__:ds};var ps=f.core.TriSegmentIntersection=function(r,i,o,l){this.point=r,this.s=i,this.t=o,this.p=l};w["verb.core.TriSegmentIntersection"]=ps,ps.__name__=["verb","core","TriSegmentIntersection"],ps.prototype={__class__:ps};var zn=f.core.CurveTriPoint=function(r,i,o){this.u=r,this.point=i,this.uv=o};w["verb.core.CurveTriPoint"]=zn,zn.__name__=["verb","core","CurveTriPoint"],zn.prototype={__class__:zn};var Qe=function(r,i,o,l,c){c==null&&(c=!1),l==null&&(l=-1),this.uv=o,this.point=r,this.normal=i,this.id=l,this.degen=c};w["verb.core.SurfacePoint"]=Qe,Qe.__name__=["verb","core","SurfacePoint"],Qe.fromUv=function(r,i){return new Qe(null,null,[r,i])},Qe.prototype={__class__:Qe};var pi=f.core.CurvePoint=function(r,i){this.u=r,this.pt=i};w["verb.core.CurvePoint"]=pi,pi.__name__=["verb","core","CurvePoint"],pi.prototype={__class__:pi};var ms=f.core.KdTree=function(r,i){this.dim=3,this.points=r,this.distanceFunction=i,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};w["verb.core.KdTree"]=ms,ms.__name__=["verb","core","KdTree"],ms.prototype={buildTree:function(r,i,o){var l=i%this.dim,c,d;return r.length==0?null:r.length==1?new jn(r[0],l,o):(r.sort(function(g,_){var y=g.point[l]-_.point[l];return y==0?0:y>0?1:-1}),c=Math.floor(r.length/2),d=new jn(r[c],l,o),d.left=this.buildTree(r.slice(0,c),i+1,d),d.right=this.buildTree(r.slice(c+1),i+1,d),d)},nearest:function(r,i,o){var l=this,c=new gs(function(S){return-S.item1}),d,g=null;g=function(S){for(var E,M=S.dimension,T=l.distanceFunction(r,S.kdPoint.point),B,O=[],F=0,R=l.dim;F<R;)F++,O.push(0);B=O;for(var j,D,X=function(K,tt){c.push(new ae(K,tt)),c.size()>i&&c.pop()},J=0,Y=l.dim;J<Y;){var U=J++;U==S.dimension?B[U]=r[U]:B[U]=S.kdPoint.point[U]}if(j=l.distanceFunction(B,S.kdPoint.point),S.right==null&&S.left==null){(c.size()<i||T<c.peek().item1)&&X(S,T);return}S.right==null?E=S.left:S.left==null?E=S.right:r[M]<S.kdPoint.point[M]?E=S.left:E=S.right,g(E),(c.size()<i||T<c.peek().item1)&&X(S,T),(c.size()<i||Math.abs(j)<c.peek().item1)&&(E==S.left?D=S.right:D=S.left,D!=null&&g(D))},d=g;for(var _=0;_<i;)_++,c.push(new ae(null,o));d(this.root);for(var y=[],I=0;I<i;){var P=I++;c.content[P].item0!=null&&y.push(new ae(c.content[P].item0.kdPoint,c.content[P].item1))}return y},__class__:ms};var gs=function(r){this.content=[],this.scoreFunction=r};w["verb.core.BinaryHeap"]=gs,gs.__name__=["verb","core","BinaryHeap"],gs.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],i=this.content.pop();return this.content.length>0&&(this.content[0]=i,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var i=this.content.length,o=0;o<i;){var l=o++;if(this.content[l]==r){var c=this.content.pop();l!=i-1&&(this.content[l]=c,this.scoreFunction(c)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var i=this.content[r];r>0;){var o=Math.floor((r+1)/2)-1,l=this.content[o];if(this.scoreFunction(i)<this.scoreFunction(l))this.content[o]=i,this.content[r]=l,r=o;else break}},sinkDown:function(r){for(var i=this.content.length,o=this.content[r],l=this.scoreFunction(o);;){var c=(r+1)*2,d=c-1,g=-1,_=0;if(d<i){var y=this.content[d];_=this.scoreFunction(y),_<l&&(g=d)}if(c<i){var I=this.content[c],P=this.scoreFunction(I);P<(g==-1?l:_)&&(g=c)}if(g!=-1)this.content[r]=this.content[g],this.content[g]=o,r=g;else break}},__class__:gs};var Vn=f.core.KdPoint=function(r,i){this.point=r,this.obj=i};w["verb.core.KdPoint"]=Vn,Vn.__name__=["verb","core","KdPoint"],Vn.prototype={__class__:Vn};var jn=f.core.KdNode=function(r,i,o){this.kdPoint=r,this.left=null,this.right=null,this.parent=o,this.dimension=i};w["verb.core.KdNode"]=jn,jn.__name__=["verb","core","KdNode"],jn.prototype={__class__:jn};var xr=function(){};w["verb.eval.IBoundingBoxTree"]=xr,xr.__name__=["verb","eval","IBoundingBoxTree"],xr.prototype={__class__:xr};var mr=function(r,i){this._boundingBox=null,this._curve=r,i==null&&(i=m.domain(this._curve.knots)/64),this._knotTol=i};w["verb.core.LazyCurveBoundingBoxTree"]=mr,mr.__name__=["verb","core","LazyCurveBoundingBoxTree"],mr.__interfaces__=[xr],mr.prototype={split:function(){var r=Z.first(this._curve.knots),i=Z.last(this._curve.knots),o=i-r,l=ge.curveSplit(this._curve,(i+r)/2+o*.1*Math.random());return new ae(new mr(l[0],this._knotTol),new mr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ve(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:mr};var gr=function(r,i){if(this._boundingBox=null,this._mesh=r,i==null){for(var o=[],l=0,c=r.faces.length;l<c;){var d=l++;o.push(d)}i=o}this._faceIndices=i};w["verb.core.LazyMeshBoundingBoxTree"]=gr,gr.__name__=["verb","core","LazyMeshBoundingBoxTree"],gr.__interfaces__=[xr],gr.prototype={split:function(){var r=oe.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),i=Z.left(r),o=Z.right(r);return new ae(new gr(this._mesh,i),new gr(this._mesh,o))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=oe.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:gr};var _r=function(r,i){this._boundingBox=null,this._polyline=r,i==null&&(i=new Ce(0,r.points.length!=0?r.points.length-1:0)),this._interval=i};w["verb.core.LazyPolylineBoundingBoxTree"]=_r,_r.__name__=["verb","core","LazyPolylineBoundingBoxTree"],_r.__interfaces__=[xr],_r.prototype={split:function(){var r=this._interval.min,i=this._interval.max,o=r+Math.ceil((i-r)/2),l=new Ce(r,o),c=new Ce(o,i);return new ae(new _r(this._polyline,l),new _r(this._polyline,c))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ve(this._polyline.points)),this._boundingBox},yield:function(){return this._interval.min},indivisible:function(r){return this._interval.max-this._interval.min==1},empty:function(){return this._interval.max-this._interval.min==0},__class__:_r};var qr=function(r,i,o,l){i==null&&(i=!1),this._boundingBox=null,this._surface=r,this._splitV=i,o==null&&(o=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=o,this._knotTolV=l};w["verb.core.LazySurfaceBoundingBoxTree"]=qr,qr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],qr.__interfaces__=[xr],qr.prototype={split:function(){var r,i;this._splitV?(r=Z.first(this._surface.knotsV),i=Z.last(this._surface.knotsV)):(r=Z.first(this._surface.knotsU),i=Z.last(this._surface.knotsU));var o=(r+i)/2,l=ge.surfaceSplit(this._surface,o,this._splitV);return new ae(new qr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new qr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Ve;for(var r=0,i=this._surface.controlPoints;r<i.length;){var o=i[r];++r,this._boundingBox.addRange(N.dehomogenize1d(o))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:qr};var Ct=f.core.Mat=function(){};w["verb.core.Mat"]=Ct,Ct.__name__=["verb","core","Mat"],Ct.mul=function(r,i){for(var o=[],l=0,c=i.length;l<c;){var d=l++;o.push(m.mul(r,i[d]))}return o},Ct.mult=function(r,i){var o,l,c,d,g,_,y,I;o=r.length,l=i.length,c=i[0].length,d=[];for(var P=o-1,S=0,E=0;P>=0;){for(g=[],_=r[P],E=c-1;E>=0;){for(y=_[l-1]*i[l-1][E],S=l-2;S>=1;)I=S-1,y+=_[S]*i[S][E]+_[I]*i[I][E],S-=2;S==0&&(y+=_[0]*i[0][E]),g[E]=y,E--}d[P]=g,P--}return d},Ct.add=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.add(r[d],i[d]))}return o},Ct.div=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.div(r[d],i))}return o},Ct.sub=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.sub(r[d],i[d]))}return o},Ct.dot=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(m.dot(r[d],i))}return o},Ct.identity=function(r){for(var i=m.zeros2d(r,r),o=0;o<r;){var l=o++;i[l][l]=1}return i},Ct.transpose=function(r){if(r.length==0)return[];for(var i=[],o=0,l=r[0].length;o<l;){var c=o++;i.push(function(d){for(var g,_=[],y=0,I=r.length;y<I;){var P=y++;_.push(r[P][c])}return g=_,g}())}return i},Ct.solve=function(r,i){return Ct.LUsolve(Ct.LU(r),i)},Ct.LUsolve=function(r,i){var o,l,c=r.LU,d=c.length,g=i.slice(),_=r.P,y,I,P;for(o=d-1;o!=-1;)g[o]=i[o],--o;for(o=0;o<d;){for(y=_[o],_[o]!=o&&(P=g[o],g[o]=g[y],g[y]=P),I=c[o],l=0;l<o;)g[o]-=g[l]*I[l],++l;++o}for(o=d-1;o>=0;){for(I=c[o],l=o+1;l<d;)g[o]-=g[l]*I[l],++l;g[o]/=I[o],--o}return g},Ct.LU=function(r){for(var i,o,l,c,d,g,_,y,I,P=[],S=0,E=r.length;S<E;){var M=S++;P.push(r[M].slice())}r=P;var T=r.length,B=T-1,O=[];for(l=0;l<T;){for(_=l,g=r[l],I=Math.abs(g[l]),o=l+1;o<T;)c=Math.abs(r[o][l]),I<c&&(I=c,_=o),++o;for(O[l]=_,_!=l&&(r[l]=r[_],r[_]=g,g=r[l]),d=g[l],i=l+1;i<T;)r[i][l]/=d,++i;for(i=l+1;i<T;){for(y=r[i],o=l+1;o<B;)y[o]-=y[l]*g[o],++o,y[o]-=y[l]*g[o],++o;o==B&&(y[o]-=y[l]*g[o]),++i}++l}return new _s(r,O)};var _s=function(r,i){this.LU=r,this.P=i};w["verb.core._Mat.LUDecomp"]=_s,_s.__name__=["verb","core","_Mat","LUDecomp"],_s.prototype={__class__:_s};var oe=f.core.Mesh=function(){};w["verb.core.Mesh"]=oe,oe.__name__=["verb","core","Mesh"],oe.getTriangleNorm=function(r,i){var o=r[i[0]],l=r[i[1]],c=r[i[2]],d=m.sub(l,o),g=m.sub(c,o),_=m.cross(d,g);return m.mul(1/m.norm(_),_)},oe.makeMeshAabb=function(r,i){for(var o=new Ve,l=0;l<i.length;){var c=i[l];++l,o.add(r.points[r.faces[c][0]]),o.add(r.points[r.faces[c][1]]),o.add(r.points[r.faces[c][2]])}return o},oe.sortTrianglesOnLongestAxis=function(r,i,o){for(var l=r.getLongestAxis(),c=[],d=0;d<o.length;){var g=o[d];++d;var _=oe.getMinCoordOnAxis(i.points,i.faces[g],l);c.push(new ae(_,g))}c.sort(function(E,M){var T=E.item0,B=M.item0;return T==B?0:T>B?1:-1});for(var y=[],I=0,P=c.length;I<P;){var S=I++;y.push(c[S].item1)}return y},oe.getMinCoordOnAxis=function(r,i,o){for(var l=1/0,c=0;c<3;){var d=c++,g=r[i[d]][o];g<l&&(l=g)}return l},oe.getTriangleCentroid=function(r,i){for(var o=[0,0,0],l=0;l<3;)for(var c=l++,d=0;d<3;){var g=d++;o[g]+=r[i[c]][g]}for(var _=0;_<3;){var y=_++;o[y]/=3}return o},oe.triangleUVFromPoint=function(r,i,o){var l=r.faces[i],c=r.points[l[0]],d=r.points[l[1]],g=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],I=r.uvs[l[2]],P=m.sub(c,o),S=m.sub(d,o),E=m.sub(g,o),M=m.norm(m.cross(m.sub(c,d),m.sub(c,g))),T=m.norm(m.cross(S,E))/M,B=m.norm(m.cross(E,P))/M,O=m.norm(m.cross(P,S))/M;return m.add(m.mul(T,_),m.add(m.mul(B,y),m.mul(O,I)))};var $r=function(r,i){if(this._empty=!1,this._face=-1,i==null){for(var o=[],l=0,c=r.faces.length;l<c;){var d=l++;o.push(d)}i=o}if(this._boundingBox=oe.makeMeshAabb(r,i),i.length<1){this._empty=!0;return}else if(i.length<2){this._face=i[0];return}var g=oe.sortTrianglesOnLongestAxis(this._boundingBox,r,i),_=Z.left(g),y=Z.right(g);this._children=new ae(new $r(r,_),new $r(r,y))};w["verb.core.MeshBoundingBoxTree"]=$r,$r.__name__=["verb","core","MeshBoundingBoxTree"],$r.__interfaces__=[xr],$r.prototype={split:function(){return this._children},boundingBox:function(){return this._boundingBox},yield:function(){return this._face},indivisible:function(r){return this._children==null},empty:function(){return this._empty},__class__:$r};var nr=f.core.Minimizer=function(){};w["verb.core.Minimizer"]=nr,nr.__name__=["verb","core","Minimizer"],nr.uncmin=function(r,i,o,l,c){o==null&&(o=1e-8),l==null&&(l=function(J){return nr.numericalGradient(r,J)}),c==null&&(c=1e3),i=i.slice(0);var d=i.length,g=r(i),_=g,y;if(isNaN(g))throw new Q("uncmin: f(x0) is a NaN!");o=Math.max(o,rt.EPSILON);var I,P,S,E=Ct.identity(d),M=0,T=[],B,O,F,R,j,D,X="";for(P=l(i);M<c;){if(!m.all(m.finite(P))){X="Gradient has Infinity or NaN";break}if(I=m.neg(Ct.dot(E,P)),!m.all(m.finite(I))){X="Search direction has Infinity or NaN";break}if(D=m.norm(I),D<o){X="Newton step smaller than tol";break}for(j=1,y=m.dot(P,I),B=i;M<c&&!(j*D<o);){if(T=m.mul(j,I),B=m.add(i,T),_=r(B),_-g>=.1*j*y||isNaN(_)){j*=.5,++M;continue}break}if(j*D<o){X="Line search step size smaller than tol";break}if(M==c){X="maxit reached during line search";break}S=l(B),O=m.sub(S,P),R=m.dot(O,T),F=Ct.dot(E,O),E=Ct.sub(Ct.add(E,Ct.mul((R+m.dot(O,F))/(R*R),nr.tensor(T,T))),Ct.div(Ct.add(nr.tensor(F,T),nr.tensor(T,F)),R)),i=B,g=_,P=S,++M}return new fs(i,g,P,E,M,X)},nr.numericalGradient=function(r,i){var o=i.length,l=r(i);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var c=i.slice(0),d,g,_=[],y,I=.001,P,S,E,M=0,T,B,O,F=0;F<o;)for(var R=F++,j=Math.max(1e-6*l,1e-8);;){if(++M,M>20)throw new Q("Numerical gradient fails");if(c[R]=i[R]+j,d=r(c),c[R]=i[R]-j,g=r(c),c[R]=i[R],isNaN(d)||isNaN(g)){j/=16;continue}if(_[R]=(d-g)/(2*j),P=i[R]-j,S=i[R],E=i[R]+j,T=(d-l)/j,B=(l-g)/j,O=m.max([Math.abs(_[R]),Math.abs(l),Math.abs(d),Math.abs(g),Math.abs(P),Math.abs(S),Math.abs(E),1e-8]),y=Math.min(m.max([Math.abs(T-_[R]),Math.abs(B-_[R]),Math.abs(T-B)])/O,j/O),y>I)j/=16;else break}return _},nr.tensor=function(r,i){for(var o=r.length,l=i.length,c=[],d,g,_=o-1;_>=0;){d=[],g=r[_];for(var y=l-1;y>=3;)d[y]=g*i[y],--y,d[y]=g*i[y],--y,d[y]=g*i[y],--y,d[y]=g*i[y],--y;for(;y>=0;)d[y]=g*i[y],--y;c[_]=d,_--}return c};var fs=function(r,i,o,l,c,d){this.solution=r,this.value=i,this.gradient=o,this.invHessian=l,this.iterations=c,this.message=d};w["verb.core.MinimizationResult"]=fs,fs.__name__=["verb","core","MinimizationResult"],fs.prototype={__class__:fs};var Dn=function(){};w["verb.core.ISerializable"]=Dn,Dn.__name__=["verb","core","ISerializable"],Dn.prototype={__class__:Dn};var ua=f.core.Deserializer=function(){};w["verb.core.Deserializer"]=ua,ua.__name__=["verb","core","Deserializer"],ua.deserialize=function(r){var i=new Xt(r),o=i.unserialize();return o};var je=f.core.Trig=function(){};w["verb.core.Trig"]=je,je.__name__=["verb","core","Trig"],je.isPointInPlane=function(r,i,o){return Math.abs(m.dot(m.sub(r,i.origin),i.normal))<o},je.distToSegment=function(r,i,o){var l=je.segmentClosestPoint(i,r,o,0,1);return m.dist(i,l.pt)},je.rayClosestPoint=function(r,i,o){var l=m.sub(r,i),c=m.dot(l,o),d=m.add(i,m.mul(c,o));return d},je.distToRay=function(r,i,o){var l=je.rayClosestPoint(r,i,o),c=m.sub(l,r);return m.norm(c)},je.threePointsAreFlat=function(r,i,o,l){var c=m.sub(i,r),d=m.sub(o,r),g=m.cross(c,d),_=m.dot(g,g);return _<l},je.segmentClosestPoint=function(r,i,o,l,c){var d=m.sub(o,i),g=m.norm(d);if(g<rt.EPSILON)return{u:l,pt:i};var _=i,y=m.mul(1/g,d),I=m.sub(r,_),P=m.dot(I,y);return P<0?{u:l,pt:i}:P>g?{u:c,pt:o}:{u:l+(c-l)*P/g,pt:m.add(_,m.mul(P,y))}};var m=f.core.Vec=function(){};w["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,i){return Math.acos(m.dot(r,i)/(m.norm(r)*m.norm(i)))},m.positiveAngleBetween=function(r,i,o){var l=m.cross(r,i),c=m.norm(r),d=m.norm(i),g=c*d,_=m.dot(r,i),y=m.norm(l)/g,I=_/g,P=Math.atan2(y,I),S=m.dot(o,l);return Math.abs(S)<rt.EPSILON||S>0?P:-P},m.signedAngleBetween=function(r,i,o){var l=m.cross(r,i),c=m.norm(r),d=m.norm(i),g=c*d,_=m.dot(r,i),y=m.norm(l)/g,I=_/g,P=Math.atan2(y,I),S=m.dot(o,l);return S>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,i){var o=r[0]*i[1]-r[1]*i[0];return Math.atan2(o,m.dot(r,i))},m.domain=function(r){return Z.last(r)-Z.first(r)},m.range=function(r){for(var i=[],o=0,l=0;l<r;)l++,i.push(o),o+=1;return i},m.span=function(r,i,o){if(o==null)return[];if(o<rt.EPSILON)return[];if(r>i&&o>0)return[];if(i>r&&o<0)return[];for(var l=[],c=r;c<=i;)l.push(c),c+=o;return l},m.neg=function(r){return r.map(function(i){return-i})},m.min=function(r){return C.fold(r,function(i,o){return Math.min(i,o)},1/0)},m.max=function(r){return C.fold(r,function(i,o){return Math.max(i,o)},-1/0)},m.all=function(r){return C.fold(r,function(i,o){return o&&i},!0)},m.finite=function(r){return r.map(function(i){return isFinite(i)})},m.onRay=function(r,i,o){return m.add(r,m.mul(o,i))},m.lerp=function(r,i,o){return m.add(m.mul(r,i),m.mul(1-r,o))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,i){return[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]]},m.dist=function(r,i){return m.norm(m.sub(r,i))},m.distSquared=function(r,i){return m.normSquared(m.sub(r,i))},m.sum=function(r){return C.fold(r,function(i,o){return o+i},0)},m.addAll=function(r){var i=sr(r)();if(!i.hasNext())return null;var o=i.next().length;return C.fold(r,function(l,c){return m.add(c,l)},m.rep(o,0))},m.addAllMutate=function(r){for(var i=r[0],o=1,l=r.length;o<l;){var c=o++;m.addMutate(i,r[c])}},m.addMulMutate=function(r,i,o){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]+i*o[d]}},m.subMulMutate=function(r,i,o){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]-i*o[d]}},m.addMutate=function(r,i){for(var o=0,l=r.length;o<l;){var c=o++;r[c]=r[c]+i[c]}},m.subMutate=function(r,i){for(var o=0,l=r.length;o<l;){var c=o++;r[c]=r[c]-i[c]}},m.mulMutate=function(r,i){for(var o=0,l=i.length;o<l;){var c=o++;i[c]=i[c]*r}},m.norm=function(r){var i=m.normSquared(r);return i!=0?Math.sqrt(i):i},m.normSquared=function(r){return C.fold(r,function(i,o){return o+i*i},0)},m.rep=function(r,i){for(var o=[],l=0;l<r;)l++,o.push(i);return o},m.zeros1d=function(r){for(var i=[],o=0;o<r;)o++,i.push(0);return i},m.zeros2d=function(r,i){for(var o=[],l=0;l<r;)l++,o.push(m.zeros1d(i));return o},m.zeros3d=function(r,i,o){for(var l=[],c=0;c<r;)c++,l.push(m.zeros2d(i,o));return l},m.dot=function(r,i){for(var o=0,l=0,c=r.length;l<c;){var d=l++;o+=r[d]*i[d]}return o},m.add=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(r[d]+i[d])}return o},m.mul=function(r,i){for(var o=[],l=0,c=i.length;l<c;){var d=l++;o.push(r*i[d])}return o},m.div=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(r[d]/i)}return o},m.sub=function(r,i){for(var o=[],l=0,c=r.length;l<c;){var d=l++;o.push(r[d]-i[d])}return o},m.isZero=function(r){for(var i=0,o=r.length;i<o;){var l=i++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,i){for(var o=[],l=0,c=0;l<r.length||c<i.length;){if(l>=r.length){o.push(i[c]),c++;continue}else if(c>=i.length){o.push(r[l]),l++;continue}var d=r[l]-i[c];if(Math.abs(d)<rt.EPSILON){o.push(r[l]),l++,c++;continue}if(d>0){o.push(i[c]),c++;continue}o.push(r[l]),l++}return o},m.sortedSetSub=function(r,i){for(var o=[],l=0,c=0;l<r.length;){if(c>=i.length){o.push(r[l]),l++;continue}if(Math.abs(r[l]-i[c])<rt.EPSILON){l++,c++;continue}o.push(r[l]),l++}return o};var bt=f.eval.Analyze=function(){};w["verb.eval.Analyze"]=bt,bt.__name__=["verb","eval","Analyze"],bt.knotMultiplicities=function(r){for(var i=[new Un(r[0],0)],o=i[0],l=0;l<r.length;){var c=r[l];++l,Math.abs(c-o.knot)>rt.EPSILON&&(o=new Un(c,0),i.push(o)),o.inc()}return i},bt.isRationalSurfaceClosed=function(r,i){i==null&&(i=!0);var o;i?o=r.controlPoints:o=Ct.transpose(r.controlPoints);for(var l=0,c=o[0].length;l<c;){var d=l++,g=m.dist(Z.first(o)[d],Z.last(o)[d])<rt.EPSILON;if(!g)return!1}return!0},bt.rationalSurfaceClosestPoint=function(r,i){var o=bt.rationalSurfaceClosestParam(r,i);return N.rationalSurfacePoint(r,o[0],o[1])},bt.rationalSurfaceClosestParam=function(r,i){for(var o=5,l=0,c,d=1e-4,g=5e-4,_,y=r.knotsU[0],I=Z.last(r.knotsU),P=r.knotsV[0],S=Z.last(r.knotsV),E=bt.isRationalSurfaceClosed(r),M=bt.isRationalSurfaceClosed(r,!1),T,B=Rt.rationalSurfaceAdaptive(r,new Kr),O=1/0,F=0,R=B.points.length;F<R;){var j=F++,D=B.points[j],X=m.normSquared(m.sub(i,D));X<O&&(O=X,T=B.uvs[j])}for(var J=function(Yt){return N.rationalSurfaceDerivatives(r,Yt[0],Yt[1],2)},Y=function(Yt,Zt,Ut){var Jt=Zt[1][0],Be=Zt[0][1],tr=Zt[2][0],Ae=Zt[0][2],Ie=Zt[1][1],Re=Zt[1][1],Ue=m.dot(Jt,Ut),ir=m.dot(Be,Ut),fr=[-Ue,-ir],ar=m.dot(Jt,Jt)+m.dot(tr,Ut),or=m.dot(Jt,Be)+m.dot(Ie,Ut),lr=m.dot(Jt,Be)+m.dot(Re,Ut),Sr=m.dot(Be,Be)+m.dot(Ae,Ut),Yn=[[ar,or],[lr,Sr]],gn=Ct.solve(Yn,fr);return m.add(gn,Yt)};l<o;){c=J(T),_=m.sub(c[0][0],i);var U=m.norm(_),K=m.dot(c[1][0],_),tt=m.norm(c[1][0])*U,et=m.dot(c[0][1],_),ot=m.norm(c[0][1])*U,ct=K/tt,ht=et/ot,pt=U<d,nt=ct<g,mt=ht<g;if(pt&&nt&&mt)return T;var $=Y(T,c,_);$[0]<y?E?$=[I-($[0]-y),$[1]]:$=[y+rt.EPSILON,$[1]]:$[0]>I&&(E?$=[y+($[0]-I),$[1]]:$=[I-rt.EPSILON,$[1]]),$[1]<P?M?$=[$[0],S-($[1]-P)]:$=[$[0],P+rt.EPSILON]:$[1]>S&&(M?$=[$[0],P+($[0]-S)]:$=[$[0],S-rt.EPSILON]);var ft=m.norm(m.mul($[0]-T[0],c[1][0])),kt=m.norm(m.mul($[1]-T[1],c[0][1]));if(ft+kt<d)return T;T=$,l++}return T},bt.rationalCurveClosestPoint=function(r,i){return N.rationalCurvePoint(r,bt.rationalCurveClosestParam(r,i))},bt.rationalCurveClosestParam=function(r,i){for(var o=1/0,l=0,c=Rt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,g=c.length-1;d<g;){var _=d++,y=c[_][0],I=c[_+1][0],P=c[_].slice(1),S=c[_+1].slice(1),E=je.segmentClosestPoint(i,P,S,y,I),M=m.norm(m.sub(i,E.pt));M<o&&(o=M,l=E.u)}for(var T=5,B=0,O,F=1e-4,R=5e-4,j,D=r.knots[0],X=Z.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],Z.last(r.controlPoints)))<rt.EPSILON,Y=l,U=function($){return N.rationalCurveDerivatives(r,$,2)},K=function($,ft,kt){var Yt=m.dot(ft[1],kt),Zt=m.dot(ft[2],kt),Ut=m.dot(ft[1],ft[1]),Jt=Zt+Ut;return $-Yt/Jt};B<T;){O=U(Y),j=m.sub(O[0],i);var tt=m.norm(j),et=m.dot(O[1],j),ot=m.norm(O[1])*tt,ct=et/ot,ht=tt<F,pt=Math.abs(ct)<R;if(ht&&pt)return Y;var nt=K(Y,O,j);nt<D?J?nt=X-(nt-D):nt=D:nt>X&&(J?nt=D+(nt-X):nt=X);var mt=m.norm(m.mul(nt-Y,O[1]));if(mt<F)return Y;Y=nt,B++}return Y},bt.rationalCurveParamAtArcLength=function(r,i,o,l,c){if(o==null&&(o=.001),i<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=yt.decomposeCurveIntoBeziers(r);var g=0;d[g];var _=-rt.EPSILON,y;for(c!=null?y=c:y=[];_<i&&g<d.length;){if(g<y.length?y[g]=y[g]:y[g]=bt.rationalBezierCurveArcLength(r),_+=y[g],i<_+rt.EPSILON)return bt.rationalBezierCurveParamAtArcLength(r,i,o,y[g]);g++}return-1},bt.rationalBezierCurveParamAtArcLength=function(r,i,o,l){if(i<0)return r.knots[0];var c;if(l!=null?c=l:c=bt.rationalBezierCurveArcLength(r),i>c)return Z.last(r.knots);var d=r.knots[0],g=0,_=Z.last(r.knots),y=c,I=0,P=0,S;for(o!=null?S=o:S=rt.TOLERANCE*2;y-g>S;)I=(d+_)/2,P=bt.rationalBezierCurveArcLength(r,I),P>i?(_=I,y=P):(d=I,g=P);return(d+_)/2},bt.rationalCurveArcLength=function(r,i,o){o==null&&(o=16),i==null?i=Z.last(r.knots):i=i;for(var l=yt.decomposeCurveIntoBeziers(r),c=0,d=l[0],g=0;c<l.length&&d.knots[0]+rt.EPSILON<i;){var _=Math.min(Z.last(d.knots),i);g+=bt.rationalBezierCurveArcLength(d,_,o),d=l[++c]}return g},bt.rationalBezierCurveArcLength=function(r,i,o){o==null&&(o=16);var l;i==null?l=Z.last(r.knots):l=i;for(var c=(l-r.knots[0])/2,d=0,g=r.degree+o,_,y,I=0;I<g;){var P=I++;_=c*bt.Tvalues[g][P]+c+r.knots[0],y=N.rationalCurveDerivatives(r,_,1),d+=bt.Cvalues[g][P]*m.norm(y[1])}return c*d};var Un=f.eval.KnotMultiplicity=function(r,i){this.knot=r,this.mult=i};w["verb.eval.KnotMultiplicity"]=Un,Un.__name__=["verb","eval","KnotMultiplicity"],Un.prototype={inc:function(){this.mult++},__class__:Un};var Je=f.eval.Check=function(){};w["verb.eval.Check"]=Je,Je.__name__=["verb","eval","Check"],Je.isValidKnotVector=function(r,i){if(r.length==0||r.length<(i+1)*2)return!1;for(var o=Z.first(r),l=0,c=i+1;l<c;){var d=l++;if(Math.abs(r[d]-o)>rt.EPSILON)return!1}o=Z.last(r);for(var g=r.length-i-1,_=r.length;g<_;){var y=g++;if(Math.abs(r[y]-o)>rt.EPSILON)return!1}return Je.isNonDecreasing(r)},Je.isNonDecreasing=function(r){for(var i=Z.first(r),o=0,l=r.length;o<l;){var c=o++;if(r[c]<i-rt.EPSILON)return!1;i=r[c]}return!0},Je.isValidNurbsCurveData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degree==null)throw new Q("Degree cannot be null!");if(r.degree<1)throw new Q("Degree must be greater than 1!");if(r.knots==null)throw new Q("Knots cannot be null!");if(r.knots.length!=r.controlPoints.length+r.degree+1)throw new Q("controlPoints.length + degree + 1 must equal knots.length!");if(!Je.isValidKnotVector(r.knots,r.degree))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r},Je.isValidNurbsSurfaceData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degreeU==null)throw new Q("DegreeU cannot be null!");if(r.degreeV==null)throw new Q("DegreeV cannot be null!");if(r.degreeU<1)throw new Q("DegreeU must be greater than 1!");if(r.degreeV<1)throw new Q("DegreeV must be greater than 1!");if(r.knotsU==null)throw new Q("KnotsU cannot be null!");if(r.knotsV==null)throw new Q("KnotsV cannot be null!");if(r.knotsU.length!=r.controlPoints.length+r.degreeU+1)throw new Q("controlPointsU.length + degreeU + 1 must equal knotsU.length!");if(r.knotsV.length!=r.controlPoints[0].length+r.degreeV+1)throw new Q("controlPointsV.length + degreeV + 1 must equal knotsV.length!");if(!Je.isValidKnotVector(r.knotsU,r.degreeU)||!Je.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var ge=f.eval.Divide=function(){};w["verb.eval.Divide"]=ge,ge.__name__=["verb","eval","Divide"],ge.surfaceSplit=function(r,i,o){o==null&&(o=!1);var l,c,d;o?(d=r.controlPoints,l=r.knotsV,c=r.degreeV):(d=Ct.transpose(r.controlPoints),l=r.knotsU,c=r.degreeU);for(var g,_=[],y=0,I=c+1;y<I;)y++,_.push(i);g=_;for(var P=[],S=[],E=N.knotSpan(c,i,l),M=null,T=0;T<d.length;){var B=d[T];++T,M=yt.curveKnotRefine(new Ht(c,l,B),g),P.push(M.controlPoints.slice(0,E+1)),S.push(M.controlPoints.slice(E+1))}var O=M.knots.slice(0,E+c+2),F=M.knots.slice(E+1);return o?[new ie(r.degreeU,c,r.knotsU.slice(),O,P),new ie(r.degreeU,c,r.knotsU.slice(),F,S)]:(P=Ct.transpose(P),S=Ct.transpose(S),[new ie(c,r.degreeV,O,r.knotsV.slice(),P),new ie(c,r.degreeV,F,r.knotsV.slice(),S)])},ge.curveSplit=function(r,i){var o=r.degree;r.controlPoints;for(var l=r.knots,c,d=[],g=0,_=o+1;g<_;)g++,d.push(i);c=d;var y=yt.curveKnotRefine(r,c),I=N.knotSpan(o,i,l),P=y.knots.slice(0,I+o+2),S=y.knots.slice(I+1),E=y.controlPoints.slice(0,I+1),M=y.controlPoints.slice(I+1);return[new Ht(o,P,E),new Ht(o,S,M)]},ge.rationalCurveByEqualArcLength=function(r,i){var o=bt.rationalCurveArcLength(r),l=o/i;return ge.rationalCurveByArcLength(r,l)},ge.rationalCurveByArcLength=function(r,i){var o=yt.decomposeCurveIntoBeziers(r),l=o.map(function(E){return bt.rationalBezierCurveArcLength(E)}),c=m.sum(l),d=[new Gn(r.knots[0],0)];if(i>c)return d;for(var g=i,_=0,y=g,I=0,P=0,S;_<o.length;){for(I+=l[_];y<I+rt.EPSILON;)S=bt.rationalBezierCurveParamAtArcLength(o[_],y-P,rt.TOLERANCE,l[_]),d.push(new Gn(S,y)),y+=g;P+=l[_],_++}return d};var Gn=f.eval.CurveLengthSample=function(r,i){this.u=r,this.len=i};w["verb.eval.CurveLengthSample"]=Gn,Gn.__name__=["verb","eval","CurveLengthSample"],Gn.prototype={__class__:Gn};var N=f.eval.Eval=function(){};w["verb.eval.Eval"]=N,N.__name__=["verb","eval","Eval"],N.rationalCurveTangent=function(r,i){var o=N.rationalCurveDerivatives(r,i,1);return o[1]},N.rationalSurfaceNormal=function(r,i,o){var l=N.rationalSurfaceDerivatives(r,i,o,1);return m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,i,o,l){l==null&&(l=1);for(var c=N.surfaceDerivatives(r,i,o,l),d=N.rational2d(c),g=N.weight2d(c),_=[],y=d[0][0].length,I=0,P=l+1;I<P;){var S=I++;_.push([]);for(var E=0,M=l-S+1;E<M;){for(var T=E++,B=d[S][T],O=1,F=T+1;O<F;){var R=O++;m.subMulMutate(B,Vt.get(T,R)*g[0][R],_[S][T-R])}for(var j=1,D=S+1;j<D;){var X=j++;m.subMulMutate(B,Vt.get(S,X)*g[X][0],_[S-X][T]);for(var J=m.zeros1d(y),Y=1,U=T+1;Y<U;){var K=Y++;m.addMulMutate(J,Vt.get(T,K)*g[X][K],_[S-X][T-K])}m.subMulMutate(B,Vt.get(S,X),J)}m.mulMutate(1/g[0][0],B),_[S].push(B)}}return _},N.rationalSurfacePoint=function(r,i,o){return N.dehomogenize(N.surfacePoint(r,i,o))},N.rationalCurveDerivatives=function(r,i,o){o==null&&(o=1);for(var l=N.curveDerivatives(r,i,o),c=N.rational1d(l),d=N.weight1d(l),g=[],_=0,y=o+1;_<y;){for(var I=_++,P=c[I],S=1,E=I+1;S<E;){var M=S++;m.subMulMutate(P,Vt.get(I,M)*d[M],g[I-M])}m.mulMutate(1/d[0],P),g.push(P)}return g},N.rationalCurvePoint=function(r,i){return N.dehomogenize(N.curvePoint(r,i))},N.surfaceDerivatives=function(r,i,o,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(c,d,r,i,o,l)},N.surfaceDerivativesGivenNM=function(r,i,o,l,c,d){var g=o.degreeU,_=o.degreeV,y=o.controlPoints,I=o.knotsU,P=o.knotsV;if(!N.areValidRelations(g,y.length,I.length)||!N.areValidRelations(_,y[0].length,P.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=y[0][0].length,E;d<g?E=d:E=g;var M;d<_?M=d:M=_;for(var T=m.zeros3d(d+1,d+1,S),B=N.knotSpanGivenN(r,g,l,I),O=N.knotSpanGivenN(i,_,c,P),F=N.derivativeBasisFunctionsGivenNI(B,l,g,r,I),R=N.derivativeBasisFunctionsGivenNI(O,c,_,i,P),j=m.zeros2d(_+1,S),D=0,X=0,J=E+1;X<J;){for(var Y=X++,U=0,K=_+1;U<K;){var tt=U++;j[tt]=m.zeros1d(S);for(var et=0,ot=g+1;et<ot;){var ct=et++;m.addMulMutate(j[tt],F[Y][ct],y[B-g+ct][O-_+tt])}}var ht=d-Y;ht<M?D=ht:D=M;for(var pt=0,nt=D+1;pt<nt;){var mt=pt++;T[Y][mt]=m.zeros1d(S);for(var $=0,ft=_+1;$<ft;){var kt=$++;m.addMulMutate(T[Y][mt],R[mt][kt],j[kt])}}}return T},N.surfacePoint=function(r,i,o){var l=r.knotsU.length-r.degreeU-2,c=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,c,r,i,o)},N.surfacePointGivenNM=function(r,i,o,l,c){var d=o.degreeU,g=o.degreeV,_=o.controlPoints,y=o.knotsU,I=o.knotsV;if(!N.areValidRelations(d,_.length,y.length)||!N.areValidRelations(g,_[0].length,I.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var P=_[0][0].length,S=N.knotSpanGivenN(r,d,l,y),E=N.knotSpanGivenN(i,g,c,I),M=N.basisFunctionsGivenKnotSpanIndex(S,l,d,y),T=N.basisFunctionsGivenKnotSpanIndex(E,c,g,I),B=S-d,O=E,F=m.zeros1d(P),R=m.zeros1d(P),j=0,D=g+1;j<D;){var X=j++;R=m.zeros1d(P),O=E-g+X;for(var J=0,Y=d+1;J<Y;){var U=J++;m.addMulMutate(R,M[U],_[B+U][O])}m.addMulMutate(F,T[X],R)}return F},N.curveRegularSamplePoints=function(r,i){for(var o=N.curveDerivatives(r,r.knots[0],r.degree),l=1/i,c=l*l,d=o[0],g=m.mul(l,o[1]),_=m.mul(c*.5,o[2]),y=m.mul(c*l*.5,o[3]),I=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),E=[],M=0,T=i+1;M<T;)M++,E.push(N.dehomogenize(d)),m.addAllMutate([d,g,_,S]),m.addAllMutate([g,I,y]),m.addAllMutate([I,P]),m.addAllMutate([_,y]);return E},N.curveRegularSamplePoints2=function(r,i){for(var o=N.curveDerivatives(r,r.knots[0],r.degree),l=1/i,c=l*l,d=o[0],g=m.mul(l,o[1]),_=m.mul(c*.5,o[2]),y=m.mul(c*l*.5,o[3]),I=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),E=[],M=0,T=i+1;M<T;)M++,E.push(N.dehomogenize(d)),m.addAllMutate([d,g,_,S]),m.addAllMutate([g,I,y]),m.addAllMutate([I,P]),m.addAllMutate([_,y]);return E},N.rationalSurfaceRegularSampleDerivatives=function(r,i,o,l){for(var c=N.surfaceRegularSampleDerivatives(r,i,o,l),d=[],g=i+1,_=o+1,y=l+1,I=0;I<g;){var P=I++,S=[];d.push(S);for(var E=0;E<_;){for(var M=E++,T=c[P][M],B=N.rational2d(T),O=N.weight2d(T),F=[],R=B[0][0].length,j=0;j<y;){var D=j++;F.push([]);for(var X=0,J=y-D;X<J;){for(var Y=X++,U=B[D][Y],K=1,tt=Y+1;K<tt;){var et=K++;m.subMulMutate(U,Vt.get(Y,et)*O[0][et],F[D][Y-et])}for(var ot=1,ct=D+1;ot<ct;){var ht=ot++;m.subMulMutate(U,Vt.get(D,ht)*O[ht][0],F[D-ht][Y]);for(var pt=m.zeros1d(R),nt=1,mt=Y+1;nt<mt;){var $=nt++;m.addMulMutate(pt,Vt.get(Y,$)*O[ht][$],F[D-ht][Y-$])}m.subMulMutate(U,Vt.get(D,ht),pt)}m.mulMutate(1/O[0][0],U),F[D].push(U)}}S.push(F)}}return d},N.surfaceRegularSampleDerivatives=function(r,i,o,l){var c=r.degreeU,d=r.degreeV,g=r.controlPoints,_=r.knotsU,y=r.knotsV,I=g[0][0].length;(Z.last(_)-_[0])/i,(Z.last(y)-y[0])/o;for(var P=N.regularlySpacedDerivativeBasisFunctions(c,_,i),S=P.item0,E=P.item1,M=N.regularlySpacedDerivativeBasisFunctions(d,y,o),T=M.item0,B=M.item1,O=[],F=i+1,R=o+1,j=0;j<F;){var D=j++,X=[];O.push(X);for(var J=0;J<R;){var Y=J++;X.push(N.surfaceDerivativesGivenBasesKnotSpans(c,d,g,S[D],T[Y],E[D],B[Y],I,l))}}return O},N.rationalSurfaceRegularSamplePoints=function(r,i,o){return N.dehomogenize2d(N.surfaceRegularSamplePoints(r,i,o))},N.surfaceRegularSamplePoints=function(r,i,o){var l=r.degreeU,c=r.degreeV,d=r.controlPoints,g=r.knotsU,_=r.knotsV,y=d[0][0].length;(Z.last(g)-g[0])/i,(Z.last(_)-_[0])/o;for(var I=N.regularlySpacedBasisFunctions(l,g,i),P=I.item0,S=I.item1,E=N.regularlySpacedBasisFunctions(c,_,o),M=E.item0,T=E.item1,B=[],O=i+1,F=o+1,R=0;R<O;){var j=R++,D=[];B.push(D);for(var X=0;X<F;){var J=X++;D.push(N.surfacePointGivenBasesKnotSpans(l,c,d,P[j],M[J],S[j],T[J],y))}}return B},N.regularlySpacedBasisFunctions=function(r,i,o){for(var l=i.length-r-2,c=(Z.last(i)-i[0])/o,d=[],g=[],_=i[0],y=N.knotSpanGivenN(l,r,_,i),I=o+1,P=0;P<I;){for(P++;_>=i[y+1];)y++;g.push(y),d.push(N.basisFunctionsGivenKnotSpanIndex(y,_,r,i)),_+=c}return new ae(g,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,i,o){for(var l=i.length-r-2,c=(Z.last(i)-i[0])/o,d=[],g=[],_=i[0],y=N.knotSpanGivenN(l,r,_,i),I=o+1,P=0;P<I;){for(P++;_>=i[y+1];)y++;g.push(y),d.push(N.derivativeBasisFunctionsGivenNI(y,_,r,l,i)),_+=c}return new ae(g,d)},N.surfacePointGivenBasesKnotSpans=function(r,i,o,l,c,d,g,_){for(var y=m.zeros1d(_),I,P=l-r,S=c-i,E=0,M=i+1;E<M;){var T=E++;I=m.zeros1d(_);for(var B=0,O=r+1;B<O;){var F=B++;m.addMulMutate(I,d[F],o[P+F][S])}S++,m.addMulMutate(y,g[T],I)}return y},N.surfaceDerivativesGivenBasesKnotSpans=function(r,i,o,l,c,d,g,_,y){var I=o[0][0].length,P;y<r?P=y:P=r;var S;y<i?S=y:S=i;for(var E=m.zeros3d(P+1,S+1,I),M=m.zeros2d(i+1,I),T=0,B=0,O=P+1;B<O;){for(var F=B++,R=0,j=i+1;R<j;){var D=R++;M[D]=m.zeros1d(I);for(var X=0,J=r+1;X<J;){var Y=X++;m.addMulMutate(M[D],d[F][Y],o[l-r+Y][c-i+D])}}var U=y-F;U<S?T=U:T=S;for(var K=0,tt=T+1;K<tt;){var et=K++;E[F][et]=m.zeros1d(I);for(var ot=0,ct=i+1;ot<ct;){var ht=ot++;m.addMulMutate(E[F][et],g[et][ht],M[ht])}}}return E},N.curveDerivatives=function(r,i,o){var l=r.knots.length-r.degree-2;return N.curveDerivativesGivenN(l,r,i,o)},N.curveDerivativesGivenN=function(r,i,o,l){var c=i.degree,d=i.controlPoints,g=i.knots;if(!N.areValidRelations(c,d.length,g.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<c?y=l:y=c;for(var I=m.zeros2d(l+1,_),P=N.knotSpanGivenN(r,c,o,g),S=N.derivativeBasisFunctionsGivenNI(P,o,c,y,g),E=0,M=y+1;E<M;)for(var T=E++,B=0,O=c+1;B<O;){var F=B++;m.addMulMutate(I[T],S[T][F],d[P-c+F])}return I},N.curvePoint=function(r,i){var o=r.knots.length-r.degree-2;return N.curvePointGivenN(o,r,i)},N.areValidRelations=function(r,i,o){return i+r+1-o==0},N.curvePointGivenN=function(r,i,o){var l=i.degree,c=i.controlPoints,d=i.knots;if(!N.areValidRelations(l,c.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var g=N.knotSpanGivenN(r,l,o,d),_=N.basisFunctionsGivenKnotSpanIndex(g,o,l,d),y=m.zeros1d(c[0].length),I=0,P=l+1;I<P;){var S=I++;m.addMulMutate(y,_[S],c[g-l+S])}return y},N.volumePoint=function(r,i,o,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,g=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,c,d,g,i,o,l)},N.volumePointGivenNML=function(r,i,o,l,c,d,g){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,y=r.degreeU,I=r.degreeV,P=r.degreeW,S=r.knotsU,E=r.knotsV,M=r.knotsW,T=_[0][0][0].length,B=N.knotSpanGivenN(i,y,c,S),O=N.knotSpanGivenN(o,I,d,E),F=N.knotSpanGivenN(l,P,g,M),R=N.basisFunctionsGivenKnotSpanIndex(B,c,y,S),j=N.basisFunctionsGivenKnotSpanIndex(O,d,I,E),D=N.basisFunctionsGivenKnotSpanIndex(F,g,P,M),X=B-y,J=m.zeros1d(T),Y=m.zeros1d(T),U=m.zeros1d(T),K=0,tt=P+1;K<tt;){var et=K++;U=m.zeros1d(T);for(var ot=F-P+et,ct=0,ht=I+1;ct<ht;){var pt=ct++;Y=m.zeros1d(T);for(var nt=O-I+pt,mt=0,$=y+1;mt<$;){var ft=mt++;m.addMulMutate(Y,R[ft],_[X+ft][nt][ot])}m.addMulMutate(U,j[pt],Y)}m.addMulMutate(J,D[et],U)}return J},N.derivativeBasisFunctions=function(r,i,o){var l=N.knotSpan(i,r,o),c=o.length-1,d=c-i-1;return N.derivativeBasisFunctionsGivenNI(l,r,i,d,o)},N.derivativeBasisFunctionsGivenNI=function(r,i,o,l,c){var d=m.zeros2d(o+1,o+1),g=m.zeros1d(o+1),_=m.zeros1d(o+1),y=0,I=0;d[0][0]=1;for(var P=1,S=o+1;P<S;){var E=P++;g[E]=i-c[r+1-E],_[E]=c[r+E]-i,y=0;for(var M=0;M<E;){var T=M++;d[E][T]=_[T+1]+g[E-T],I=d[T][E-1]/d[E][T],d[T][E]=y+_[T+1]*I,y=g[E-T]*I}d[E][E]=y}for(var B=m.zeros2d(l+1,o+1),O=m.zeros2d(2,o+1),F=0,R=1,j=0,D=0,X=0,J=0,Y=0,U=0,K=o+1;U<K;){var tt=U++;B[0][tt]=d[tt][o]}for(var et=0,ot=o+1;et<ot;){var ct=et++;F=0,R=1,O[0][0]=1;for(var ht=1,pt=l+1;ht<pt;){var nt=ht++;j=0,D=ct-nt,X=o-nt,ct>=nt&&(O[R][0]=O[F][0]/d[X+1][D],j=O[R][0]*d[D][X]),D>=-1?J=1:J=-D,ct-1<=X?Y=nt-1:Y=o-ct;for(var mt=J,$=Y+1;mt<$;){var ft=mt++;O[R][ft]=(O[F][ft]-O[F][ft-1])/d[X+1][D+ft],j+=O[R][ft]*d[D+ft][X]}ct<=X&&(O[R][nt]=-O[F][nt-1]/d[X+1][ct],j+=O[R][nt]*d[ct][X]),B[nt][ct]=j;var kt=F;F=R,R=kt}}for(var Yt=o,Zt=1,Ut=l+1;Zt<Ut;){for(var Jt=Zt++,Be=0,tr=o+1;Be<tr;){var Ae=Be++;B[Jt][Ae]*=Yt}Yt*=o-Jt}return B},N.basisFunctions=function(r,i,o){var l=N.knotSpan(i,r,o);return N.basisFunctionsGivenKnotSpanIndex(l,r,i,o)},N.basisFunctionsGivenKnotSpanIndex=function(r,i,o,l){var c=m.zeros1d(o+1),d=m.zeros1d(o+1),g=m.zeros1d(o+1),_=0,y=0;c[0]=1;for(var I=1,P=o+1;I<P;){var S=I++;d[S]=i-l[r+1-S],g[S]=l[r+S]-i,_=0;for(var E=0;E<S;){var M=E++;y=c[M]/(g[M+1]+d[S-M]),c[M]=_+g[M+1]*y,_=d[S-M]*y}c[S]=_}return c},N.knotSpan=function(r,i,o){return N.knotSpanGivenN(o.length-r-2,r,i,o)},N.knotSpanGivenN=function(r,i,o,l){if(o>l[r+1]-rt.EPSILON)return r;if(o<l[i]+rt.EPSILON)return i;for(var c=i,d=r+1,g=Math.floor((c+d)/2);o<l[g]||o>=l[g+1];)o<l[g]?d=g:c=g,g=Math.floor((c+d)/2);return g},N.dehomogenize=function(r){for(var i=r.length,o=[],l=r[i-1],c=r.length-1,d=0;d<c;){var g=d++;o.push(r[g]/l)}return o},N.rational1d=function(r){var i=r[0].length-1;return r.map(function(o){return o.slice(0,i)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var i=r[0].length-1;return r.map(function(o){return o[i]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,i){var o=r.length,l=r[0].length,c=[],d=0,g=[],_;i!=null?_=i:_=m.rep(r.length,1);for(var y=0;y<o;){var I=y++,P=[];g=r[I],d=_[I];for(var S=0;S<l;){var E=S++;P.push(g[E]*d)}P.push(d),c.push(P)}return c},N.homogenize2d=function(r,i){var o=r.length,l=[],c;if(i!=null)c=i;else{for(var d=[],g=0;g<o;)g++,d.push(m.rep(r[0].length,1));c=d}for(var _=0;_<o;){var y=_++;l.push(N.homogenize1d(r[y],c[y]))}return l};var ut=f.eval.Intersect=function(){};w["verb.eval.Intersect"]=ut,ut.__name__=["verb","eval","Intersect"],ut.surfaces=function(r,i,o){var l=Rt.rationalSurfaceAdaptive(r),c=Rt.rationalSurfaceAdaptive(i),d=ut.meshes(l,c),g=d.map(function(_){return _.map(function(y){return ut.surfacesAtPointWithEstimate(r,i,y.uv0,y.uv1,o)})});return g.map(function(_){return gt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},ut.surfacesAtPointWithEstimate=function(r,i,o,l,c){var d,g,_,y,I,P,S,E,M,T,B,O,F,R=5,j=0;do{if(d=N.rationalSurfaceDerivatives(r,o[0],o[1],1),g=d[0][0],y=d[1][0],I=d[0][1],_=m.normalized(m.cross(y,I)),P=m.dot(_,g),S=N.rationalSurfaceDerivatives(i,l[0],l[1],1),E=S[0][0],T=S[1][0],B=S[0][1],M=m.normalized(m.cross(T,B)),O=m.dot(M,E),F=m.distSquared(g,E),F<c*c)break;var D=m.normalized(m.cross(_,M)),X=m.dot(D,g),J=ut.threePlanes(_,P,M,O,D,X);if(J==null)throw new Q("panic!");var Y=m.sub(J,g),U=m.sub(J,E),K=m.cross(y,_),tt=m.cross(I,_),et=m.cross(T,M),ot=m.cross(B,M),ct=m.dot(tt,Y)/m.dot(tt,y),ht=m.dot(K,Y)/m.dot(K,I),pt=m.dot(ot,U)/m.dot(ot,T),nt=m.dot(et,U)/m.dot(et,B);o=m.add([ct,ht],o),l=m.add([pt,nt],l),j++}while(j<R);return new ds(o,l,g,F)},ut.meshes=function(r,i,o,l){o==null&&(o=new gr(r)),l==null&&(l=new gr(i));var c=ut.boundingBoxTrees(o,l,0),d=Z.unique(c.map(function(g){return ut.triangles(r,g.item0,i,g.item1)}).filter(function(g){return g!=null}).filter(function(g){return m.distSquared(g.min.point,g.max.point)>rt.EPSILON}),function(g,_){var y=m.sub(g.min.uv0,_.min.uv0),I=m.dot(y,y),P=m.sub(g.max.uv0,_.max.uv0),S=m.dot(P,P),E=m.sub(g.min.uv0,_.max.uv0),M=m.dot(E,E),T=m.sub(g.max.uv0,_.min.uv0),B=m.dot(T,T);return I<rt.EPSILON&&S<rt.EPSILON||M<rt.EPSILON&&B<rt.EPSILON});return ut.makeMeshIntersectionPolylines(d)},ut.meshSlices=function(r,i,o,l){for(var c=new $r(r),d=c.boundingBox(),g=d.min[0],_=d.min[1],y=d.max[0],I=d.max[1],P=m.span(i,o,l),S=[],E=0;E<P.length;){var M=P[E];++E;var T=[[g,_,M],[y,_,M],[y,I,M],[g,I,M]],B=[[0,0],[1,0],[1,1],[0,1]],O=[[0,1,2],[0,2,3]],F=new rr(O,T,null,B);S.push(ut.meshes(r,F,c))}return S},ut.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var i=0;i<r.length;){var o=r[i];++i,o.max.opp=o.min,o.min.opp=o.max}for(var l=ut.kdTreeFromSegments(r),c=[],d=0;d<r.length;){var g=r[d];++d,c.push(g.min),c.push(g.max)}for(var _=0;_<c.length;){var y=c[_];if(++_,y.adj==null){var I=ut.lookupAdjacentSegment(y,l,r.length);I!=null&&I.adj==null&&(y.adj=I,I.adj=y)}}var P=c.filter(function(R){return R.adj==null});P.length==0&&(P=c);for(var S=[],E=0,M=!1;P.length!=0;){var T=P.pop();if(!T.visited){for(var B=[],O=T;O!=null&&!(O.visited||(O.visited=!0,O.opp.visited=!0,B.push(O),E+=2,O=O.opp.adj,O==T)););B.length>0&&(B.push(B[B.length-1].opp),S.push(B))}if(P.length==0&&c.length>0&&(M||E<c.length)){M=!0;var F=c.pop();P.push(F)}}return S},ut.kdTreeFromSegments=function(r){for(var i=[],o=0;o<r.length;){var l=r[o];++o,i.push(new Vn(l.min.point,l.min)),i.push(new Vn(l.max.point,l.max))}return new ms(i,m.distSquared)},ut.lookupAdjacentSegment=function(r,i,o){var l=i.nearest(r.point,o,rt.EPSILON).filter(function(c){return r!=c.item0.obj}).map(function(c){return c.item0.obj});return l.length==1?l[0]:null},ut.curveAndSurface=function(r,i,o,l,c){o==null&&(o=.001),l!=null?l=l:l=new mr(r),c!=null?c=c:c=new qr(i);var d=ut.boundingBoxTrees(l,c,o);return Z.unique(d.map(function(g){var _=g.item0,y=g.item1,I=Z.first(_.knots),P=Z.last(_.knots),S=(I+P)/2,E=Z.first(y.knotsU),M=Z.last(y.knotsU),T=Z.first(y.knotsV),B=Z.last(y.knotsV),O=[(E+M)/2,(T+B)/2];return ut.curveAndSurfaceWithEstimate(_,y,[S].concat(O),o)}).filter(function(g){return m.distSquared(g.curvePoint,g.surfacePoint)<o*o}),function(g,_){return Math.abs(g.u-_.u)<.5*o})},ut.curveAndSurfaceWithEstimate=function(r,i,o,l){l==null&&(l=.001);var c=function(y){var I=N.rationalCurvePoint(r,y[0]),P=N.rationalSurfacePoint(i,y[1],y[2]),S=m.sub(I,P);return m.dot(S,S)},d=function(y){var I=N.rationalCurveDerivatives(r,y[0],1),P=N.rationalSurfaceDerivatives(i,y[1],y[2],1),S=m.sub(P[0][0],I[0]),E=m.mul(-1,I[1]),M=P[1][0],T=P[0][1];return[2*m.dot(E,S),2*m.dot(M,S),2*m.dot(T,S)]},g=nr.uncmin(c,o,l*l,d),_=g.solution;return new us(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(i,_[1],_[2]))},ut.polylineAndMesh=function(r,i,o){for(var l=ut.boundingBoxTrees(new _r(r),new gr(i),o),c=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,I=ut.segmentWithTriangle(r.points[_],r.points[_+1],i.points,i.faces[y]);if(I!=null){var P=I.point,S=m.lerp(I.p,[r.params[_]],[r.params[_+1]])[0],E=oe.triangleUVFromPoint(i,y,P);c.push(new cs(P,S,E,_,y))}}return c},ut.boundingBoxTrees=function(r,i,o){o==null&&(o=1e-9);var l=[],c=[];l.push(r),c.push(i);for(var d=[];l.length>0;){var g=l.pop(),_=c.pop();if(!(g.empty()||_.empty())&&g.boundingBox().intersects(_.boundingBox(),o)){var y=g.indivisible(o),I=_.indivisible(o);if(y&&I){d.push(new ae(g.yield(),_.yield()));continue}else if(y&&!I){var P=_.split();l.push(g),c.push(P.item1),l.push(g),c.push(P.item0);continue}else if(!y&&I){var S=g.split();l.push(S.item1),c.push(_),l.push(S.item0),c.push(_);continue}var E=g.split(),M=_.split();l.push(E.item1),c.push(M.item1),l.push(E.item1),c.push(M.item0),l.push(E.item0),c.push(M.item1),l.push(E.item0),c.push(M.item0)}}return d},ut.curves=function(r,i,o){var l=ut.boundingBoxTrees(new mr(r),new mr(i),0);return Z.unique(l.map(function(c){return ut.curvesWithEstimate(r,i,Z.first(c.item0.knots),Z.first(c.item1.knots),o)}).filter(function(c){return m.distSquared(c.point0,c.point1)<o}),function(c,d){return Math.abs(c.u0-d.u0)<o*5})},ut.curvesWithEstimate=function(r,i,o,l,c){var d=function(E){var M=N.rationalCurvePoint(r,E[0]),T=N.rationalCurvePoint(i,E[1]),B=m.sub(M,T);return m.dot(B,B)},g=function(E){var M=N.rationalCurveDerivatives(r,E[0],1),T=N.rationalCurveDerivatives(i,E[1],1),B=m.sub(M[0],T[0]),O=M[1],F=m.mul(-1,T[1]);return[2*m.dot(O,B),2*m.dot(F,B)]},_=nr.uncmin(d,[o,l],c*c,g),y=_.solution[0],I=_.solution[1],P=N.rationalCurvePoint(r,y),S=N.rationalCurvePoint(i,I);return new pn(P,S,y,I)},ut.triangles=function(r,i,o,l){var c=r.faces[i],d=o.faces[l],g=oe.getTriangleNorm(r.points,c),_=oe.getTriangleNorm(o.points,d),y=r.points[c[0]],I=o.points[d[0]],P=ut.planes(y,g,I,_);if(P==null)return null;var S=ut.clipRayInCoplanarTriangle(P,r,i);if(S==null)return null;var E=ut.clipRayInCoplanarTriangle(P,o,l);if(E==null)return null;var M=ut.mergeTriangleClipIntervals(S,E,r,i,o,l);return M==null?null:new Ce(new Xr(M.min.uv0,M.min.uv1,M.min.point,i,l),new Xr(M.max.uv0,M.max.uv1,M.max.point,i,l))},ut.clipRayInCoplanarTriangle=function(r,i,o){for(var l=i.faces[o],c=[i.points[l[0]],i.points[l[1]],i.points[l[2]]],d=[i.uvs[l[0]],i.uvs[l[1]],i.uvs[l[2]]],g=[m.sub(d[1],d[0]),m.sub(d[2],d[1]),m.sub(d[0],d[2])],_=[m.sub(c[1],c[0]),m.sub(c[2],c[1]),m.sub(c[0],c[2])],y=_.map(m.normalized),I=_.map(m.norm),P=null,S=null,E=0;E<3;){var M=E++,T=c[M],B=y[M],O=ut.rays(T,B,r.origin,r.dir);if(O!=null){var F=O.u0,R=O.u1;F<-rt.EPSILON||F>I[M]+rt.EPSILON||((P==null||R<P.u)&&(P=new zn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[M],g[M],F/I[M]))),(S==null||R>S.u)&&(S=new zn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[M],g[M],F/I[M]))))}}return S==null||P==null?null:new Ce(P,S)},ut.mergeTriangleClipIntervals=function(r,i,o,l,c,d){if(i.min.u>r.max.u+rt.EPSILON||r.min.u>i.max.u+rt.EPSILON)return null;var g;r.min.u>i.min.u?g=new ae(r.min,0):g=new ae(i.min,1);var _;r.max.u<i.max.u?_=new ae(r.max,0):_=new ae(i.max,1);var y=new Ce(new Xr(null,null,g.item0.point,l,d),new Xr(null,null,_.item0.point,l,d));return g.item1==0?(y.min.uv0=g.item0.uv,y.min.uv1=oe.triangleUVFromPoint(c,d,g.item0.point)):(y.min.uv0=oe.triangleUVFromPoint(o,l,g.item0.point),y.min.uv1=g.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=oe.triangleUVFromPoint(c,d,_.item0.point)):(y.max.uv0=oe.triangleUVFromPoint(o,l,_.item0.point),y.max.uv1=_.item0.uv),y},ut.planes=function(r,i,o,l){var c=m.cross(i,l);if(m.dot(c,c)<rt.EPSILON)return null;var d=0,g=Math.abs(c[0]),_=Math.abs(c[1]),y=Math.abs(c[2]);_>g&&(d=1,g=_),y>g&&(d=2,g=y);var I,P,S,E;d==0?(I=i[1],P=i[2],S=l[1],E=l[2]):d==1?(I=i[0],P=i[2],S=l[0],E=l[2]):(I=i[0],P=i[1],S=l[0],E=l[1]);var M=-m.dot(r,i),T=-m.dot(o,l),B=I*E-P*S,O=(P*T-M*E)/B,F=(M*S-I*T)/B,R;return d==0?R=[0,O,F]:d==1?R=[O,0,F]:R=[O,F,0],new Fn(R,m.normalized(c))},ut.threePlanes=function(r,i,o,l,c,d){var g=m.cross(o,c),_=m.dot(r,g);if(Math.abs(_)<rt.EPSILON)return null;var y=m.sub(m.mul(d,o),m.mul(l,c)),I=m.add(m.mul(i,g),m.cross(r,y));return m.mul(1/_,I)},ut.polylines=function(r,i,o){for(var l=ut.boundingBoxTrees(new _r(r),new _r(i),o),c=[],d=0;d<l.length;){var g=l[d];++d;var _=g.item0,y=g.item1,I=ut.segments(r.points[_],r.points[_+1],i.points[y],i.points[y+1],o);I!=null&&(I.u0=m.lerp(I.u0,[r.params[_]],[r.params[_+1]])[0],I.u1=m.lerp(I.u1,[i.params[y]],[i.params[y+1]])[0],c.push(I))}return c},ut.segments=function(r,i,o,l,c){var d=m.sub(i,r),g=Math.sqrt(m.dot(d,d)),_=m.mul(1/g,d),y=m.sub(l,o),I=Math.sqrt(m.dot(y,y)),P=m.mul(1/I,y),S=ut.rays(r,_,o,P);if(S!=null){var E=Math.min(Math.max(0,S.u0/g),1),M=Math.min(Math.max(0,S.u1/I),1),T=m.onRay(r,d,E),B=m.onRay(o,y,M),O=m.distSquared(T,B);if(O<c*c)return new pn(T,B,E,M)}return null},ut.rays=function(r,i,o,l){var c=m.dot(i,l),d=m.dot(i,o),g=m.dot(i,r),_=m.dot(l,o),y=m.dot(l,r),I=m.dot(i,i),P=m.dot(l,l),S=I*P-c*c;if(Math.abs(S)<rt.EPSILON)return null;var E=c*(d-g)-I*(_-y),M=E/S,T=(d-g+M*c)/I,B=m.onRay(r,i,T),O=m.onRay(o,l,M);return new pn(B,O,T,M)},ut.segmentWithTriangle=function(r,i,o,l){var c=o[l[0]],d=o[l[1]],g=o[l[2]],_=m.sub(d,c),y=m.sub(g,c),I=m.cross(_,y),P=m.sub(i,r),S=m.sub(r,c),E=-m.dot(I,S),M=m.dot(I,P);if(Math.abs(M)<rt.EPSILON)return null;var T=E/M;if(T<0||T>1)return null;var B=m.add(r,m.mul(T,P)),O=m.dot(_,y),F=m.dot(_,_),R=m.dot(y,y),j=m.sub(B,c),D=m.dot(j,_),X=m.dot(j,y),J=O*O-F*R;if(Math.abs(J)<rt.EPSILON)return null;var Y=(O*X-R*D)/J,U=(O*D-F*X)/J;return Y>1+rt.EPSILON||U>1+rt.EPSILON||U<-rt.EPSILON||Y<-rt.EPSILON||Y+U>1+rt.EPSILON?null:new ps(B,Y,U,T)},ut.segmentAndPlane=function(r,i,o,l){var c=m.dot(l,m.sub(i,r));if(Math.abs(c)<rt.EPSILON)return null;var d=m.dot(l,m.sub(o,r)),g=d/c;return g>1+rt.EPSILON||g<-rt.EPSILON?null:{p:g}};var gt=f.eval.Make=function(){};w["verb.eval.Make"]=gt,gt.__name__=["verb","eval","Make"],gt.rationalTranslationalSurface=function(r,i){for(var o=N.rationalCurvePoint(i,Z.first(i.knots)),l=Z.first(i.knots),c=Z.last(i.knots),d=2*i.controlPoints.length,g=(c-l)/(d-1),_=[],y=0;y<d;){var I=y++,P=m.sub(N.rationalCurvePoint(i,l+I*g),o),S=yt.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(S)}return gt.loftedSurface(_)},gt.surfaceBoundaryCurves=function(r){var i=gt.surfaceIsocurve(r,Z.first(r.knotsU),!1),o=gt.surfaceIsocurve(r,Z.last(r.knotsU),!1),l=gt.surfaceIsocurve(r,Z.first(r.knotsV),!0),c=gt.surfaceIsocurve(r,Z.last(r.knotsV),!0);return[i,o,l,c]},gt.surfaceIsocurve=function(r,i,o){o==null&&(o=!1);var l;o?l=r.knotsV:l=r.knotsU;var c;o?c=r.degreeV:c=r.degreeU;for(var d=bt.knotMultiplicities(l),g=-1,_=0,y=d.length;_<y;){var I=_++;if(Math.abs(i-d[I].knot)<rt.EPSILON){g=I;break}}var P=c+1;g>=0&&(P=P-d[g].mult);var S;P>0?S=yt.surfaceKnotRefine(r,m.rep(P,i),o):S=r;var E=N.knotSpan(c,i,l);return Math.abs(i-Z.first(l))<rt.EPSILON?E=0:Math.abs(i-Z.last(l))<rt.EPSILON&&(E=(o?S.controlPoints[0].length:S.controlPoints.length)-1),o?new Ht(S.degreeU,S.knotsU,function(M){for(var T,B=[],O=0,F=S.controlPoints;O<F.length;){var R=F[O];++O,B.push(R[E])}return T=B,T}()):new Ht(S.degreeV,S.knotsV,S.controlPoints[E])},gt.loftedSurface=function(r,i){r=yt.unifyCurveKnotVectors(r);var o=r[0].degree;i==null&&(i=3),i>r.length-1&&(i=r.length-1);for(var l=r[0].knots,c=[],d=[],g=0,_=r[0].controlPoints.length;g<_;){var y=[g++],I=r.map(function(S){return function(E){return E.controlPoints[S[0]]}}(y)),P=gt.rationalInterpCurve(I,i,!0);d.push(P.controlPoints),c=P.knots}return new ie(o,i,l,c,d)},gt.clonedCurve=function(r){return new Ht(r.degree,r.knots.slice(),r.controlPoints.map(function(i){return i.slice()}))},gt.rationalBezierCurve=function(r,i){for(var o=r.length-1,l=[],c=0,d=o+1;c<d;)c++,l.push(0);for(var g=0,_=o+1;g<_;)g++,l.push(1);return i==null&&(i=m.rep(r.length,1)),new Ht(o,l,N.homogenize1d(r,i))},gt.fourPointSurface=function(r,i,o,l,c){c==null&&(c=3);for(var d=c,g=[],_=0,y=c+1;_<y;){for(var I=_++,P=[],S=0,E=c+1;S<E;){var M=S++,T=1-I/d,B=m.lerp(T,r,i),O=m.lerp(T,l,o),F=m.lerp(1-M/d,B,O);F.push(1),P.push(F)}g.push(P)}var R=m.rep(c+1,0),j=m.rep(c+1,1);return new ie(c,c,R.concat(j),R.concat(j),g)},gt.ellipseArc=function(r,i,o,l,c){var d=m.norm(i),g=m.norm(o);i=m.normalized(i),o=m.normalized(o),c<l&&(c=2*Math.PI+l);var _=c-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var I=_/y,P=Math.cos(I/2),S=m.add(r,m.add(m.mul(d*Math.cos(l),i),m.mul(g*Math.sin(l),o))),E=m.sub(m.mul(Math.cos(l),o),m.mul(Math.sin(l),i)),M=[],T=m.zeros1d(2*y+3),B=0,O=l,F=m.zeros1d(y*2);M[0]=S,F[0]=1;for(var R=1,j=y+1;R<j;){var D=R++;O+=I;var X=m.add(r,m.add(m.mul(d*Math.cos(O),i),m.mul(g*Math.sin(O),o)));F[B+2]=1,M[B+2]=X;var J=m.sub(m.mul(Math.cos(O),o),m.mul(Math.sin(O),i)),Y=ut.rays(S,m.mul(1/m.norm(E),E),X,m.mul(1/m.norm(J),J)),U=m.add(S,m.mul(Y.u0,E));F[B+1]=P,M[B+1]=U,B+=2,D<y&&(S=X,E=J)}for(var K=2*y+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+K]=1}switch(y){case 2:T[3]=T[4]=.5;break;case 3:T[3]=T[4]=.3333333333333333,T[5]=T[6]=.6666666666666666;break;case 4:T[3]=T[4]=.25,T[5]=T[6]=.5,T[7]=T[8]=.75;break}return new Ht(2,T,N.homogenize1d(M,F))},gt.arc=function(r,i,o,l,c,d){return gt.ellipseArc(r,m.mul(l,m.normalized(i)),m.mul(l,m.normalized(o)),c,d)},gt.polyline=function(r){for(var i=[0,0],o=0,l=0,c=r.length-1;l<c;){var d=l++;o+=m.dist(r[d],r[d+1]),i.push(o)}i.push(o),i=m.mul(1/o,i);for(var g,_=[],y=0,I=r.length;y<I;)y++,_.push(1);return g=_,new Ht(1,i,N.homogenize1d(r.slice(0),g))},gt.extrudedSurface=function(r,i,o){for(var l=[[],[],[]],c=[[],[],[]],d=N.dehomogenize1d(o.controlPoints),g=N.weight1d(o.controlPoints),_=m.mul(i,r),y=m.mul(.5*i,r),I=0,P=d.length;I<P;){var S=I++;l[2][S]=d[S],l[1][S]=m.add(y,d[S]),l[0][S]=m.add(_,d[S]),c[0][S]=g[S],c[1][S]=g[S],c[2][S]=g[S]}return new ie(2,o.degree,[0,0,0,1,1,1],o.knots,N.homogenize2d(l,c))},gt.cylindricalSurface=function(r,i,o,l,c){var d=m.cross(r,i),g=gt.arc(o,i,d,c,0,2*Math.PI);return gt.extrudedSurface(r,l,g)},gt.revolvedSurface=function(r,i,o,l){var c=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),g,_;l<=Math.PI/2?(g=1,_=m.zeros1d(6+2*(g-1))):l<=Math.PI?(g=2,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(g=3,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(g=4,_=m.zeros1d(6+2*(g-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/g,I=3+2*(g-1),P=0;P<3;){var S=P++;_[S]=0,_[I+S]=1}for(var E=Math.cos(y/2),M=0,T=m.zeros1d(g+1),B=m.zeros1d(g+1),O=m.zeros3d(2*g+1,c.length,3),F=m.zeros2d(2*g+1,c.length),R=1,j=g+1;R<j;){var D=R++;M+=y,B[D]=Math.cos(M),T[D]=Math.sin(M)}for(var X=0,J=c.length;X<J;){var Y=X++,U=je.rayClosestPoint(c[Y],i,o),K=m.sub(c[Y],U),tt=m.norm(K),et=m.cross(o,K);tt>rt.EPSILON&&(K=m.mul(1/tt,K),et=m.mul(1/tt,et)),O[0][Y]=c[Y];var ot=c[Y];F[0][Y]=d[Y];for(var ct=et,ht=0,pt=1,nt=g+1;pt<nt;){var mt=pt++,$;tt==0?$=U:$=m.add(U,m.add(m.mul(tt*B[mt],K),m.mul(tt*T[mt],et))),O[ht+2][Y]=$,F[ht+2][Y]=d[Y];var ft=m.sub(m.mul(B[mt],et),m.mul(T[mt],K));if(tt==0)O[ht+1][Y]=U;else{var kt=ut.rays(ot,m.mul(1/m.norm(ct),ct),$,m.mul(1/m.norm(ft),ft)),Yt=m.add(ot,m.mul(kt.u0,ct));O[ht+1][Y]=Yt}F[ht+1][Y]=E*d[Y],ht+=2,mt<g&&(ot=$,ct=ft)}}return new ie(2,r.degree,_,r.knots,N.homogenize2d(O,F))},gt.sphericalSurface=function(r,i,o,l){var c=gt.arc(r,m.mul(-1,i),o,l,0,Math.PI);return gt.revolvedSurface(c,r,i,2*Math.PI)},gt.conicalSurface=function(r,i,o,l,c){var d=2*Math.PI,g=1,_=[m.add(o,m.mul(l,r)),m.add(o,m.mul(c,i))],y=[0,0,1,1],I=[1,1],P=new Ht(g,y,N.homogenize1d(_,I));return gt.revolvedSurface(P,o,r,d)},gt.rationalInterpCurve=function(r,i,o,l,c){if(o==null&&(o=!1),i==null&&(i=3),r.length<i+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],g=1,_=r.length;g<_;){var y=g++,I=m.norm(m.sub(r[y],r[y-1])),P=d[d.length-1];d.push(P+I)}for(var S=d[d.length-1],E=0,M=d.length;E<M;){var T=E++;d[T]=d[T]/S}var B=m.rep(i+1,0),O=l!=null&&c!=null,F;O?F=0:F=1;var R;O?R=d.length-i+1:R=d.length-i;for(var j=F;j<R;){for(var D=j++,X=0,J=0;J<i;){var Y=J++;X+=d[D+Y]}B.push(1/i*X)}var U=B.concat(m.rep(i+1,1)),K=[],tt;O?tt=r.length+1:tt=r.length-1;var et;O?et=r.length-(i-1):et=r.length-(i+1);for(var ot=0;ot<d.length;){var ct=d[ot];++ot;var ht=N.knotSpanGivenN(tt,i,ct,U),pt=N.basisFunctionsGivenKnotSpanIndex(ht,ct,i,U),nt=ht-i,mt=m.zeros1d(nt),$=m.zeros1d(et-nt);K.push(mt.concat(pt).concat($))}if(O){var ft=K[0].length-2,kt=[-1,1].concat(m.zeros1d(ft)),Yt=m.zeros1d(ft).concat([-1,1]);Z.spliceAndInsert(K,1,0,kt),Z.spliceAndInsert(K,K.length-1,0,Yt)}for(var Zt=r[0].length,Ut=[],Jt=(1-U[U.length-i-2])/i,Be=U[i+1]/i,tr=0;tr<Zt;){var Ae=[tr++],Ie;if(!O)Ie=r.map(function(lr){return function(Sr){return Sr[lr[0]]}}(Ae));else{Ie=[r[0][Ae[0]]],Ie.push(Be*l[Ae[0]]);for(var Re=1,Ue=r.length-1;Re<Ue;){var ir=Re++;Ie.push(r[ir][Ae[0]])}Ie.push(Jt*c[Ae[0]]),Ie.push(Z.last(r)[Ae[0]])}var fr=Ct.solve(K,Ie);Ut.push(fr)}var ar=Ct.transpose(Ut);if(!o){var or=m.rep(ar.length,1);ar=N.homogenize1d(ar,or)}return new Ht(i,U,ar)};var yt=f.eval.Modify=function(){};w["verb.eval.Modify"]=yt,yt.__name__=["verb","eval","Modify"],yt.curveReverse=function(r){return new Ht(r.degree,yt.knotsReverse(r.knots),Z.reversed(r.controlPoints))},yt.surfaceReverse=function(r,i){return i==null&&(i=!1),i?new ie(r.degreeU,r.degreeV,r.knotsU,yt.knotsReverse(r.knotsV),function(o){for(var l,c=[],d=0,g=r.controlPoints;d<g.length;){var _=g[d];++d,c.push(Z.reversed(_))}return l=c,l}()):new ie(r.degreeU,r.degreeV,yt.knotsReverse(r.knotsU),r.knotsV,Z.reversed(r.controlPoints))},yt.knotsReverse=function(r){var i=Z.first(r);Z.last(r);for(var o=[i],l=r.length,c=1;c<l;){var d=c++;o.push(o[d-1]+(r[l-d]-r[l-d-1]))}return o},yt.unifyCurveKnotVectors=function(r){r=r.map(gt.clonedCurve);for(var i=C.fold(r,function(U,K){return yt.imax(U.degree,K)},0),o=0,l=r.length;o<l;){var c=o++;r[c].degree<i&&(r[c]=yt.curveElevateDegree(r[c],i))}for(var d,g=[],_=0;_<r.length;){var y=r[_];++_,g.push(new Ce(Z.first(y.knots),Z.last(y.knots)))}d=g;for(var I=0,P=r.length;I<P;){var S=I++,E=[d[S].min];r[S].knots=r[S].knots.map(function(U){return function(K){return K-U[0]}}(E))}for(var M=d.map(function(U){return U.max-U.min}),T=C.fold(M,function(U,K){return Math.max(U,K)},0),B=0,O=r.length;B<O;){var F=B++,R=[T/M[F]];r[F].knots=r[F].knots.map(function(U){return function(K){return K*U[0]}}(R))}for(var j=C.fold(r,function(U,K){return m.sortedSetUnion(U.knots,K)},[]),D=0,X=r.length;D<X;){var J=D++,Y=m.sortedSetSub(j,r[J].knots);Y.length==0&&(r[J]=r[J]),r[J]=yt.curveKnotRefine(r[J],Y)}return r},yt.imin=function(r,i){return r<i?r:i},yt.imax=function(r,i){return r>i?r:i},yt.curveElevateDegree=function(r,i){if(i<=r.degree)return r;var o=r.knots.length-r.degree-2,l=r.degree,c=r.knots,d=r.controlPoints,g=i-r.degree,_=r.controlPoints[0].length,y=m.zeros2d(l+g+1,l+1),I=[],P=[],S=[],E=o+l+1,M=i,T=Math.floor(M/2),B=[],O=[];y[0][0]=1,y[M][l]=1;for(var F=1,R=T+1;F<R;)for(var j=F++,D=1/Vt.get(M,j),X=yt.imin(l,j),J=yt.imax(0,j-g),Y=X+1;J<Y;){var U=J++;y[j][U]=D*Vt.get(l,U)*Vt.get(g,j-U)}for(var K=T+1;K<M;)for(var tt=K++,et=yt.imin(l,tt),ot=yt.imax(0,tt-g),ct=et+1;ot<ct;){var ht=ot++;y[tt][ht]=y[M-tt][l-ht]}var pt=M+1,nt=-1,mt=l,$=l+1,ft=1,kt=c[0];B[0]=d[0];for(var Yt=0,Zt=M+1;Yt<Zt;){var Ut=Yt++;O[Ut]=kt}for(var Jt=0,Be=l+1;Jt<Be;){var tr=Jt++;I[tr]=d[tr]}for(;$<E;){for(var Ae=$;$<E&&c[$]==c[$+1];)$=$+1;var Ie=$-Ae+1,Re=c[$],Ue=nt;nt=l-Ie;var ir;Ue>0?ir=Math.floor((Ue+2)/2):ir=1;var fr;if(nt>0?fr=Math.floor(M-(nt+1)/2):fr=M,nt>0){for(var ar=Re-kt,or=[],lr=l;lr>Ie;)or[lr-Ie-1]=ar/(c[mt+lr]-kt),lr--;for(var Sr=1,Yn=nt+1;Sr<Yn;){for(var gn=Sr++,Rc=nt-gn,ma=Ie+gn,_n=l;_n>=ma;)I[_n]=m.add(m.mul(or[_n-ma],I[_n]),m.mul(1-or[_n-ma],I[_n-1])),_n--;S[Rc]=I[l]}}for(var ol=ir,Fc=M+1;ol<Fc;){var Xn=ol++;P[Xn]=m.zeros1d(_);for(var zc=yt.imin(l,Xn),ll=yt.imax(0,Xn-g),Vc=zc+1;ll<Vc;){var hl=ll++;P[Xn]=m.add(P[Xn],m.mul(y[Xn][hl],I[hl]))}}if(Ue>1)for(var ga=pt-2,_a=pt,ul=Re-kt,jc=(Re-O[pt-1])/ul,cl=1;cl<Ue;){for(var fa=cl++,Pr=ga,fn=_a,en=fn-pt+1;fn-Pr>fa;){if(Pr<ft){var Dc=(Re-O[Pr])/(kt-O[Pr]);B[Pr]=m.lerp(Dc,B[Pr],B[Pr-1])}if(fn>=ir){if(fn-fa<=pt-M+Ue){var Uc=(Re-O[fn-fa])/ul;P[en]=m.lerp(Uc,P[en],P[en+1])}}else P[en]=m.lerp(jc,P[en],P[en+1]);Pr=Pr+1,fn=fn-1,en=en-1}ga=ga-1,_a=_a+1}if(mt!=l)for(var dl=0,Gc=M-Ue;dl<Gc;)dl++,O[pt]=kt,pt=pt+1;for(var pl=ir,Wc=fr+1;pl<Wc;){var Hc=pl++;B[ft]=P[Hc],ft=ft+1}if($<E){for(var ml=0;ml<nt;){var gl=ml++;I[gl]=S[gl]}for(var _l=nt,Yc=l+1;_l<Yc;){var fl=_l++;I[fl]=d[$-l+fl]}mt=$,$=$+1,kt=Re}else for(var yl=0,Xc=M+1;yl<Xc;){var qc=yl++;O[pt+qc]=Re}}return new Ht(i,O,B)},yt.rationalSurfaceTransform=function(r,i){for(var o=N.dehomogenize2d(r.controlPoints),l=0,c=o.length;l<c;)for(var d=l++,g=0,_=o[d].length;g<_;){var y=g++,I=o[d][y];I.push(1),o[d][y]=Ct.dot(i,I).slice(0,I.length-1)}return new ie(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(o,N.weight2d(r.controlPoints)))},yt.rationalCurveTransform=function(r,i){for(var o=N.dehomogenize1d(r.controlPoints),l=0,c=o.length;l<c;){var d=l++,g=o[d];g.push(1),o[d]=Ct.dot(i,g).slice(0,g.length-1)}return new Ht(r.degree,r.knots.slice(),N.homogenize1d(o,N.weight1d(r.controlPoints)))},yt.surfaceKnotRefine=function(r,i,o){var l=[],c,d,g;o?(g=r.controlPoints,c=r.knotsV,d=r.degreeV):(g=Ct.transpose(r.controlPoints),c=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<g.length;){var I=g[y];++y,_=yt.curveKnotRefine(new Ht(d,c,I),i),l.push(_.controlPoints)}var P=_.knots;return o?new ie(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Ct.transpose(l),new ie(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},yt.decomposeCurveIntoBeziers=function(r){for(var i=r.degree,o=r.controlPoints,l=r.knots,c=bt.knotMultiplicities(l),d=i+1,g=0;g<c.length;){var _=c[g];if(++g,_.mult<d){var y=m.rep(d-_.mult,_.knot),I=yt.curveKnotRefine(new Ht(i,l,o),y);l=I.knots,o=I.controlPoints}}l.length/d-1;for(var P=d*2,S=[],E=0;E<o.length;){var M=l.slice(E,E+P),T=o.slice(E,E+d);S.push(new Ht(i,M,T)),E+=d}return S},yt.curveKnotRefine=function(r,i){if(i.length==0)return gt.clonedCurve(r);for(var o=r.degree,l=r.controlPoints,c=r.knots,d=l.length-1,g=d+o+1,_=i.length-1,y=N.knotSpan(o,i[0],c),I=N.knotSpan(o,i[_],c),P=[],S=[],E=0,M=y-o+1;E<M;){var T=E++;P[T]=l[T]}for(var B=I-1,O=d+1;B<O;){var F=B++;P[F+_+1]=l[F]}for(var R=0,j=y+1;R<j;){var D=R++;S[D]=c[D]}for(var X=I+o,J=g+1;X<J;){var Y=X++;S[Y+_+1]=c[Y]}for(var U=I+o-1,K=I+o+_,tt=_;tt>=0;){for(;i[tt]<=c[U]&&U>y;)P[K-o-1]=l[U-o-1],S[K]=c[U],K=K-1,U=U-1;P[K-o-1]=P[K-o];for(var et=1,ot=o+1;et<ot;){var ct=et++,ht=K-o+ct,pt=S[K+ct]-i[tt];Math.abs(pt)<rt.EPSILON?P[ht-1]=P[ht]:(pt=pt/(S[K+ct]-c[U-o+ct]),P[ht-1]=m.add(m.mul(pt,P[ht-1]),m.mul(1-pt,P[ht])))}S[K]=i[tt],K=K-1,tt--}return new Ht(o,S,P)},yt.curveKnotInsert=function(r,i,o){for(var l=r.degree,c=r.controlPoints,d=r.knots,g=0,_=c.length,y=N.knotSpan(l,i,d),I=[],P=[],S=[],E=1,M=y+1;E<M;){var T=E++;P[T]=d[T]}for(var B=1,O=o+1;B<O;){var F=B++;P[y+F]=i}for(var R=y+1,j=d.length;R<j;){var D=R++;P[D+o]=d[D]}for(var X=0,J=y-l+1;X<J;){var Y=X++;S[Y]=c[Y]}for(var U=y-g;U<_;){var K=U++;S[K+o]=c[K]}for(var tt=0,et=l-g+1;tt<et;){var ot=tt++;I[ot]=c[y-l+ot]}for(var ct=0,ht=0,pt=1,nt=o+1;pt<nt;){var mt=pt++;ct=y-l+mt;for(var $=0,ft=l-mt-g+1;$<ft;){var kt=$++;ht=(i-d[ct+kt])/(d[kt+y+1]-d[ct+kt]),I[kt]=m.add(m.mul(ht,I[kt+1]),m.mul(1-ht,I[kt]))}S[ct]=I[0],S[y+o-mt-g]=I[l-mt-g]}for(var Yt=ct+1,Zt=y-g;Yt<Zt;){var Ut=Yt++;S[Ut]=I[Ut-ct]}return new Ht(l,P,S)};var Rt=f.eval.Tess=function(){};w["verb.eval.Tess"]=Rt,Rt.__name__=["verb","eval","Tess"],Rt.rationalCurveRegularSample=function(r,i,o){return Rt.rationalCurveRegularSampleRange(r,r.knots[0],Z.last(r.knots),i,o)},Rt.rationalCurveRegularSampleRange=function(r,i,o,l,c){l<1&&(l=2);for(var d=[],g=(o-i)/(l-1),_=0,y=0;y<l;){var I=y++;_=i+g*I,c?d.push([_].concat(N.rationalCurvePoint(r,_))):d.push(N.rationalCurvePoint(r,_))}return d},Rt.rationalCurveAdaptiveSample=function(r,i,o){if(o==null&&(o=!1),i==null&&(i=1e-6),r.degree==1)if(o){for(var l=[],c=0,d=r.controlPoints.length;c<d;){var g=c++;l.push([r.knots[g+1]].concat(N.dehomogenize(r.controlPoints[g])))}return l}else return r.controlPoints.map(N.dehomogenize);return Rt.rationalCurveAdaptiveSampleRange(r,r.knots[0],Z.last(r.knots),i,o)},Rt.rationalCurveAdaptiveSampleRange=function(r,i,o,l,c){var d=N.rationalCurvePoint(r,i),g=N.rationalCurvePoint(r,o),_=.5+.2*Math.random(),y=i+(o-i)*_,I=N.rationalCurvePoint(r,y),P=m.sub(d,g),S=m.sub(d,I);if(m.dot(P,P)<l&&m.dot(S,S)>l||!je.threePointsAreFlat(d,I,g,l)){var E=i+(o-i)*.5,M=Rt.rationalCurveAdaptiveSampleRange(r,i,E,l,c),T=Rt.rationalCurveAdaptiveSampleRange(r,E,o,l,c);return M.slice(0,-1).concat(T)}else return c?[[i].concat(d),[o].concat(g)]:[d,g]},Rt.rationalSurfaceNaive=function(r,i,o){i<1&&(i=1),o<1&&(o=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,c=r.knotsV,d=Z.last(l)-l[0],g=Z.last(c)-c[0],_=d/i,y=g/o,I=[],P=[],S=[],E=0,M=i+1;E<M;)for(var T=E++,B=0,O=o+1;B<O;){var F=B++,R=T*_,j=F*y;P.push([R,j]);var D=N.rationalSurfaceDerivatives(r,R,j,1),X=D[0][0];I.push(X);var J=m.normalized(m.cross(D[1][0],D[0][1]));S.push(J)}for(var Y=[],U=0;U<i;)for(var K=U++,tt=0;tt<o;){var et=tt++,ot=K*(o+1)+et,ct=(K+1)*(o+1)+et,ht=ct+1,pt=ot+1,nt=[ot,ct,ht],mt=[ot,ht,pt];Y.push(nt),Y.push(mt)}return new rr(Y,I,S,P)},Rt.divideRationalSurfaceAdaptive=function(r,i){i==null&&(i=new Kr),i.minDivsU!=null?i.minDivsU=i.minDivsU:i.minDivsU=1,i.minDivsV!=null?i.minDivsU=i.minDivsV:i.minDivsU=1,i.refine!=null?i.refine=i.refine:i.refine=!0;var o=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,c;i.minDivsU>o?c=i.minDivsU=i.minDivsU:c=i.minDivsU=o;var d;i.minDivsV>l?d=i.minDivsV=i.minDivsV:d=i.minDivsV=l;for(var g=Z.last(r.knotsU),_=r.knotsU[0],y=Z.last(r.knotsV),I=r.knotsV[0],P=(g-_)/c,S=(y-I)/d,E=[],M=[],T=0,B=d+1;T<B;){for(var O=T++,F=[],R=0,j=c+1;R<j;){var D=R++,X=_+P*D,J=I+S*O,Y=N.rationalSurfaceDerivatives(r,X,J,1),U=m.normalized(m.cross(Y[0][1],Y[1][0]));F.push(new Qe(Y[0][0],U,[X,J],-1,m.isZero(U)))}M.push(F)}for(var K=0;K<d;)for(var tt=K++,et=0;et<c;){var ot=et++,ct=[M[d-tt-1][ot],M[d-tt-1][ot+1],M[d-tt][ot+1],M[d-tt][ot]];E.push(new Ir(r,ct))}if(!i.refine)return E;for(var ht=0;ht<d;)for(var pt=ht++,nt=0;nt<c;){var mt=nt++,$=pt*c+mt,ft=Rt.north($,pt,mt,c,d,E),kt=Rt.east($,pt,mt,c,d,E),Yt=Rt.south($,pt,mt,c,d,E),Zt=Rt.west($,pt,mt,c,d,E);E[$].neighbors=[Yt,kt,ft,Zt],E[$].divide(i)}return E},Rt.north=function(r,i,o,l,c,d){return i==0?null:d[r-l]},Rt.south=function(r,i,o,l,c,d){return i==c-1?null:d[r+l]},Rt.east=function(r,i,o,l,c,d){return o==l-1?null:d[r+1]},Rt.west=function(r,i,o,l,c,d){return o==0?null:d[r-1]},Rt.triangulateAdaptiveRefinementNodeTree=function(r){for(var i=rr.empty(),o=0;o<r.length;){var l=r[o];++o,l.triangulate(i)}return i},Rt.rationalSurfaceAdaptive=function(r,i){i!=null?i=i:i=new Kr;var o=Rt.divideRationalSurfaceAdaptive(r,i);return Rt.triangulateAdaptiveRefinementNodeTree(o)};var Kr=f.core.AdaptiveRefinementOptions=function(){this.minDivsV=1,this.minDivsU=1,this.refine=!0,this.maxDepth=10,this.minDepth=0,this.normTol=.025};w["verb.eval.AdaptiveRefinementOptions"]=Kr,Kr.__name__=["verb","eval","AdaptiveRefinementOptions"],Kr.prototype={__class__:Kr};var Ir=f.core.AdaptiveRefinementNode=function(r,i,o){if(this.srf=r,o==null?this.neighbors=[null,null,null,null]:this.neighbors=o,this.corners=i,this.corners==null){var l=r.knotsU[0],c=Z.last(r.knotsU),d=r.knotsV[0],g=Z.last(r.knotsV);this.corners=[Qe.fromUv(l,d),Qe.fromUv(c,d),Qe.fromUv(c,g),Qe.fromUv(l,g)]}};w["verb.eval.AdaptiveRefinementNode"]=Ir,Ir.__name__=["verb","eval","AdaptiveRefinementNode"],Ir.prototype={isLeaf:function(){return this.children==null},center:function(){return this.centerPoint!=null?this.centerPoint:this.evalSrf(this.u05,this.v05)},evalCorners:function(){this.u05=(this.corners[0].uv[0]+this.corners[2].uv[0])/2,this.v05=(this.corners[0].uv[1]+this.corners[2].uv[1])/2;for(var r=0;r<4;){var i=r++;if(this.corners[i].point==null){var o=this.corners[i];this.evalSrf(o.uv[0],o.uv[1],o)}}},evalSrf:function(r,i,o){var l=N.rationalSurfaceDerivatives(this.srf,r,i,1),c=l[0][0],d=m.cross(l[0][1],l[1][0]),g=m.isZero(d);return g||(d=m.normalized(d)),o!=null?(o.degen=g,o.point=c,o.normal=d,o):new Qe(c,d,[r,i],-1,g)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){case 0:return this.children[0].getEdgeCorners(0);case 1:return this.children[0].getEdgeCorners(1).concat(this.children[1].getEdgeCorners(1));case 2:return this.children[1].getEdgeCorners(2);case 3:return this.children[1].getEdgeCorners(3).concat(this.children[0].getEdgeCorners(3))}switch(r){case 0:return this.children[0].getEdgeCorners(0).concat(this.children[1].getEdgeCorners(0));case 1:return this.children[1].getEdgeCorners(1);case 2:return this.children[1].getEdgeCorners(2).concat(this.children[0].getEdgeCorners(2));case 3:return this.children[0].getEdgeCorners(3)}return null},getAllCorners:function(r){var i=[this.corners[r]];if(this.neighbors[r]==null)return i;var o=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,c=rt.EPSILON,d=this,g=[function(y){return y.uv[0]>d.corners[0].uv[0]+c&&y.uv[0]<d.corners[2].uv[0]-c},function(y){return y.uv[1]>d.corners[0].uv[1]+c&&y.uv[1]<d.corners[2].uv[1]-c}],_=o.filter(g[l]);return _.reverse(),i.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){case 0:this.midPoints[0]=this.evalSrf(this.u05,this.corners[0].uv[1]);break;case 1:this.midPoints[1]=this.evalSrf(this.corners[1].uv[0],this.v05);break;case 2:this.midPoints[2]=this.evalSrf(this.u05,this.corners[2].uv[1]);break;case 3:this.midPoints[3]=this.evalSrf(this.corners[0].uv[0],this.v05);break}return this.midPoints[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,i=0;i<r;){var o=i++;if(this.corners[o],this.corners[o].degen){var l=this.corners[(o+1)%r],c=this.corners[(o+3)%r];l.degen?this.corners[o].normal=c.normal:this.corners[o].normal=l.normal}}},shouldDivide:function(r,i){if(i<r.minDepth)return!0;if(i>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=m.normSquared(m.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var o=this.center();return m.normSquared(m.sub(o.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(o.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(o.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(o.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Kr),r.normTol==null&&(r.normTol=.085),r.minDepth==null&&(r.minDepth=0),r.maxDepth==null&&(r.maxDepth=10),this._divide(r,0,!0)},_divide:function(r,i,o){if(this.evalCorners(),!!this.shouldDivide(r,i)){if(i++,this.splitVert&&!this.splitHoriz?o=!1:!this.splitVert&&this.splitHoriz&&(o=!0),this.horizontal=o,this.horizontal){var l=[this.corners[0],this.corners[1],this.midpoint(1),this.midpoint(3)],c=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new Ir(this.srf,l),new Ir(this.srf,c)],this.children[0].neighbors=[this.neighbors[0],this.neighbors[1],this.children[1],this.neighbors[3]],this.children[1].neighbors=[this.children[0],this.neighbors[1],this.neighbors[2],this.neighbors[3]]}else{var d=[this.corners[0],this.midpoint(0),this.midpoint(2),this.corners[3]],g=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new Ir(this.srf,d),new Ir(this.srf,g)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var I=y[_];++_,I._divide(r,i,!o)}}},triangulate:function(r){if(r==null&&(r=rr.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var i=0,o=this.children;i<o.length;){var l=o[i];if(++i,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var i=r.points.length,o=[],l=[],c=0,d=0;d<4;){var g=d++,_=this.getAllCorners(g);_.length==2&&(c=g+1);for(var y=0,I=_.length;y<I;){var P=y++;o.push(_[P])}}for(var S=0;S<o.length;){var E=o[S];if(++S,E.id!=-1){l.push(E.id);continue}r.uvs.push(E.uv),r.points.push(E.point),r.normals.push(E.normal),E.id=i,l.push(i),i++}if(o.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(o.length==5){var M=l.length;return r.faces.push([l[c],l[(c+2)%M],l[(c+1)%M]]),r.faces.push([l[(c+4)%M],l[(c+3)%M],l[c]]),r.faces.push([l[c],l[(c+3)%M],l[(c+2)%M]]),r}var T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var B=r.points.length-1,O=0,F=o.length-1;O<o.length;)r.faces.push([B,l[O],l[F]]),F=O++;return r},__class__:Ir};var It=f.exe.Dispatcher=function(){};w["verb.exe.Dispatcher"]=It,It.__name__=["verb","exe","Dispatcher"],It.init=function(){It._init||(It._workerPool=new Zr(It.THREADS),It._init=!0)},It.dispatchMethod=function(r,i,o){It.init();var l=new Bn,c=function(d){l.resolve(d)};return It._workerPool.addWork(dt.getClassName(r),i,o,c),new xe(l)};var Zr=f.exe.WorkerPool=function(r,i){i==null&&(i="verb.js"),r==null&&(r=1),this._callbacks=new xt,this._working=new xt,this._pool=[],this._queue=[];for(var o=0;o<r;){o++;var l;try{l=new Worker(Zr.basePath+i)}catch(c){c instanceof Q&&(c=c.val),l=new Worker(Zr.basePath+i.substring(0,-3)+".min.js")}this._pool.push(l)}};w["verb.exe.WorkerPool"]=Zr,Zr.__name__=["verb","exe","WorkerPool"],Zr.prototype={addWork:function(r,i,o,l){var c=new mn(r,i,o);this._callbacks.set(c.id,l),this._queue.push(c),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var i=this._queue.shift(),o=[i.id],l=[this._pool.shift()];this._working.h[o[0]]=l[0],l[0].onmessage=function(c,d){return function(g){r._working.remove(d[0]),r._pool.push(c[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](g.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),v.log(_)}r.processQueue()}}(l,o),l[0].postMessage(i)}},__class__:Zr};var mn=function(r,i,o){this.className=r,this.methodName=i,this.args=o,this.id=mn.uuid++};w["verb.exe._WorkerPool.Work"]=mn,mn.__name__=["verb","exe","_WorkerPool","Work"],mn.prototype={__class__:mn};var Wn=function(){};w["verb.geom.ICurve"]=Wn,Wn.__name__=["verb","geom","ICurve"],Wn.__interfaces__=[Dn],Wn.prototype={__class__:Wn};var Ot=f.geom.NurbsCurve=function(r){this._data=Je.isValidNurbsCurveData(r)};w["verb.geom.NurbsCurve"]=Ot,Ot.__name__=["verb","geom","NurbsCurve"],Ot.__interfaces__=[Wn],Ot.byKnotsControlPointsWeights=function(r,i,o,l){return new Ot(new Ht(r,i.slice(),N.homogenize1d(o,l)))},Ot.byPoints=function(r,i){return i==null&&(i=3),new Ot(gt.rationalInterpCurve(r,i))},Ot.__super__=ee,Ot.prototype=k(ee.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new Ht(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ot(this._data)},domain:function(){return new Ce(Z.first(this._data.knots),Z.last(this._data.knots))},transform:function(r){return new Ot(yt.rationalCurveTransform(this._data,r))},transformAsync:function(r){return It.dispatchMethod(yt,"rationalCurveTransform",[this._data,r]).then(function(i){return new Ot(i)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return It.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return It.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,i){return i==null&&(i=1),N.rationalCurveDerivatives(this._data,r,i)},derivativesAsync:function(r,i){return i==null&&(i=1),It.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,i])},closestPoint:function(r){return bt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return It.dispatchMethod(bt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return bt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return It.dispatchMethod(bt,"rationalCurveClosestParam",[this._data,r])},length:function(){return bt.rationalCurveArcLength(this._data)},lengthAsync:function(){return It.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return bt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return It.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,i){return bt.rationalCurveParamAtArcLength(this._data,r,i)},paramAtLengthAsync:function(r,i){return It.dispatchMethod(bt,"rationalCurveParamAtArcLength",[this._data,r,i])},divideByEqualArcLength:function(r){return ge.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return It.dispatchMethod(ge,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return ge.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return It.dispatchMethod(ge,"rationalCurveByArcLength",[this._data,r])},split:function(r){return ge.curveSplit(this._data,r).map(function(i){return new Ot(i)})},splitAsync:function(r){return It.dispatchMethod(ge,"curveSplit",[this._data,r]).then(function(i){return i.map(function(o){return new Ot(o)})})},reverse:function(){return new Ot(yt.curveReverse(this._data))},reverseAsync:function(){return It.dispatchMethod(yt,"curveReverse",[this._data]).then(function(r){return new Ot(r)})},tessellate:function(r){return Rt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return It.dispatchMethod(Rt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ot});var Qr=f.geom.Arc=function(r,i,o,l,c,d){Ot.call(this,gt.arc(r,i,o,l,c,d)),this._center=r,this._xaxis=i,this._yaxis=o,this._radius=l,this._minAngle=c,this._maxAngle=d};w["verb.geom.Arc"]=Qr,Qr.__name__=["verb","geom","Arc"],Qr.__super__=Ot,Qr.prototype=k(Ot.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},radius:function(){return this._radius},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Qr});var ys=f.geom.BezierCurve=function(r,i){Ot.call(this,gt.rationalBezierCurve(r,i))};w["verb.geom.BezierCurve"]=ys,ys.__name__=["verb","geom","BezierCurve"],ys.__super__=Ot,ys.prototype=k(Ot.prototype,{__class__:ys});var vs=f.geom.Circle=function(r,i,o,l){Qr.call(this,r,i,o,l,0,Math.PI*2)};w["verb.geom.Circle"]=vs,vs.__name__=["verb","geom","Circle"],vs.__super__=Qr,vs.prototype=k(Qr.prototype,{__class__:vs});var Hn=function(){};w["verb.geom.ISurface"]=Hn,Hn.__name__=["verb","geom","ISurface"],Hn.__interfaces__=[Dn],Hn.prototype={__class__:Hn};var Mt=f.geom.NurbsSurface=function(r){this._data=Je.isValidNurbsSurfaceData(r)};w["verb.geom.NurbsSurface"]=Mt,Mt.__name__=["verb","geom","NurbsSurface"],Mt.__interfaces__=[Hn],Mt.byKnotsControlPointsWeights=function(r,i,o,l,c,d){return new Mt(new ie(r,i,o,l,N.homogenize2d(c,d)))},Mt.byCorners=function(r,i,o,l){return new Mt(gt.fourPointSurface(r,i,o,l))},Mt.byLoftingCurves=function(r,i){return new Mt(gt.loftedSurface(function(o){for(var l,c=[],d=0;d<r.length;){var g=r[d];++d,c.push(g.asNurbs())}return l=c,l}(),i))},Mt.__super__=ee,Mt.prototype=k(ee.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new ie(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Mt(this.asNurbs())},domainU:function(){return new Ce(Z.first(this._data.knotsU),Z.last(this._data.knotsU))},domainV:function(){return new Ce(Z.first(this._data.knotsV),Z.last(this._data.knotsV))},point:function(r,i){return N.rationalSurfacePoint(this._data,r,i)},pointAsync:function(r,i){return It.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,i])},normal:function(r,i){return N.rationalSurfaceNormal(this._data,r,i)},normalAsync:function(r,i){return It.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,i])},derivatives:function(r,i,o){return o==null&&(o=1),N.rationalSurfaceDerivatives(this._data,r,i,o)},derivativesAsync:function(r,i,o){return o==null&&(o=1),It.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,i,o])},closestParam:function(r){return bt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return It.dispatchMethod(bt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return bt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return It.dispatchMethod(bt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,i){return i==null&&(i=!1),ge.surfaceSplit(this._data,r,i).map(function(o){return new Mt(o)})},splitAsync:function(r,i){return i==null&&(i=!1),It.dispatchMethod(ge,"surfaceSplit",[this._data,r,i]).then(function(o){return o.map(function(l){return new Mt(l)})})},reverse:function(r){return r==null&&(r=!1),new Mt(yt.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),It.dispatchMethod(yt,"surfaceReverse",[this._data,r]).then(function(i){return new Mt(i)})},isocurve:function(r,i){return i==null&&(i=!1),new Ot(gt.surfaceIsocurve(this._data,r,i))},isocurveAsync:function(r,i){return i==null&&(i=!1),It.dispatchMethod(gt,"surfaceIsocurve",[this._data,r,i]).then(function(o){return new Ot(o)})},boundaries:function(r){return gt.surfaceBoundaryCurves(this._data).map(function(i){return new Ot(i)})},boundariesAsync:function(r){return It.dispatchMethod(gt,"surfaceBoundaryCurves",[this._data]).then(function(i){return i.map(function(o){return new Ot(o)})})},tessellate:function(r){return Rt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return It.dispatchMethod(Rt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Mt(yt.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return It.dispatchMethod(yt,"rationalSurfaceTransform",[this._data,r]).then(function(i){return new Mt(i)})},__class__:Mt});var bs=f.geom.ConicalSurface=function(r,i,o,l,c){Mt.call(this,gt.conicalSurface(r,i,o,l,c)),this._axis=r,this._xaxis=i,this._base=o,this._height=l,this._radius=c};w["verb.geom.ConicalSurface"]=bs,bs.__name__=["verb","geom","ConicalSurface"],bs.__super__=Mt,bs.prototype=k(Mt.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:bs});var ws=f.geom.CylindricalSurface=function(r,i,o,l,c){Mt.call(this,gt.cylindricalSurface(r,i,o,l,c)),this._axis=r,this._xaxis=i,this._base=o,this._height=l,this._radius=c};w["verb.geom.CylindricalSurface"]=ws,ws.__name__=["verb","geom","CylindricalSurface"],ws.__super__=Mt,ws.prototype=k(Mt.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:ws});var Jr=f.geom.EllipseArc=function(r,i,o,l,c){Ot.call(this,gt.ellipseArc(r,i,o,l,c)),this._center=r,this._xaxis=i,this._yaxis=o,this._minAngle=l,this._maxAngle=c};w["verb.geom.EllipseArc"]=Jr,Jr.__name__=["verb","geom","EllipseArc"],Jr.__super__=Ot,Jr.prototype=k(Ot.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Jr});var xs=f.geom.Ellipse=function(r,i,o){Jr.call(this,r,i,o,0,Math.PI*2)};w["verb.geom.Ellipse"]=xs,xs.__name__=["verb","geom","Ellipse"],xs.__super__=Jr,xs.prototype=k(Jr.prototype,{__class__:xs});var Is=f.geom.ExtrudedSurface=function(r,i){Mt.call(this,gt.extrudedSurface(m.normalized(i),m.norm(i),r.asNurbs())),this._profile=r,this._direction=i};w["verb.geom.ExtrudedSurface"]=Is,Is.__name__=["verb","geom","ExtrudedSurface"],Is.__super__=Mt,Is.prototype=k(Mt.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:Is});var tn=f.geom.Intersect=function(){};w["verb.geom.Intersect"]=tn,tn.__name__=["verb","geom","Intersect"],tn.curves=function(r,i,o){return o==null&&(o=.001),ut.curves(r.asNurbs(),i.asNurbs(),o)},tn.curvesAsync=function(r,i,o){return o==null&&(o=.001),It.dispatchMethod(ut,"curves",[r.asNurbs(),i.asNurbs(),o])},tn.curveAndSurface=function(r,i,o){return o==null&&(o=.001),ut.curveAndSurface(r.asNurbs(),i.asNurbs(),o)},tn.curveAndSurfaceAsync=function(r,i,o){return o==null&&(o=.001),It.dispatchMethod(ut,"curveAndSurface",[r.asNurbs(),i.asNurbs(),o])},tn.surfaces=function(r,i,o){return o==null&&(o=.001),ut.surfaces(r.asNurbs(),i.asNurbs(),o).map(function(l){return new Ot(l)})},tn.surfacesAsync=function(r,i,o){return o==null&&(o=.001),It.dispatchMethod(ut,"surfaces",[r.asNurbs(),i.asNurbs(),o]).then(function(l){return l.map(function(c){return new Ot(c)})})};var Ss=f.geom.Line=function(r,i){Ot.call(this,gt.polyline([r,i])),this._start=r,this._end=i};w["verb.geom.Line"]=Ss,Ss.__name__=["verb","geom","Line"],Ss.__super__=Ot,Ss.prototype=k(Ot.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:Ss});var Ps=f.geom.RevolvedSurface=function(r,i,o,l){Mt.call(this,gt.revolvedSurface(r.asNurbs(),i,o,l)),this._profile=r,this._center=i,this._axis=o,this._angle=l};w["verb.geom.RevolvedSurface"]=Ps,Ps.__name__=["verb","geom","RevolvedSurface"],Ps.__super__=Mt,Ps.prototype=k(Mt.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:Ps});var As=f.geom.SphericalSurface=function(r,i){Mt.call(this,gt.sphericalSurface(r,[0,0,1],[1,0,0],i)),this._center=r,this._radius=i};w["verb.geom.SphericalSurface"]=As,As.__name__=["verb","geom","SphericalSurface"],As.__super__=Mt,As.prototype=k(Mt.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:As});var Es=f.geom.SweptSurface=function(r,i){Mt.call(this,gt.rationalTranslationalSurface(r.asNurbs(),i.asNurbs())),this._profile=r,this._rail=i};w["verb.geom.SweptSurface"]=Es,Es.__name__=["verb","geom","SweptSurface"],Es.__super__=Mt,Es.prototype=k(Mt.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:Es});function sr(r){return r instanceof Array?function(){return L.iter(r)}:typeof r.iterator=="function"?De(r,r.iterator):r.iterator}var ca,Oc=0;function De(r,i){if(i==null)return null;i.__id__==null&&(i.__id__=Oc++);var o;return r.hx__closures__==null?r.hx__closures__={}:o=r.hx__closures__[i.__id__],o==null&&(o=function(){return o.method.apply(o.scope,arguments)},o.scope=r,o.method=i,r.hx__closures__[i.__id__]=o),o}w.Math=Math,String.prototype.__class__=w.String=String,String.__name__=["String"],w.Array=Array,Array.__name__=["Array"],Date.prototype.__class__=w.Date=Date,Date.__name__=["Date"];var Cc=w.Int={__name__:["Int"]},Bc=w.Dynamic={__name__:["Dynamic"]},nl=w.Float=Number;nl.__name__=["Float"];var sl=w.Bool=Boolean;sl.__ename__=["Bool"];var il=w.Class={__name__:["Class"]},al={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var i=[],o=0,l=this.length;o<l;){var c=o++;i[c]=r(this[c])}return i}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var i=[],o=0,l=this.length;o<l;){var c=o++,d=this[c];r(d)&&i.push(d)}return i});var da={},mi=x.ArrayBuffer||me;mi.prototype.slice==null&&(mi.prototype.slice=me.sliceImpl),x.DataView;var pa=x.Uint8Array||pr._new;(function(r,i){if(r.setImmediate)return;var o=1,l={},c=!1,d=r.document,g;function _(R){return l[o]=y.apply(i,R),o++}function y(R){var j=[].slice.call(arguments,1);return function(){typeof R=="function"?R.apply(i,j):new Function(""+R)()}}function I(R){if(c)setTimeout(y(I,R),0);else{var j=l[R];if(j){c=!0;try{j()}finally{P(R),c=!1}}}}function P(R){delete l[R]}function S(){g=function(){var R=_(arguments);return process.nextTick(y(I,R)),R}}function E(){if(r.postMessage&&!r.importScripts){var R=!0,j=r.onmessage;return r.onmessage=function(){R=!1},r.postMessage("","*"),r.onmessage=j,R}}function M(){var R="setImmediate$"+Math.random()+"$",j=function(D){D.source===r&&typeof D.data=="string"&&D.data.indexOf(R)===0&&I(+D.data.slice(R.length))};r.addEventListener?r.addEventListener("message",j,!1):r.attachEvent("onmessage",j),g=function(){var D=_(arguments);return r.postMessage(R+D,"*"),D}}function T(){var R=new MessageChannel;R.port1.onmessage=function(j){var D=j.data;I(D)},g=function(){var j=_(arguments);return R.port2.postMessage(j),j}}function B(){var R=d.documentElement;g=function(){var j=_(arguments),D=d.createElement("script");return D.onreadystatechange=function(){I(j),D.onreadystatechange=null,R.removeChild(D),D=null},R.appendChild(D),j}}function O(){g=function(){var R=_(arguments);return setTimeout(y(I,R),0),R}}var F=Object.getPrototypeOf&&Object.getPrototypeOf(r);F=F&&F.setTimeout?F:r,{}.toString.call(r.process)==="[object process]"?S():E()?M():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?B():O(),F.setImmediate=g,F.clearImmediate=P})(new Function("return this")()),Kt.USE_CACHE=!1,Kt.USE_ENUM_INDEX=!1,Kt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Xt.DEFAULT_RESOLVER=dt,Xt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Bt.count=0,pe.i64tmp=function(r){var i,o=new Wt(0,0);return i=o,i}(),Lt.__toStr={}.toString,pr.BYTES_PER_ELEMENT=1,At.queue=new V,Vt.memo=new xt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",bt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],bt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],It.THREADS=1,It._init=!1,Zr.basePath="",mn.uuid=0,di.main()}(typeof console<"u"?console:{log:function(){}},e,typeof u<"u"?u:typeof s<"u"?s:typeof self<"u"?self:this),e})})(Oh);var _d=Oh.exports;const $n=gd(_d);class Ia{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,a){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-a,this.c3=2*t-2*e+s+a}initCatmullRom(t,e,s,a,h){this.init(e,s,h*(s-t),h*(a-e))}initNonuniformCatmullRom(t,e,s,a,h,u,p){let v=(e-t)/h-(s-t)/(h+u)+(s-e)/u,f=(s-e)/u-(a-e)/(u+p)+(a-s)/p;v*=u,f*=u,this.init(e,s,v,f)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}let Ch=class extends oi{constructor(t=[],e=!1,s="centripetal",a=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new q,this._px=new Ia,this._py=new Ia,this._pz=new Ia,this._points=t.map(h=>new G(h)),this._closed=e,this._curveType=s,this._tension=a}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new G}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new G}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new G){const s=e,a=this._points,h=a.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(a[0]);const u=(h-(this._closed?0:1))*t;let p=Math.floor(u),v=u-p;this._closed?p+=p>0?0:(Math.floor(Math.abs(p)/h)+1)*h:v===0&&p===h-1&&(p=h-2,v=1);let f,x;this._closed||p>0?f=a[(p-1)%h]:(this._tmp.subVectors(a[0],a[1]).add(a[0]),f=new G(this._tmp.x,this._tmp.y,this._tmp.z));const w=a[p%h],A=a[(p+1)%h];if(this._closed||p+2<h?x=a[(p+2)%h]:(this._tmp.subVectors(a[h-1],a[h-2]).add(a[h-1]),x=new G(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const k=this._curveType==="chordal"?.5:.25;let L=Math.pow(f.distanceToSquared(w),k),C=Math.pow(w.distanceToSquared(A),k),V=Math.pow(A.distanceToSquared(x),k);C<1e-4&&(C=1),L<1e-4&&(L=C),V<1e-4&&(V=C),this._px.initNonuniformCatmullRom(f.x,w.x,A.x,x.x,L,C,V),this._py.initNonuniformCatmullRom(f.y,w.y,A.y,x.y,L,C,V),this._pz.initNonuniformCatmullRom(f.z,w.z,A.z,x.z,L,C,V)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,w.x,A.x,x.x,this._tension),this._py.initCatmullRom(f.y,w.y,A.y,x.y,this._tension),this._pz.initCatmullRom(f.z,w.z,A.z,x.z,this._tension));return s.set(this._px.calc(v),this._py.calc(v),this._pz.calc(v)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new G(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const s=new G;return s.copy(e),s.applyMatrix4(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Nt;const t=new Nt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}};class Mn{constructor(t,e,s,a){this._degree=t,this._knots=[...e],this._controlPoints=s.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=a?[...a]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return $s(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Ah(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,a){return new Mn(t,e,s,a)}static byPoints(t,e,s="Uniform"){let a;switch(s){case"Chord":a=Sh(e,t);break;case"SqrtChord":a=Ph(e,t);break;case"Uniform":default:a=Ih(e,t.length);break}const h=t.map(p=>({x:p[0],y:p[1],z:p[2]})),u=new Array(h.length).fill(1);return new Mn(e,a,h,u)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:a}=this.getParameterRange();for(let h=0;h<=t;h++){const u=s+(a-s)*(h/t);e.push(this.point(u))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),a=this.point(e),h=this.point(s),u=a[0]-h[0],p=a[1]-h[1],v=a[2]-h[2];return Math.sqrt(u*u+p*p+v*v)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new Ch(t,!0,"centripetal"),s=Math.max(50,t.length*2);return e.getPoints(s)}static createClosedCurve(t,e,s="Chord"){const a=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return Mn.byPoints(a,e,s)}}class Gr extends oi{constructor(t,e,s,a,h){super();const u=arguments.length;if(u<2||u>5)throw Ze.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let p,v=3,f=!1;if(u>=3&&(Array.isArray(s)?(p=s,u>=4&&(v=a||3),u>=5&&(f=h)):s!==void 0&&(v=s||3,u>=4&&(f=a))),s===void 0&&u>=4&&(v=a||3,u>=5&&(f=h)),this._degree=v,this._closed=f,this._controlPoints.length<this._degree+1)throw Ze.ILLEGAL_PARAMETERS;const x=this.toVerbPoints(this._controlPoints);this._nurbsCurve=$n.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,x,p)}else{if(this._fitPoints=t,this._knotParameterization=e,u>=3&&(this._degree=s||3),u>=4&&(this._closed=a),this._fitPoints.length<this._degree+1)throw Ze.ILLEGAL_PARAMETERS;const p=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=$n.geom.NurbsCurve.byPoints(p,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=Mn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=$n.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=$n.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=Mn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=$n.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=$n.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,s,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0}))}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(e=>({x:e.x,y:e.y,z:e.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],a=this._nurbsCurve.point(s);return new G(a[0],a[1],a[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],a=this._nurbsCurve.point(s);return new G(a[0],a[1],a[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,a=this._fitPoints[s];return{x:a.x,y:a.y,z:a.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],a=e.knots(),h=this._nurbsCurve.degree(),u=a[h],p=a[a.length-h-1],v=(p-u)/(t-1);for(let f=0;f<t;f++){const x=f===t-1?p:u+f*v,w=e.point(x);s.push(new G(w[0],w[1],w[2]))}return s}getCurvePoints(t,e){const s=[],a=t.knots(),h=a[3],u=(a[a.length-4]-h)/(e-1);for(let p=0;p<e;p++){const v=h+p*u;s.push(t.point(v))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Nt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,a)=>{e[a]=[s.x,s.y,s.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((s,a)=>{e[a]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,a)=>{e[a]={x:s[0],y:s[1],z:s[2]}}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Gr(t,e,s,!0)}}var oo=(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))(oo||{});class is{static get instance(){return this._instance||(this._instance=new is),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,a=[],h=!0,u,p){var f;const v=[];if(e!=null){const x=this.createKey(e.name,s);let w;if(this.has(x))w=this.get(x);else{const A=(f=t.basePoint)==null?void 0:f.clone();t.basePoint=void 0;const k=e.newIterator();let L=!0;for(const C of k)if(C.color.isByBlock&&s?(Ml.copy(C.color),C.color.setRGBValue(s),this.addEntity(C,v,t),C.color.copy(Ml)):this.addEntity(C,v,t),L&&v.length>0){const V=v[0];t.basePoint=V.basePoint,L=!1}w=t.group(v),w&&h&&ue.name&&!ue.name.startsWith("*U")&&this.set(x,w),t.basePoint=A}return w&&u&&(w.applyMatrix(u),p&&(p.x!=0||p.y!=0||p.z!=1)&&(u.setFromExtrusionDirection(p),w.applyMatrix(u))),w&&a&&a.length>0&&(w.bakeTransformToChildren(),a.forEach(A=>w.addChild(A))),w}else return t.group(v)}addEntity(t,e,s){const a=t.worldDraw(s);a&&(this.attachEntityInfo(a,t),e.push(a))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const Ml=new ce;var lo=(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))(lo||{});const fd=["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"],Bh=n=>fd[n],Ti="Continuous",ne="Standard",xi="ByLayer",Rh="ByBlock";var Fh=(n=>(n[n.kInches=0]="kInches",n[n.kMillimeters=1]="kMillimeters",n[n.kPixels=2]="kPixels",n))(Fh||{}),zh=(n=>(n[n.k0degrees=0]="k0degrees",n[n.k90degrees=1]="k90degrees",n[n.k180degrees=2]="k180degrees",n[n.k270degrees=3]="k270degrees",n))(zh||{}),Vh=(n=>(n[n.kDisplay=0]="kDisplay",n[n.kExtents=1]="kExtents",n[n.kLimits=2]="kLimits",n[n.kView=3]="kView",n[n.kWindow=4]="kWindow",n[n.kLayout=5]="kLayout",n))(Vh||{}),sn=(n=>(n[n.kDraft=0]="kDraft",n[n.kPreview=1]="kPreview",n[n.kNormal=2]="kNormal",n[n.kPresentation=3]="kPresentation",n[n.kMaximum=4]="kMaximum",n[n.kCustom=5]="kCustom",n))(sn||{}),Zn=(n=>(n[n.kAsDisplayed=0]="kAsDisplayed",n[n.kWireframe=1]="kWireframe",n[n.kHidden=2]="kHidden",n[n.kRendered=3]="kRendered",n[n.kVisualStyle=4]="kVisualStyle",n[n.kRenderPreset=5]="kRenderPreset",n))(Zn||{}),jh=(n=>(n[n.kScaleToFit=0]="kScaleToFit",n[n.k1_128in_1ft=1]="k1_128in_1ft",n[n.k1_64in_1ft=2]="k1_64in_1ft",n[n.k1_32in_1ft=3]="k1_32in_1ft",n[n.k1_16in_1ft=4]="k1_16in_1ft",n[n.k3_32in_1ft=5]="k3_32in_1ft",n[n.k1_8in_1ft=6]="k1_8in_1ft",n[n.k3_16in_1ft=7]="k3_16in_1ft",n[n.k1_4in_1ft=8]="k1_4in_1ft",n[n.k3_8in_1ft=9]="k3_8in_1ft",n[n.k1_2in_1ft=10]="k1_2in_1ft",n[n.k3_4in_1ft=11]="k3_4in_1ft",n[n.k1in_1ft=12]="k1in_1ft",n[n.k3in_1ft=13]="k3in_1ft",n[n.k6in_1ft=14]="k6in_1ft",n[n.k1ft_1ft=15]="k1ft_1ft",n[n.k1_1=16]="k1_1",n[n.k1_2=17]="k1_2",n[n.k1_4=18]="k1_4",n[n.k1_5=19]="k1_5",n[n.k1_8=20]="k1_8",n[n.k1_10=21]="k1_10",n[n.k1_16=22]="k1_16",n[n.k1_20=23]="k1_20",n[n.k1_30=24]="k1_30",n[n.k1_40=25]="k1_40",n[n.k1_50=26]="k1_50",n[n.k1_100=27]="k1_100",n[n.k2_1=28]="k2_1",n[n.k4_1=29]="k4_1",n[n.k8_1=30]="k8_1",n[n.k10_1=31]="k10_1",n[n.k100_1=32]="k100_1",n[n.k1000_1=33]="k1000_1",n[n.k1and1_2in_1ft=34]="k1and1_2in_1ft",n))(jh||{});const yd={0:0,1:1/1536,2:1/768,3:1/384,4:1/192,5:1/128,6:1/96,7:1/64,8:1/48,9:1/32,10:1/24,11:1/16,12:1/12,13:1/4,14:1/2,15:1,16:1,17:1/2,18:1/4,19:1/5,20:1/8,21:1/10,22:1/16,23:1/20,24:1/30,25:1/40,26:1/50,27:1/100,28:2,29:4,30:8,31:10,32:100,33:1e3,34:1/8};class Dh extends Hr{constructor(t=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new Et,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new Et,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._plotWindowArea=new ve,this._modelType=t,this._plotCentered=!1,this._plotHidden=!1,this._plotPaperUnits=1,this._plotPlotStyles=!0,this._plotRotation=0,this._plotType=5,this._plotViewportBorders=!1,this._printLineweights=!0,this._scaleLineweights=!1,this._drawViewportsFirst=!1,this._showPlotStyles=!0,this._shadePlotType=0,this._shadePlotResLevel=2,this._shadePlotCustomDpi=300,this._shadePlotId=void 0,this._stdScaleType=0,this._useStandardScale=!0}get plotSettingsName(){return this._plotSettingsName}set plotSettingsName(t){this._plotSettingsName=t}getPlotSettingsName(){return this._plotSettingsName}setPlotSettingsName(t){this._plotSettingsName=t}get plotCfgName(){return this._plotCfgName}set plotCfgName(t){this._plotCfgName=t}getPlotCfgName(){return this._plotCfgName}get canonicalMediaName(){return this._canonicalMediaName}set canonicalMediaName(t){this._canonicalMediaName=t}getCanonicalMediaName(){return this._canonicalMediaName}get currentStyleSheet(){return this._currentStyleSheet}set currentStyleSheet(t){this._currentStyleSheet=t}getCurrentStyleSheet(){return this._currentStyleSheet}get plotOrigin(){return this._plotOrigin}set plotOrigin(t){this._plotOrigin=t}getPlotOrigin(){return this._plotOrigin}get customPrintScale(){return this._customPrintScale}set customPrintScale(t){this._customPrintScale=t}getCustomPrintScale(){return this._customPrintScale}get plotPaperSize(){return this._plotPaperSize}set plotPaperSize(t){this._plotPaperSize=t}getPlotPaperSize(){return this._plotPaperSize}get plotPaperMargins(){return this._plotPaperMargins}set plotPaperMargins(t){this._plotPaperMargins=t}getPlotPaperMargins(){return this._plotPaperMargins}get plotViewName(){return this._plotViewName}set plotViewName(t){this._plotViewName=t}getPlotViewName(){return this._plotViewName}get plotWindowArea(){return this._plotWindowArea}set plotWindowArea(t){this._plotWindowArea=t}getPlotWindowArea(){return this._plotWindowArea}get modelType(){return this._modelType}set modelType(t){this._modelType=t}getModelType(){return this._modelType}setModelType(t){this._modelType=t}get drawViewportsFirst(){return this._drawViewportsFirst}set drawViewportsFirst(t){this._drawViewportsFirst=t}setDrawViewportsFirst(t){this._drawViewportsFirst=t}get plotCentered(){return this._plotCentered}set plotCentered(t){this._plotCentered=t}setPlotCentered(t){this._plotCentered=t}get plotHidden(){return this._plotHidden}set plotHidden(t){this._plotHidden=t}setPlotHidden(t){this._plotHidden=t}get plotPaperUnits(){return this._plotPaperUnits}set plotPaperUnits(t){this._plotPaperUnits=t}get plotPlotStyles(){return this._plotPlotStyles}set plotPlotStyles(t){this._plotPlotStyles=t}setPlotPlotStyles(t){this._plotPlotStyles=t}get plotRotation(){return this._plotRotation}set plotRotation(t){this._plotRotation=t}get plotType(){return this._plotType}set plotType(t){this._plotType=t}get plotViewportBorders(){return this._plotViewportBorders}set plotViewportBorders(t){this._plotViewportBorders=t}setPlotViewportBorders(t){this._plotViewportBorders=t}get printLineweights(){return this._printLineweights}set printLineweights(t){this._printLineweights=t}setPrintLineweights(t){this._printLineweights=t}get scaleLineweights(){return this._scaleLineweights}set scaleLineweights(t){this._scaleLineweights=t}setScaleLineweights(t){this._scaleLineweights=t}get showPlotStyles(){return this._showPlotStyles}set showPlotStyles(t){this._showPlotStyles=t}setShowPlotStyles(t){this._showPlotStyles=t}get shadePlot(){return this._shadePlotType}set shadePlot(t){this._shadePlotType=t}setShadePlot(t){this._shadePlotType=t}get shadePlotResLevel(){return this._shadePlotResLevel}set shadePlotResLevel(t){this._shadePlotResLevel=t}setShadePlotResLevel(t){this._shadePlotResLevel=t}get shadePlotCustomDPI(){return this._shadePlotCustomDpi}set shadePlotCustomDPI(t){this._shadePlotCustomDpi=t}setShadePlotCustomDPI(t){this._shadePlotCustomDpi=t}get shadePlotId(){return this._shadePlotId}set shadePlotId(t){this._shadePlotId=t}get plotWireframe(){return this._shadePlotType===1}get plotAsRaster(){return this._shadePlotType===3||this._shadePlotType===4||this._shadePlotType===5}get stdScaleType(){return this._stdScaleType}set stdScaleType(t){this._stdScaleType=t}get stdScale(){return yd[this._stdScaleType]??1}get useStandardScale(){return this._useStandardScale}set useStandardScale(t){this._useStandardScale=t}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPlotSettings"),t.writeString(1,this.plotSettingsName),t.writeString(2,this.plotCfgName),t.writeString(4,this.canonicalMediaName),t.writeString(6,this.plotViewName),t.writeDouble(40,this.plotPaperMargins.left),t.writeDouble(41,this.plotPaperMargins.bottom),t.writeDouble(42,this.plotPaperMargins.right),t.writeDouble(43,this.plotPaperMargins.top),t.writeDouble(44,this.plotPaperSize.x),t.writeDouble(45,this.plotPaperSize.y),t.writeDouble(46,this.plotOrigin.x),t.writeDouble(47,this.plotOrigin.y),t.writeDouble(48,this.plotWindowArea.min.x),t.writeDouble(49,this.plotWindowArea.min.y),t.writeDouble(140,this.plotWindowArea.max.x),t.writeDouble(141,this.plotWindowArea.max.y),t.writeDouble(142,this.customPrintScale.numerator),t.writeDouble(143,this.customPrintScale.denominator);let e=0;return this.plotViewportBorders&&(e|=1),this.showPlotStyles&&(e|=2),this.plotCentered&&(e|=4),this.plotHidden&&(e|=8),this.useStandardScale&&(e|=16),this.plotPlotStyles&&(e|=32),this.scaleLineweights&&(e|=64),this.printLineweights&&(e|=128),this.drawViewportsFirst&&(e|=512),this.modelType&&(e|=1024),t.writeInt16(70,e),t.writeInt16(72,this.plotPaperUnits),t.writeInt16(73,this.plotRotation),t.writeInt16(74,this.plotType),t.writeString(7,this.currentStyleSheet),t.writeInt16(75,this.stdScaleType),t.writeInt16(76,this.shadePlot),t.writeInt16(77,this.shadePlotResLevel),t.writeInt16(78,this.shadePlotCustomDPI),t.writeDouble(147,this.stdScale),t.writeObjectId(333,this.shadePlotId),this}}class hi extends Dh{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new ve,this._extents=new Nt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayout"),t.writeString(1,this.layoutName),t.writeInt16(70,this.tabSelected?1:0),t.writeInt16(71,this.tabOrder),t.writeObjectId(330,this.blockTableRecordId),t.writePoint2d(10,this.limits.min),t.writePoint2d(11,this.limits.max),t.writePoint3d(14,this.extents.min),t.writePoint3d(15,this.extents.max),this}}class ui{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}class Ks extends Hr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,e.ownerId=this.objectId,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e),this.database.events.dictObjetSet.dispatch({database:this.database,object:e,key:t})}remove(t){const e=this.getAt(t);return e?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t}),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,a)=>{s===e&&(this._recordsByName.delete(a),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:a}))}),!0):!1}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new ui(this._recordsByName)}entries(){return this._recordsByName.entries()}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(281,1);for(const[e,s]of this._recordsByName)t.writeString(3,e),t.writeObjectId(350,s.objectId);return this}}class Uh extends Ks{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class cn extends Hr{constructor(t,e){t=t||{},ns(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTableRecord"),this}}const on=class on extends cn{static isModelSapceName(t){return t.toLowerCase()==on.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(on.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new G,this._layoutId="",this._entities=new Map}get isModelSapce(){return on.isModelSapceName(this.name)}get isPaperSapce(){return on.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(t){this._origin.copy(t)}get layoutId(){return this._layoutId}set layoutId(t){this._layoutId=t}appendEntity(t){if(Array.isArray(t))for(let e=0;e<t.length;++e){const s=t[e];s.database=this.database,s.ownerId=this.objectId,s.resolveEffectiveProperties(),this._entities.set(s.objectId,s)}else t.database=this.database,t.ownerId=this.objectId,t.resolveEffectiveProperties(),this._entities.set(t.objectId,t);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}removeEntity(t){const e=Array.isArray(t)?t:[t],s=[];return e.forEach(a=>{const h=this._entities.get(a);h&&s.push(h),this._entities.delete(a)}),s.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:s}),s.length>0}newIterator(){return new ui(this._entities)}getIdAt(t){return this._entities.get(t)}dxfOutBlockRecord(t){return t.writeStart("BLOCK_RECORD"),this.dxfOut(t),this}dxfOutBlockBegin(t){return t.writeStart("BLOCK"),t.writeHandle(5,`BLOCK:${this.objectId}`),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbBlockBegin"),t.writeString(8,"0"),t.writeString(2,this.name),t.writeInt16(70,0),t.writePoint3d(10,this.origin),t.writeString(3,this.name),this}dxfOutBlockEnd(t){return t.writeStart("ENDBLK"),t.writeHandle(5,`ENDBLK:${this.objectId}`),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbBlockEnd"),this}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeObjectId(340,this.layoutId),this}};on.MODEL_SPACE_NAME="*Model_Space",on.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let ue=on;class Gh{constructor(){this.events={layoutCreated:new he,layoutRemoved:new he,layoutRenamed:new he,layoutSwitched:new he}}countLayouts(t){return this.getWorkingDatabase(t).objects.layout.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).objects.layout.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),a=s.objects.layout.getIdAt(t);return this.setCurrentLayoutInternal(a,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),a=s.objects.layout.getBtrIdAt(t);return this.setCurrentLayoutInternal(a,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),a=s.objects.layout.getAt(t);return this.setCurrentLayoutInternal(a,s)}renameLayout(t,e,s){const h=this.getWorkingDatabase(s).objects.layout.getAt(t);return h?(h.layoutName=e,this.events.layoutRenamed.dispatch({layout:h,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).objects.layout.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).objects.layout,a=s.getAt(t);let h=!1;return a&&(h=s.remove(t),h&&this.events.layoutRemoved.dispatch({layout:a})),h}createLayout(t,e){const s=this.getWorkingDatabase(e),a=new hi;a.layoutName=t,a.tabOrder=s.objects.layout.maxTabOrder;const h=new ue;return h.name=`*Paper_Space${a.tabOrder}`,s.tables.blockTable.add(h),s.objects.layout.setAt(t,a),this.events.layoutCreated.dispatch({layout:a}),{layout:a,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.objects.layout.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Xa().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}Ql(()=>new Gh);class Wh extends Hr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImageDef"),t.writeString(1,this.sourceFileName),t.writeInt16(280,1),t.writeInt16(281,0),this}}var Hh=(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))(Hh||{});class ho extends Hr{constructor(){super(...arguments),this._data=null}get data(){return this._data}set data(t){this._data=t}clear(){var t;(t=this._data)==null||t.clear()}clone(){var e;const t=new ho;return t._data=((e=this._data)==null?void 0:e.clone())??null,t}getDuplicateRecordCloning(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXrecord"),t.writeInt16(280,1),t.writeResultBuffer(this.data),this}}class Yh{constructor(t){this.db=t}createDefaultLayer(){const t=new ce;return t.colorIndex=7,this.db.tables.layerTable.add(new ci({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new ln({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ln({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ln({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new la({name:ne,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new On({name:ne,dimtxsty:ne}))}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 ei;e.patternName="SOLID";const s=new oa;s.add(new ts({x:0,y:0},{x:-1,y:.125})),s.add(new ts({x:-1,y:.125},{x:-1,y:-.125})),s.add(new ts({x:-1,y:-.125},{x:0,y:0})),e.add(s);const a=new ue;a.name="_CAXARROW",a.appendEntity(e),this.db.tables.blockTable.add(a)}}}var Xh=(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))(Xh||{}),zt=(n=>(n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(zt||{});function vd(n){let t=0;for(const e of n)t|=1<<e-1;return t}function bd(n){const t=[];for(const e of Object.values(zt)){if(typeof e!="number")continue;const s=1<<e-1;n&s&&t.push(e)}return t}function wd(n,t){return n^1<<t-1}function xd(n,t){return(n&1<<t-1)!==0}function Id(n,t){return n|1<<t-1}function Sd(n,t){return n&~(1<<t-1)}var uo=(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))(uo||{});function Pd(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function Ad(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}var co=(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))(co||{}),hn=(n=>(n[n.ByBlock=-2]="ByBlock",n[n.ByDIPs=-4]="ByDIPs",n[n.ByLayer=-1]="ByLayer",n[n.ByLineWeightDefault=-3]="ByLineWeightDefault",n[n.LineWeight000=0]="LineWeight000",n[n.LineWeight005=5]="LineWeight005",n[n.LineWeight009=9]="LineWeight009",n[n.LineWeight013=13]="LineWeight013",n[n.LineWeight015=15]="LineWeight015",n[n.LineWeight018=18]="LineWeight018",n[n.LineWeight020=20]="LineWeight020",n[n.LineWeight025=25]="LineWeight025",n[n.LineWeight030=30]="LineWeight030",n[n.LineWeight035=35]="LineWeight035",n[n.LineWeight040=40]="LineWeight040",n[n.LineWeight050=50]="LineWeight050",n[n.LineWeight053=53]="LineWeight053",n[n.LineWeight060=60]="LineWeight060",n[n.LineWeight070=70]="LineWeight070",n[n.LineWeight080=80]="LineWeight080",n[n.LineWeight090=90]="LineWeight090",n[n.LineWeight100=100]="LineWeight100",n[n.LineWeight106=106]="LineWeight106",n[n.LineWeight120=120]="LineWeight120",n[n.LineWeight140=140]="LineWeight140",n[n.LineWeight158=158]="LineWeight158",n[n.LineWeight200=200]="LineWeight200",n[n.LineWeight211=211]="LineWeight211",n))(hn||{}),Ur=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(Ur||{}),Pe=(n=>(n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n))(Pe||{}),po=(n=>(n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",n))(po||{}),mo=(n=>(n[n.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",n[n.TOP=1]="TOP",n[n.BOTTOM=2]="BOTTOM",n[n.FRONT=3]="FRONT",n[n.BACK=4]="BACK",n[n.LEFT=5]="LEFT",n[n.RIGHT=6]="RIGHT",n))(mo||{}),go=(n=>(n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",n))(go||{});let qh=class $h{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new ve;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new ve;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new $h;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}};const xo=class xo extends Hr{constructor(){super(...arguments),this._lineType=xi,this._visibility=!0,this._transparency=new na}get type(){return this.constructor.typeName}get dxfEntityTypeName(){switch(this.type){case"BlockReference":return"INSERT";case"Polyline":return"LWPOLYLINE";case"2dPolyline":case"3dPolyline":return"POLYLINE";case"2dVertex":case"3dVertex":return"VERTEX";case"Face":return"3DFACE";case"RasterImage":return"IMAGE";case"Table":return"ACAD_TABLE";case"AlignedDimension":case"RadialDimension":case"DiametricDimension":case"OrdinateDimension":case"3PointAngularDimension":case"ArcDimension":return"DIMENSION";default:return this.type.toUpperCase()}}get layer(){return this._layer==null&&(this._layer=this.database.clayer??"0"),this._layer}set layer(t){this._layer=t}get color(){return this._color==null&&(this._color=new ce,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._color}set color(t){this._color==null&&(this._color=new ce),this._color.copy(t)}get resolvedColor(){let t=this.color;if(t.isByLayer){const e=this.getLayerColor();e&&e.RGB!=null&&(t=e)}else t.isByBlock;return t}get rgbColor(){const e=this.resolvedColor.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||xi}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??hn.ByLayer),this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t.clone()}dxfOutFields(t){t.writeSubclassMarker("AcDbEntity"),t.writeString(8,this.layer),t.writeString(6,this.lineType),t.writeDouble(48,this.linetypeScale),t.writeInt16(60,this.visibility?0:1),t.writeCmColor(this.color),t.writeInt16(370,this.lineWeight),t.writeTransparency(this.transparency);const e=this.database.tables.blockTable.getIdAt(this.ownerId);return e!=null&&e.isPaperSapce&&t.writeInt16(67,1),this}resolveEffectiveProperties(){this._layer==null&&(this._layer=this.database.clayer??"0"),this._color==null&&(this._color=new ce,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??hn.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,a,h){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){const s=t.subEntityTraits;s.color=this.resolvedColor,s.rgbColor=this.rgbColor,s.lineType=this.lineStyle,s.lineTypeScale=this.linetypeScale,s.lineWeight=this.lineWeight,s.transparency=this.transparency,s.layer=this.layer,"thickness"in this&&(s.thickness=this.thickness);const a=this.subWorldDraw(t,e);return this.attachEntityInfo(a),a}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:t=>{this.color.copy(t)}}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:t=>{this.layer=t}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:()=>this.lineType,set:t=>{this.lineType=t}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:()=>this.linetypeScale,set:t=>{this.linetypeScale=t}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:()=>this.lineWeight,set:t=>{this.lineWeight=t}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:()=>this.transparency,set:t=>{this.transparency=t}}}]}}get lineStyle(){var a;const{type:t,name:e}=this.getLineType(),s=(a=this.database)==null?void 0:a.tables.linetypeTable.getAt(e);return s?{type:t,...s.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==xi){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Rh?{type:"ByBlock",name:Ti}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:Ti}}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}attachEntityInfo(t){t&&(t.objectId=this.objectId,this.attrs.has("ownerId")&&(t.ownerId=this.ownerId),t.layerName=this.layer,t.visible=this.visibility)}};xo.typeName="Entity";let Le=xo;const Io=class Io extends Le{};Io.typeName="Curve";let Oe=Io;var Qn=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.FitCurvePoly=1]="FitCurvePoly",n[n.QuadSplinePoly=2]="QuadSplinePoly",n[n.CubicSplinePoly=3]="CubicSplinePoly",n))(Qn||{});const So=class So extends Oe{constructor(t,e,s=0,a=!1,h=0,u=0,p=null){super(),this._polyType=t,this._elevation=s;const v=p&&(p==null?void 0:p.length)===e.length,f=e.map((x,w)=>({x:x.x,y:x.y,bulge:v?p[w]:void 0}));this._geo=new un(f,a)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){return this._geo.getPointAt(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const s=this._geo.getPointAt(e);t.push(new G(s.x,s.y,0))}return t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const u=this._geo.getPointAt(h);a.push(new G(u.x,u.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}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(38,this.elevation),this}};So.typeName="2dPolyline";let Js=So;var Kh=(n=>(n[n.Vertex=0]="Vertex",n[n.CurveFitVertex=1]="CurveFitVertex",n[n.SplineFitVertex=8]="SplineFitVertex",n[n.SplineCtlVertex=9]="SplineCtlVertex",n))(Kh||{});const Po=class Po extends Le{constructor(){super(),this._position=new G,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 Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,s,a){a.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.writePoint3d(10,this.position),t.writeDouble(40,this.startWidth),t.writeDouble(41,this.endWidth),t.writeDouble(42,this.bulge),t.writeInt16(70,this.vertexType),this}};Po.typeName="2dVertex";let ja=Po;var Zs=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.QuadSplinePoly=1]="QuadSplinePoly",n[n.CubicSplinePoly=2]="CubicSplinePoly",n))(Zs||{});const Ao=class Ao extends Oe{constructor(t,e,s=!1){super(),this._polyType=t,this._geo=new un(e,s)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){return this._geo.getPointAt(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const s=this._geo.getPointAt(e);t.push(new G(s.x,s.y,0))}return t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:for(let h=0;h<this._geo.numberOfVertices;++h){const u=this._geo.getPointAt(h);a.push(new G(u.x,u.y,0))}break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,0))),t.lines(e)}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}};Ao.typeName="3dPolyline";let ti=Ao;var Zh=(n=>(n[n.SimpleVertex=0]="SimpleVertex",n[n.ControlVertex=1]="ControlVertex",n[n.FitVertex=2]="FitVertex",n))(Zh||{});const Eo=class Eo extends Le{constructor(){super(),this._position=new G,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 Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,s,a){a.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}};Eo.typeName="3dVertex";let Da=Eo;const ko=class ko extends Oe{constructor(t,e,s,a,h=q.Z_AXIS){super(),this._geo=new ao(t,e,s,a,h,q.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"arcLength",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"totalAngle",type:"float",editable:!1,accessor:{get:()=>St.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,a){const h=this.startPoint,u=this.endPoint;switch(t){case zt.EndPoint:a.push(h),a.push(u);break;case zt.MidPoint:a.push(this.midPoint);break;case zt.Nearest:{const p=this._geo.nearestPoint(e);a.push(p)}break;case zt.Perpendicular:break;case zt.Tangent:{const p=this._geo.tangentPoints(e);a.push(...p);break}}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbArc"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeAngle(50,this.startAngle),t.writeAngle(51,this.endAngle),t.writeVector3d(210,this.normal),this}};ko.typeName="Arc";let Ni=ko;var Qh=(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))(Qh||{}),Jh=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Jh||{});const Mo=class Mo extends Le{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new G,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new Nt}subGetOsnapPoints(t,e,s,a){zt.Insertion===t&&a.push(this._position)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt(ne)||t.getAt(ne)),e.textStyle}subWorldDraw(t,e){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Ur.BOTTOM_TO_TOP,attachmentPoint:Pe.BottomLeft};return t.mtext(s,this.getTextStyle(),e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbText"),t.writePoint3d(10,this.position),t.writeDouble(39,this.thickness),t.writeDouble(40,this.height),t.writeString(1,this.textString),t.writeAngle(50,this.rotation),t.writeDouble(41,this.widthFactor),t.writeAngle(51,this.oblique),t.writeString(7,this.styleName),t.writeInt16(72,this.horizontalMode),t.writeInt16(73,this.verticalMode),t.writePoint3d(11,this.position),this}};Mo.typeName="Text";let rs=Mo;var de=(n=>(n[n.Invisible=1]="Invisible",n[n.Const=2]="Const",n[n.Verifiable=4]="Verifiable",n[n.Preset=8]="Preset",n))(de||{}),br=(n=>(n[n.MultiLine=2]="MultiLine",n[n.ConstMultiLine=4]="ConstMultiLine",n))(br||{});const To=class To extends rs{constructor(){super(),this._flags=0,this._prompt="",this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&1)!==0}set isInvisible(t){t?this._flags|=1:this._flags&=-2}get prompt(){return this._prompt}set prompt(t){this._prompt=t}get isConst(){return(this._flags&2)!==0}set isConst(t){t?this._flags|=2:this._flags&=-3}get isVerifiable(){return(this._flags&4)!==0}set isVerifiable(t){t?this._flags|=4:this._flags&=-5}get isPreset(){return(this._flags&8)!==0}set isPreset(t){t?this._flags|=8:this._flags&=-9}get isMTextAttribute(){return(this._mtextFlag&2)!==0}set isMTextAttribute(t){t?this._mtextFlag|=2:this._mtextFlag&=-3}get isConstMTextAttribute(){return(this._mtextFlag&4)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=4:this._mtextFlag&=-5}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}subWorldDraw(t){}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttributeDefinition"),t.writeString(3,this.prompt),t.writeString(2,this.tag),t.writeInt16(70,this.isInvisible?1:0),t.writeInt16(73,this.fieldLength),t.writeInt16(74,this.isReallyLocked?1:0),this}};To.typeName="AttDef";let Li=To;const No=class No extends rs{constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&de.Invisible)!==0}set isInvisible(t){t?this._flags|=de.Invisible:this._flags&=~de.Invisible}get isConst(){return(this._flags&de.Const)!==0}set isConst(t){t?this._flags|=de.Const:this._flags&=~de.Const}get isVerifiable(){return(this._flags&de.Verifiable)!==0}set isVerifiable(t){t?this._flags|=de.Verifiable:this._flags&=~de.Verifiable}get isPreset(){return(this._flags&de.Preset)!==0}set isPreset(t){t?this._flags|=de.Preset:this._flags&=~de.Preset}get isMTextAttribute(){return(this._mtextFlag&br.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=br.MultiLine:this._mtextFlag&=~br.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&br.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=br.ConstMultiLine:this._mtextFlag&=~br.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}};No.typeName="Attrib";let Oi=No;const Lo=class Lo extends Le{constructor(t){super(),this._blockName=t,this._position=new G,this._rotation=0,this._normal=new q(0,0,1),this._scaleFactors=new G(1,1,1),this._attribs=new Map}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockName(){return this._blockName}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId}attributeIterator(){return new ui(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??G.ORIGIN,s=new Ke().makeTranslation(-e.x,-e.y,-e.z),a=new Ke().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),h=new Cn().setFromAxisAngle(q.Z_AXIS,this._rotation),u=new Ke().makeRotationFromQuaternion(h),p=new Ke().makeTranslation(this._position.x,this._position.y,this._position.z);return new Ke().multiplyMatrices(p,u).multiply(a).multiply(s)}subGetOsnapPoints(t,e,s,a,h){zt.Insertion===t?a.push(this._position):h&&this.subEntityGetOsnapPoints(t,e,s,a,h)}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(s=>{e.properties.push({name:s.tag,type:"string",editable:!s.isConst,skipTranslation:!0,accessor:{get:()=>s.textString,set:a=>{s.textString=a}}})})}return t}get geometricExtents(){const t=new Nt,e=this.blockTableRecord;if(e!=null){const a=e.newIterator();for(const h of a)t.union(h.geometricExtents)}const s=this.blockTransform;return t.applyMatrix4(s),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const s=this.blockTransform,a=[];return this._attribs.forEach(u=>{if(!u.isInvisible){const p=u.worldDraw(t);p&&a.push(p)}}),is.instance.draw(t,e,this.rgbColor,a,!0,s,this._normal)}else return t.group([])}subEntityGetOsnapPoints(t,e,s,a,h){var p;if(h===this.objectId)return;const u=(p=this.database)==null?void 0:p.tables.blockTable;if(u!=null){const v=u.getEntityById(h);if(v){const f=[];v.subGetOsnapPoints(t,e,s,f,h);const x=this.blockTransform;f.forEach(w=>{const A=w.clone().applyMatrix4(x);a.push(A)})}}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockReference"),t.writePoint3d(10,this.position),t.writeString(2,this.blockName),t.writeDouble(41,this.scaleFactors.x),t.writeDouble(42,this.scaleFactors.y),t.writeDouble(43,this.scaleFactors.z),t.writeAngle(50,this.rotation),t.writeVector3d(210,this.normal),this}};Lo.typeName="BlockReference";let Ln=Lo;const Oo=class Oo extends Oe{constructor(t,e,s=q.Z_AXIS){super(),this._geo=new ao(t,e,0,Qt,s,q.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,s,a){switch(t){case zt.Center:case zt.Centroid:a.push(this._geo.center);break;case zt.Quadrant:a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case zt.Nearest:{const h=this._geo.nearestPoint(e);a.push(h)}break;case zt.Tangent:{const h=this._geo.tangentPoints(e);a.push(...h);break}}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"diameter",type:"float",editable:!1,accessor:{get:()=>this._geo.radius*2}},{name:"perimeter",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeVector3d(210,this.normal),this}};Oo.typeName="Circle";let Ci=Oo;const Co=class Co extends Oe{constructor(t,e,s,a,h,u,p){super(),this._geo=new aa(t,e,s,a,h,u,p)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:this.closed||(a.push(this._geo.startPoint),a.push(this._geo.endPoint));break;case zt.MidPoint:this.closed||a.push(this._geo.midPoint);break;case zt.Quadrant:this.closed&&(a.push(this._geo.getPointAtAngle(0)),a.push(this._geo.getPointAtAngle(Math.PI/2)),a.push(this._geo.getPointAtAngle(Math.PI)),a.push(this._geo.getPointAtAngle(Math.PI/2*3)));break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){return t.ellipticalArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbEllipse"),t.writePoint3d(10,this.center),t.writePoint3d(11,{x:this.majorAxisRadius,y:0,z:0}),t.writeVector3d(210,this.normal),t.writeDouble(40,this.minorAxisRadius/this.majorAxisRadius),t.writeDouble(41,this.startAngle),t.writeDouble(42,this.endAngle),this}};Co.typeName="Ellipse";let Bi=Co;const Bo=class Bo extends Le{constructor(){super(),this._vertices=[new G,new G,new G],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 G),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 Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=this._vertices.length,s=new Float32Array(e*3),a=new Uint16Array(e*2);for(let h=0;h<e;h++)s[h*3]=this._vertices[h].x,s[h*3+1]=this._vertices[h].y,s[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(a[h*2]=h,a[h*2+1]=(h+1)%4);return t.lineSegments(s,3,a)}dxfOutFields(t){super.dxfOutFields(t);const e=this.getVertexAt(0),s=this.getVertexAt(1),a=this.getVertexAt(2),h=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,s),t.writePoint3d(12,a),t.writePoint3d(13,h);let u=0;for(let p=0;p<4;++p)this.isEdgeVisibleAt(p)||(u|=1<<p);return t.writeInt16(70,u),this}};Bo.typeName="Face";let Ri=Bo;var Qs=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(Qs||{}),tu=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(tu||{});const Ro=class Ro extends Le{constructor(){super(),this._elevation=0,this._geo=new ia,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(t){this._isSolidFill=t}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:Qs[0],value:0},{label:Qs[1],value:1},{label:Qs[2],value:2}],accessor:{get:()=>this.patternType,set:t=>{this.patternType=t}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:t=>{this.patternName=t}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:t=>{this.patternAngle=t}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:t=>{this.patternScale=t}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){const e=t.subEntityTraits;return e.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,definitionLines:this.definitionLines},t.area(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=this._geo.loops;return t.writeSubclassMarker("AcDbHatch"),t.writePoint3d(10,{x:0,y:0,z:this.elevation}),t.writeVector3d(210,{x:0,y:0,z:1}),t.writeString(2,this.patternName||(this.isSolidFill?"SOLID":"USER")),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,0),t.writeInt16(91,e.length),e.forEach((s,a)=>{const h=a===0;if(s instanceof un){const u=s.vertices,p=u.some(f=>(f.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,p?1:0),t.writeInt16(73,s.closed?1:0),t.writeInt16(93,u.length);for(const f of u)t.writePoint2d(10,f),p&&t.writeDouble(42,f.bulge??0);t.writeInt16(97,0);return}if(s instanceof oa){const u=h?1:0;t.writeInt16(92,u),t.writeInt16(93,s.numberOfEdges);for(const p of s.curves){if(p instanceof ts){t.writeInt16(72,1),t.writePoint2d(10,p.startPoint),t.writePoint2d(11,p.endPoint);continue}if(p instanceof Nn){t.writeInt16(72,2),t.writePoint2d(10,p.center),t.writeDouble(40,p.radius),t.writeAngle(50,p.startAngle),t.writeAngle(51,p.endAngle),t.writeInt16(73,p.clockwise?0:1);continue}if(p instanceof li){t.writeInt16(72,3),t.writePoint2d(10,p.center);const v=new Et(p.majorAxisRadius*Math.cos(p.rotation),p.majorAxisRadius*Math.sin(p.rotation));t.writePoint2d(11,v);const f=p.majorAxisRadius===0?0:p.minorAxisRadius/p.majorAxisRadius;t.writeDouble(40,f),t.writeAngle(50,p.startAngle),t.writeAngle(51,p.endAngle),t.writeInt16(73,p.clockwise?0:1);continue}if(p instanceof Gr){const v=p.knots,f=p.controlPoints,x=p.weights,w=p.fitPoints,A=x.some(k=>k!==1);t.writeInt16(72,4),t.writeInt16(94,p.degree),t.writeInt16(73,A?1:0),t.writeInt16(74,p.closed?1:0),t.writeInt16(95,v.length),t.writeInt16(96,f.length),v.forEach(k=>t.writeDouble(40,k)),f.forEach((k,L)=>{t.writePoint2d(10,k),A&&t.writeDouble(42,x[L]??1)}),t.writeInt16(97,(w==null?void 0:w.length)??0),w==null||w.forEach(k=>t.writePoint2d(11,k))}}t.writeInt16(97,0)}}),t.writeInt16(75,this.hatchStyle),t.writeInt16(76,this.patternType),t.writeAngle(52,this.patternAngle),t.writeDouble(41,this.patternScale),t.writeInt16(77,0),t.writeInt16(78,this.definitionLines.length),this.definitionLines.forEach(s=>{t.writeAngle(53,s.angle),t.writePoint2d(43,s.base),t.writePoint2d(45,s.offset),t.writeInt16(79,s.dashLengths.length),s.dashLengths.forEach(a=>t.writeDouble(49,a))}),t.writeInt16(98,0),this}};Ro.typeName="Hatch";let ei=Ro;var eu=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(eu||{});const Fo=class Fo extends Oe{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get vertices(){return this._vertices.map(t=>t.clone())}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new G().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Nt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}subWorldDraw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e)}else return t.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Gr(this._vertices,"Uniform"),this._updated=!1)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLeader"),t.writeString(3,this.dimensionStyle),t.writeInt16(71,this.hasArrowHead?1:0),t.writeInt16(72,this.annoType),t.writeInt16(73,this.hasHookLine?1:0),t.writeInt16(74,this.isSplined?1:0),t.writeInt16(76,this.numVertices);for(const e of this.vertices)t.writePoint3d(10,e);return this}};Fo.typeName="Leader";let Fi=Fo;const zo=class zo extends Oe{constructor(t,e){super(),this._geo=new es(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,a){const h=this.startPoint,u=this.endPoint;switch(t){case zt.EndPoint:a.push(h),a.push(u);break;case zt.MidPoint:a.push(this.midPoint);break;case zt.Nearest:{const p=this._geo.project(e);a.push(p)}break;case zt.Perpendicular:{const p=this._geo.perpPoint(e);a.push(p)}break;case zt.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,s=this.endPoint,a=[new G(e.x,e.y,0),new G(s.x,s.y,0)];return t.lines(a)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),t.writePoint3d(10,this.startPoint),t.writePoint3d(11,this.endPoint),this}};zo.typeName="Line";let ri=zo;const Vo=class Vo extends Le{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new G,this._attachmentPoint=Pe.TopLeft,this._direction=new q(1,0,0),this._drawingDirection=Ur.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Nt}subGetOsnapPoints(t,e,s,a){zt.Insertion===t&&a.push(this._location)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:Pe[1],value:1},{label:Pe[2],value:2},{label:Pe[3],value:3},{label:Pe[4],value:4},{label:Pe[5],value:5},{label:Pe[6],value:6},{label:Pe[7],value:7},{label:Pe[8],value:8},{label:Pe[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Ur[1],value:1},{label:Ur[2],value:2},{label:Ur[3],value:3},{label:Ur[4],value:4},{label:Ur[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt(ne)||t.getAt(ne)),e.textStyle}subWorldDraw(t,e){const s={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor};return t.mtext(s,this.getTextStyle(),e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMText"),t.writePoint3d(10,this.location),t.writeDouble(40,this.height),t.writeDouble(41,this.width),t.writeString(1,this.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}};Vo.typeName="MText";let ni=Vo;const jo=class jo extends Oe{constructor(t,e,s,a,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(a!==void 0)+ +(h!==void 0);if(u<2||u>5)throw Ze.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Gr(t,e,s,a):this._geo=new Gr(t,e,s,a,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(this._geo.startPoint),a.push(this._geo.endPoint);break}}subWorldDraw(t){const e=this._geo.getPoints(100);return t.lines(e)}dxfOutFields(t){var s;const e=this._geo;super.dxfOutFields(t),t.writeSubclassMarker("AcDbSpline"),t.writeInt16(70,this.closed?1:0),t.writeInt16(71,e.degree),t.writeInt16(72,e.knots.length),t.writeInt16(73,e.controlPoints.length),t.writeInt16(74,((s=e.fitPoints)==null?void 0:s.length)??0);for(const a of e.knots)t.writeDouble(40,a);for(const a of e.weights)t.writeDouble(41,a);for(const a of e.controlPoints)t.writePoint3d(10,a);for(const a of e.fitPoints??[])t.writePoint3d(11,a);return this}};jo.typeName="Spline";let si=jo;const Ed=new q,Do=class Do extends Ln{constructor(t,e,s){super(t),this._attachmentPoint=Pe.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Nt}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){let e=0,s=0;const a=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let u=0;for(let A=0;A<=this.numRows;A++){e-=A>0?this.rowHeight(A-1):0,s=0;for(let k=0;k<=this.numColumns;k++)s+=k>0?this.columnWidth(k-1):0,h[u++]=s,h[u++]=e,h[u++]=0}const p=[],v=new Array(this.numRows*this.numColumns).fill(!1);s=0,u=0;let f=0;for(let A=0;A<this.numColumns;A++){s+=A>0?this.columnWidth(A-1):0,e=0;for(let k=0;k<this.numRows;k++){e+=k>0?this.rowHeight(k-1):0;const L=this.cell(k*this.numColumns+A);if(f=k*this.numColumns+A,L&&!v[f]){const C=L.borderWidth??1,V=L.borderHeight??1;this.fillVisited(v,f,this.numColumns,C,V),a[u++]=A+k*(this.numColumns+1),a[u++]=A+k*(this.numColumns+1)+C;const z=h[a[u-1]*3]-s,st=A+(k+V)*(this.numColumns+1)+C;A+C==this.numColumns&&(a[u++]=A+k*(this.numColumns+1)+C,a[u++]=st);const _t=-h[st*3+1]-e;if(k+V==this.numRows&&(a[u++]=A+(k+V)*(this.numColumns+1)+V,a[u++]=A+(k+V)*(this.numColumns+1)),a[u++]=A+(k+V)*(this.numColumns+1),a[u++]=A+k*(this.numColumns+1),L.text){const it=L.attachmentPoint||this.attachmentPoint||Pe.MiddleCenter,H=this.getTableTextOffset(it,z,_t),dt={text:L.text,height:L.textHeight,width:z,position:Ed.set(s,-e,0).clone().add(H),rotation:this.rotation,attachmentPoint:it},at=this.getTextStyle(L);p.push(t.mtext(dt,at))}}}}p.push(t.lineSegments(h,3,a));const x=t.group(p),w=new Cn;return w.setFromAxisAngle(q.Z_AXIS,this.rotation),Tl.compose(this.position,w,this.scaleFactors),x.applyMatrix(Tl),x}fillVisited(t,e,s,a,h){if(h==1&&a==1)t[e]=!0;else for(let u=0;u<a;++u)for(let p=0;p<h;++p)t[e+u+p*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let s;return t.textStyle&&(s=e.getAt(t.textStyle)),s||(s=e.getAt(ne)||e.getAt(ne)),s.textStyle}getTableTextOffset(t,e,s){const a=new q;switch(t){case 1:break;case 2:a.setX(e/2);break;case 3:a.setX(e);break;case 4:a.setY(-s/2);break;case 5:a.set(e/2,-s/2,0);break;case 6:a.set(e,-s/2,0);break;case 7:a.setY(-s);break;case 8:a.set(e/2,-s,0);break;case 9:a.set(e,-s,0);break}return a}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable"),t.writeInt16(71,this.attachmentPoint),t.writeInt32(91,this.numRows),t.writeInt32(92,this.numColumns);for(let e=0;e<this.numRows;++e)t.writeDouble(141,this.rowHeight(e));for(let e=0;e<this.numColumns;++e)t.writeDouble(142,this.columnWidth(e));return this}};Do.typeName="Table";let zi=Do;const Tl=new Ke,Uo=class Uo extends Oe{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new G,new G,new G,new G]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(...this._vertices);break}}subWorldDraw(t){const e=new un(this._vertices,!0),s=new ia;s.add(e);const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(s)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTrace"),t.writeDouble(38,this.elevation),t.writeDouble(39,this.thickness),t.writePoint3d(10,this.getPointAt(0)),t.writePoint3d(11,this.getPointAt(1)),t.writePoint3d(12,this.getPointAt(2)),t.writePoint3d(13,this.getPointAt(3)),this}};Uo.typeName="Trace";let Vi=Uo;const Go=class Go extends Oe{constructor(){super(),this._elevation=0,this._geo=new un}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,a=-1,h=-1){const u=a<0?void 0:a,p=h<0?void 0:h,v={x:e.x,y:e.y,bulge:s,startWidth:u,endWidth:p};this._geo.addVertexAt(t,v)}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 G(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}subGetOsnapPoints(t,e,s,a){const h=new Array;for(let u=0;u<this.numberOfVertices;++u)h.push(this.getPoint3dAt(u));switch(t){case zt.EndPoint:a.push(...h);break}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(a=>e.push(new G().set(a.x,a.y,this.elevation))),t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyline"),t.writeInt32(90,this.numberOfVertices),t.writeInt16(70,this.closed?1:0),t.writeDouble(38,this.elevation);for(let e=0;e<this.numberOfVertices;++e)t.writePoint2d(10,this.getPoint2dAt(e));return this}};Go.typeName="Polyline";let ji=Go;const Wo=class Wo extends Le{constructor(){super(),this._geo=new G}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Nt().expandByPoint(this._geo)}subGetOsnapPoints(t,e,s,a){zt.Node===t&&a.push(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}subWorldDraw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbPoint"),t.writePoint3d(10,this.position),this}};Wo.typeName="Point";let Di=Wo;var ru=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(ru||{}),nu=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(nu||{});const Ho=class Ho extends Le{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new G,this._scale=new te(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.objects.imageDefinition.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Nt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}subWorldDraw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,a=new ve;a.setFromPoints(this._clipBoundary);const h=new Et;h.setX(this._position.x-a.min.x*e),h.setY(this._position.y-a.min.y*s),this._clipBoundary.forEach(u=>{const p=u.x*e+h.x,v=u.y*s+h.y;t.push(new G(p,v,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){Nl.copy(t[1]);for(let e=1;e<4;e++)yi.copy(t[e]),yi.rotateAround(Nl,this._rotation),t[e].setX(yi.x),t[e].setY(yi.y)}t.push(t[0])}return t}dxfOutFields(t){if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImage"),t.writePoint3d(10,this.position),t.writePoint3d(11,{x:this.width*this.scale.x,y:0,z:0}),t.writePoint3d(12,{x:0,y:this.height*this.scale.y,z:0}),t.writeObjectId(340,this.imageDefId),t.writeInt16(70,this.isImageShown?1:0),t.writeInt16(280,this.clipBoundaryType),t.writeInt16(281,this.isClipped?1:0),t.writeInt16(282,this.isImageTransparent?1:0),t.writeInt16(283,this.brightness),t.writeInt16(360,this.contrast),t.writeInt16(361,this.fade),this.isClipped){t.writeInt16(91,this.clipBoundary.length);for(const e of this.clipBoundary)t.writePoint2d(14,e)}return this}};Ho.typeName="RasterImage";let ii=Ho;const Nl=new Et,yi=new Et,Yo=class Yo extends Oe{constructor(){super(),this._basePoint=new G,this._unitDir=new q}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subGetOsnapPoints(t,e,s,a){switch(t){case zt.EndPoint:a.push(this.basePoint);break}}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRay"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}};Yo.typeName="Ray";let Ui=Yo;const Xo=class Xo extends Le{constructor(){super(),this._centerPoint=new G,this._height=0,this._width=0,this._viewCenter=new G,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new Nt}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 qh;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),s.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new G(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new G(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new G(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),s}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewport"),t.writePoint3d(10,this.centerPoint),t.writeDouble(40,this.height),t.writeDouble(41,this.width),t.writePoint3d(12,this.viewCenter),t.writeDouble(45,this.viewHeight),t.writeInt32(69,this.number),this}};Xo.typeName="Viewport";let Gi=Xo;const qo=class qo extends ii{subWorldDraw(t){const e=this.boundaryPath(),s=new ia;return s.add(new un(e)),t.area(s)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbWipeout"),this}};qo.typeName="Wipeout";let Wi=qo;const $o=class $o extends Oe{constructor(){super(),this._basePoint=new G,this._unitDir=new q}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subWorldDraw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXline"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}};$o.typeName="Xline";let Hi=$o;var su=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(su||{});const Ko=class Ko extends Le{constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new G,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new G,this._textRotation=0,this._normal=new q(0,0,1)}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(t)}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new On),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}subWorldDraw(t){if(this.dimBlockId){const s=this.database.tables.blockTable.getAt(this.dimBlockId);if(s){const a=this.computeDimBlockTransform();return is.instance.draw(t,s,this.rgbColor,[],!1,a,this._normal)}}return t.group([])}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,s){const a=new G().subVectors(e,t).normalize();return new G(e).addScaledVector(a,s)}findPointOnLine2(t,e,s){const a=t.x+s*Math.cos(e),h=t.y+s*Math.sin(e);return{x:a,y:h}}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():co.Closed}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??G.ORIGIN,s=new Ke().makeTranslation(-e.x,-e.y,-e.z),a=new Ke().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new Ke().multiplyMatrices(a,s)}dxfOutFields(t){super.dxfOutFields(t);const e=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return t.writeSubclassMarker("AcDbDimension"),t.writeString(3,this.dimensionStyleName??this.dimensionStyle.name),t.writePoint3d(10,this.dimBlockPosition),t.writeString(1,this.dimensionText??""),t.writeAngle(53,this.textRotation),t.writePoint3d(11,this.textPosition),t.writeInt16(70,0),t.writeVector3d(210,this.normal),t.writeObjectId(340,e==null?void 0:e.objectId),this}};Ko.typeName="Dimension";let Wr=Ko;const Zo=class Zo extends Wr{constructor(t,e,s,a,h=null,u=null){super(),this._centerPoint=new G().copy(t),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(s),this._arcPoint=new G().copy(a),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Nt}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}};Zo.typeName="3PointAngularDimension";let Yi=Zo;const Qo=class Qo extends Wr{constructor(t,e,s,a=null,h=null){super(),this._dimLinePoint=new G().copy(s),this._xLine1Point=new G().copy(t),this._xLine2Point=new G().copy(e),this._oblique=0,this._rotation=0,this.calculateRotation(),a?this.dimensionText=a:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new Nt}get isAppendArrow(){return!1}createDimBlock(t){const e=new ue;e.name=t;const s=this.createLines();s.forEach(p=>e.appendEntity(new ri(p.startPoint,p.endPoint))),this.createArrows(s[0]).forEach(p=>e.appendEntity(p));const h=s[0].midPoint,u=this.createMText(h,this._rotation);return u&&e.appendEntity(u),e}createMText(t,e){const s=a=>({x:Math.cos(a),y:Math.sin(a),z:0});if(this.dimensionText){const a=new ni;return a.attachmentPoint=Pe.MiddleLeft,a.layer="0",a.color=new ce(lt.ByBlock),a.location=t,a.contents=this.dimensionText??"",a.height=10,a.direction=s(e),a.styleName=this.dimensionStyle.dimtxsty,a}}createArrows(t){const e=[];return e.push(this.createArrow(t.startPoint,this.rotation+Math.PI,10)),e.push(this.createArrow(t.endPoint,this.rotation,10)),e}createArrow(t,e,s){const a="_CAXARROW",h=new Ln(a);return h.position=t,h.rotation=e,h.scaleFactors={x:s,y:s,z:s},h}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),a=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),u=new es(a,h);return t.push(u),e.endPoint=a,this.adjustExtensionLine(e),t.push(e),s.endPoint=h,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new es(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,a=t.endPoint,h=new q().subVectors(a,s).normalize(),p=new q().subVectors(e,s).dot(h),v=new q().copy(h).multiplyScalar(p);return new q().addVectors(s,v)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,s=e.x-t.x,a=e.y-t.y;this._rotation=Math.atan2(a,s)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAlignedDimension"),t.writePoint3d(13,this.xLine1Point),t.writePoint3d(14,this.xLine2Point),t.writePoint3d(15,this.dimLinePoint),t.writeAngle(50,this.rotation),t.writeAngle(52,this.oblique),this}};Qo.typeName="AlignedDimension";let Xi=Qo;const Jo=class Jo extends Wr{constructor(t,e,s,a,h=null,u=null){super(),this._arcPoint=new G().copy(a),this._xLine1Point=new G().copy(e),this._xLine2Point=new G().copy(s),this._centerPoint=new G().copy(t),this.dimensionText=h,this.dimensionStyleName=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Nt}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}};Jo.typeName="ArcDimension";let Ua=Jo;const tl=class tl extends Wr{constructor(t,e,s=0,a=null,h=null){super(),this._chordPoint=new G().copy(t),this._farChordPoint=new G().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=a,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Nt}drawLines(t,e){const s=[],a=e.length;return a==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):a==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{s.push(this.drawLine(t,h))}),s}drawLine(t,e,s){if(s){const a=[e.startPoint,e.endPoint];return t.lines(a)}else return e.worldDraw(t)}sortLines(t){const e=(s,a)=>s.x!==a.x?s.x-a.x:s.y!==a.y?s.y-a.y:s.z-a.z;t.sort((s,a)=>{const h=e(s.startPoint,a.startPoint);return h!==0?h:e(s.endPoint,a.endPoint)})}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbDiametricDimension"),t.writePoint3d(15,this.chordPoint),t.writePoint3d(16,this.farChordPoint),t.writeDouble(40,this.leaderLength),t.writeAngle(52,this.extArcStartAngle),t.writeAngle(53,this.extArcEndAngle),this}};tl.typeName="DiametricDimension";let qi=tl;const el=class el extends Wr{constructor(t,e,s=null,a=null){super(),this._definingPoint=new G().copy(t),this._leaderEndPoint=new G().copy(e),this.dimensionText=s,this.dimensionStyleName=a}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new Nt}get arrowLineCount(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbOrdinateDimension"),t.writePoint3d(13,this.definingPoint),t.writePoint3d(14,this.leaderEndPoint),this}};el.typeName="OrdinateDimension";let $i=el;const rl=class rl extends Wr{constructor(t,e,s,a=null,h=null){super(),this._center=new G().copy(t),this._chordPoint=new G().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=a,this.dimensionStyleName=h}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new Nt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRadialDimension"),t.writePoint3d(15,this.center),t.writePoint3d(13,this.chordPoint),t.writeDouble(40,this.leaderLength),t.writeAngle(52,this.extArcStartAngle),t.writeAngle(53,this.extArcEndAngle),this}};rl.typeName="RadialDimension";let Ki=rl;class dn extends Hr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}add(t){t.database=this.database,t.ownerId=this.objectId;const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),s=this._recordsByName.get(e);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this._recordsById.has(t)}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new ui(this._recordsByName)}normalizeName(t){return t}}class iu extends dn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(ue.MODEL_SPACE_NAME);return t||(t=new ue,t.name=ue.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){for(const e of this.database.tables.blockTable.newIterator()){const s=e.getIdAt(t);if(s)return s}}removeEntity(t){let e=!1;for(const s of this.database.tables.blockTable.newIterator())if(s.removeEntity(t)){e=!0;break}return e}normalizeName(t){let e=t;if(ue.isModelSapceName(t))e=ue.MODEL_SPACE_NAME;else if(ue.isPaperSapceName(t)){const s=ue.PAPER_SPACE_NAME_PREFIX,a=t.substring(s.length);e=s+a}return e}}class au extends dn{constructor(t){super(t)}}var ou=(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))(ou||{}),lu=(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))(lu||{}),hu=(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))(hu||{}),uu=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(uu||{}),cu=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(cu||{});const ta=class ta extends cn{constructor(t,e){t=t||{},ns(t,ta.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}dxfOutFields(t){super.dxfOutFields(t);const e=this.database.tables.textStyleTable.getAt(this.dimtxsty),s=this.database.tables.blockTable.getAt(this.dimldrblk),a=this.database.tables.blockTable.getAt(this.dimblk),h=this.database.tables.blockTable.getAt(this.dimblk1),u=this.database.tables.blockTable.getAt(this.dimblk2);return t.writeSubclassMarker("AcDbDimStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeString(3,this.dimpost),t.writeString(4,this.dimapost),t.writeDouble(40,this.dimscale),t.writeDouble(41,this.dimasz),t.writeDouble(42,this.dimexo),t.writeDouble(43,this.dimdli),t.writeDouble(44,this.dimexe),t.writeDouble(140,this.dimtxt),t.writeDouble(147,this.dimgap),t.writeInt16(170,this.dimalt),t.writeInt16(171,this.dimtol),t.writeInt16(172,this.dimlim),t.writeInt16(173,this.dimtih),t.writeInt16(174,this.dimtoh),t.writeObjectId(340,e==null?void 0:e.objectId),t.writeObjectId(341,s==null?void 0:s.objectId),t.writeObjectId(342,a==null?void 0:a.objectId),t.writeObjectId(343,h==null?void 0:h.objectId),t.writeObjectId(344,u==null?void 0:u.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}};ta.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:ne,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let On=ta;class ci extends cn{constructor(t,e){t=t||{},ns(t,{color:new ce,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new na,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeCmColor(this.color),t.writeString(6,this.linetype),t.writeInt16(290,this.isPlottable?1:0),t.writeInt16(370,this.lineWeight),t.writeTransparency(this.transparency),this.description&&t.writeString(4,this.description),this}}class du extends dn{constructor(t){super(t);const e=new ce,s=new ci({name:"0",standardFlags:0,linetype:Ti,lineWeight:hn.ByLineWeightDefault,isOff:!1,color:e,isPlottable:!0});this.add(s)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class pu extends dn{constructor(t){super(t)}}class ln extends cn{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLinetypeTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.linetype.standardFlag),t.writeString(3,this.comments),t.writeInt16(72,65),t.writeInt16(73,this.numDashes),t.writeDouble(40,this.patternLength);for(const e of this.linetype.pattern??[])t.writeDouble(49,e.elementLength),t.writeInt16(74,e.elementTypeFlag);return this}}class mu extends dn{constructor(t){super(t)}get fonts(){const t=new Set,e=a=>{if(a){const h=a.lastIndexOf(".");if(h>=0){const u=a.substring(0,h).toLowerCase();t.add(u)}else t.add(a.toLowerCase())}},s=this.newIterator();for(const a of s)e(a.fileName),e(a.bigFontFileName);return Array.from(t)}}class la extends cn{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTextStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.textStyle.standardFlag),t.writeDouble(40,this.textSize),t.writeDouble(41,this.xScale),t.writeAngle(50,this.obliquingAngle),t.writeInt16(71,this.isVertical?4:this.textStyle.textGenerationFlag),t.writeDouble(42,this.priorSize),t.writeString(3,this.fileName),t.writeString(4,this.bigFontFileName),this}}class gu extends dn{constructor(t){super(t)}}const kd={center:new Et,viewDirectionFromTarget:new G(0,0,1),viewTarget:new G(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:po.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new G(0,0,0),ucsXAxis:new G(1,0,0),ucsYAxis:new G(0,1,0),orthographicType:mo.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:go.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class _o extends cn{constructor(){super(),this._circleSides=100,this._center=new Et,this._lowerLeftCorner=new Et(0,0),this._upperRightCorner=new Et(1,1),this._snapBase=new Et(0,0),this._snapAngle=0,this._snapSpacing=new Et(0,0),this._standardFlag=0,this._gridSpacing=new Et,this._gridMajor=10,this._gsView=kd}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewportTableRecord"),t.writeString(2,this.name),t.writeDouble(45,this.gsView.viewHeight),t.writePoint2d(10,this.lowerLeftCorner),t.writePoint2d(11,this.upperRightCorner),t.writePoint2d(12,this.center),t.writePoint2d(13,this.snapBase),t.writePoint2d(14,this.snapIncrements),t.writePoint2d(15,this.gridIncrements),t.writeInt16(70,this.standardFlag),t.writeInt16(71,this.circleSides),t.writeDouble(42,this.gsView.lensLength),t.writePoint3d(16,this.gsView.viewDirectionFromTarget),t.writePoint3d(17,this.gsView.viewTarget),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.gsView.viewTwistAngle),t.writeInt16(61,this.gridMajor),t.writeInt16(281,this.backgroundObjectId?1:0),t.writeObjectId(332,this.backgroundObjectId),this}}class _u extends dn{constructor(t){super(t)}}class fu extends cn{constructor(t){super(),this.name=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRegAppTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),this}}const jt={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",CECOLOR:"CECOLOR",CELTSCALE:"CELTSCALE",CELWEIGHT:"CELWEIGHT",CLAYER:"CLAYER",COLORTHEME:"COLORTHEME",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",INSUNITS:"INSUNITS",LTSCALE:"LTSCALE",LWDISPLAY:"LWDISPLAY",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",OSMODE:"OSMODE",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",TEXTSTYLE:"TEXTSTYLE",WHITEBKCOLOR:"WHITEBKCOLOR"},Md=Object.freeze(Object.values(jt)),ea=class ea{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new he},this.registerVar({name:jt.CECOLOR,type:"color",isDbVar:!0,defaultValue:new ce(lt.ByLayer)}),this.registerVar({name:jt.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:jt.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:hn.ByLayer}),this.registerVar({name:jt.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:jt.COLORTHEME,type:"number",isDbVar:!1,defaultValue:"0"}),this.registerVar({name:jt.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:jt.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new ce(lt.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:jt.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:jt.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:jt.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:ne}),this.registerVar({name:jt.WHITEBKCOLOR,type:"boolean",isDbVar:!1,defaultValue:!1})}static instance(){return this._instance||(this._instance=new ea),this._instance}registerVar(t){const e=this.normalizeName(t.name);this.registry.set(e,{...t,name:e}),t.isDbVar||this.cache.set(e,t.defaultValue)}registerMany(t){t.forEach(e=>this.registerVar(e))}getVar(t,e){t=this.normalizeName(t);const s=this.getDescriptor(t);if(s){if(s.isDbVar)return e[t.toLowerCase()];if(this.cache.has(t))return this.cache.get(t)}}setVar(t,e,s){t=this.normalizeName(t);const a=this.getDescriptor(t);if(a){const h=this.getVar(t,s);if(a.type!=="string"&&(typeof e=="string"||e instanceof String)){if(a.type==="number"){const u=Number(e);if(Number.isNaN(u))throw new Error("Invalid number input!");e=u}else if(a.type==="boolean")e=this.parseBoolean(e);else if(a.type==="color"){const u=ce.fromString(e);if(u==null)throw new Error("Invalid color value!");e=u}}a.isDbVar?s[t.toLowerCase()]=e:(this.cache.set(t,e),this.hasValueChanged(h,e)&&this.events.sysVarChanged.dispatch({database:s,name:t,newVal:e,oldVal:h}))}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(this.normalizeName(t))}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),s=new Set(["true","t","1","yes","y"]),a=new Set(["false","f","0","no","n"]);return s.has(e)?!0:(a.has(e),!1)}hasValueChanged(t,e){return t instanceof ce&&e instanceof ce?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};ea._instance=null;let Zi=ea;const ra=class ra extends Hr{constructor(){super(),this.events={dictObjetSet:new he,dictObjectErased:new he,entityAppended:new he,entityModified:new he,entityErased:new he,layerAppended:new he,layerModified:new he,layerErased:new he,openProgress:new he},this._version=new er("AC1014"),this._angBase=0,this._angDir=0,this._aunits=oo.DecimalDegrees,this._celtscale=1,this._cecolor=new ce,this._celweight=hn.ByLayer,this._clayer="0",this._textstyle=ne,this._extents=new Nt,this._insunits=uo.Millimeters,this._ltscale=1,this._lwdisplay=!0,this._pdmode=0,this._pdsize=0,this._osmode=0,this._tables={appIdTable:new _u(this),blockTable:new iu(this),dimStyleTable:new au(this),linetypeTable:new pu(this),textStyleTable:new mu(this),layerTable:new du(this),viewportTable:new gu(this)},this._objects={dictionary:new Ks(this),imageDefinition:new Ks(this),layout:new Uh(this),xrecord:new Ks(this)},this._tables.appIdTable.add(new fu(ra.MLIGHTCAD_APPID))}get tables(){return this._tables}get objects(){return this._objects}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(jt.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get version(){return this._version}set version(t){this.updateSysVar(jt.ACADVER,this._version,new er(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(jt.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(jt.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}set lwdisplay(t){this.updateSysVar(jt.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(jt.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(jt.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(jt.CELWEIGHT,this._celweight,t??hn.ByLayer,e=>{this._celweight=e})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(jt.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(jt.TEXTSTYLE,this._textstyle,t??ne,e=>{this._textstyle=e})}get angBase(){return this._angBase}set angBase(t){this.updateSysVar(jt.ANGBASE,this._angBase,t??0,e=>{this._angBase=e})}get angDir(){return this._angDir}set angDir(t){this.updateSysVar(jt.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(jt.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(jt.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(jt.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(jt.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(jt.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}async read(t,e,s=Xs.DXF){const a=vr.instance.get(s);if(a==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await a.read(t,this,e&&e.minimumChunkSize||10,async(h,u,p,v)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:u,subStageStatus:p,data:v}),e&&e.fontLoader&&u=="FONT"&&p=="END"){const f=v||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}},e==null?void 0:e.timeout)}async openUri(t,e){var k;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const s=await fetch(t);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${s.status}'!`);const a=s.headers.get("content-length"),h=a?parseInt(a,10):null;let u=0;const p=(k=s.body)==null?void 0:k.getReader();if(!p)throw new Error("Failed to get response reader");const v=[];for(;;){const{done:L,value:C}=await p.read();if(L)break;if(v.push(C),u+=C.length,h!==null){const V=Math.round(u/h*100);this.events.openProgress.dispatch({database:this,percentage:V,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(u);let x=0;for(const L of v)f.set(L,x),x+=L.length;const A=this.getFileNameFromUri(t).toLowerCase().split(".").pop();A==="dwg"?await this.read(f.buffer,e,Xs.DWG):A==="dxf"?await this.read(f.buffer,e,Xs.DXF):await this.read(f.buffer,e,A),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(t,e=16,s=this.version.name,a=!1){this.ensureDxfExportDefaults();const h=s instanceof er?s:new er(s),u=new Vl({database:this,precision:e,version:h});return this.writeDxfHeaderSection(u),this.writeDxfTablesSection(u,h),this.writeDxfBlocksSection(u),this.writeDxfEntitiesSection(u),this.writeDxfObjectsSection(u),u.writeStart("EOF"),u.toString()}async regen(){await new Lc(this).read(null,this,500,async(e,s,a,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:s,subStageStatus:a,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Yh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureDxfExportDefaults(){if(!this.tables.layerTable.has("0")){const e=new ce;e.colorIndex=7,this.tables.layerTable.add(new ci({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has("ByBlock")||this.tables.linetypeTable.add(new ln({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has("ByLayer")||this.tables.linetypeTable.add(new ln({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has("Continuous")||this.tables.linetypeTable.add(new ln({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0})),this.tables.textStyleTable.has(ne)||this.tables.textStyleTable.add(new la({name:ne,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),this.tables.dimStyleTable.has(ne)||this.tables.dimStyleTable.add(new On({name:ne,dimtxsty:ne})),!this.tables.viewportTable.has("*ACTIVE")){const e=new _o;e.name="*ACTIVE",this.tables.viewportTable.add(e)}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}}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,"$INSUNITS"),t.writeInt16(70,this.insunits),t.writeString(9,"$LTSCALE"),t.writeDouble(40,this.ltscale),t.writeString(9,"$LWDISPLAY"),t.writeInt16(70,this.lwdisplay?1:0),t.writeString(9,"$CLAYER"),t.writeString(8,this.clayer),t.writeString(9,"$TEXTSTYLE"),t.writeString(7,this.textstyle),t.writeString(9,"$ANGBASE"),t.writeAngle(50,this.angBase),t.writeString(9,"$ANGDIR"),t.writeInt16(70,this.angDir),t.writeString(9,"$EXTMIN"),t.writePoint3d(10,this.extmin),t.writeString(9,"$EXTMAX"),t.writePoint3d(10,this.extmax),t.writeString(9,"$PDMODE"),t.writeInt32(70,this.pdmode),t.writeString(9,"$PDSIZE"),t.writeDouble(40,this.pdsize),t.writeString(9,"$OSMODE"),t.writeInt32(70,this.osmode),t.endSection()}writeDxfTablesSection(t,e){t.startSection("TABLES"),this.writeDxfTable(t,"VPORT",this.tables.viewportTable.newIterator(),"VPORT"),this.writeDxfTable(t,"LTYPE",this.tables.linetypeTable.newIterator(),"LTYPE"),this.writeDxfTable(t,"LAYER",this.tables.layerTable.newIterator(),"LAYER"),this.writeDxfTable(t,"STYLE",this.tables.textStyleTable.newIterator(),"STYLE"),this.writeDxfTable(t,"APPID",this.tables.appIdTable.newIterator(),"APPID"),this.writeDxfTable(t,"DIMSTYLE",this.tables.dimStyleTable.newIterator(),"DIMSTYLE"),e.value>=19&&this.writeDxfTable(t,"BLOCK_RECORD",this.tables.blockTable.newIterator(),"BLOCK_RECORD"),t.endSection()}writeDxfBlocksSection(t){t.startSection("BLOCKS");for(const e of this.tables.blockTable.newIterator()){if(e.dxfOutBlockBegin(t),!e.isModelSapce&&!e.isPaperSapce)for(const s of e.newIterator())this.writeDxfEntity(t,s);e.dxfOutBlockEnd(t)}t.endSection()}writeDxfEntitiesSection(t){t.startSection("ENTITIES");for(const e of this.tables.blockTable.newIterator())if(!(!e.isModelSapce&&!e.isPaperSapce))for(const s of e.newIterator())this.writeDxfEntity(t,s);t.endSection()}writeDxfObjectsSection(t){t.startSection("OBJECTS"),this.objects.layout.ownerId=this.objects.dictionary.objectId,this.objects.imageDefinition.ownerId=this.objects.dictionary.objectId,this.objects.xrecord.ownerId=this.objects.dictionary.objectId,t.writeStart("DICTIONARY"),t.writeHandle(5,this.objects.dictionary.objectId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(281,1),t.writeString(3,"ACAD_LAYOUT"),t.writeObjectId(350,this.objects.layout.objectId),this.objects.imageDefinition.numEntries>0&&(t.writeString(3,"ISM_RASTER_IMAGE_DICT"),t.writeObjectId(350,this.objects.imageDefinition.objectId)),this.objects.xrecord.numEntries>0&&(t.writeString(3,"MLIGHT_XRECORD"),t.writeObjectId(350,this.objects.xrecord.objectId)),t.writeStart("DICTIONARY"),this.objects.layout.dxfOut(t),this.objects.imageDefinition.numEntries>0&&(t.writeStart("DICTIONARY"),this.objects.imageDefinition.dxfOut(t)),this.objects.xrecord.numEntries>0&&(t.writeStart("DICTIONARY"),this.objects.xrecord.dxfOut(t));for(const e of this.objects.layout.newIterator())t.writeStart("LAYOUT"),e.dxfOut(t);for(const e of this.objects.imageDefinition.newIterator())t.writeStart("IMAGEDEF"),e.dxfOut(t);for(const e of this.objects.xrecord.newIterator())t.writeStart("XRECORD"),e.dxfOut(t);t.endSection()}writeDxfTable(t,e,s,a){const h=[...s];t.startTable(e,h.length);for(const u of h){if(a==="BLOCK_RECORD"&&u instanceof ue){u.dxfOutBlockRecord(t);continue}t.writeStart(a),u.dxfOut(t)}t.endTable()}writeDxfEntity(t,e){if(t.writeStart(e.dxfEntityTypeName),e.dxfOut(t),e instanceof Js){for(let s=0;s<e.numberOfVertices;++s)t.writeStart("VERTEX"),t.writeHandle(5,`VERTEX:${e.objectId}:${s}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint3d(10,{x:e.getPointAt(s).x,y:e.getPointAt(s).y,z:e.elevation}),t.writeInt16(70,0);t.writeStart("SEQEND"),t.writeHandle(5,`SEQEND:${e.objectId}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity");return}if(e instanceof ti){for(let s=0;s<e.numberOfVertices;++s){const a=e.getPointAt(s);t.writeStart("VERTEX"),t.writeHandle(5,`VERTEX:${e.objectId}:${s}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb3dPolylineVertex"),t.writePoint3d(10,{x:a.x,y:a.y,z:0}),t.writeInt16(70,32)}t.writeStart("SEQEND"),t.writeHandle(5,`SEQEND:${e.objectId}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity");return}if(e instanceof Ln){let s=!1;for(const a of e.attributeIterator())s=!0,t.writeStart("ATTRIB"),a.dxfOut(t);s&&(t.writeStart("SEQEND"),t.writeHandle(5,`SEQEND:${e.objectId}`),t.writeObjectId(330,e.objectId),t.writeSubclassMarker("AcDbEntity"))}}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._objects.layout.removeAll(),this._currentSpace=void 0,this._extents.makeEmpty()}updateSysVar(t,e,s,a){this.hasSysVarValueChanged(e,s)&&(a(s),this.triggerSysVarChangedEvent(t,e,s))}hasSysVarValueChanged(t,e){return t instanceof ce&&e instanceof ce?!t.equals(e):t instanceof er&&e instanceof er?t.value!==e.value:!Object.is(t,e)}triggerSysVarChangedEvent(t,e,s){const a=Zi.instance(),h=t.toLowerCase();a.getDescriptor(h)!=null&&a.events.sysVarChanged.dispatch({database:this,name:h,oldVal:e,newVal:s})}getFileNameFromUri(t){try{const s=new URL(t).pathname.split("/");return s[s.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}};ra.MLIGHTCAD_APPID="mlightcad";let Ga=ra;const yu="Load Database",Ll=3e4,Td=12e4,Nd=1024*1024;class Fe extends Yl{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Ya.getInstance().getEntry(yu),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const a=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",a?a.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-s),a}}class fo{constructor(t={}){this.config=t}async read(t,e,s,a,h){const u={name:yu,data:{total:0},format(){let x="";return Object.keys(this.data).forEach(w=>{w!=="total"&&(x+=`- ${w}: ${this.data[w]} ms
|
|
7
|
+
`)}),x+=`- total: ${this.data.total} ms`,x}};Ya.getInstance().collect(u),this.progress=a;const p={value:0},v=new Xl;v.setCompleteCallback(()=>this.onFinished()),v.setErrorCallback(x=>this.onError(x)),v.addTask(new Fe({stage:"START",step:1,progress:p,task:async x=>x},a)),v.addTask(new Fe({stage:"PARSE",step:5,progress:p,task:async x=>await this.parse(x,h)},a)),v.addTask(new Fe({stage:"FONT",step:5,progress:p,task:async x=>{const w=this.getFonts(x.model);return{model:x.model,data:w}}},a)),v.addTask(new Fe({stage:"LTYPE",step:1,progress:p,task:async x=>(this.processLineTypes(x.model,e),x)},a)),v.addTask(new Fe({stage:"STYLE",step:1,progress:p,task:async x=>(this.processTextStyles(x.model,e),x)},a)),v.addTask(new Fe({stage:"DIMSTYLE",step:1,progress:p,task:async x=>(this.processDimStyles(x.model,e),x)},a)),v.addTask(new Fe({stage:"LAYER",step:1,progress:p,task:async x=>(this.processLayers(x.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),x)},a)),v.addTask(new Fe({stage:"VPORT",step:1,progress:p,task:async x=>(this.processViewports(x.model,e),x)},a)),v.addTask(new Fe({stage:"HEADER",step:1,progress:p,task:async x=>(this.processHeader(x.model,e),x)},a)),v.addTask(new Fe({stage:"BLOCK_RECORD",step:5,progress:p,task:async x=>(this.processBlockTables(x.model,e),x)},a)),v.addTask(new Fe({stage:"OBJECT",step:5,progress:p,task:async x=>(this.processObjects(x.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),x)},a)),v.addTask(new Fe({stage:"BLOCK",step:5,progress:p,task:async x=>(await this.processBlocks(x.model,e),x)},a)),v.addTask(new Fe({stage:"ENTITY",step:100,progress:p,task:async x=>(await this.processEntities(x.model,e,s,p,a),x)},a)),v.addTask(new Fe({stage:"END",step:0,progress:p,task:async x=>x},a));const f=Date.now();await v.run(t),u.data.total=Date.now()-f}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return console.error(`Error occurred in conversion stage '${t.task.name}': `,t.error),t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),is.instance.clear())}getParserWorkerTimeout(t,e){const s=e??this.config.timeout;if(s!=null)return s;const a=Math.ceil(t.byteLength/Nd),h=Ll+a*1e3;return Math.min(Td,Math.max(Ll,h))}async parse(t,e){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,a,h){throw new Error("Not impelemented yet!")}}var _e,ks,re,le,Ms,ur,Ee,Er,cr,vn,Ts,Ns,bn,wn,Ls,Os,Cs,We,kr,$t,xn,Bs,vt,ke,Rs,Me,Fs,Mr,Tr,dr,zs,In,He,Nr,Sn,Sa,Pa,Lr,Or,Vs,js,Cr,Ds,Aa,Ea,fe,Br,ye,Ye,ka,Ma,Ta,Na,Rr,Xe,Pn,Us,An,qe,Fr,$e,zr;(_e={})[_e.None=0]="None",_e[_e.Anonymous=1]="Anonymous",_e[_e.NonConstant=2]="NonConstant",_e[_e.Xref=4]="Xref",_e[_e.XrefOverlay=8]="XrefOverlay",_e[_e.ExternallyDependent=16]="ExternallyDependent",_e[_e.ResolvedOrDependent=32]="ResolvedOrDependent",_e[_e.ReferencedXref=64]="ReferencedXref";(ks={})[ks.BYBLOCK=0]="BYBLOCK",ks[ks.BYLAYER=256]="BYLAYER";(re={})[re.Rotated=0]="Rotated",re[re.Aligned=1]="Aligned",re[re.Angular=2]="Angular",re[re.Diameter=3]="Diameter",re[re.Radius=4]="Radius",re[re.Angular3Point=5]="Angular3Point",re[re.Ordinate=6]="Ordinate",re[re.ReferenceIsExclusive=32]="ReferenceIsExclusive",re[re.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",re[re.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(le={})[le.TopLeft=1]="TopLeft",le[le.TopCenter=2]="TopCenter",le[le.TopRight=3]="TopRight",le[le.MiddleLeft=4]="MiddleLeft",le[le.MiddleCenter=5]="MiddleCenter",le[le.MiddleRight=6]="MiddleRight",le[le.BottomLeft=7]="BottomLeft",le[le.BottomCenter=8]="BottomCenter",le[le.BottomRight=9]="BottomRight";(Ms={})[Ms.AtLeast=1]="AtLeast",Ms[Ms.Exact=2]="Exact";var Ol=((ur={})[ur.Center=0]="Center",ur[ur.Above=1]="Above",ur[ur.Outside=2]="Outside",ur[ur.JIS=3]="JIS",ur[ur.Below=4]="Below",ur),Kn=((Ee={})[Ee.Feet=0]="Feet",Ee[Ee.None=1]="None",Ee[Ee.Inch=2]="Inch",Ee[Ee.FeetAndInch=3]="FeetAndInch",Ee[Ee.Leading=4]="Leading",Ee[Ee.Trailing=8]="Trailing",Ee[Ee.LeadingAndTrailing=12]="LeadingAndTrailing",Ee),Ld=((Er={})[Er.None=0]="None",Er[Er.Leading=1]="Leading",Er[Er.Trailing=2]="Trailing",Er[Er.LeadingAndTrailing=3]="LeadingAndTrailing",Er),Od=((cr={})[cr.Center=0]="Center",cr[cr.Left=1]="Left",cr[cr.Right=2]="Right",cr[cr.OverFirst=3]="OverFirst",cr[cr.OverSecond=4]="OverSecond",cr),Cd=((vn={})[vn.Bottom=0]="Bottom",vn[vn.Center=1]="Center",vn[vn.Top=2]="Top",vn),Bd=((Ts={})[Ts.PatternFill=0]="PatternFill",Ts[Ts.SolidFill=1]="SolidFill",Ts);(Ns={})[Ns.NonAssociative=0]="NonAssociative",Ns[Ns.Associative=1]="Associative";(bn={})[bn.Normal=0]="Normal",bn[bn.Outer=1]="Outer",bn[bn.Ignore=2]="Ignore";(wn={})[wn.UserDefined=0]="UserDefined",wn[wn.Predefined=1]="Predefined",wn[wn.Custom=2]="Custom";(Ls={})[Ls.NotAnnotated=0]="NotAnnotated",Ls[Ls.Annotated=1]="Annotated";(Os={})[Os.Solid=0]="Solid",Os[Os.Gradient=1]="Gradient";(Cs={})[Cs.TwoColor=0]="TwoColor",Cs[Cs.OneColor=1]="OneColor";var Rd=((We={})[We.Default=0]="Default",We[We.External=1]="External",We[We.Polyline=2]="Polyline",We[We.Derived=4]="Derived",We[We.Textbox=8]="Textbox",We[We.Outermost=16]="Outermost",We),vi=((kr={})[kr.Line=1]="Line",kr[kr.Circular=2]="Circular",kr[kr.Elliptic=3]="Elliptic",kr[kr.Spline=4]="Spline",kr),Fd=(($t={})[$t.Off=0]="Off",$t[$t.Solid=1]="Solid",$t[$t.Dashed=2]="Dashed",$t[$t.Dotted=3]="Dotted",$t[$t.ShotDash=4]="ShotDash",$t[$t.MediumDash=5]="MediumDash",$t[$t.LongDash=6]="LongDash",$t[$t.DoubleShortDash=7]="DoubleShortDash",$t[$t.DoubleMediumDash=8]="DoubleMediumDash",$t[$t.DoubleLongDash=9]="DoubleLongDash",$t[$t.DoubleMediumLongDash=10]="DoubleMediumLongDash",$t[$t.SparseDot=11]="SparseDot",$t);Fd.Off;(xn={})[xn.Standard=-3]="Standard",xn[xn.ByLayer=-2]="ByLayer",xn[xn.ByBlock=-1]="ByBlock";(Bs={})[Bs.English=0]="English",Bs[Bs.Metric=1]="Metric";(vt={})[vt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",vt[vt.FRONT_CLIPPING=2]="FRONT_CLIPPING",vt[vt.BACK_CLIPPING=4]="BACK_CLIPPING",vt[vt.UCS_FOLLOW=8]="UCS_FOLLOW",vt[vt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",vt[vt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",vt[vt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",vt[vt.FAST_ZOOM=128]="FAST_ZOOM",vt[vt.SNAP_MODE=256]="SNAP_MODE",vt[vt.GRID_MODE=512]="GRID_MODE",vt[vt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",vt[vt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",vt[vt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",vt[vt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",vt[vt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",vt[vt.UNUSED=32768]="UNUSED",vt[vt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",vt[vt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",vt[vt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",vt[vt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",vt[vt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",vt[vt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(ke={})[ke.OPTIMIZED_2D=0]="OPTIMIZED_2D",ke[ke.WIREFRAME=1]="WIREFRAME",ke[ke.HIDDEN_LINE=2]="HIDDEN_LINE",ke[ke.FLAT_SHADED=3]="FLAT_SHADED",ke[ke.GOURAUD_SHADED=4]="GOURAUD_SHADED",ke[ke.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",ke[ke.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(Rs={})[Rs.UCS_UNCHANGED=0]="UCS_UNCHANGED",Rs[Rs.HAS_OWN_UCS=1]="HAS_OWN_UCS";(Me={})[Me.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",Me[Me.TOP=1]="TOP",Me[Me.BOTTOM=2]="BOTTOM",Me[Me.FRONT=3]="FRONT",Me[Me.BACK=4]="BACK",Me[Me.LEFT=5]="LEFT",Me[Me.RIGHT=6]="RIGHT";(Fs={})[Fs.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Fs[Fs.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Mr={})[Mr.ByLayer=0]="ByLayer",Mr[Mr.ByBlock=1]="ByBlock",Mr[Mr.ByDictionaryDefault=2]="ByDictionaryDefault",Mr[Mr.ByObject=3]="ByObject";function Pt(n,t,e){return n.code===t&&(e==null||n.value===e)}function Ft(n){let t={};n.rewind();let e=n.next(),s=e.code;if(t.x=e.value,(e=n.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=n.next()).code!==s+20?n.rewind():t.z=e.value,t}let yo=Symbol();function wt(n,t){return(e,s,a)=>{let h=function(v,f=!1){return v.reduce((x,w)=>{w.pushContext&&x.push({});let A=x[x.length-1];for(let k of typeof w.code=="number"?[w.code]:w.code){let L=A[k]??(A[k]=[]);w.isMultiple&&L.length&&f&&console.warn(`Snippet ${L[L.length-1].name} for code(${k}) is shadowed by ${w.name}`),L.push(w)}return x},[{}])}(n,s.debug),u=!1,p=h.length-1;for(;!Pt(e,0,"EOF");){let v=function(V,z,st){return V.find((_t,it)=>{var H;return it>=st&&((H=_t[z])==null?void 0:H.length)})}(h,e.code,p),f=v==null?void 0:v[e.code],x=f==null?void 0:f[f.length-1];if(!v||!x){s.rewind();break}x.isMultiple||v[e.code].pop();let{name:w,parser:A,isMultiple:k,isReducible:L}=x,C=A==null?void 0:A(e,s,a);if(C===yo){s.rewind();break}if(w){let[V,z]=function(st,_t){let it=_t.split(".");if(!it.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let H=st;for(let dt=0;dt<it.length-1;++dt){let at=La(it[dt]),Wt=La(it[dt+1]);Object.prototype.hasOwnProperty.call(H,at)||(typeof Wt=="number"?H[at]=[]:H[at]={}),H=H[at]}return[H,La(it[it.length-1])]}(a,w);k&&!L?(Object.prototype.hasOwnProperty.call(V,z)||(V[z]=[]),V[z].push(C)):V[z]=C}x.pushContext&&(p-=1),u=!0,e=s.next()}return t&&Object.setPrototypeOf(a,t),u}}function La(n){let t=Number.parseInt(n);return Number.isNaN(t)?n:t}function b({value:n}){return n}function W(n,t){return Ft(t)}function Dt({value:n}){return!!n}let zd=[{code:1001,name:"xdata",parser:vu}];function vu(n,t){var a;if(!Pt(n,1001))throw Error("XData must starts with code 1001");let e={appName:n.value,value:[]};n=t.next();let s=[e.value];for(;!Pt(n,0,"EOF")&&n.code>=1e3;){let h=s[s.length-1];switch(n.code){case 1002:n.value==="{"?s.push([]):(s.pop(),(a=s[s.length-1])==null||a.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Vr(n.code),value:n.value});break;case 1003:h.push({name:"layer",type:Vr(n.code),value:n.value});break;case 1005:h.push({name:"handle",type:Vr(n.code),value:n.value});break;case 1010:h.push({type:Vr(n.code),value:Ft(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Vr(n.code),value:Ft(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Vr(n.code),value:Ft(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Vr(n.code),value:Ft(t)});break;case 1041:h.push({name:"distance",type:Vr(n.code),value:n.value});break;case 1042:h.push({name:"scale",type:Vr(n.code),value:n.value})}n=t.next()}return t.rewind(),e}function Vr(n){switch(n){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function Tn(n,t,e){for(;Pt(n,102);){var s;let a=n.value;if(n=t.next(),!a.startsWith("{")){t.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${a}`),function(u,p){for(;!Pt(u,102)&&!Pt(u,0,"EOF");)u=p.next()}(n,t),n=t.next();continue}let h=a.slice(1).trim();e.extensions??(e.extensions={}),(s=e.extensions)[h]??(s[h]=[]),function(u,p,v){for(;!Pt(u,102,"}")&&!Pt(u,0,"EOF");)v.push(u),u=p.next()}(n,t,e.extensions[h]),n=t.next()}t.rewind()}let Vd=0;function bu(n){if(!n)throw TypeError("entity cannot be undefined or null");n.handle||(n.handle=Vd++)}var jd=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function wu(n){return jd[n]}(Tr={})[Tr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Tr[Tr.CAST=1]="CAST",Tr[Tr.RECEIVE=2]="RECEIVE",Tr[Tr.IGNORE=3]="IGNORE";let Gt=[...zd,{code:284,name:"shadowMode",parser:b},{code:390,name:"plotStyleHardId",parser:b},{code:380,name:"plotStyleType",parser:b},{code:440,name:"transparency",parser:b},{code:430,name:"colorName",parser:b},{code:420,name:"color",parser:b},{code:310,name:"proxyEntity",isMultiple:!0,parser:b},{code:92,name:"proxyByte",parser:b},{code:60,name:"isVisible",parser:Dt},{code:48,name:"lineTypeScale",parser:b},{code:370,name:"lineweight",parser:b},{code:62,name:"colorIndex",parser(n,t,e){let s=n.value;return s>0&&s<256&&(e.color=wu(Math.abs(s))),s}},{code:347,name:"materialObjectHardId",parser:b},{code:6,name:"lineType",parser:b},{code:8,name:"layer",parser:b},{code:410,name:"layoutTabName",parser:b},{code:67,name:"isInPaperSpace",parser:Dt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:b},{code:102,parser:Tn},{code:102,parser:Tn},{code:102,parser:Tn},{code:5,name:"handle",parser:b}];function ha(n){return[{code:3,name:n,parser:(t,e,s)=>(s._code3text=(s._code3text??"")+t.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:n,parser:(t,e,s)=>(s._code1text=t.value,(s._code3text??"")+s._code1text)}]}function xu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Dd={extrusionDirection:{x:0,y:0,z:1}},Ud=[{code:210,name:"extrusionDirection",parser:W},{code:51,name:"endAngle",parser:b},{code:50,name:"startAngle",parser:b},{code:100,name:"subclassMarker",parser:b},{code:40,name:"radius",parser:b},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:b},{code:100},...Gt];class Iu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){xu(this,"parser",wt(Ud,Dd))}}xu(Iu,"ForEntityName","ARC");(dr={})[dr.NONE=0]="NONE",dr[dr.INVISIBLE=1]="INVISIBLE",dr[dr.CONSTANT=2]="CONSTANT",dr[dr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",dr[dr.PRESET=8]="PRESET";(zs={})[zs.MULTILINE=2]="MULTILINE",zs[zs.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(In={})[In.NONE=0]="NONE",In[In.MIRRORED_X=2]="MIRRORED_X",In[In.MIRRORED_Y=4]="MIRRORED_Y";var Gd=((He={})[He.LEFT=0]="LEFT",He[He.CENTER=1]="CENTER",He[He.RIGHT=2]="RIGHT",He[He.ALIGNED=3]="ALIGNED",He[He.MIDDLE=4]="MIDDLE",He[He.FIT=5]="FIT",He),Wd=((Nr={})[Nr.BASELINE=0]="BASELINE",Nr[Nr.BOTTOM=1]="BOTTOM",Nr[Nr.MIDDLE=2]="MIDDLE",Nr[Nr.TOP=3]="TOP",Nr);function Su(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Pu={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Gd.LEFT,valign:Wd.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Au=[{code:73,name:"valign",parser:b},{code:100},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:72,name:"valign",parser:b},{code:72,name:"halign",parser:b},{code:71,name:"generationFlag",parser:b},{code:7,name:"styleName",parser:b},{code:51,name:"obliqueAngle",parser:b},{code:41,name:"xScale",parser:b},{code:50,name:"rotation",parser:b},{code:1,name:"text",parser:b},{code:40,name:"textHeight",parser:b},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Eu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Su(this,"parser",wt(Au,Pu))}}function ku(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Su(Eu,"ForEntityName","TEXT");let Hd={...Pu},Yd=[{code:2},{code:40,name:"annotationScale",parser:b},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:b},{code:70,name:"numberOfSecondaryAttributes",parser:b},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:b},{code:280,name:"isDuplicatedRecord",parser:Dt},{code:100},{code:280,name:"isLocked",parser:Dt},{code:74,name:"valign",parser:b},{code:73},{code:70,name:"attributeFlag",parser:b},{code:2,name:"tag",parser:b},{code:3,name:"prompt",parser:b},{code:280},{code:100,name:"subclassMarker",parser:b},...Au.slice(2)];class Mu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ku(this,"parser",wt(Yd,Hd))}}ku(Mu,"ForEntityName","ATTDEF");(Sn={})[Sn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Sn[Sn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Sn[Sn.BY_STYLE=5]="BY_STYLE";function Xd(n,t){let e={};for(let s of n){let a=t(s);a!=null&&(e[a]??(e[a]=[]),e[a].push(s))}return e}function*Qi(n,t=1/0,e=1){for(let s=n;s!==t;s+=e)yield s}function an(n){return{x:n.x??0,y:n.y??0,z:n.z??0}}function vo(n,t,e){if(Pt(t,102))return Tn(t,e,n),!0;switch(t.code){case 0:n.type=t.value;break;case 5:n.handle=t.value;break;case 330:n.ownerBlockRecordSoftId=t.value;break;case 67:n.isInPaperSpace=!!t.value;break;case 8:n.layer=t.value;break;case 6:n.lineType=t.value;break;case 347:n.materialObjectHardId=t.value;break;case 62:n.colorIndex=t.value,n.color=wu(Math.abs(t.value));break;case 370:n.lineweight=t.value;break;case 48:n.lineTypeScale=t.value;break;case 60:n.isVisible=!!t.value;break;case 92:n.proxyByte=t.value;break;case 310:n.proxyEntity=t.value;break;case 100:break;case 420:n.color=t.value;break;case 430:n.transparency=t.value;break;case 390:n.plotStyleHardId=t.value;break;case 284:n.shadowMode=t.value;break;case 1001:n.xdata=vu(t,e);break;default:return!1}return!0}function Tu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let qd={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Ii=[{code:46,name:"annotationHeight",parser:b},{code:101,parser(n,t){(function(e){e.rewind();let s=e.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=e.next();while(s.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:b},{code:49,name:"columnGutter",parser:b},{code:48,name:"columnWidth",parser:b},{code:79,name:"columnAutoHeight",parser:b},{code:78,name:"columnFlowReversed",parser:b},{code:76,name:"columnCount",parser:b},{code:75,name:"columnType",parser:b},{code:441,name:"backgroundFillTransparency",parser:b},{code:63,name:"backgroundFillColor",parser:b},{code:45,name:"fillBoxScale",parser:b},{code:[...Qi(430,440)],name:"backgroundColor",parser:b},{code:[...Qi(420,430)],name:"backgroundColor",parser:b},{code:90,name:"backgroundFill",parser:b},{code:44,name:"lineSpacing",parser:b},{code:73,name:"lineSpacingStyle",parser:b},{code:50,name:"rotation",parser:b},{code:43},{code:42},{code:11,name:"direction",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:7,name:"styleName",parser:b},...ha("text"),{code:72,name:"drawingDirection",parser:b},{code:71,name:"attachmentPoint",parser:b},{code:41,name:"width",parser:b},{code:40,name:"height",parser:b},{code:10,name:"insertionPoint",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Nu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Tu(this,"parser",wt(Ii,qd))}}function Lu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Tu(Nu,"ForEntityName","MTEXT");let $d={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Kd=[...Ii.slice(Ii.findIndex(({name:n})=>n==="columnType"),Ii.findIndex(({name:n})=>n==="subclassMarker")+1),{code:100},{code:0,parser(n){if(!Pt(n,0,"MTEXT"))return yo}},{code:2,name:"definitionTag",parser:b},{code:40,name:"annotationScale",parser:b},{code:10,name:"alignmentPoint",parser:W},{code:340,name:"secondaryAttributesHardId",parser:b},{code:70,name:"numberOfSecondaryAttributes",parser:b},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:b},{code:280,name:"isDuplicatedEntriesKeep",parser:Dt},{code:100},{code:280,name:"lockPositionFlag",parser:Dt},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"alignmentPoint",parser:W},{code:74,name:"verticalJustification",parser:b},{code:72,name:"horizontalJustification",parser:b},{code:71,name:"textGenerationFlag",parser:b},{code:7,name:"textStyle",parser:b},{code:51,name:"obliqueAngle",parser:b},{code:41,name:"scale",parser:b},{code:50,name:"rotation",parser:b},{code:73},{code:70,name:"attributeFlag",parser:b},{code:2,name:"tag",parser:b},{code:280},{code:100,name:"subclassMarker",parser:b},{code:1,name:"text",parser:b},{code:40,name:"textHeight",parser:b},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:b},{code:100},...Gt];class Ou{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Lu(this,"parser",wt(Kd,$d))}}function Cu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Lu(Ou,"ForEntityName","ATTRIB");let Zd=[...ha("data"),{code:70,name:"version",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Bu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Cu(this,"parser",wt(Zd))}}function Ru(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Cu(Bu,"ForEntityName","BODY");let Qd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Jd=[{code:210,name:"extrusionDirection",parser:W},{code:40,name:"radius",parser:b},{code:10,name:"center",parser:W},{code:39,name:"thickness",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Fu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ru(this,"parser",wt(Jd,Qd))}}Ru(Fu,"ForEntityName","CIRCLE");class Si{parseEntity(t,e){let s={};for(;!Pt(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(a,h,u){switch(h.code){case 100:a.subclassMarker=h.value;break;case 280:a.version=h.value;break;case 2:a.name=h.value;break;case 10:a.definitionPoint=Ft(u);break;case 11:a.textPoint=Ft(u);break;case 12:a.insertionPoint=Ft(u);break;case 13:a.subDefinitionPoint1=Ft(u);break;case 14:a.subDefinitionPoint2=Ft(u);break;case 15:a.centerPoint=Ft(u);break;case 16:a.arcPoint=Ft(u);break;case 70:a.dimensionType=h.value;break;case 71:a.attachmentPoint=h.value;break;case 72:a.textLineSpacingStyle=h.value;break;case 40:a.leaderLength=h.value;break;case 41:a.textLineSpacingFactor=h.value;break;case 42:a.measurement=h.value;break;case 1:a.text=h.value;break;case 50:a.rotationAngle=h.value;break;case 52:a.obliqueAngle=h.value;break;case 53:a.textRotation=h.value;break;case 51:a.ocsRotation=h.value;break;case 210:a.extrusionDirection=Ft(u);break;case 3:a.styleName=h.value;break;default:vo(a,h,u)}})(s,e,t),e=t.next()}return s}}function zu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Pa="DIMENSION",(Sa="ForEntityName")in Si?Object.defineProperty(Si,Sa,{value:Pa,enumerable:!0,configurable:!0,writable:!0}):Si[Sa]=Pa;let t0={extrusionDirection:{x:0,y:0,z:1}},e0=[{code:42,name:"endAngle",parser:b},{code:41,name:"startAngle",parser:b},{code:40,name:"axisRatio",parser:b},{code:210,name:"extrusionDirection",parser:W},{code:11,name:"majorAxisEndPoint",parser:W},{code:10,name:"center",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Vu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){zu(this,"parser",wt(e0,t0))}}zu(Vu,"ForEntityName","ELLIPSE");(Lr={})[Lr.First=1]="First",Lr[Lr.Second=2]="Second",Lr[Lr.Third=4]="Third",Lr[Lr.Fourth=8]="Fourth";function ju(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let r0=[{code:13,name:"vertices.3",parser:W},{code:12,name:"vertices.2",parser:W},{code:11,name:"vertices.1",parser:W},{code:10,name:"vertices.0",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Du{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ju(this,"parser",wt(r0))}}ju(Du,"ForEntityName","3DFACE");let Uu=[{code:330,name:"sourceBoundaryObjects",parser:b,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:b}],n0=[{code:11,name:"end",parser:W},{code:10,name:"start",parser:W}],s0=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:b},{code:50,name:"startAngle",parser:b},{code:40,name:"radius",parser:b},{code:10,name:"center",parser:W}],i0=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:b},{code:50,name:"startAngle",parser:b},{code:40,name:"lengthOfMinorAxis",parser:b},{code:11,name:"end",parser:W},{code:10,name:"center",parser:W}],a0=[{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:11,name:"fitDatum",isMultiple:!0,parser:W},{code:97,name:"numberOfFitData",parser:b},{code:10,name:"controlPoints",isMultiple:!0,parser(n,t){let e={...Ft(t),weight:1};return(n=t.next()).code===42?e.weight=n.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:b},{code:96,name:"numberOfControlPoints",parser:b},{code:95,name:"numberOfKnots",parser:b},{code:74,name:"isPeriodic",parser:Dt},{code:73,name:"splineFlag",parser:b},{code:94,name:"degree",parser:b}],o0={[vi.Line]:n0,[vi.Circular]:s0,[vi.Elliptic]:i0,[vi.Spline]:a0},l0=[...Uu,{code:72,name:"edges",parser(n,t){let e={type:n.value},s=wt(o0[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(n=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:b}],h0=[...Uu,{code:10,name:"vertices",parser(n,t){let e={...Ft(t),bulge:0};return(n=t.next()).code===42?e.bulge=n.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:b},{code:73,name:"isClosed",parser:Dt},{code:72,name:"hasBulge",parser:Dt}],u0=[{code:49,name:"dashLengths",parser:b,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:b},{code:45,name:"offset",parser:Cl},{code:43,name:"base",parser:Cl},{code:53,name:"angle",parser:b}];function Cl(n,t){let e=n.code+1,s={x:n.value,y:1};return(n=t.next()).code===e?s.y=n.value:t.rewind(),s}function Gu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let c0={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},d0=[{code:470},{code:463},{code:462,name:"colorTint",parser:b},{code:461,name:"gradientDefinition",parser:b},{code:460,name:"gradientRotation",parser:b},{code:453,name:"numberOfColors",parser:b},{code:452,name:"gradientColorFlag",parser:b},{code:451},{code:450,name:"gradientFlag",parser:b},{code:10,name:"seedPoints",parser:W,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:W},{code:98,name:"numberOfSeedPoints",parser:b},{code:47,name:"pixelSize",parser:b},{code:53,name:"definitionLines",parser:function(n,t){let e={};return wt(u0)(n,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:b},{code:77,name:"isDouble",parser:Dt},{code:73,name:"isAnnotated",parser:Dt},{code:41,name:"patternScale",parser:b},{code:52,name:"patternAngle",parser:b},{code:76,name:"patternType",parser:b},{code:75,name:"hatchStyle",parser:b},{code:92,name:"boundaryPaths",parser:function(n,t){let e={boundaryPathTypeFlag:n.value},s=e.boundaryPathTypeFlag&Rd.Polyline;return n=t.next(),s?wt(h0)(n,t,e):wt(l0)(n,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:b},{code:71,name:"associativity",parser:b},{code:63,name:"patternFillColor",parser:b},{code:70,name:"solidFill",parser:b},{code:2,name:"patternName",parser:b},{code:210,name:"extrusionDirection",parser:W},{code:10,name:"elevationPoint",parser:W},{code:100,name:"subclassMarker",parser:b,pushContext:!0},...Gt];class Wu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gu(this,"parser",wt(d0,c0))}}Gu(Wu,"ForEntityName","HATCH");(Or={})[Or.ShowImage=1]="ShowImage",Or[Or.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",Or[Or.UseClippingBoundary=4]="UseClippingBoundary",Or[Or.TransparencyIsOn=8]="TransparencyIsOn";(Vs={})[Vs.Rectangular=1]="Rectangular",Vs[Vs.Polygonal=2]="Polygonal";(js={})[js.Outside=0]="Outside",js[js.Inside=1]="Inside";function Hu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let p0={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},m0=[{code:290,name:"clipMode",parser:b},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:W},{code:91,name:"countBoundaryPoints",parser:b},{code:71,name:"clippingBoundaryType",parser:b},{code:360,name:"imageDefReactorHandle",parser:b},{code:283,name:"fade",parser:b},{code:282,name:"contrast",parser:b},{code:281,name:"brightness",parser:b},{code:280,name:"isClipped",parser:Dt},{code:70,name:"flags",parser:b},{code:340,name:"imageDefHandle",parser:b},{code:13,name:"imageSize",parser:W},{code:12,name:"vPixel",parser:W},{code:11,name:"uPixel",parser:W},{code:10,name:"position",parser:W},{code:90,name:"version",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Yu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Hu(this,"parser",wt(m0,p0))}}function Xu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Hu(Yu,"ForEntityName","IMAGE");let g0={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},_0=[{code:210,name:"extrusionDirection",parser:W},{code:45,name:"rowSpacing",parser:b},{code:44,name:"columnSpacing",parser:b},{code:71,name:"rowCount",parser:b},{code:70,name:"columnCount",parser:b},{code:50,name:"rotation",parser:b},{code:43,name:"zScale",parser:b},{code:42,name:"yScale",parser:b},{code:41,name:"xScale",parser:b},{code:10,name:"insertionPoint",parser:W},{code:2,name:"name",parser:b},{code:66,name:"isVariableAttributes",parser:Dt},{code:100,name:"subclassMarker",parser:b},...Gt];class qu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Xu(this,"parser",wt(_0,g0))}}function $u(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Xu(qu,"ForEntityName","INSERT");let f0={isArrowheadEnabled:!0},y0=[{code:213,name:"offsetFromAnnotation",parser:W},{code:212,name:"offsetFromBlock",parser:W},{code:211,name:"horizontalDirection",parser:W},{code:210,name:"normal",parser:W},{code:340,name:"associatedAnnotation",parser:b},{code:77,name:"byBlockColor",parser:b},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:76,name:"numberOfVertices",parser:b},{code:41,name:"textWidth",parser:b},{code:40,name:"textHeight",parser:b},{code:75,name:"isHooklineExists",parser:Dt},{code:74,name:"isHooklineSameDirection",parser:Dt},{code:73,name:"leaderCreationFlag",parser:b},{code:72,name:"isSpline",parser:Dt},{code:71,name:"isArrowheadEnabled",parser:Dt},{code:3,name:"styleName",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Ku{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){$u(this,"parser",wt(y0,f0))}}$u(Ku,"ForEntityName","LEADER");(Cr={})[Cr.TextAnnotation=0]="TextAnnotation",Cr[Cr.ToleranceAnnotation=1]="ToleranceAnnotation",Cr[Cr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Cr[Cr.NoAnnotation=3]="NoAnnotation";function Zu(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let v0={thickness:0,extrusionDirection:{x:0,y:0,z:1}},b0=[{code:210,name:"extrusionDirection",parser:W},{code:11,name:"endPoint",parser:W},{code:10,name:"startPoint",parser:W},{code:39,name:"thickness",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Qu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zu(this,"parser",wt(b0,v0))}}Zu(Qu,"ForEntityName","LINE");(Ds={})[Ds.IS_CLOSED=1]="IS_CLOSED",Ds[Ds.PLINE_GEN=128]="PLINE_GEN";let w0={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},x0={bulge:0},I0=[{code:42,name:"bulge",parser:b},{code:41,name:"endWidth",parser:b},{code:40,name:"startWidth",parser:b},{code:91,name:"id",parser:b},{code:20,name:"y",parser:b},{code:10,name:"x",parser:b}],S0=[{code:210,name:"extrusionDirection",parser:W},{code:10,name:"vertices",isMultiple:!0,parser(n,t){let e={};return wt(I0,x0)(n,t,e),e}},{code:39,name:"thickness",parser:b},{code:38,name:"elevation",parser:b},{code:43,name:"constantWidth",parser:b},{code:70,name:"flag",parser:b},{code:90,name:"numberOfVertices",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class Pi{parseEntity(t,e){let s={};return wt(S0,w0)(e,t,s),s}}function Ju(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ea="LWPOLYLINE",(Aa="ForEntityName")in Pi?Object.defineProperty(Pi,Aa,{value:Ea,enumerable:!0,configurable:!0,writable:!0}):Pi[Aa]=Ea;let P0=[{code:90,name:"overridenSubEntityCount",parser:b},{code:140,name:"edgeCreaseWeights",parser:b,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:b},{code:94,parser(n,t,e){e.edgeCount=n.value,e.edgeIndices=[];for(let s=0;s<e.edgeCount;++s){let a=[];n=t.next(),a[0]=n.value,n=t.next(),a[1]=n.value,e.edgeIndices.push(a)}}},{code:93,parser(n,t,e){e.totalFaceIndices=n.value,e.faceIndices=[];let s=[];for(let h=0;h<e.totalFaceIndices&&!Pt(n,0);++h)n=t.next(),s.push(n.value);let a=0;for(;a<s.length;){let h=s[a++],u=[];for(let p=0;p<h;++p)u.push(s[a++]);e.faceIndices.push(u)}}},{code:10,name:"vertices",parser:W,isMultiple:!0},{code:92,name:"verticesCount",parser:b},{code:91,name:"subdivisionLevel",parser:b},{code:40,name:"blendCrease",parser:b},{code:72,name:"isBlendCreased",parser:Dt},{code:71,name:"version",parser:b},{code:100,name:"subclassMarker",parser:function({value:n}){return n.trim()},pushContext:!0},...Gt];class tc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ju(this,"parser",wt(P0))}}function ec(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ju(tc,"ForEntityName","MESH");let A0={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},E0=[{code:50,name:"angle",parser:b},{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:b},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class rc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ec(this,"parser",wt(E0,A0))}}ec(rc,"ForEntityName","POINT");(fe={})[fe.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",fe[fe.CURVE_FIT=2]="CURVE_FIT",fe[fe.SPLINE_FIT=4]="SPLINE_FIT",fe[fe.POLYLINE_3D=8]="POLYLINE_3D",fe[fe.POLYGON_3D=16]="POLYGON_3D",fe[fe.CLOSED_POLYGON=32]="CLOSED_POLYGON",fe[fe.POLYFACE=64]="POLYFACE",fe[fe.CONTINUOUS=128]="CONTINUOUS";var bi=((Br={})[Br.NONE=0]="NONE",Br[Br.QUADRATIC=5]="QUADRATIC",Br[Br.CUBIC=6]="CUBIC",Br[Br.BEZIER=8]="BEZIER",Br),k0=((ye={})[ye.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ye[ye.TANGENT_DEFINED=2]="TANGENT_DEFINED",ye[ye.NOT_USED=4]="NOT_USED",ye[ye.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ye[ye.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ye[ye.FOR_POLYLINE=32]="FOR_POLYLINE",ye[ye.FOR_POLYGON=64]="FOR_POLYGON",ye[ye.POLYFACE=128]="POLYFACE",ye);function nc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let M0={startWidth:0,endWidth:0,bulge:0},T0=[{code:91,name:"id",parser:b},{code:[...Qi(71,75)],name:"faces",isMultiple:!0,parser:b},{code:50,name:"tangentDirection",parser:b},{code:70,name:"flag",parser:b},{code:42,name:"bulge",parser:b},{code:41,name:"endWidth",parser:b},{code:40,name:"startWidth",parser:b},{code:30,name:"z",parser:b},{code:20,name:"y",parser:b},{code:10,name:"x",parser:b},{code:100,name:"subclassMarker",parser:b},{code:100},...Gt];class bo{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nc(this,"parser",wt(T0,M0))}}function sc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}nc(bo,"ForEntityName","VERTEX");let N0={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},L0=[{code:0,name:"vertices",isMultiple:!0,parser:(n,t)=>Pt(n,0,"VERTEX")?(n=t.next(),new bo().parseEntity(t,n)):yo},{code:210,name:"extrusionDirection",parser:W},{code:75,name:"smoothType",parser:b},{code:74,name:"surfaceNDensity",parser:b},{code:73,name:"surfaceMDensity",parser:b},{code:72,name:"meshNVertexCount",parser:b},{code:71,name:"meshMVertexCount",parser:b},{code:41,name:"endWidth",parser:b},{code:40,name:"startWidth",parser:b},{code:70,name:"flag",parser:b},{code:39,name:"thickness",parser:b},{code:30,name:"elevation",parser:b},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:b},...Gt];class ic{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){sc(this,"parser",wt(L0,N0))}}function ac(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}sc(ic,"ForEntityName","POLYLINE");let O0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class oc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ac(this,"parser",wt(O0))}}function lc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ac(oc,"ForEntityName","RAY");let C0=[...ha("data"),{code:70,name:"version",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class hc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){lc(this,"parser",wt(C0))}}function uc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}lc(hc,"ForEntityName","REGION");let B0={vertices:[],backLineVertices:[]},R0=[{code:360,name:"geometrySettingHardId",parser:b},{code:12,name:"backLineVertices",isMultiple:!0,parser:W},{code:93,name:"numberOfBackLineVertices",parser:b},{code:11,name:"vertices",isMultiple:!0,parser:W},{code:92,name:"verticesCount",parser:b},{code:[63,411],name:"indicatorColor",parser:b},{code:70,name:"indicatorTransparency",parser:b},{code:41,name:"bottomHeight",parser:b},{code:40,name:"topHeight",parser:b},{code:10,name:"verticalDirection",parser:W},{code:1,name:"name",parser:b},{code:91,name:"flag",parser:b},{code:90,name:"state",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class cc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){uc(this,"parser",wt(R0,B0))}}function dc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}uc(cc,"ForEntityName","SECTION");let F0={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},z0=[{code:210,name:"extrusionDirection",parser:W},{code:39,name:"thickness",parser:b},{code:[...Qi(10,14)],name:"points",isMultiple:!0,parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class pc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dc(this,"parser",wt(z0,F0))}}function mc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}dc(pc,"ForEntityName","SOLID");let V0=[{code:350,name:"historyObjectSoftId",parser:b},{code:100,name:"subclassMarker",parser:b},...ha("data"),{code:70,name:"version",parser:b},{code:100},...Gt];class gc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){mc(this,"parser",wt(V0))}}mc(gc,"ForEntityName","3DSOLID");(Ye={})[Ye.NONE=0]="NONE",Ye[Ye.CLOSED=1]="CLOSED",Ye[Ye.PERIODIC=2]="PERIODIC",Ye[Ye.RATIONAL=4]="RATIONAL",Ye[Ye.PLANAR=8]="PLANAR",Ye[Ye.LINEAR=16]="LINEAR";function _c(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let j0={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},D0=[{code:11,name:"fitPoints",isMultiple:!0,parser:W},{code:10,name:"controlPoints",isMultiple:!0,parser:W},{code:41,name:"weights",isMultiple:!0,parser:b},{code:40,name:"knots",isMultiple:!0,parser:b},{code:13,name:"endTangent",parser:W},{code:12,name:"startTangent",parser:W},{code:44,name:"fitTolerance",parser:b},{code:43,name:"controlTolerance",parser:b},{code:42,name:"knotTolerance",parser:b},{code:74,name:"numberOfFitPoints",parser:b},{code:73,name:"numberOfControlPoints",parser:b},{code:72,name:"numberOfKnots",parser:b},{code:71,name:"degree",parser:b},{code:70,name:"flag",parser:b},{code:210,name:"normal",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class fc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){_c(this,"parser",wt(D0,j0))}}_c(fc,"ForEntityName","SPLINE");class Ai{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=an(Ft(t)),e=t.lastReadGroup;break;case 11:s.directionVector=an(Ft(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerDictionaryId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(a,h){let u=!1,p=!1,v={};for(;!a.isEOF()&&h.code!==0&&!p;)switch(h.code){case 171:if(u){p=!0;continue}v.cellType=h.value,u=!0,h=a.next();break;case 172:v.flagValue=h.value,h=a.next();break;case 173:v.mergedValue=h.value,h=a.next();break;case 174:v.autoFit=h.value,h=a.next();break;case 175:v.borderWidth=h.value,h=a.next();break;case 176:v.borderHeight=h.value,h=a.next();break;case 91:v.overrideFlag=h.value,h=a.next();break;case 178:v.virtualEdgeFlag=h.value,h=a.next();break;case 145:v.rotation=h.value,h=a.next();break;case 345:v.fieldObjetId=h.value,h=a.next();break;case 340:v.blockTableRecordId=h.value,h=a.next();break;case 146:v.blockScale=h.value,h=a.next();break;case 177:v.blockAttrNum=h.value,h=a.next();break;case 7:v.textStyle=h.value,h=a.next();break;case 140:v.textHeight=h.value,h=a.next();break;case 170:v.attachmentPoint=h.value,h=a.next();break;case 92:v.extendedCellFlags=h.value,h=a.next();break;case 285:v.rightBorderVisibility=!!(h.value??!0),h=a.next();break;case 286:v.bottomBorderVisibility=!!(h.value??!0),h=a.next();break;case 288:v.leftBorderVisibility=!!(h.value??!0),h=a.next();break;case 289:v.topBorderVisibility=!!(h.value??!0),h=a.next();break;case 301:(function(f,x,w){for(;w.code!==304;)switch(w.code){case 301:case 93:case 90:case 94:w=x.next();break;case 1:f.text=w.value,w=x.next();break;case 300:f.attrText=w.value,w=x.next();break;case 302:f.text=w.value?w.value:f.text,w=x.next();break;default:console.log(`Ignore code: ${w.code}, value: ${w.value}`),w=x.next()}})(v,a,h),h=a.next();break;default:return v}return u=!1,p=!1,v}(t,e)),e=t.lastReadGroup;break;default:vo(s,e,t),e=t.next()}}return s}}function yc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ma="ACAD_TABLE",(ka="ForEntityName")in Ai?Object.defineProperty(Ai,ka,{value:Ma,enumerable:!0,configurable:!0,writable:!0}):Ai[ka]=Ma;let U0=[{code:11,name:"xAxisDirection",parser:W},{code:210,name:"extrusionDirection",parser:W},{code:1,name:"text",parser:b},{code:10,name:"position",parser:W},{code:3,name:"styleName",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class vc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){yc(this,"parser",wt(U0))}}yc(vc,"ForEntityName","TOLERANCE");class Ei{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(a,h,u){if(u==="EOF")return!1;switch(u.code){case 0:return!1;case 8:a.layer=u.value;break;case 100:a.subclassMarker=u.value;break;case 10:a.viewportCenter=an(Ft(h));break;case 40:a.width=u.value;break;case 41:a.height=u.value;break;case 68:a.status=u.value;break;case 69:a.viewportId=u.value;break;case 12:a.displayCenter=Ft(h);break;case 13:a.snapBase=Ft(h);break;case 14:a.snapSpacing=Ft(h);break;case 15:a.gridSpacing=Ft(h);break;case 16:a.viewDirection=an(Ft(h));break;case 17:a.targetPoint=an(Ft(h));break;case 42:a.perspectiveLensLength=u.value;break;case 43:a.frontClipZ=u.value;break;case 44:a.backClipZ=u.value;break;case 45:a.viewHeight=u.value;break;case 50:a.snapAngle=u.value;break;case 51:a.viewTwistAngle=u.value;break;case 72:a.circleZoomPercent=u.value;break;case 331:a.frozenLayerIds??(a.frozenLayerIds=[]),a.frozenLayerIds.push(u.value);break;case 90:a.statusBitFlags=u.value;break;case 340:a.clippingBoundaryId=u.value;break;case 1:a.sheetName=u.value;break;case 281:a.renderMode=u.value;break;case 71:a.ucsPerViewport=u.value;break;case 110:a.ucsOrigin=an(Ft(h));break;case 111:a.ucsXAxis=an(Ft(h));break;case 112:a.ucsYAxis=an(Ft(h));break;case 345:a.ucsId=u.value;break;case 346:a.ucsBaseId=u.value;break;case 79:a.orthographicType=u.value;break;case 146:a.elevation=u.value;break;case 170:a.shadePlotMode=u.value;break;case 61:a.majorGridFrequency=u.value;break;case 332:a.backgroundId=u.value;break;case 333:a.shadePlotId=u.value;break;case 348:a.visualStyleId=u.value;break;case 292:a.isDefaultLighting=!!u.value;break;case 282:a.defaultLightingType=u.value;break;case 141:a.brightness=u.value;break;case 142:a.contrast=u.value;break;case 63:case 421:case 431:a.ambientLightColor=u.value;break;case 361:a.sunId=u.value;break;case 335:case 343:case 344:case 91:a.softPointer=u.value}return!0}(s,t,e)&&vo(s,e,t),e=t.next()}return s}}Na="VIEWPORT",(Ta="ForEntityName")in Ei?Object.defineProperty(Ei,Ta,{value:Na,enumerable:!0,configurable:!0,writable:!0}):Ei[Ta]=Na;(Rr={})[Rr.ShowImage=1]="ShowImage",Rr[Rr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Rr[Rr.UseClippingBoundary=4]="UseClippingBoundary",Rr[Rr.Transparency=8]="Transparency";function bc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let G0={brightness:50,constrast:50,fade:0},W0=[{code:14,name:"boundary",isMultiple:!0,parser:W},{code:91,name:"numberOfVertices",parser:b},{code:71,name:"boundaryType",parser:b},{code:360,name:"imageDefReactorHardId",parser:b},{code:283,name:"fade",parser:b},{code:282,name:"contrast",parser:b},{code:281,name:"brightness",parser:b},{code:280,name:"isClipping",parser:Dt},{code:70,name:"displayFlag",parser:b},{code:340,name:"imageDefHardId",parser:b},{code:13,name:"imageSize",parser:W},{code:12,name:"vDirection",parser:W},{code:11,name:"uDirection",parser:W},{code:10,name:"position",parser:W},{code:90,name:"classVersion",parser:b},{code:100,name:"subclassMarker",parser:b},...Gt];class wc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){bc(this,"parser",wt(W0,G0))}}function xc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}bc(wc,"ForEntityName","WIPEOUT");let H0=[{code:11,name:"direction",parser:W},{code:10,name:"position",parser:W},{code:100,name:"subclassMarker",parser:b},...Gt];class Ic{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){xc(this,"parser",wt(H0))}}function Sc(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}xc(Ic,"ForEntityName","XLINE");let Y0={},X0=[{code:170,name:"multileaderType",parser:b},{code:291,name:"doglegEnabled",parser:Dt},{code:40,name:"doglegLength",parser:b},{code:172,name:"contentType",parser:b},{code:3,name:"textContent",parser:b},{code:12,name:"textAnchor",parser:W},{code:344,name:"blockHandle",parser:b},{code:15,name:"blockPosition",parser:W},{code:302,name:"leaderSections",parser:function(n,t,e){let s,a={leaderLines:[]};for(;t.hasNext()&&(s=t.next()).code!==303;)switch(s.code){case 10:a.landingPoint=(s.value,Ft(t));break;case 11:a.doglegVector=(s.value,Ft(t));break;case 40:a.doglegLength=s.value;break;case 304:a.leaderLines.push(function(h,u,p){let v,f={vertices:[]};for(;u.hasNext()&&(v=u.next()).code!==305;)v.code===10&&f.vertices.push((v.value,Ft(u)));return f}(0,t))}return a},isMultiple:!0},...Gt];class Pc{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sc(this,"parser",wt(X0,Y0))}}Sc(Pc,"ForEntityName","MULTILEADER");let q0=Object.fromEntries([Iu,Mu,Ou,Bu,Fu,Si,Vu,Du,Yu,qu,Ku,Qu,Pi,tc,Nu,Pc,rc,ic,oc,hc,cc,pc,gc,fc,Ai,Eu,vc,Wu,bo,Ei,wc,Ic].map(n=>[n.ForEntityName,new n]));function Ac(n,t){let e=[];for(;!Pt(n,0,"EOF");){if(n.code===0){if(n.value==="ENDBLK"||n.value==="ENDSEC"){t.rewind();break}let s=q0[n.value];if(s){let a=n.value;n=t.next();let h=s.parseEntity(t,n);h.type=a,bu(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${n.value}`)}n=t.next()}return e}function $0(n,t){let e={};for(;!Pt(n,0,"EOF")&&!Pt(n,0,"ENDSEC");){if(Pt(n,0,"BLOCK")){let s=K0(n=t.next(),t);bu(s),s.name&&(e[s.name]=s)}n=t.next()}return e}function K0(n,t){let e={};for(;!Pt(n,0,"EOF");){if(Pt(n,0,"ENDBLK")){for(n=t.next();!Pt(n,0,"EOF");){if(Pt(n,100,"AcDbBlockEnd"))return e;n=t.next()}break}switch(n.code){case 1:e.xrefPath=n.value;break;case 2:e.name=n.value;break;case 3:e.name2=n.value;break;case 5:e.handle=n.value;break;case 8:e.layer=n.value;break;case 10:e.position=Ft(t);break;case 67:e.paperSpace=!!n.value&&n.value==1;break;case 70:n.value!==0&&(e.type=n.value);break;case 100:break;case 330:e.ownerHandle=n.value;break;case 0:e.entities=Ac(n,t)}n=t.next()}return e}function Z0(n,t){let e=null,s={};for(;!Pt(n,0,"EOF")&&!Pt(n,0,"ENDSEC");)n.code===9?e=n.value:n.code===10?s[e]=Ft(t):s[e]=n.value,n=t.next();return s}(Xe={})[Xe.NOT_APPLICABLE=0]="NOT_APPLICABLE",Xe[Xe.KEEP_EXISTING=1]="KEEP_EXISTING",Xe[Xe.USE_CLONE=2]="USE_CLONE",Xe[Xe.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Xe[Xe.VALUE_NAME=4]="VALUE_NAME",Xe[Xe.UNMANGLE_NAME=5]="UNMANGLE_NAME";let wo=[{code:330,name:"ownerObjectId",parser:b},{code:102,parser:Tn},{code:102,parser:Tn},{code:102,parser:Tn},{code:5,name:"handle",parser:b}],Q0=[{code:3,name:"entries",parser:(n,t)=>{let e={name:n.value};return(n=t.next()).code===350?e.objectSoftId=n.value:n.code===360?e.objectHardId=n.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:b},{code:280,name:"isHardOwned",parser:Dt},{code:100,name:"subclassMarker",parser:b},...wo],J0=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:b},{code:90,name:"version",parser:b},{code:1,name:"fileName",parser:b},{code:10,name:"size",parser:W},{code:11,name:"sizeOfOnePixel",parser:W},{code:280,name:"isLoaded",parser:b},{code:281,name:"resolutionUnits",parser:b},{code:100,name:"subclassMarker",parser:b}];(Pn={})[Pn.NOUNIT=0]="NOUNIT",Pn[Pn.CENTIMETERS=2]="CENTIMETERS",Pn[Pn.INCH=5]="INCH";(Us={})[Us.PSLTSCALE=1]="PSLTSCALE",Us[Us.LIMCHECK=2]="LIMCHECK";(An={})[An.INCHES=0]="INCHES",An[An.MILLIMETERS=1]="MILLIMETERS",An[An.PIXELS=2]="PIXELS";(qe={})[qe.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",qe[qe.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",qe[qe.DRAWING_LIMITS=2]="DRAWING_LIMITS",qe[qe.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",qe[qe.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",qe[qe.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Fr={})[Fr.AS_DISPLAYED=0]="AS_DISPLAYED",Fr[Fr.WIREFRAME=1]="WIREFRAME",Fr[Fr.HIDDEN=2]="HIDDEN",Fr[Fr.RENDERED=3]="RENDERED";($e={})[$e.DRAFT=0]="DRAFT",$e[$e.PREVIEW=1]="PREVIEW",$e[$e.NORMAL=2]="NORMAL",$e[$e.PRESENTATION=3]="PRESENTATION",$e[$e.MAXIMUM=4]="MAXIMUM",$e[$e.CUSTOM=5]="CUSTOM";let Ec=[{code:333,name:"shadePlotId",parser:b},{code:149,name:"imageOriginY",parser:b},{code:148,name:"imageOriginX",parser:b},{code:147,name:"scaleFactor",parser:b},{code:78,name:"shadePlotCustomDPI",parser:b},{code:77,name:"shadePlotResolution",parser:b},{code:76,name:"shadePlotMode",parser:b},{code:75,name:"standardScaleType",parser:b},{code:7,name:"currentStyleSheet",parser:b},{code:74,name:"plotType",parser:b},{code:73,name:"plotRotation",parser:b},{code:72,name:"plotPaperUnit",parser:b},{code:70,name:"layoutFlag",parser:b},{code:143,name:"printScaleDenominator",parser:b},{code:142,name:"printScaleNumerator",parser:b},{code:141,name:"windowAreaYMax",parser:b},{code:140,name:"windowAreaXMax",parser:b},{code:49,name:"windowAreaYMin",parser:b},{code:48,name:"windowAreaXMin",parser:b},{code:47,name:"plotOriginY",parser:b},{code:46,name:"plotOriginX",parser:b},{code:45,name:"paperHeight",parser:b},{code:44,name:"paperWidth",parser:b},{code:43,name:"marginTop",parser:b},{code:42,name:"marginRight",parser:b},{code:41,name:"marginBottom",parser:b},{code:40,name:"marginLeft",parser:b},{code:6,name:"plotViewName",parser:b},{code:4,name:"paperSize",parser:b},{code:2,name:"configName",parser:b},{code:1,name:"pageSetupName",parser:b},{code:100,name:"subclassMarker",parser:b},...wo],tp=[{code:346,name:"orthographicUcsId",parser:b},{code:345,name:"namedUcsId",parser:b},{code:331,name:"viewportId",parser:b},{code:330,name:"paperSpaceTableId",parser:b},{code:76,name:"orthographicType",parser:b},{code:17,name:"ucsYAxis",parser:W},{code:16,name:"ucsXAxis",parser:W},{code:13,name:"ucsOrigin",parser:W},{code:146,name:"elevation",parser:b},{code:15,name:"maxExtent",parser:W},{code:14,name:"minExtent",parser:W},{code:12,name:"insertionPoint",parser:W},{code:11,name:"maxLimit",parser:W},{code:10,name:"minLimit",parser:W},{code:71,name:"tabOrder",parser:b},{code:70,name:"controlFlag",parser:b},{code:1,name:"layoutName",parser:b},{code:100,name:"subclassMarker",parser:b},...Ec],ep=[{code:40,name:"wcsToOCSTransform",parser:Bl},{code:40,name:"ocsToWCSTransform",parser:Bl},{code:41,name:"backClippingDistance",parser:b},{code:73,name:"isBackClipping",parser:Dt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:b},{code:72,name:"isFrontClipping",parser:Dt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Dt},{code:11,name:"position",parser:W},{code:210,name:"normal",parser:W},{code:10,name:"boundaryVertices",parser:W,isMultiple:!0},{code:70,name:"boundaryCount",parser:b},{code:100,name:"subclassMarker",parser:b},{code:100},...wo];function Bl(n,t){let e=[];for(let s=0;s<3&&Pt(n,40);++s){let a=[];for(let h=0;h<4&&Pt(n,40);++h)a.push(n.value),n=t.next();e.push(a)}return t.rewind(),e}let rp={LAYOUT:tp,PLOTSETTINGS:Ec,DICTIONARY:Q0,SPATIAL_FILTER:ep,IMAGEDEF:J0};function np(n,t){let e=[];for(;n.code!==0||!["EOF","ENDSEC"].includes(n.value);){let s=n.value,a=rp[s];if(n.code===0&&(a!=null&&a.length)){let h=wt(a),u={name:s};h(n=t.next(),t,u)?(e.push(u),n=t.peek()):n=t.next()}else n=t.next()}return{byName:Xd(e,({name:s})=>s)}}let as=[{code:100,name:"subclassMarker",parser:b},{code:330,name:"ownerObjectId",parser:b},{code:102,parser(n,t){for(;!Pt(n,0,"EOF")&&!Pt(n,102,"}");)n=t.next()}},{code:5,name:"handle",parser:b}],sp=wt([{code:310,name:"bmpPreview",parser:b},{code:281,name:"scalability",parser:b},{code:280,name:"explodability",parser:b},{code:70,name:"insertionUnits",parser:b},{code:340,name:"layoutObjects",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),ip=[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:Ol.Above,defaultValueImperial:Ol.Center},{name:"DIMZIN",code:78,defaultValue:Kn.Trailing,defaultValueImperial:Kn.Feet},{name:"DIMAZIN",code:79,defaultValue:Ld.None},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:2,defaultValueImperial:4},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:",",defaultValueImperial:"."},{name:"DIMJUST",code:280,defaultValue:Od.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Cd.Center},{name:"DIMTZIN",code:284,defaultValue:Kn.Trailing,defaultValueImperial:Kn.Feet},{name:"DIMALTZ",code:285,defaultValue:Kn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Kn.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}],ap=wt([...ip.map(n=>({...n,parser:b})),{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},{code:105,name:"handle",parser:b},...as.filter(n=>n.code!==5)]),op=wt([{code:347,name:"materialObjectId",parser:b},{code:390,name:"plotStyleNameObjectId",parser:b},{code:370,name:"lineweight",parser:b},{code:290,name:"isPlotting",parser:Dt},{code:6,name:"lineType",parser:b},{code:62,name:"colorIndex",parser:b},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]);(zr={})[zr.NONE=0]="NONE",zr[zr.AbsoluteRotation=1]="AbsoluteRotation",zr[zr.TextEmbedded=2]="TextEmbedded",zr[zr.ShapeEmbedded=4]="ShapeEmbedded";let lp=wt([{code:9,name:"text",parser:b},{code:45,name:"offsetY",parser:b},{code:44,name:"offsetX",parser:b},{code:50,name:"rotation",parser:b},{code:46,name:"scale",parser:b},{code:340,name:"styleObjectId",parser:b},{code:75,name:"shapeNumber",parser:b},{code:74,name:"elementTypeFlag",parser:b},{code:49,name:"elementLength",parser:b}],{elementTypeFlag:0,elementLength:0}),hp=wt([{code:49,name:"pattern",parser(n,t){let e={};return lp(n,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:b},{code:73,name:"numberOfLineTypes",parser:b},{code:72,parser:b},{code:3,name:"description",parser:b},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),up=wt([{code:1e3,name:"extendedFont",parser:b},{code:1001},{code:4,name:"bigFont",parser:b},{code:3,name:"font",parser:b},{code:42,name:"lastHeight",parser:b},{code:71,name:"textGenerationFlag",parser:b},{code:50,name:"obliqueAngle",parser:b},{code:41,name:"widthFactor",parser:b},{code:40,name:"fixedTextHeight",parser:b},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),cp=wt([{code:[63,421,431],name:"ambientColor",parser:b},{code:142,name:"contrast",parser:b},{code:141,name:"brightness",parser:b},{code:282,name:"defaultLightingType",parser:b},{code:292,name:"isDefaultLightingOn",parser:Dt},{code:348,name:"visualStyleObjectId",parser:b},{code:333,name:"shadePlotObjectId",parser:b},{code:332,name:"backgroundObjectId",parser:b},{code:61,name:"majorGridLines",parser:b},{code:170,name:"shadePlotSetting",parser:b},{code:146,name:"elevation",parser:b},{code:79,name:"orthographicType",parser:b},{code:112,name:"ucsYAxis",parser:W},{code:111,name:"ucsXAxis",parser:W},{code:110,name:"ucsOrigin",parser:W},{code:74,name:"ucsIconSetting",parser:b},{code:71,name:"viewMode",parser:b},{code:281,name:"renderMode",parser:b},{code:1,name:"styleSheet",parser:b},{code:[331,441],name:"frozenLayers",parser:b,isMultiple:!0},{code:72,name:"circleSides",parser:b},{code:51,name:"viewTwistAngle",parser:b},{code:50,name:"snapRotationAngle",parser:b},{code:45,name:"viewHeight",parser:b},{code:44,name:"backClippingPlane",parser:b},{code:43,name:"frontClippingPlane",parser:b},{code:42,name:"lensLength",parser:b},{code:17,name:"viewTarget",parser:W},{code:16,name:"viewDirectionFromTarget",parser:W},{code:15,name:"gridSpacing",parser:W},{code:14,name:"snapSpacing",parser:W},{code:13,name:"snapBasePoint",parser:W},{code:12,name:"center",parser:W},{code:11,name:"upperRightCorner",parser:W},{code:10,name:"lowerLeftCorner",parser:W},{code:70,name:"standardFlag",parser:b},{code:2,name:"name",parser:b},{code:100,name:"subclassMarker",parser:b},...as]),dp={BLOCK_RECORD:sp,DIMSTYLE:ap,LAYER:op,LTYPE:hp,STYLE:up,VPORT:cp},pp=wt([{code:70,name:"maxNumberOfEntries",parser:b},{code:100,name:"subclassMarker",parser:b},{code:330,name:"ownerObjectId",parser:b},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:b},{code:2,name:"name",parser:b}]);function mp(n,t){var s;let e={};for(;!Pt(n,0,"EOF")&&!Pt(n,0,"ENDSEC");){if(Pt(n,0,"TABLE")){n=t.next();let a={entries:[]};pp(n,t,a),e[a.name]=a}if(Pt(n,0)&&!Pt(n,0,"ENDTAB")){let a=n.value;n=t.next();let h=dp[a];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${a}'`),n=t.next();continue}let u={};h(n,t,u),(s=e[a])==null||s.entries.push(u)}n=t.next()}return e}function Gs(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}class Rl{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=Fl(t,this._data[this._pointer++],this.debug),s={code:t,value:e};return Pt(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=Fl(t.code,this._data[this._pointer+1],this.debug),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t,e=!1){Gs(this,"_data",void 0),Gs(this,"debug",void 0),Gs(this,"_pointer",void 0),Gs(this,"_eof",void 0),Gs(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Fl(n,t,e=!1){return n<=9?t:n>=10&&n<=59?parseFloat(t.trim()):n>=60&&n<=99?parseInt(t.trim()):n>=100&&n<=109?t:n>=110&&n<=149?parseFloat(t.trim()):n>=160&&n<=179?parseInt(t.trim()):n>=210&&n<=239?parseFloat(t.trim()):n>=270&&n<=289?parseInt(t.trim()):n>=290&&n<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(t.trim()):n>=300&&n<=369?t:n>=370&&n<=389?parseInt(t.trim()):n>=390&&n<=399?t:n>=400&&n<=409?parseInt(t.trim()):n>=410&&n<=419?t:n>=420&&n<=429?parseInt(t.trim()):n>=430&&n<=439?t:n>=440&&n<=459?parseInt(t.trim()):n>=460&&n<=469?parseFloat(t.trim()):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?t:n>=1010&&n<=1059?parseFloat(t.trim()):n>=1060&&n<=1071?parseInt(t.trim()):(e&&console.warn("WARNING: Group code does not have a defined type: %j",{code:n,value:t}),t)}function Wa(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}class gp{constructor(){Wa(this,"encoding","utf-8"),Wa(this,"encodingFailureFatal",!1)}}class _p extends EventTarget{parseSync(t,e=!1){let s=new Rl(t.split(/\r\n|\r|\n/g),e);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(t){let e="",s=this;return new Promise((a,h)=>{t.on("data",u=>{e+=u}),t.on("end",()=>{try{let u=e.split(/\r\n|\r|\n/g),p=new Rl(u);if(!p.hasNext())throw Error("Empty file");a(s.parseAll(p))}catch(u){h(u)}}),t.on("error",u=>{h(u)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let a=s.body.getReader(),h="";for(;;){let{done:u,value:p}=await a.read();if(u){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(p,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!Pt(s,0,"EOF");)Pt(s,0,"SECTION")&&(Pt(s=t.next(),2,"HEADER")?(s=t.next(),e.header=Z0(s,t)):Pt(s,2,"BLOCKS")?(s=t.next(),e.blocks=$0(s,t)):Pt(s,2,"ENTITIES")?(s=t.next(),e.entities=Ac(s,t)):Pt(s,2,"TABLES")?(s=t.next(),e.tables=mp(s,t)):Pt(s,2,"OBJECTS")&&(s=t.next(),e.objects=np(s,t))),s=t.next();return e}constructor(t=new gp){super(),Wa(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}class fp{parse(t){const e=new _p,s=this.getDxfInfoFromBuffer(t);let a="";return s.version&&s.version.value<=23&&s.encoding?a=new TextDecoder(s.encoding).decode(t):a=new TextDecoder().decode(t),e.parseSync(a)}getDxfInfoFromBuffer(t){var f,x,w;const s=new TextDecoder("utf-8");let a=0,h="",u=null,p=null,v=!1;for(;a<t.byteLength;){const A=Math.min(a+65536,t.byteLength),k=t.slice(a,A);a=A;const C=(h+s.decode(k,{stream:!0})).split(/\r?\n/);h=C.pop()??"";for(let V=0;V<C.length;V++){const z=C[V].trim();if(z==="SECTION"&&((f=C[V+2])==null?void 0:f.trim())==="HEADER")v=!0;else if(z==="ENDSEC"&&v)return{version:u,encoding:p};if(v&&z==="$ACADVER"){const st=(x=C[V+2])==null?void 0:x.trim();st&&(u=new er(st))}else if(v&&z==="$DWGCODEPAGE"){const st=(w=C[V+2])==null?void 0:w.trim();if(st){const _t=lo[st];p=Bh(_t)}}if(u&&p)return{version:u,encoding:p}}}return{version:u,encoding:p}}}class zl{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):t.type=="ARC"?this.convertArc(t):t.type=="ATTDEF"?this.convertAttributeDefinition(t):t.type=="ATTRIB"?this.convertAttribute(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertFace(t){const e=new Ri;return t.vertices.forEach((s,a)=>e.setVertexAt(a,s)),e}convertArc(t){return new Ni(t.center,t.radius,St.degToRad(t.startAngle),St.degToRad(t.endAngle),t.extrusionDirection??q.Z_AXIS)}convertAttributeCommon(t,e){e.textString=t.text,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=t.rotation,e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.tag=t.tag,e.fieldLength=0,e.isInvisible=(t.attributeFlag&de.Invisible)!==0,e.isConst=(t.attributeFlag&de.Const)!==0,e.isVerifiable=(t.attributeFlag&de.Verifiable)!==0,e.isPreset=(t.attributeFlag&de.Preset)!==0,e.isReallyLocked=!!t.isReallyLocked,e.isMTextAttribute=(t.mtextFlag&br.MultiLine)!==0,e.isConstMTextAttribute=(t.mtextFlag&br.ConstMultiLine)!==0}convertAttribute(t){const e=new Oi;return this.convertAttributeCommon(t,e),e.styleName=t.textStyle,e.horizontalMode=t.horizontalJustification,e.verticalMode=t.verticalJustification,e.widthFactor=t.scale??1,e.lockPositionInBlock=t.lockPositionFlag,e}convertAttributeDefinition(t){const e=new Li;return this.convertAttributeCommon(t,e),e.styleName=t.styleName,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e.prompt=t.prompt,e}convertCirle(t){return new Ci(t.center,t.radius,t.extrusionDirection??q.Z_AXIS)}convertEllipse(t){const e=new q(t.majorAxisEndPoint),s=e.length();return new Bi(t.center,t.extrusionDirection??q.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new ri(new G(e.x,e.y,e.z||0),new G(s.x,s.y,s.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new si(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new si(e,"Uniform",t.degree,!!(t.flag&1))}}catch(e){console.log(`Failed to convert spline with error: ${e}`)}return null}convertPoint(t){const e=new Di;return e.position=t.position,e}convertSolid(t){const e=new Vi;return t.points.forEach((s,a)=>e.setPointAt(a,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),s=!!(t.flag&8),a=[],h=[];if(t.vertices.map(u=>{u.flag&k0.SPLINE_CONTROL_POINT||(a.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0))}),s){let u=Zs.SimplePoly;return t.flag&4&&(t.smoothType==bi.CUBIC?u=Zs.CubicSplinePoly:t.smoothType==bi.QUADRATIC&&(u=Zs.QuadSplinePoly)),new ti(u,a,e)}else{let u=Qn.SimplePoly;return t.flag&2?u=Qn.FitCurvePoly:t.flag&4&&(t.smoothType==bi.CUBIC?u=Qn.CubicSplinePoly:t.smoothType==bi.QUADRATIC&&(u=Qn.QuadSplinePoly)),new Js(u,a,0,e,t.startWidth,t.endWidth,h)}}convertLWPolyline(t){const e=new ji;return e.closed=!!(t.flag&1),t.vertices.forEach((s,a)=>{e.addVertexAt(a,new Et(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var a;const e=new ei;return(a=t.definitionLines)==null||a.forEach(h=>{e.definitionLines.push({angle:h.angle,base:h.base,offset:h.offset,dashLengths:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.isSolidFill=t.solidFill==Bd.SolidFill,e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const p=h,v=new un;v.closed=p.isClosed,p.vertices.forEach((f,x)=>{v.addVertexAt(x,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(v)}else{const p=h,v=new oa;p.edges.forEach(f=>{if(f.type==1){const x=f;v.add(new ts(x.start,x.end))}else if(f.type==2){const x=f;v.add(new Nn(x.center,x.radius,St.degToRad(x.startAngle||0),St.degToRad(x.endAngle||0),!x.isCCW))}else if(f.type==3){const x=f;new te().subVectors(x.end,x.center);const A=Math.sqrt(Math.pow(x.end.x,2)+Math.pow(x.end.y,2)),k=A*x.lengthOfMinorAxis;let L=St.degToRad(x.startAngle||0),C=St.degToRad(x.endAngle||0);const V=Math.atan2(x.end.y,x.end.x);x.isCCW||(L=Math.PI*2-L,C=Math.PI*2-C),v.add(new li({...x.center,z:0},A,k,L,C,!x.isCCW,V))}else if(f.type==4){const x=f;if(x.numberOfControlPoints>0&&x.numberOfKnots>0){const w=x.controlPoints.map(L=>({x:L.x,y:L.y,z:0}));let A=!0;const k=x.controlPoints.map(L=>(L.weight==null&&(A=!1),L.weight||1));v.add(new Gr(w,x.knots,A?k:void 0))}else if(x.numberOfFitData>0){const w=x.fitDatum.map(A=>({x:A.x,y:A.y,z:0}));v.add(new Gr(w,"Uniform"))}}}),e.add(v)}}),e}convertTable(t){const e=new zi(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,a)=>e.setColumnWidth(a,s)),t.rowHeightArr.forEach((s,a)=>e.setRowHeight(a,s)),t.cells.forEach((s,a)=>{e.setCell(a,s)}),e}convertText(t){const e=new rs;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=St.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new ni;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=St.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new q(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new Fi;return t.vertices.forEach(s=>{e.appendVertex(s)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new Xi(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(s.dimBlockPosition={...e.insertionPoint,z:0}),s.rotation=St.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new Yi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new $i(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new Ki(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new qi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,e.imageDefId=t.imageDefHandle,e.isClipped=t.isClipped,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new Et(s))}),e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new ii;return this.processImage(t,e),e.clipBoundaryType=t.clippingBoundaryType,e}processWipeout(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.displayFlag|4)>0,e.isImageShown=(t.displayFlag|3)>0,e.isImageTransparent=(t.displayFlag|8)>0,e.imageDefId=t.imageDefHardId,e.isClipped=t.isClipping,t.boundary.forEach(s=>{e.clipBoundary.push(new Et(s))}),e.clipBoundaryType=t.boundaryType,e.width=Math.sqrt(t.uDirection.x**2+t.uDirection.y**2+t.uDirection.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vDirection.x**2+t.vDirection.y**2+t.vDirection.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uDirection.y,t.uDirection.x)}convertWipeout(t){const e=new Wi;return this.processWipeout(t,e),e}convertViewport(t){const e=new Gi;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new Ui;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Hi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Ln(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?St.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&e.color.setRGBValue(t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=na.deserialize(t.transparency))}numberArrayToPointArray(t,e){const s=t.length;let a=0;if(s/2==e?a=2:s/3==e&&(a=3),a==0)return;const h=[];for(let u=0,p=s/a;u<p;++u)h.push({x:t[u*a],y:t[u*a+1],z:a==3?t[u*a+2]:0});return h}}class yp{convertLayout(t,e){var h,u;const s=new hi;s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,s.plotSettingsName=t.pageSetupName,s.plotCfgName=t.configName,s.canonicalMediaName=t.paperSize,s.plotViewName=t.plotViewName,s.currentStyleSheet=t.currentStyleSheet,s.plotPaperMargins={left:t.marginLeft,right:t.marginRight,top:t.marginTop,bottom:t.marginBottom},s.plotPaperSize.copy({x:t.paperWidth,y:t.paperHeight}),s.plotOrigin.copy({x:t.plotOriginX,y:t.plotOriginY}),s.plotWindowArea.min.copy({x:t.windowAreaXMin,y:t.windowAreaYMin}),s.plotWindowArea.max.copy({x:t.windowAreaXMax,y:t.windowAreaYMax}),s.customPrintScale={numerator:t.printScaleNumerator,denominator:t.printScaleDenominator},s.plotPaperUnits=t.plotPaperUnit,s.plotRotation=t.plotRotation,s.plotType=t.plotType,s.stdScaleType=t.standardScaleType,s.shadePlot=(()=>{switch(t.shadePlotMode){case 1:return Zn.kWireframe;case 2:return Zn.kHidden;case 3:return Zn.kRendered;default:return Zn.kAsDisplayed}})(),s.shadePlotResLevel=(()=>{switch(t.shadePlotResolution){case 1:return sn.kPreview;case 2:return sn.kNormal;case 3:return sn.kPresentation;case 4:return sn.kMaximum;case 5:return sn.kCustom;default:return sn.kDraft}})(),t.shadePlotCustomDPI!=null&&(s.shadePlotCustomDPI=t.shadePlotCustomDPI),t.shadePlotId&&(s.shadePlotId=t.shadePlotId);const a=t.layoutFlag??0;if(s.plotViewportBorders=(a&1)!==0,s.showPlotStyles=(a&2)!==0,s.plotCentered=(a&4)!==0,s.plotHidden=(a&8)!==0,s.useStandardScale=(a&16)!==0,s.plotPlotStyles=(a&32)!==0,s.scaleLineweights=(a&64)!==0,s.printLineweights=(a&128)!==0,s.drawViewportsFirst=(a&512)!==0,s.modelType=(a&1024)!==0,t.layoutName==="Model"){const p=ue.MODEL_SPACE_NAME.toUpperCase();(h=e.tables.BLOCK_RECORD)==null||h.entries.some(v=>v.name.toUpperCase()===p?(s.blockTableRecordId=v.handle,!0):!1)}else(u=e.tables.BLOCK_RECORD)==null||u.entries.some(p=>p.layoutObjects===t.handle?(s.blockTableRecordId=p.handle,!0):!1),s.blockTableRecordId||(s.blockTableRecordId=t.paperSpaceTableId);return t.minLimit&&s.limits.min.copy(t.minLimit),t.maxLimit&&s.limits.max.copy(t.maxLimit),t.minExtent&&s.extents.min.copy(t.minExtent),t.maxExtent&&s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new Wh;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class kc{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),a=this.generateTaskId();try{return await this.executeInWorker(a,t,e||this.config.workerUrl)}catch(h){const u=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:u}}}async executeInWorker(t,e,s){const a=Date.now();return new Promise((h,u)=>{const p=this.getAvailableWorker(s),v=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(p),u(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:w=>{clearTimeout(v),this.releaseWorker(p),h(w)},reject:w=>{clearTimeout(v),this.releaseWorker(p),u(w)},timeout:v});const f=w=>{const{id:A,success:k,data:L,error:C}=w.data;if(A!==t)return;this.cleanupTask(t);const V=Date.now()-a;h(k?{success:!0,data:L,duration:V}:{success:!1,error:C,duration:V})},x=w=>{this.cleanupTask(t),u(new Error(`Worker error: ${w.message}`))};p.addEventListener("message",f),p.addEventListener("error",x),p.postMessage({id:t,input:e})})}cleanupTask(t){const e=this.pendingTasks.get(t);e&&(clearTimeout(e.timeout),this.pendingTasks.delete(t))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(t){for(const[s,a]of this.workers)if(!a.isBusy)return a.isBusy=!0,a.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const s=new Worker(t,{type:"module"}),a=this.generateWorkerId(),h={worker:s,isBusy:!0,id:a,createdAt:new Date};return this.workers.set(a,h),s}const e=Array.from(this.workers.values()).sort((s,a)=>s.createdAt.getTime()-a.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,s]of this.workers)if(s.worker===t){s.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(t=>t.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[t,e]of this.pendingTasks)clearTimeout(e.timeout),e.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[t,e]of this.workers)e.worker.terminate();this.workers.clear()}}class Mc{constructor(t){this.framework=new kc(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Tc(n){return new Mc(n)}class vp{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:s}=t.data;try{const a=await this.executeTask(s);this.sendResponse(e,!0,a)}catch(a){this.sendResponse(e,!1,void 0,a instanceof Error?a.message:String(a))}}}sendResponse(t,e,s,a){const h={id:t,success:e,data:s,error:a};self.postMessage(h)}}class Nc extends fo{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t,e){const s=this.config,a=this.getParserWorkerTimeout(t,e);if(s.useWorker&&s.parserWorkerUrl){const h=Tc({workerUrl:s.parserWorkerUrl,timeout:a,maxConcurrentWorkers:1}),u=await h.execute(t);if(h.destroy(),u.success)return{model:u.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${u.error}'`)}else return{model:new fp().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,s=u=>{if(u){const p=u.lastIndexOf(".");return p>=0?u.substring(0,p).toLowerCase():u.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(u=>{const p=[];if(u.font){const v=s(u.font);v&&p.push(v)}if(u.bigFont){const v=s(u.bigFont);v&&p.push(v)}if(u.extendedFont){const v=s(u.extendedFont);v&&p.push(v)}e.set(u.name,p)});const a=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,a),Array.from(a)}getFontsInBlock(t,e,s,a){const h=/\\f(.*?)\|/g;t.forEach(u=>{if(u.type=="MTEXT"){const p=u;[...p.text.matchAll(h)].forEach(x=>{a.add(x[1].toLowerCase())});const f=s.get(p.styleName);f==null||f.forEach(x=>a.add(x))}else if(u.type=="TEXT"){const p=u,v=s.get(p.styleName);v==null||v.forEach(f=>a.add(f))}else if(u.type=="INSERT"){const v=e[u.name];v&&v.entities&&this.getFontsInBlock(v.entities,e,s,a)}})}async processEntities(t,e,s,a,h){const u=new zl;let p=t.entities;const v=p.length,f=new $a(v,100-a.value,s);this.config.convertByEntityType&&(p=this.groupAndFlattenByType(p));const x=new Map;for(let A=0;A<v;A++){const k=p[A];if(k.type==="ATTRIB"){const L=u.convert(k);if(L&&L.ownerId&&L.ownerId!=="0"){let C=x.get(L==null?void 0:L.ownerId);C==null&&(C=[],x.set(L.ownerId,C)),C.push(L)}}}const w=e.tables.blockTable.modelSpace;await f.processChunk(async(A,k)=>{let L=[],C=A<k?p[A].type:"";for(let z=A;z<k;z++){const st=p[z];if(!(st.ownerBlockRecordSoftId&&st.ownerBlockRecordSoftId!==w.objectId)&&st.type!=="ATTRIB"){const _t=u.convert(st);if(_t){if(this.config.convertByEntityType&&st.type!==C&&(w.appendEntity(L),L=[],C=st.type),st.type==="INSERT"){const it=x.get(_t.objectId);it&&it.length>0&&it.forEach(H=>{_t.appendAttributes(H)})}L.push(_t)}}}w.appendEntity(L);let V=a.value+k/v*(100-a.value);V>100&&(V=100),h&&await h(V,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(t,e,s=!1){const a=new zl,h=t.length,u=[],p=e.objectId,v=[];for(let f=0;f<h;f++){const x=t[f],w=a.convert(x);w&&(x.type==="ATTRIB"?v.push(w):(!s||x.ownerBlockRecordSoftId===p)&&u.push(w))}v.forEach(f=>{const x=e.getIdAt(f.ownerId);x&&x.appendAttributes(f)}),e.appendEntity(u)}processBlocks(t,e){const s=t.blocks;for(const[a,h]of Object.entries(s)){let u=e.tables.blockTable.getAt(h.name);u||(u=new ue,u.objectId=h.handle,u.name=a,u.origin.copy(h.position),e.tables.blockTable.add(u)),h.entities?this.processEntitiesInBlock(h.entities,u):u.isPaperSapce&&this.processEntitiesInBlock(t.entities,u,!0)}}processHeader(t,e){const s=t.header;s.$ACADVER&&(e.version=s.$ACADVER),e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,s.$AUNITS!=null&&(e.aunits=s.$AUNITS),e.celtscale=s.$CELTSCALE||1,e.ltscale=s.$LTSCALE||1,s.$EXTMAX&&(e.extmax=s.$EXTMAX),s.$EXTMIN&&(e.extmin=s.$EXTMIN),s.$INSUNITS!=null&&(e.insunits=s.$INSUNITS),e.osmode=s.$OSMODE||0,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0,e.textstyle=s.$TEXTSTYLE||ne}processBlockTables(t,e){var a;const s=(a=t.tables.BLOCK_RECORD)==null?void 0:a.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(h=>{const u=new ue;u.objectId=h.handle,u.name=h.name,u.layoutId=h.layoutObjects,e.tables.blockTable.add(u)}))}processObjects(t,e){const s=t.objects.byName,a=new yp;if("LAYOUT"in s){const h=e.objects.layout;s.LAYOUT.forEach(u=>{const p=a.convertLayout(u,t);h.setAt(p.layoutName,p)})}if("IMAGEDEF"in s){const h=e.objects.imageDefinition;s.IMAGEDEF.forEach(u=>{const p=a.convertImageDef(u);h.setAt(p.objectId,p)})}}processViewports(t,e){var a,h;const s=(h=(a=t.tables)==null?void 0:a.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const p=new _o;this.processCommonTableEntryAttrs(u,p),u.circleSides&&(p.circleSides=u.circleSides),p.standardFlag=u.standardFlag,p.center.copy(u.center),p.lowerLeftCorner.copy(u.lowerLeftCorner),p.upperRightCorner.copy(u.upperRightCorner),u.snapBasePoint&&p.snapBase.copy(u.snapBasePoint),u.snapRotationAngle&&(p.snapAngle=u.snapRotationAngle),u.snapSpacing&&p.snapIncrements.copy(u.snapSpacing),u.majorGridLines&&(p.gridMajor=u.majorGridLines),u.gridSpacing&&p.gridIncrements.copy(u.gridSpacing),u.backgroundObjectId&&(p.backgroundObjectId=u.backgroundObjectId),p.gsView.center.copy(u.center),p.gsView.viewDirectionFromTarget.copy(u.viewDirectionFromTarget),p.gsView.viewTarget.copy(u.viewTarget),u.lensLength&&(p.gsView.lensLength=u.lensLength),u.frontClippingPlane&&(p.gsView.frontClippingPlane=u.frontClippingPlane),u.backClippingPlane&&(p.gsView.backClippingPlane=u.backClippingPlane),u.viewHeight&&(p.gsView.viewHeight=u.viewHeight),u.viewTwistAngle&&(p.gsView.viewTwistAngle=u.viewTwistAngle),u.frozenLayers&&(p.gsView.frozenLayers=u.frozenLayers),u.styleSheet&&(p.gsView.styleSheet=u.styleSheet),u.renderMode&&(p.gsView.renderMode=u.renderMode),u.viewMode&&(p.gsView.viewMode=u.viewMode),u.ucsIconSetting&&(p.gsView.ucsIconSetting=u.ucsIconSetting),u.ucsOrigin&&p.gsView.ucsOrigin.copy(u.ucsOrigin),u.ucsXAxis&&p.gsView.ucsXAxis.copy(u.ucsXAxis),u.ucsYAxis&&p.gsView.ucsYAxis.copy(u.ucsYAxis),u.orthographicType&&(p.gsView.orthographicType=u.orthographicType),u.shadePlotSetting&&(p.gsView.shadePlotSetting=u.shadePlotSetting),u.shadePlotObjectId&&(p.gsView.shadePlotObjectId=u.shadePlotObjectId),u.visualStyleObjectId&&(p.gsView.visualStyleObjectId=u.visualStyleObjectId),u.isDefaultLightingOn&&(p.gsView.isDefaultLightingOn=u.isDefaultLightingOn),u.defaultLightingType&&(p.gsView.defaultLightingType=u.defaultLightingType),u.brightness&&(p.gsView.brightness=u.brightness),u.contrast&&(p.gsView.contrast=u.contrast),u.ambientColor&&(p.gsView.ambientColor=u.ambientColor),e.tables.viewportTable.add(p)})}processLayers(t,e){var a,h;const s=(h=(a=t.tables)==null?void 0:a.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const p=new ce;p.colorIndex=u.colorIndex;const v=new ci({name:u.name,standardFlags:u.standardFlag,linetype:u.lineType,lineWeight:u.lineweight,isOff:u.colorIndex<0,color:p,isPlottable:u.isPlotting});this.processCommonTableEntryAttrs(u,v),e.tables.layerTable.add(v)})}processLineTypes(t,e){var a,h;const s=(h=(a=t.tables)==null?void 0:a.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(u=>{const p=new ln(u);this.processCommonTableEntryAttrs(u,p),p.name=u.name,e.tables.linetypeTable.add(p)})}processTextStyles(t,e){var a;const s=(a=t.tables.STYLE)==null?void 0:a.entries;s&&s.length>0&&s.forEach(h=>{const u=new la(h);this.processCommonTableEntryAttrs(h,u),e.tables.textStyleTable.add(u)})}processDimStyles(t,e){var a;const s=(a=t.tables.DIMSTYLE)==null?void 0:a.entries;s&&s.length>0&&s.forEach(h=>{const u={name:h.name,ownerId:h.ownerObjectId,dimpost:h.DIMPOST||"",dimapost:h.DIMAPOST||"",dimscale:h.DIMSCALE,dimasz:h.DIMASZ,dimexo:h.DIMEXO,dimdli:h.DIMDLI,dimexe:h.DIMEXE,dimrnd:h.DIMRND,dimdle:h.DIMDLE,dimtp:h.DIMTP,dimtm:h.DIMTM,dimtxt:h.DIMTXT,dimcen:h.DIMCEN,dimtsz:h.DIMTSZ,dimaltf:h.DIMALTF,dimlfac:h.DIMLFAC,dimtvp:h.DIMTVP,dimtfac:h.DIMTFAC,dimgap:h.DIMGAP,dimaltrnd:h.DIMALTRND,dimtol:h.DIMTOL==null||h.DIMTOL==0?0:1,dimlim:h.DIMLIM==null||h.DIMLIM==0?0:1,dimtih:h.DIMTIH==null||h.DIMTIH==0?0:1,dimtoh:h.DIMTOH==null||h.DIMTOH==0?0:1,dimse1:h.DIMSE1==null||h.DIMSE1==0?0:1,dimse2:h.DIMSE2==null||h.DIMSE2==0?0:1,dimtad:h.DIMTAD,dimzin:h.DIMZIN,dimazin:h.DIMAZIN,dimalt:h.DIMALT,dimaltd:h.DIMALTD,dimtofl:h.DIMTOFL,dimsah:h.DIMSAH,dimtix:h.DIMTIX,dimsoxd:h.DIMSOXD,dimclrd:h.DIMCLRD,dimclre:h.DIMCLRE,dimclrt:h.DIMCLRT,dimadec:h.DIMADEC||0,dimunit:h.DIMUNIT||2,dimdec:h.DIMDEC,dimtdec:h.DIMTDEC,dimaltu:h.DIMALTU,dimalttd:h.DIMALTTD,dimaunit:h.DIMAUNIT,dimfrac:h.DIMFRAC,dimlunit:h.DIMLUNIT,dimdsep:h.DIMDSEP,dimtmove:h.DIMTMOVE||0,dimjust:h.DIMJUST,dimsd1:h.DIMSD1,dimsd2:h.DIMSD2,dimtolj:h.DIMTOLJ,dimtzin:h.DIMTZIN,dimaltz:h.DIMALTZ,dimalttz:h.DIMALTTZ,dimfit:h.DIMFIT||0,dimupt:h.DIMUPT,dimatfit:h.DIMATFIT,dimtxsty:h.DIMTXSTY||ne,dimldrblk:h.DIMLDRBLK||"",dimblk:h.DIMBLK||"",dimblk1:h.DIMBLK1||"",dimblk2:h.DIMBLK2||"",dimlwd:h.DIMLWD,dimlwe:h.DIMLWE},p=new On(u);this.processCommonTableEntryAttrs(h,p),e.tables.dimStyleTable.add(p)})}processCommonTableEntryAttrs(t,e){e.name=t.name,t.handle!=null&&(e.objectId=t.handle),e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},s=[];for(const a of t)e[a.type]||(e[a.type]=[],s.push(a.type)),e[a.type].push(a);return s.flatMap(a=>e[a])}}class Lc extends fo{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,s,a,h){let u=t.tables.blockTable.modelSpace.newIterator().toArray();const p=u.length,v=new $a(p,100-a.value,s);this.config.convertByEntityType&&(u=this.groupAndFlattenByType(u));const f=e.tables.blockTable.modelSpace;await v.processChunk(async(x,w)=>{let A=[],k=x<w?u[x].type:"";for(let L=x;L<w;L++){const C=u[L];this.config.convertByEntityType&&C.type!==k&&(this.triggerEvents(f,A),A=[],k=C.type),A.push(C)}if(this.triggerEvents(f,A),h){let L=a.value+w/p*(100-a.value);L>100&&(L=100),await h(L,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const s=e.newIterator().toArray();this.triggerEvents(e,s)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const s of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const s of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},s=[];for(const a of t)e[a.type]||(e[a.type]=[],s.push(a.type)),e[a.type].push(a);return s.flatMap(a=>e[a])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}exports.AC_DB_SYSTEM_VARIABLE_NAMES=Md;exports.AcCmColor=ce;exports.AcCmColorMethod=lt;exports.AcCmColorUtil=nn;exports.AcCmEntityColor=Kc;exports.AcCmErrors=Ze;exports.AcCmEventDispatcher=Zc;exports.AcCmEventManager=he;exports.AcCmLoader=id;exports.AcCmLoadingManager=ql;exports.AcCmObject=Wl;exports.AcCmPerformanceCollector=Ya;exports.AcCmTask=Yl;exports.AcCmTaskScheduler=Xl;exports.AcCmTransparency=na;exports.AcCmTransparencyMethod=Ne;exports.AcDb2dPolyline=Js;exports.AcDb2dVertex=ja;exports.AcDb2dVertexType=Kh;exports.AcDb3PointAngularDimension=Yi;exports.AcDb3dPolyline=ti;exports.AcDb3dVertex=Da;exports.AcDb3dVertexType=Zh;exports.AcDbAlignedDimension=Xi;exports.AcDbAngleUnits=oo;exports.AcDbArc=Ni;exports.AcDbArcDimension=Ua;exports.AcDbAttribute=Oi;exports.AcDbAttributeDefinition=Li;exports.AcDbAttributeFlags=de;exports.AcDbAttributeMTextFlag=br;exports.AcDbBaseWorker=vp;exports.AcDbBatchProcessing=$a;exports.AcDbBlockReference=Ln;exports.AcDbBlockTable=iu;exports.AcDbBlockTableRecord=ue;exports.AcDbCircle=Ci;exports.AcDbCodePage=lo;exports.AcDbCurve=Oe;exports.AcDbDataGenerator=Yh;exports.AcDbDatabase=Ga;exports.AcDbDatabaseConverter=fo;exports.AcDbDatabaseConverterManager=vr;exports.AcDbDiametricDimension=qi;exports.AcDbDictionary=Ks;exports.AcDbDimArrowType=Xh;exports.AcDbDimStyleTable=au;exports.AcDbDimStyleTableRecord=On;exports.AcDbDimTextHorizontal=ou;exports.AcDbDimTextVertical=lu;exports.AcDbDimVerticalJustification=cu;exports.AcDbDimZeroSuppression=hu;exports.AcDbDimZeroSuppressionAngular=uu;exports.AcDbDimension=Wr;exports.AcDbDuplicateRecordCloning=Hh;exports.AcDbDwgVersion=er;exports.AcDbDxfCode=Ha;exports.AcDbDxfConverter=Nc;exports.AcDbDxfFiler=Vl;exports.AcDbEllipse=Bi;exports.AcDbEntity=Le;exports.AcDbFace=Ri;exports.AcDbFileType=Xs;exports.AcDbHatch=ei;exports.AcDbHatchPatternType=Qs;exports.AcDbHatchStyle=tu;exports.AcDbHostApplicationServices=ki;exports.AcDbLayerTable=du;exports.AcDbLayerTableRecord=ci;exports.AcDbLayout=hi;exports.AcDbLayoutDictionary=Uh;exports.AcDbLayoutManager=Gh;exports.AcDbLeader=Fi;exports.AcDbLeaderAnnotationType=eu;exports.AcDbLine=ri;exports.AcDbLineSpacingStyle=su;exports.AcDbLinetypeTable=pu;exports.AcDbLinetypeTableRecord=ln;exports.AcDbMText=ni;exports.AcDbObject=Hr;exports.AcDbObjectIterator=ui;exports.AcDbOpenMode=Jl;exports.AcDbOrdinateDimension=$i;exports.AcDbOsnapMode=zt;exports.AcDbPlotPaperUnits=Fh;exports.AcDbPlotRotation=zh;exports.AcDbPlotSettings=Dh;exports.AcDbPlotShadePlotResLevel=sn;exports.AcDbPlotShadePlotType=Zn;exports.AcDbPlotStdScaleType=jh;exports.AcDbPlotType=Vh;exports.AcDbPoint=Di;exports.AcDbPoly2dType=Qn;exports.AcDbPoly3dType=Zs;exports.AcDbPolyline=ji;exports.AcDbRadialDimension=Ki;exports.AcDbRasterImage=ii;exports.AcDbRasterImageClipBoundaryType=ru;exports.AcDbRasterImageDef=Wh;exports.AcDbRasterImageImageDisplayOpt=nu;exports.AcDbRay=Ui;exports.AcDbRegAppTable=_u;exports.AcDbRegAppTableRecord=fu;exports.AcDbRegenerator=Lc;exports.AcDbRenderingCache=is;exports.AcDbResultBuffer=qa;exports.AcDbSpline=si;exports.AcDbSymbolTable=dn;exports.AcDbSymbolTableRecord=cn;exports.AcDbSysVarManager=Zi;exports.AcDbSystemVariables=jt;exports.AcDbTable=zi;exports.AcDbText=rs;exports.AcDbTextHorizontalMode=Qh;exports.AcDbTextStyleTable=mu;exports.AcDbTextStyleTableRecord=la;exports.AcDbTextVerticalMode=Jh;exports.AcDbTrace=Vi;exports.AcDbUnitsValue=uo;exports.AcDbViewport=Gi;exports.AcDbViewportTable=gu;exports.AcDbViewportTableRecord=_o;exports.AcDbWipeout=Wi;exports.AcDbWorkerApi=Mc;exports.AcDbWorkerManager=kc;exports.AcDbXline=Hi;exports.AcDbXrecord=ho;exports.AcGeArea2d=ia;exports.AcGeBox2d=ve;exports.AcGeBox3d=Nt;exports.AcGeCatmullRomCurve3d=Ch;exports.AcGeCircArc2d=Nn;exports.AcGeCircArc3d=ao;exports.AcGeCurve2d=ss;exports.AcGeEllipseArc2d=li;exports.AcGeEllipseArc3d=aa;exports.AcGeEuler=pd;exports.AcGeGeometryUtil=xh;exports.AcGeLine2d=ts;exports.AcGeLine3d=es;exports.AcGeLoop2d=oa;exports.AcGeMathUtil=St;exports.AcGeMatrix2d=sa;exports.AcGeMatrix3d=Ke;exports.AcGeNurbsCurve=Mn;exports.AcGePlane=ai;exports.AcGePoint2d=Et;exports.AcGePoint3d=G;exports.AcGePolyline2d=un;exports.AcGeQuaternion=Cn;exports.AcGeShape2d=io;exports.AcGeSpline3d=Gr;exports.AcGeTol=ro;exports.AcGeVector2d=te;exports.AcGeVector3d=q;exports.AcGiArrowType=co;exports.AcGiDefaultLightingType=go;exports.AcGiLineWeight=hn;exports.AcGiMTextAttachmentPoint=Pe;exports.AcGiMTextFlowDirection=Ur;exports.AcGiOrthographicType=mo;exports.AcGiRenderMode=po;exports.AcGiViewport=qh;exports.AcTrStringUtil=sd;exports.ByBlock=Rh;exports.ByLayer=xi;exports.DEBUG_MODE=rd;exports.DEFAULT_LINE_TYPE=Ti;exports.DEFAULT_TEXT_STYLE=ne;exports.DEFAULT_TOL=no;exports.DEG2RAD=Ka;exports.DefaultLoadingManager=$l;exports.FLOAT_TOL=En;exports.ORIGIN_POINT_2D=od;exports.ORIGIN_POINT_3D=eo;exports.RAD2DEG=Za;exports.TAU=Qt;exports.acdbDisableOsnapMode=Sd;exports.acdbEnableOsnapMode=Id;exports.acdbHasOsnapMode=xd;exports.acdbHostApplicationServices=Xa;exports.acdbMaskToOsnapModes=bd;exports.acdbOsnapModesToMask=vd;exports.acdbToggleOsnapMode=wd;exports.basisFunction=Mi;exports.calculateCurveLength=Ah;exports.ceilPowerOfTwo=mh;exports.clamp=Dr;exports.clone=Ws;exports.createWorkerApi=Tc;exports.damp=nh;exports.deepClone=Oa;exports.defaults=ns;exports.degToRad=ch;exports.dwgCodePageToEncoding=Bh;exports.euclideanModulo=Qa;exports.evaluateNurbsPoint=$s;exports.floorPowerOfTwo=gh;exports.generateChordKnots=Sh;exports.generateSqrtChordKnots=Ph;exports.generateUUID=th;exports.generateUniformKnots=Ih;exports.has=jl;exports.intPartLength=to;exports.interpolateControlPoints=ld;exports.inverseLerp=rh;exports.isBetween=_h;exports.isBetweenAngle=fh;exports.isEmpty=Dl;exports.isEqual=Jn;exports.isImperialUnits=Ad;exports.isMetricUnits=Pd;exports.isPointInPolygon=so;exports.isPolygonIntersect=wh;exports.isPowerOfTwo=ph;exports.lerp=Ja;exports.log=Ys;exports.mapLinear=eh;exports.normalizeAngle=qs;exports.pingpong=sh;exports.radToDeg=dh;exports.randFloat=lh;exports.randFloatSpread=hh;exports.randInt=oh;exports.relativeEps=yh;exports.seededRandom=uh;exports.setAcDbHostApplicationServicesProvider=Zl;exports.setAcDbLayoutManagerFactory=Ql;exports.setLogLevel=nd;exports.smootherstep=ah;exports.smoothstep=ih;
|