@mlightcad/cad-simple-viewer-cli 1.7.8-preview.0 → 1.7.8-preview.1
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/LICENSE +21 -21
- package/README.md +163 -163
- package/dist-runner/assets/{cad-html-plugin-DcL4hbLo.js → cad-html-plugin-sPFUE7nW.js} +2 -2
- package/dist-runner/assets/{cad-pdf-plugin-SbwTrPyy.js → cad-pdf-plugin-BBOPzTrv.js} +2 -2
- package/dist-runner/assets/{cad-svg-plugin-BrF5C6WG.js → cad-svg-plugin-CXH4E96n.js} +2 -2
- package/dist-runner/assets/{index-CkMa1VwR.js → index-Dvp0LgkP.js} +2 -2
- package/dist-runner/index.html +12 -12
- package/examples/batch-export-html-multi-preview.mjs +306 -306
- package/examples/batch-export-html.mjs +105 -105
- package/examples/batch-export-png.mjs +103 -103
- package/examples/create-drawing-dxf.scr +15 -15
- package/examples/create-drawing-png.scr +19 -19
- package/examples/create-shapes-dxf.scr +17 -17
- package/examples/export-dxf.scr +5 -5
- package/examples/export-html-multi-preview.scr +20 -20
- package/examples/export-html-multi.scr +15 -15
- package/examples/export-html.scr +12 -12
- package/examples/export-pdf.scr +9 -9
- package/examples/export-png.scr +9 -9
- package/examples/freeze-layer-png.scr +15 -15
- package/examples/index.json +114 -114
- package/examples/open-quit.scr +2 -2
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();const OG="modulepreload",DG=function(r,e){return new URL(r,e).href},TI={},Qg=function(e,t,n){let i=Promise.resolve();if(t&&t.length>0){let a=function(u){return Promise.all(u.map(h=>Promise.resolve(h).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const s=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=a(t.map(u=>{if(u=DG(u,n),u in TI)return;TI[u]=!0;const h=u.endsWith(".css"),d=h?'[rel="stylesheet"]':"";if(!!n)for(let m=s.length-1;m>=0;m--){const g=s[m];if(g.href===u&&(!h||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const p=document.createElement("link");if(p.rel=h?"stylesheet":OG,h||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),h)return new Promise((m,g)=>{p.addEventListener("load",m),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(a){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=a,window.dispatchEvent(s),!s.defaultPrevented)throw a}return i.then(a=>{for(const s of a||[])s.status==="rejected"&&o(s.reason);return e().catch(o)})},RG="HtmlPlugin",FG=["-chtml","chtml"];let Q_={};function BG(r,e){e&&(Q_={...Q_,...e});const t={...Q_};r.registerLazyPlugin({name:RG,triggers:[...FG],loader:async()=>{const{createHtmlPlugin:n}=await Qg(async()=>{const{createHtmlPlugin:i}=await import("./cad-html-plugin-DcL4hbLo.js");return{createHtmlPlugin:i}},[],import.meta.url);return n(t)}})}const NG="PdfPlugin",zG=["-cpdf","cpdf","ipdf"];function jG(r,e={}){const t=e.disableExport===!0,n=t?["ipdf"]:[...zG];r.registerLazyPlugin({name:NG,triggers:[...n],loader:async()=>{const{createPdfPlugin:i}=await Qg(async()=>{const{createPdfPlugin:o}=await import("./cad-pdf-plugin-SbwTrPyy.js");return{createPdfPlugin:o}},[],import.meta.url);return i({disableExport:t})}})}var na;(function(r){r[r.Invalid=-9999]="Invalid",r[r.Start=0]="Start",r[r.Text=1]="Text",r[r.AttributeTag=2]="AttributeTag",r[r.BlockName=2]="BlockName",r[r.ShapeName=2]="ShapeName",r[r.SymbolTableName=2]="SymbolTableName",r[r.SymbolTableRecordName=2]="SymbolTableRecordName",r[r.MlineStyleName=2]="MlineStyleName",r[r.AttributePrompt=3]="AttributePrompt",r[r.Description=3]="Description",r[r.DimPostString=3]="DimPostString",r[r.DimStyleName=3]="DimStyleName",r[r.LinetypeProse=3]="LinetypeProse",r[r.TextFontFile=3]="TextFontFile",r[r.CLShapeName=4]="CLShapeName",r[r.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",r[r.SymbolTableRecordComments=4]="SymbolTableRecordComments",r[r.TextBigFontFile=4]="TextBigFontFile",r[r.Handle=5]="Handle",r[r.DimensionBlock=5]="DimensionBlock",r[r.LinetypeName=6]="LinetypeName",r[r.DimBlk1=6]="DimBlk1",r[r.TextStyleName=7]="TextStyleName",r[r.DimBlk2=7]="DimBlk2",r[r.LayerName=8]="LayerName",r[r.CLShapeText=9]="CLShapeText",r[r.XCoordinate=10]="XCoordinate",r[r.YCoordinate=20]="YCoordinate",r[r.ZCoordinate=30]="ZCoordinate",r[r.Real=40]="Real",r[r.TxtSize=40]="TxtSize",r[r.ViewportHeight=40]="ViewportHeight",r[r.Angle=50]="Angle",r[r.ViewportSnapAngle=50]="ViewportSnapAngle",r[r.Visibility=60]="Visibility",r[r.Int16=70]="Int16",r[r.Int32=90]="Int32",r[r.Int64=160]="Int64",r[r.Int8=280]="Int8",r[r.Thickness=39]="Thickness",r[r.Elevation=38]="Elevation",r[r.LinetypeScale=48]="LinetypeScale",r[r.DashLength=49]="DashLength",r[r.MlineOffset=49]="MlineOffset",r[r.LinetypeElement=49]="LinetypeElement",r[r.NormalX=210]="NormalX",r[r.NormalY=220]="NormalY",r[r.NormalZ=230]="NormalZ",r[r.UcsOrg=110]="UcsOrg",r[r.UcsOrientationX=111]="UcsOrientationX",r[r.UcsOrientationY=112]="UcsOrientationY",r[r.ViewHeight=45]="ViewHeight",r[r.ViewWidth=41]="ViewWidth",r[r.ViewLensLength=42]="ViewLensLength",r[r.ViewFrontClip=43]="ViewFrontClip",r[r.ViewBackClip=44]="ViewBackClip",r[r.ViewBrightness=141]="ViewBrightness",r[r.ViewContrast=142]="ViewContrast",r[r.ViewMode=71]="ViewMode",r[r.ViewportActive=68]="ViewportActive",r[r.ViewportAspect=41]="ViewportAspect",r[r.ViewportGrid=76]="ViewportGrid",r[r.ViewportIcon=74]="ViewportIcon",r[r.ViewportNumber=69]="ViewportNumber",r[r.ViewportSnap=75]="ViewportSnap",r[r.ViewportSnapPair=78]="ViewportSnapPair",r[r.ViewportSnapStyle=77]="ViewportSnapStyle",r[r.ViewportTwist=51]="ViewportTwist",r[r.ViewportVisibility=67]="ViewportVisibility",r[r.ViewportZoom=73]="ViewportZoom",r[r.Color=62]="Color",r[r.ColorRgb=420]="ColorRgb",r[r.ColorName=430]="ColorName",r[r.LineWeight=370]="LineWeight",r[r.PlotStyleNameType=380]="PlotStyleNameType",r[r.PlotStyleNameId=390]="PlotStyleNameId",r[r.GradientObjType=450]="GradientObjType",r[r.GradientAngle=460]="GradientAngle",r[r.GradientName=470]="GradientName",r[r.GradientColCount=453]="GradientColCount",r[r.GradientPatType=451]="GradientPatType",r[r.GradientTintType=452]="GradientTintType",r[r.GradientShift=461]="GradientShift",r[r.GradientColVal=463]="GradientColVal",r[r.GradientTintVal=462]="GradientTintVal",r[r.SoftPointerId=330]="SoftPointerId",r[r.HardPointerId=340]="HardPointerId",r[r.SoftOwnershipId=350]="SoftOwnershipId",r[r.HardOwnershipId=360]="HardOwnershipId",r[r.ArbitraryHandle=320]="ArbitraryHandle",r[r.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",r[r.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",r[r.ExtendedDataControlString=1002]="ExtendedDataControlString",r[r.ExtendedDataLayerName=1003]="ExtendedDataLayerName",r[r.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",r[r.ExtendedDataHandle=1005]="ExtendedDataHandle",r[r.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",r[r.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",r[r.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",r[r.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",r[r.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",r[r.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",r[r.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",r[r.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",r[r.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",r[r.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",r[r.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",r[r.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",r[r.ExtendedDataReal=1040]="ExtendedDataReal",r[r.ExtendedDataDist=1041]="ExtendedDataDist",r[r.ExtendedDataScale=1042]="ExtendedDataScale",r[r.ExtendedDataInteger16=1070]="ExtendedDataInteger16",r[r.ExtendedDataInteger32=1071]="ExtendedDataInteger32",r[r.XTextString=300]="XTextString",r[r.XReal=140]="XReal",r[r.XInt16=170]="XInt16",r[r.XXInt16=270]="XXInt16",r[r.Subclass=100]="Subclass",r[r.ControlString=102]="ControlString",r[r.EmbeddedObjectStart=101]="EmbeddedObjectStart",r[r.End=-1]="End",r[r.FirstEntityId=-2]="FirstEntityId",r[r.HeaderId=-2]="HeaderId",r[r.XDataStart=-3]="XDataStart",r[r.Operator=-4]="Operator",r[r.PReactors=-5]="PReactors",r[r.XDictionary=-6]="XDictionary"})(na||(na={}));var Je;(function(r){r[r.ByColor=1]="ByColor",r[r.ByACI=2]="ByACI",r[r.ByLayer=3]="ByLayer",r[r.ByBlock=4]="ByBlock",r[r.None=0]="None"})(Je||(Je={}));var UG=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},VG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},II={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},e1=[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],Na=(function(){function r(){}return r.getColorByIndex=function(e){return e1[e]},r.getIndexByColor=function(e){for(var t=e1.length-1,n=1;n<t;++n)if(e1[n]===e)return n},r.getColorByName=function(e){return II[e.toLowerCase()]},r.getNameByColor=function(e){var t,n;try{for(var i=UG(Object.entries(II)),o=i.next();!o.done;o=i.next()){var a=VG(o.value,2),s=a[0],l=a[1];if(l===e)return s}}catch(c){t={error:c}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},r.getNameByIndex=function(e){var t=this.getColorByIndex(e);return this.getNameByColor(t)},r})(),HG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},nt=(function(){function r(e,t){e===void 0&&(e=Je.ByLayer),this._colorMethod=e,this._colorMethod==Je.ByColor&&t==null?this._value=16777215:this._colorMethod==Je.ByACI?t==null?this._value=8:t===0?this._colorMethod=Je.ByBlock:t===256?this._colorMethod=Je.ByLayer:this._value=Math.max(0,Math.min(t,256)):this._value=t}return Object.defineProperty(r.prototype,"colorMethod",{get:function(){return this._colorMethod},set:function(e){this._colorMethod=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"red",{get:function(){var e=this.RGB;return e!=null?e>>16&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"green",{get:function(){var e=this.RGB;return e!=null?e>>8&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blue",{get:function(){var e=this.RGB;return e!=null?e&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"RGB",{get:function(){switch(this._colorMethod){case Je.ByColor:case Je.ByBlock:case Je.ByLayer:return this._value;case Je.ByACI:return this._value?Na.getColorByIndex(this._value):this._value;default:return}},enumerable:!1,configurable:!0}),r.prototype.setRGB=function(e,t,n){var i=Math.max(0,Math.min(255,Math.round(e))),o=Math.max(0,Math.min(255,Math.round(t))),a=Math.max(0,Math.min(255,Math.round(n)));return this._value=i<<16|o<<8|a,this._colorMethod=Je.ByColor,this},r.prototype.setRGBValue=function(e){return e==null||!Number.isFinite(e)?(console.warn("Invalid RGB value:",e),this):(this._value=e&16777215,this._colorMethod=Je.ByColor,this)},r.prototype.setRGBFromCss=function(e){if(!e)return this;var t=e.trim().toLowerCase();if(t.startsWith("#")){var n=0,i=0,o=0;if(t.length===7)n=parseInt(t.substr(1,2),16),i=parseInt(t.substr(3,2),16),o=parseInt(t.substr(5,2),16);else if(t.length===4)n=parseInt(t[1]+t[1],16),i=parseInt(t[2]+t[2],16),o=parseInt(t[3]+t[3],16);else return console.warn("Invalid hex color:",e),this;return this.setRGB(n,i,o)}var a=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(a){var n=parseInt(a[1],10),i=parseInt(a[2],10),o=parseInt(a[3],10);return this.setRGB(n,i,o)}var s=Na.getColorByName(e);return s!==void 0?this.setRGBValue(s):(console.warn("Unknown CSS color string:",e),this)},r.prototype.setScalar=function(e){return this.setRGB(e,e,e)},Object.defineProperty(r.prototype,"hexColor",{get:function(){var e=this.RGB;if(e!=null){var t=e.toString(16).padStart(6,"0").toUpperCase();return"0x"+t}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cssColor",{get:function(){var e=this.RGB;if(e!=null)return"rgb(".concat(e>>16&255,",").concat(e>>8&255,",").concat(e&255,")")},enumerable:!1,configurable:!0}),r.prototype.cssColorAlpha=function(e){var t=this.RGB;if(t!=null)return"rgba(".concat(t>>16&255,",").concat(t>>8&255,",").concat(t&255,",").concat(e,")")},Object.defineProperty(r.prototype,"colorIndex",{get:function(){return this._colorMethod===Je.ByACI?this._value:this._colorMethod===Je.ByLayer?256:this._colorMethod===Je.ByBlock?0:void 0},set:function(e){if(e!=null){var t=Math.max(0,Math.min(256,Math.round(e)));t===0?(this._colorMethod=Je.ByBlock,this._value=void 0):t===256?(this._colorMethod=Je.ByLayer,this._value=void 0):(this._colorMethod=Je.ByACI,this._value=t)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByColor",{get:function(){return this._colorMethod===Je.ByColor},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByACI",{get:function(){return this._colorMethod===Je.ByACI},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isForeground",{get:function(){return this._colorMethod===Je.ByACI&&this._value===7},enumerable:!1,configurable:!0}),r.prototype.setForeground=function(){return this._colorMethod=Je.ByACI,this._value=7,this},Object.defineProperty(r.prototype,"isByLayer",{get:function(){return this._colorMethod===Je.ByLayer},enumerable:!1,configurable:!0}),r.prototype.setByLayer=function(e){return this._colorMethod=Je.ByLayer,e==null?this._value=256:this._value=e,this},Object.defineProperty(r.prototype,"isByBlock",{get:function(){return this._colorMethod===Je.ByBlock},enumerable:!1,configurable:!0}),r.prototype.setByBlock=function(e){return this._colorMethod=Je.ByBlock,e==null?this._value=0:this._value=e,this},Object.defineProperty(r.prototype,"colorName",{get:function(){switch(this._colorMethod){case Je.ByLayer:return"ByLayer";case Je.ByBlock:return"ByBlock";case Je.ByColor:return this._value?Na.getNameByColor(this._value):"";case Je.ByACI:return this._value?Na.getNameByIndex(this._value):"";default:return}},set:function(e){if(e){var t=Na.getColorByName(e);t!==void 0?(this._value=t,this._colorMethod=Je.ByColor):console.warn("Unknown color name:",e)}},enumerable:!1,configurable:!0}),r.prototype.clone=function(){var e=new r;return e._colorMethod=this._colorMethod,e._value=this._value,e},r.prototype.copy=function(e){return this._colorMethod=e._colorMethod,this._value=e._value,this},r.prototype.equals=function(e){return this._colorMethod===e._colorMethod&&this._value===e._value},r.prototype.toString=function(){switch(this._colorMethod){case Je.None:return"None";case Je.ByLayer:return"ByLayer";case Je.ByBlock:return"ByBlock";case Je.ByACI:return this._value!==void 0?String(this._value):"";case Je.ByColor:return this._value?"RGB:".concat(this.red,",").concat(this.green,",").concat(this.blue):"";default:return""}},r.fromString=function(e){if(e){var t=e.trim();if(/^none$/i.test(t))return new r(Je.None);if(/^bylayer$/i.test(t))return new r(Je.ByLayer);if(/^byblock$/i.test(t))return new r(Je.ByBlock);var n=t.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(n){var i=Number(n[1]),o=Number(n[2]),a=Number(n[3]),s=new r(Je.ByColor);return s.setRGB(i,o,a),s}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(t)){var l=HG(t.split(",").map(Number),3),i=l[0],o=l[1],a=l[2],s=new r(Je.ByColor);return s.setRGB(i,o,a),s}if(/^\d+$/.test(t)){var c=parseInt(t,10);return new r(Je.ByACI,c)}if(/^book\$/i.test(t)){var u=t.substring(t.indexOf("$")+1),h=Na.getColorByName(u);if(h!=null)return new r(Je.ByColor,h);console.warn("Unknown color book entry:",e);return}var d=Na.getColorByName(t);if(d!=null)return new r(Je.ByColor,d);console.warn("Unknown color name:",e)}},r})(),qi={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")}},GG=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},WG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},$G=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},Ft=(function(){function r(){this.listeners=[]}return Object.defineProperty(r.prototype,"listenerCount",{get:function(){return this.listeners.length},enumerable:!1,configurable:!0}),r.prototype.addEventListener=function(e){this.listeners.push(e)},r.prototype.removeEventListener=function(e){this.listeners=this.listeners.filter(function(t){return t!==e})},r.prototype.replaceEventListener=function(e){this.removeEventListener(e),this.addEventListener(e)},r.prototype.dispatch=function(e){for(var t,n,i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];try{for(var a=GG(this.listeners),s=a.next();!s.done;s=a.next()){var l=s.value,c=l;c.call.apply(c,$G([null,e],WG(i),!1))}}catch(u){t={error:u}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},r})(),fE=function(){return fE=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},fE.apply(this,arguments)},XG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},YG=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},g4=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Rd(r){return r===null||typeof r!="object"?r:Array.isArray(r)?YG([],XG(r),!1):fE({},r)}function rf(r){if(r===null||typeof r!="object")return r;if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r))return r.map(rf);var e={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=rf(r[t]));return e}function Sa(r){for(var e,t,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];try{for(var o=g4(n),a=o.next();!a.done;a=o.next()){var s=a.value;if(s)for(var l in s)Object.prototype.hasOwnProperty.call(s,l)&&r[l]===void 0&&(r[l]=s[l])}}catch(c){e={error:c}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return r}function y4(r,e){return r!=null&&Object.prototype.hasOwnProperty.call(r,e)}function v4(r){return r==null?!0:Array.isArray(r)||typeof r=="string"?r.length===0:r instanceof Map||r instanceof Set?r.size===0:typeof r=="object"?Object.keys(r).length===0:!1}function Yc(r,e){var t,n;if(r===e)return!0;if(r==null||e==null)return r===e;if(typeof r!=typeof e)return!1;if(typeof r!="object")return r===e;if(Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)){if(r.length!==e.length)return!1;for(var i=0;i<r.length;i++)if(!Yc(r[i],e[i]))return!1;return!0}var o=Object.keys(r),a=Object.keys(e);if(o.length!==a.length)return!1;try{for(var s=g4(o),l=s.next();!l.done;l=s.next()){var c=l.value;if(!Object.prototype.hasOwnProperty.call(e,c)||!Yc(r[c],e[c]))return!1}}catch(u){t={error:u}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return!0}function qG(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Qb={exports:{}},KG=Qb.exports,LI;function ZG(){return LI||(LI=1,(function(r){(function(e,t){r.exports?r.exports=t():e.log=t()})(KG,function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],o={},a=null;function s(m,g){var y=m[g];if(typeof y.bind=="function")return y.bind(m);try{return Function.prototype.bind.call(y,m)}catch{return function(){return Function.prototype.apply.apply(y,[m,arguments])}}}function l(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(m){return m==="debug"&&(m="log"),typeof console===t?!1:m==="trace"&&n?l:console[m]!==void 0?s(console,m):console.log!==void 0?s(console,"log"):e}function u(){for(var m=this.getLevel(),g=0;g<i.length;g++){var y=i[g];this[y]=g<m?e:this.methodFactory(y,m,this.name)}if(this.log=this.debug,typeof console===t&&m<this.levels.SILENT)return"No console available for logging"}function h(m){return function(){typeof console!==t&&(u.call(this),this[m].apply(this,arguments))}}function d(m,g,y){return c(m)||h.apply(this,arguments)}function f(m,g){var y=this,v,x,b,w="loglevel";typeof m=="string"?w+=":"+m:typeof m=="symbol"&&(w=void 0);function _(k){var T=(i[k]||"silent").toUpperCase();if(!(typeof window===t||!w)){try{window.localStorage[w]=T;return}catch{}try{window.document.cookie=encodeURIComponent(w)+"="+T+";"}catch{}}}function P(){var k;if(!(typeof window===t||!w)){try{k=window.localStorage[w]}catch{}if(typeof k===t)try{var T=window.document.cookie,O=encodeURIComponent(w),I=T.indexOf(O+"=");I!==-1&&(k=/^([^;]+)/.exec(T.slice(I+O.length+1))[1])}catch{}return y.levels[k]===void 0&&(k=void 0),k}}function S(){if(!(typeof window===t||!w)){try{window.localStorage.removeItem(w)}catch{}try{window.document.cookie=encodeURIComponent(w)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function E(k){var T=k;if(typeof T=="string"&&y.levels[T.toUpperCase()]!==void 0&&(T=y.levels[T.toUpperCase()]),typeof T=="number"&&T>=0&&T<=y.levels.SILENT)return T;throw new TypeError("log.setLevel() called with invalid level: "+k)}y.name=m,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=g||d,y.getLevel=function(){return b??x??v},y.setLevel=function(k,T){return b=E(k),T!==!1&&_(b),u.call(y)},y.setDefaultLevel=function(k){x=E(k),P()||y.setLevel(k,!1)},y.resetLevel=function(){b=null,S(),u.call(y)},y.enableAll=function(k){y.setLevel(y.levels.TRACE,k)},y.disableAll=function(k){y.setLevel(y.levels.SILENT,k)},y.rebuild=function(){if(a!==y&&(v=E(a.getLevel())),u.call(y),a===y)for(var k in o)o[k].rebuild()},v=E(a?a.getLevel():"WARN");var C=P();C!=null&&(b=E(C)),u.call(y)}a=new f,a.getLogger=function(g){if(typeof g!="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var y=o[g];return y||(y=o[g]=new f(g,a.methodFactory)),y};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return o},a.default=a,a})})(Qb)),Qb.exports}var JG=ZG();const QG=qG(JG);var Ht=QG.getLogger("mlightcad");Ht.setDefaultLevel("warn");var pE=(function(){function r(e,t){this._changing=!1,this._pending=!1;var n=e||{};t&&Sa(n,t),this.attributes=n}return Object.defineProperty(r.prototype,"events",{get:function(){var e;return(e=this._events)!==null&&e!==void 0?e:this._events={attrChanged:new Ft,modelChanged:new Ft}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"changed",{get:function(){var e;return(e=this._changed)!==null&&e!==void 0?e:this._changed={}},enumerable:!1,configurable:!0}),r.prototype.get=function(e){return this.attributes[e]},r.prototype.set=function(e,t,n){var i,o,a,s;if(e==null)return this;var l;typeof e=="object"?(l=e,n=t):(l={},l[e]=t),n||(n={});var c=n.unset,u=n.silent,h=this._events;if(!c&&!this._changing&&(h===void 0||h.attrChanged.listenerCount===0&&h.modelChanged.listenerCount===0)){if(typeof e=="object"){var d=e;for(var f in d)this.attributes[f]=d[f]}else this.attributes[e]=t;return this}if(!c){var p=!0;for(var f in l)if(this.attributes[f]!==l[f]){p=!1;break}if(p)return this._changing||(this._previousAttributes=Rd(this.attributes),this._changed={}),this}var m=null,g=this._changing;this._changing=!0,g||(this._previousAttributes=Rd(this.attributes),this._changed={});var y=this.attributes,v=(i=this._changed)!==null&&i!==void 0?i:this._changed={},x=(o=this._previousAttributes)!==null&&o!==void 0?o:{};for(var f in l){if(t=l[f],!c&&y[f]===t){x[f]===t||Yc(x[f],t)?delete v[f]:v[f]=t;continue}Yc(y[f],t)||(m||(m=[])).push(f),Yc(x[f],t)?delete v[f]:v[f]=t,c?delete y[f]:y[f]=t}if(!u&&(m&&(this._pending=n),m))for(var b=0;b<m.length;b++)(a=this._events)===null||a===void 0||a.attrChanged.dispatch({object:this,attrName:m[b],attrValue:y[m[b]],options:n});if(g)return this;if(!u)for(;this._pending;)n=this._pending,this._pending=!1,(s=this._events)===null||s===void 0||s.modelChanged.dispatch({object:this,options:n});return this._pending=!1,this._changing=!1,this},r.prototype.has=function(e){return this.get(e)!=null},r.prototype.hasChanged=function(e){return e==null?!v4(this._changed):this._changed?y4(this._changed,e):!1},r.prototype.changedAttributes=function(e){var t;if(!e)return this.hasChanged()?Rd((t=this._changed)!==null&&t!==void 0?t:{}):{};var n=this._changing?this._previousAttributes:this.attributes,i={};for(var o in e){var a=e[o];Yc(n==null?void 0:n[o],a)||(i[o]=a)}return i},r.prototype.previous=function(e){var t;return e==null?null:(t=this._previousAttributes)===null||t===void 0?void 0:t[e]},r.prototype.previousAttributes=function(){var e;return Rd((e=this._previousAttributes)!==null&&e!==void 0?e:{})},r.prototype.clone=function(){var e=Rd(this.attributes);return new r(e)},r})(),eW=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},tW=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},ey=(function(){function r(){this.entries=new Map}return r.getInstance=function(){return r.instance||(r.instance=new r),r.instance},r.prototype.collect=function(e){this.entries.set(e.name,e)},r.prototype.printAll=function(){var e,t;try{for(var n=eW(this.entries),i=n.next();!i.done;i=n.next()){var o=tW(i.value,2),a=o[0],s=o[1];console.log("".concat(a,":")),console.log(s.format())}}catch(l){e={error:l}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.clear=function(){this.entries.clear()},r.prototype.getAll=function(){return Array.from(this.entries.values())},r.prototype.getEntry=function(e){return this.entries.get(e)},r.prototype.remove=function(e){return this.entries.delete(e)},r})(),Gr;(function(r){r[r.ByLayer=0]="ByLayer",r[r.ByBlock=1]="ByBlock",r[r.ByAlpha=2]="ByAlpha",r[r.ErrorValue=3]="ErrorValue"})(Gr||(Gr={}));var tr=(function(){function r(e){e!==void 0?(this._method=Gr.ByAlpha,this._alpha=r.clampAlpha(e)):(this._method=Gr.ByLayer,this._alpha=255)}return Object.defineProperty(r.prototype,"method",{get:function(){return this._method},set:function(e){this._method=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"alpha",{get:function(){return this._alpha},set:function(e){this._alpha=r.clampAlpha(e),this._method=Gr.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"percentage",{get:function(){if(this._method===Gr.ByAlpha)return Math.round((1-this._alpha/255)*100)},set:function(e){var t=Math.max(0,Math.min(100,e)),n=Math.round(255*(1-t/100));this.alpha=n},enumerable:!1,configurable:!0}),r.clampAlpha=function(e){return Math.max(0,Math.min(255,Math.floor(e)))},Object.defineProperty(r.prototype,"isByAlpha",{get:function(){return this._method===Gr.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByBlock",{get:function(){return this._method===Gr.ByBlock},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByLayer",{get:function(){return this._method===Gr.ByLayer},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isClear",{get:function(){return this.isByAlpha&&this._alpha===0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSolid",{get:function(){return this.isByAlpha&&this._alpha===255},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isInvalid",{get:function(){return this._method===Gr.ErrorValue},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var e=this._method;return e<<24|this._alpha},r.prototype.clone=function(){var e=new r;return e._method=this._method,e._alpha=this._alpha,e},r.prototype.equals=function(e){return this._method===e._method&&this._alpha===e._alpha},r.prototype.toString=function(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()},r.fromString=function(e){var t=e.trim(),n=t.toLowerCase();if(n===""||n==="."||n==="use current"||n==="bylayer"){var i=new r;return i._method=Gr.ByLayer,i}if(n==="byblock"){var o=new r;return o._method=Gr.ByBlock,o}var a=Number(t);if(Number.isInteger(a)&&a>=0&&a<=255){var s=new r;return a<=90?s.percentage=a:s.alpha=a,s}var l=new r;return l._method=Gr.ErrorValue,l},r.deserialize=function(e){var t=e>>>24&255,n=e&255,i=t>=Gr.ByLayer&&t<=Gr.ErrorValue?t:Gr.ErrorValue,o=new r;return o._method=i,o._alpha=r.clampAlpha(n),o},r})(),nW=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(u){try{c(n.next(u))}catch(h){a(h)}}function l(u){try{c(n.throw(u))}catch(h){a(h)}}function c(u){u.done?o(u.value):i(u.value).then(s,l)}c((n=n.apply(r,e||[])).next())})},rW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},fg=50;function cp(){return new Promise(function(r){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return r()}):setTimeout(r,0)})}function ou(){return new Promise(function(r){if(typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"){var e=globalThis.requestAnimationFrame;e(function(){return e(function(){return r()})})}else setTimeout(r,0)})}var ty=(function(){function r(e){e===void 0&&(e=fg),this._budgetMs=e,this._lastYieldCompletedAt=r.now()}return Object.defineProperty(r.prototype,"budgetMs",{get:function(){return this._budgetMs},enumerable:!1,configurable:!0}),r.prototype.maybeYield=function(){return nW(this,arguments,void 0,function(e){var t;return e===void 0&&(e=cp),rW(this,function(n){switch(n.label){case 0:return t=r.now(),t-this._lastYieldCompletedAt<this._budgetMs?[2,!1]:[4,e()];case 1:return n.sent(),this._lastYieldCompletedAt=r.now(),[2,!0]}})})},r.prototype.mark=function(){this._lastYieldCompletedAt=r.now()},r.now=function(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()},r})(),t1=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(u){try{c(n.next(u))}catch(h){a(h)}}function l(u){try{c(n.throw(u))}catch(h){a(h)}}function c(u){u.done?o(u.value):i(u.value).then(s,l)}c((n=n.apply(r,e||[])).next())})},Uy=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},b4=(function(){function r(e){this.name=e}return r.prototype.run=function(e){throw new Error("run() must be implemented by subclass")},r})(),x4=(function(){function r(){this.tasks=[],this.onProgress=function(){},this.onComplete=function(){},this.onError=function(){return!1}}return r.prototype.scheduleTask=function(e){return t1(this,void 0,void 0,function(){return Uy(this,function(t){switch(t.label){case 0:return[4,cp()];case 1:return t.sent(),[2,e()]}})})},r.prototype.addTask=function(e){this.tasks.push(e)},r.prototype.setProgressCallback=function(e){this.onProgress=e},r.prototype.setCompleteCallback=function(e){this.onComplete=e},r.prototype.setErrorCallback=function(e){this.onError=e},r.prototype.run=function(e){return t1(this,void 0,void 0,function(){var t,n,i,o,a,s,l=this;return Uy(this,function(c){switch(c.label){case 0:t=this.tasks.length,n=e,i=function(u){var h,d,f;return Uy(this,function(p){switch(p.label){case 0:h=o.tasks[u],p.label=1;case 1:return p.trys.push([1,3,,4]),[4,o.scheduleTask(function(){return t1(l,void 0,void 0,function(){var m;return Uy(this,function(g){switch(g.label){case 0:return[4,h.run(n)];case 1:return m=g.sent(),this.onProgress((u+1)/t,h),[2,m]}})})})];case 2:return n=p.sent(),[3,4];case 3:return d=p.sent(),f=o.onError({error:d,taskIndex:u,task:h}),f?[2,{value:Promise.reject(d)}]:[3,4];case 4:return[2]}})},o=this,a=0,c.label=1;case 1:return a<t?[5,i(a)]:[3,4];case 2:if(s=c.sent(),typeof s=="object")return[2,s.value];c.label=3;case 3:return a++,[3,1];case 4:return this.onComplete(n),[2]}})})},r})(),ui=["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"],OI=1234567,Jk=Math.PI/180,Qk=180/Math.PI;function w4(){var r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=ui[r&255]+ui[r>>8&255]+ui[r>>16&255]+ui[r>>24&255]+"-"+ui[e&255]+ui[e>>8&255]+"-"+ui[e>>16&15|64]+ui[e>>24&255]+"-"+ui[t&63|128]+ui[t>>8&255]+"-"+ui[t>>16&255]+ui[t>>24&255]+ui[n&255]+ui[n>>8&255]+ui[n>>16&255]+ui[n>>24&255];return i.toLowerCase()}function Tf(r,e,t){return Math.max(e,Math.min(t,r))}function eA(r,e){return(r%e+e)%e}function _4(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function S4(r,e,t){return r!==e?(t-r)/(e-r):0}function tA(r,e,t){return(1-t)*r+t*e}function P4(r,e,t,n){return tA(r,e,1-Math.exp(-t*n))}function E4(r,e){return e===void 0&&(e=1),e-Math.abs(eA(r,e*2)-e)}function M4(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function k4(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function A4(r,e){return r+Math.floor(Math.random()*(e-r+1))}function C4(r,e){return r+Math.random()*(e-r)}function T4(r){return r*(.5-Math.random())}function I4(r){r!==void 0&&(OI=r);var e=OI+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function L4(r){return r*Jk}function O4(r){return r*Qk}function D4(r){return(r&r-1)===0&&r!==0}function R4(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function F4(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function th(r){var e=Math.PI*2;return(r%e+e)%e}function B4(r,e,t){return r>e&&r<t||r>t&&r<e}function N4(r,e,t,n){return n===void 0&&(n=!1),r=th(r),e=th(e),t=th(t),n?e>t?r<=e&&r>=t:r<=e||r>=t:e<t?r>=e&&r<=t:r>=e||r<=t}function z4(r,e,t){var n=th(t-r),i=th(e-r);return i<=n+1e-7}function nA(r){return r=Math.abs(r),r<1?0:Math.ceil(Math.log10(Math.abs(r)+1))}function j4(r,e){e===void 0&&(e=1e-7);var t=nA(r);return Math.max(Math.pow(10,t)*e,e)}var Te={DEG2RAD:Jk,RAD2DEG:Qk,generateUUID:w4,clamp:Tf,euclideanModulo:eA,mapLinear:_4,inverseLerp:S4,lerp:tA,damp:P4,pingpong:E4,smoothstep:M4,smootherstep:k4,randInt:A4,randFloat:C4,randFloatSpread:T4,seededRandom:I4,degToRad:L4,radToDeg:O4,isPowerOfTwo:D4,ceilPowerOfTwo:R4,floorPowerOfTwo:F4,normalizeAngle:th,isBetween:B4,isBetweenAngle:N4,isAngleOnCcwSweep:z4,intPartLength:nA,relativeEps:j4},iW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},vn=(function(){function r(e,t){this.x=0,this.y=0;var n=+(e!==void 0)+ +(t!==void 0);if(n!==0){if(n===1&&e instanceof Array){this.x=e[0],this.y=e[1];return}if(n===1){var i=e,o=i.x,a=i.y;this.x=o,this.y=a;return}if(n===2){this.x=e,this.y=t;return}throw qi.ILLEGAL_PARAMETERS}}return Object.defineProperty(r.prototype,"width",{get:function(){return this.x},set:function(e){this.x=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this.y},set:function(e){this.y=e},enumerable:!1,configurable:!0}),r.prototype.set=function(e,t){return this.x=e,this.y=t,this},r.prototype.setScalar=function(e){return this.x=e,this.y=e,this},r.prototype.setX=function(e){return this.x=e,this},r.prototype.setY=function(e){return this.y=e,this},r.prototype.setComponent=function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},r.prototype.getComponent=function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},r.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},r.prototype.addScalar=function(e){return this.x+=e,this.y+=e,this},r.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},r.prototype.addScaledVector=function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},r.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this},r.prototype.subScalar=function(e){return this.x-=e,this.y-=e,this},r.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},r.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this},r.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this},r.prototype.divide=function(e){return this.x/=e.x,this.y/=e.y,this},r.prototype.divideScalar=function(e){return this.multiplyScalar(1/e)},r.prototype.applyMatrix2d=function(e){var t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this},r.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},r.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},r.prototype.clamp=function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},r.prototype.clampScalar=function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},r.prototype.clampLength=function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},r.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},r.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},r.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},r.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},r.prototype.dot=function(e){return this.x*e.x+this.y*e.y},r.prototype.cross=function(e){return this.x*e.y-this.y*e.x},r.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)},r.prototype.normalize=function(){return this.divideScalar(this.length()||1)},r.prototype.angle=function(){var e=Math.atan2(-this.y,-this.x)+Math.PI;return e},r.prototype.angleTo=function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,n)))},r.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},r.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},r.prototype.manhattanDistanceTo=function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},r.prototype.setLength=function(e){return this.normalize().multiplyScalar(e)},r.prototype.lerp=function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},r.prototype.lerpVectors=function(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this},r.prototype.equals=function(e){return e.x===this.x&&e.y===this.y},r.prototype.fromArray=function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this},r.prototype.toArray=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e},r.prototype.rotateAround=function(e,t){var n=Math.cos(t),i=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*i+e.x,this.y=o*i+a*n+e.y,this},r.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this},r.prototype.relativeEps=function(e){return e===void 0&&(e=1e-7),Math.min(Te.relativeEps(this.x,e),Te.relativeEps(this.y,e))},r.prototype[Symbol.iterator]=function(){return iW(this,function(e){switch(e.label){case 0:return[4,this.x];case 1:return e.sent(),[4,this.y];case 2:return e.sent(),[2]}})},r.EMPTY=Object.freeze(new r(0,0)),r})(),ny=(function(){function r(e,t,n,i,o,a,s,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!=null&&t!=null&&n!=null&&i!=null&&o!=null&&a!=null&&s!=null&&l!=null&&c!=null&&this.set(e,t,n,i,o,a,s,l,c)}return r.prototype.set=function(e,t,n,i,o,a,s,l,c){var u=this.elements;return u[0]=e,u[1]=i,u[2]=s,u[3]=t,u[4]=o,u[5]=l,u[6]=n,u[7]=a,u[8]=c,this},r.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},r.prototype.copy=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},r.prototype.extractBasis=function(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this},r.prototype.setFromMatrix4=function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},r.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},r.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},r.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,o=this.elements,a=n[0],s=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],p=n[8],m=i[0],g=i[3],y=i[6],v=i[1],x=i[4],b=i[7],w=i[2],_=i[5],P=i[8];return o[0]=a*m+s*v+l*w,o[3]=a*g+s*x+l*_,o[6]=a*y+s*b+l*P,o[1]=c*m+u*v+h*w,o[4]=c*g+u*x+h*_,o[7]=c*y+u*b+h*P,o[2]=d*m+f*v+p*w,o[5]=d*g+f*x+p*_,o[8]=d*y+f*b+p*P,this},r.prototype.multiplyScalar=function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},r.prototype.determinant=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*s*c-n*o*u+n*s*l+i*o*c-i*a*l},r.prototype.invert=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=u*a-s*c,d=s*l-u*o,f=c*o-a*l,p=t*h+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);var m=1/p;return e[0]=h*m,e[1]=(i*c-u*n)*m,e[2]=(s*n-i*a)*m,e[3]=d*m,e[4]=(u*t-i*l)*m,e[5]=(i*o-s*t)*m,e[6]=f*m,e[7]=(n*l-c*t)*m,e[8]=(a*t-n*o)*m,this},r.prototype.transpose=function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},r.prototype.getNormalMatrix=function(e){return this.setFromMatrix4(e).invert().transpose()},r.prototype.transposeIntoArray=function(e){var t=this.elements;return e.elements[0]=t[0],e.elements[1]=t[3],e.elements[2]=t[6],e.elements[3]=t[1],e.elements[4]=t[4],e.elements[5]=t[7],e.elements[6]=t[2],e.elements[7]=t[5],e.elements[8]=t[8],this},r.prototype.setUvTransform=function(e,t,n,i,o,a,s){var l=Math.cos(o),c=Math.sin(o);return this.set(n*l,n*c,-n*(l*a+c*s)+a+e,-i*c,i*l,-i*(-c*a+l*s)+s+t,0,0,1),this},r.prototype.scale=function(e,t){return this.premultiply(n1.makeScale(e,t)),this},r.prototype.rotate=function(e){return this.premultiply(n1.makeRotation(-e)),this},r.prototype.translate=function(e,t){return this.premultiply(n1.makeTranslation(e,t)),this},r.prototype.makeTranslation=function(e,t){return e instanceof vn?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this},r.prototype.makeRotation=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this},r.prototype.makeScale=function(e,t){return this.set(e,0,0,0,t,0,0,0,1),this},r.prototype.equals=function(e){for(var t=this.elements,n=e.elements,i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0},r.prototype.fromArray=function(e,t){t===void 0&&(t=0);for(var n=0;n<9;n++)this.elements[n]=e[n+t];return this},r.prototype.toArray=function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e},r.prototype.clone=function(){return new r().fromArray(this.elements)},r.IDENTITY=Object.freeze(new r),r})(),n1=new ny,tn=1e-6,lt=2*Math.PI,rA={x:0,y:0,z:0},Le=(function(){function r(){this.equalPointTol=tn,this.equalVectorTol=tn}return r.prototype.clone=function(){var e=new r;return e.equalPointTol=this.equalPointTol,e.equalVectorTol=this.equalVectorTol,e},r.prototype.equalPoint2d=function(e,t){return new vn(e).sub(t).length()<this.equalPointTol},r.prototype.equalPoint3d=function(e,t){return new X(e).sub(t).length()<this.equalPointTol},r.equalToZero=function(e,t){return t===void 0&&(t=tn),e<t&&e>-t},r.equal=function(e,t,n){return n===void 0&&(n=tn),Math.abs(e-t)<n},r.great=function(e,t,n){return n===void 0&&(n=tn),e-t>n},r.less=function(e,t,n){return n===void 0&&(n=tn),e-t<n},r.isPositive=function(e,t){return t===void 0&&(t=tn),e>t},r.isNonPositive=function(e,t){return t===void 0&&(t=tn),e<=t},r})(),du=new Le,oW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},pg=(function(){function r(e,t,n,i){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),i===void 0&&(i=1),this._x=e,this._y=t,this._z=n,this._w=i}return r.slerpFlat=function(e,t,n,i,o,a,s){var l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3],d=o[a+0],f=o[a+1],p=o[a+2],m=o[a+3];if(s===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(s===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(h!==m||l!==d||c!==f||u!==p){var g=1-s,y=l*d+c*f+u*p+h*m,v=y>=0?1:-1,x=1-y*y;if(x>Number.EPSILON){var b=Math.sqrt(x),w=Math.atan2(b,y*v);g=Math.sin(g*w)/b,s=Math.sin(s*w)/b}var _=s*v;if(l=l*g+d*_,c=c*g+f*_,u=u*g+p*_,h=h*g+m*_,g===1-s){var P=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=P,c*=P,u*=P,h*=P}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h},r.multiplyQuaternionsFlat=function(e,t,n,i,o,a){var s=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=o[a],d=o[a+1],f=o[a+2],p=o[a+3];return e[t]=s*p+u*h+l*f-c*d,e[t+1]=l*p+u*d+c*h-s*f,e[t+2]=c*p+u*f+s*d-l*h,e[t+3]=u*p-s*h-l*d-c*f,e},Object.defineProperty(r.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"w",{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),r.prototype.set=function(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this},r.prototype.clone=function(){return new r(this._x,this._y,this._z,this._w)},r.prototype.copy=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},r.prototype.setFromEuler=function(e,t){t===void 0&&(t=!0);var n=e.x,i=e.y,o=e.z,a=e.order,s=Math.cos,l=Math.sin,c=s(n/2),u=s(i/2),h=s(o/2),d=l(n/2),f=l(i/2),p=l(o/2);switch(a){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this},r.prototype.setFromAxisAngle=function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this},r.prototype.setFromRotationMatrix=function(e){var t=e.elements,n=t[0],i=t[4],o=t[8],a=t[1],s=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+s+h;if(d>0){var f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(o-c)*f,this._z=(a-i)*f}else if(n>s&&n>h){var f=2*Math.sqrt(1+n-s-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(o+c)/f}else if(s>h){var f=2*Math.sqrt(1+s-n-h);this._w=(o-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+u)/f}else{var f=2*Math.sqrt(1+h-n-s);this._w=(a-i)/f,this._x=(o+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this},r.prototype.setFromUnitVectors=function(e,t){var n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()},r.prototype.angleTo=function(e){return 2*Math.acos(Math.abs(Tf(this.dot(e),-1,1)))},r.prototype.rotateTowards=function(e,t){var n=this.angleTo(e);if(n===0)return this;var i=Math.min(1,t/n);return this.slerp(e,i),this},r.prototype.identity=function(){return this.set(0,0,0,1)},r.prototype.invert=function(){return this.conjugate()},r.prototype.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},r.prototype.dot=function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},r.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},r.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},r.prototype.normalize=function(){var e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this},r.prototype.multiply=function(e){return this.multiplyQuaternions(this,e)},r.prototype.premultiply=function(e){return this.multiplyQuaternions(e,this)},r.prototype.multiplyQuaternions=function(e,t){var n=e._x,i=e._y,o=e._z,a=e._w,s=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+a*s+i*c-o*l,this._y=i*u+a*l+o*s-n*c,this._z=o*u+a*c+n*l-i*s,this._w=a*u-n*s-i*l-o*c,this._onChangeCallback(),this},r.prototype.slerp=function(e,t){if(t===0)return this;if(t===1)return this.copy(e);var n=this._x,i=this._y,o=this._z,a=this._w,s=a*e._w+n*e._x+i*e._y+o*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=o,this;var l=1-s*s;if(l<=Number.EPSILON){var c=1-t;return this._w=c*a+t*this._w,this._x=c*n+t*this._x,this._y=c*i+t*this._y,this._z=c*o+t*this._z,this.normalize(),this}var u=Math.sqrt(l),h=Math.atan2(u,s),d=Math.sin((1-t)*h)/u,f=Math.sin(t*h)/u;return this._w=a*d+this._w*f,this._x=n*d+this._x*f,this._y=i*d+this._y*f,this._z=o*d+this._z*f,this._onChangeCallback(),this},r.prototype.slerpQuaternions=function(e,t,n){return this.copy(e).slerp(t,n)},r.prototype.random=function(){var e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),o*Math.sin(t),o*Math.cos(t))},r.prototype.equals=function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},r.prototype.fromArray=function(e,t){return t===void 0&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},r.prototype.toArray=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},r.prototype.toJSON=function(){return this.toArray()},r.prototype._onChange=function(e){return this._onChangeCallback=e,this},r.prototype._onChangeCallback=function(){},r.prototype[Symbol.iterator]=function(){return oW(this,function(e){switch(e.label){case 0:return[4,this._x];case 1:return e.sent(),[4,this._y];case 2:return e.sent(),[4,this._z];case 3:return e.sent(),[4,this._w];case 4:return e.sent(),[2]}})},r})(),aW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},X=(function(){function r(e,t,n){this.x=0,this.y=0,this.z=0;var i=+(e!==void 0)+ +(t!==void 0)+ +(n!==void 0);if(i!==0){if(i===1&&e instanceof Array){this.x=e[0],this.y=e[1],this.z=e[2];return}if(i===1){var o=e,a=o.x,s=o.y,l=o.z;this.x=a,this.y=s,this.z=l||0;return}if(i===3){this.x=e,this.y=t,this.z=n;return}throw qi.ILLEGAL_PARAMETERS}}return r.prototype.set=function(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this},r.prototype.setScalar=function(e){return this.x=e,this.y=e,this.z=e,this},r.prototype.setX=function(e){return this.x=e,this},r.prototype.setY=function(e){return this.y=e,this},r.prototype.setZ=function(e){return this.z=e,this},r.prototype.setComponent=function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},r.prototype.getComponent=function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},r.prototype.clone=function(){return new r(this.x,this.y,this.z)},r.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z||0,this},r.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z||0,this},r.prototype.addScalar=function(e){return this.x+=e,this.y+=e,this.z+=e,this},r.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},r.prototype.addScaledVector=function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},r.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},r.prototype.subScalar=function(e){return this.x-=e,this.y-=e,this.z-=e,this},r.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},r.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},r.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this},r.prototype.multiplyVectors=function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},r.prototype.applyEuler=function(e){return this.applyQuaternion(DI.setFromEuler(e))},r.prototype.applyAxisAngle=function(e,t){return this.applyQuaternion(DI.setFromAxisAngle(e,t))},r.prototype.applyMatrix3=function(e){var t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*i,this.y=o[1]*t+o[4]*n+o[7]*i,this.z=o[2]*t+o[5]*n+o[8]*i,this},r.prototype.applyNormalMatrix=function(e){return this.applyMatrix3(e).normalize()},r.prototype.applyMatrix4=function(e){var t=this.x,n=this.y,i=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*i+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*i+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*i+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*i+o[14])*a,this},r.prototype.applyQuaternion=function(e){var t=this.x,n=this.y,i=this.z,o=e.x,a=e.y,s=e.z,l=e.w,c=2*(a*i-s*n),u=2*(s*t-o*i),h=2*(o*n-a*t);return this.x=t+l*c+a*h-s*u,this.y=n+l*u+s*c-o*h,this.z=i+l*h+o*u-a*c,this},r.prototype.transformDirection=function(e){var t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i,this.y=o[1]*t+o[5]*n+o[9]*i,this.z=o[2]*t+o[6]*n+o[10]*i,this.normalize()},r.prototype.divide=function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},r.prototype.divideScalar=function(e){return this.multiplyScalar(1/e)},r.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},r.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},r.prototype.clamp=function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},r.prototype.clampScalar=function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},r.prototype.clampLength=function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},r.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},r.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},r.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},r.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},r.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},r.prototype.isParallelTo=function(e){var t=this.dot(e),n=this.length(),i=e.length();return Math.abs(t)===n*i},r.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},r.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},r.prototype.normalize=function(){return this.divideScalar(this.length()||1)},r.prototype.setLength=function(e){return this.normalize().multiplyScalar(e)},r.prototype.lerp=function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},r.prototype.lerpVectors=function(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this},r.prototype.cross=function(e){return this.crossVectors(this,e)},r.prototype.crossVectors=function(e,t){var n=e.x,i=e.y,o=e.z,a=t.x,s=t.y,l=t.z;return this.x=i*l-o*s,this.y=o*a-n*l,this.z=n*s-i*a,this},r.prototype.projectOnVector=function(e){var t=e.lengthSq();if(t===0)return this.set(0,0,0);var n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)},r.prototype.projectOnPlane=function(e){return r1.copy(this).projectOnVector(e),this.sub(r1)},r.prototype.reflect=function(e){return this.sub(r1.copy(e).multiplyScalar(2*this.dot(e)))},r.prototype.angleTo=function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,n)))},r.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},r.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i},r.prototype.manhattanDistanceTo=function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},r.prototype.setFromMatrixPosition=function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},r.prototype.setFromMatrixScale=function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this},r.prototype.setFromMatrixColumn=function(e,t){return this.fromArray(e.elements,t*4)},r.prototype.setFromMatrix3Column=function(e,t){return this.fromArray(e.elements,t*3)},r.prototype.equals=function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},r.prototype.fromArray=function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},r.prototype.toArray=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},r.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},r.prototype.randomDirection=function(){var e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this},r.prototype[Symbol.iterator]=function(){return aW(this,function(e){switch(e.label){case 0:return[4,this.x];case 1:return e.sent(),[4,this.y];case 2:return e.sent(),[4,this.z];case 3:return e.sent(),[2]}})},r.ORIGIN=Object.freeze(new r(0,0,0)),r.X_AXIS=Object.freeze(new r(1,0,0)),r.NEGATIVE_X_AXIS=Object.freeze(new r(-1,0,0)),r.Y_AXIS=Object.freeze(new r(0,1,0)),r.NEGATIVE_Y_AXIS=Object.freeze(new r(0,-1,0)),r.Z_AXIS=Object.freeze(new r(0,0,1)),r.NEGATIVE_Z_AXIS=Object.freeze(new r(0,0,-1)),r})(),r1=new X,DI=new pg,Ue=(function(){function r(e,t,n,i,o,a,s,l,c,u,h,d,f,p,m,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!=null&&t!=null&&n!=null&&i!=null&&o!=null&&a!=null&&s!=null&&l!=null&&c!=null&&u!=null&&h!=null&&d!=null&&f!=null&&p!=null&&m!=null&&g!=null&&this.set(e,t,n,i,o,a,s,l,c,u,h,d,f,p,m,g)}return r.makeTranslation=function(e,t,n){return new r().makeTranslation(e,t,n)},r.prototype.set=function(e,t,n,i,o,a,s,l,c,u,h,d,f,p,m,g){var y=this.elements;return y[0]=e,y[4]=t,y[8]=n,y[12]=i,y[1]=o,y[5]=a,y[9]=s,y[13]=l,y[2]=c,y[6]=u,y[10]=h,y[14]=d,y[3]=f,y[7]=p,y[11]=m,y[15]=g,this},r.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},r.prototype.clone=function(){return new r().fromArray(this.elements)},r.prototype.copy=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},r.prototype.copyPosition=function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},r.prototype.setFromMatrix3=function(e){var t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this},r.prototype.setFromExtrusionDirection=function(e){var t=Math.hypot(e.x,e.y,e.z);if(!Number.isFinite(t)||t<1e-12)return this.identity(),this;var n=Math.abs(t-1)>1e-6?e.clone().multiplyScalar(1/t):e;if(du.equalPoint3d(n,X.Z_AXIS))this.identity();else{var i=new X(1,0,0);Math.abs(n.x)<1/64&&Math.abs(n.y)<1/64?i.crossVectors(X.Y_AXIS,n).normalize():i.crossVectors(X.Z_AXIS,n).normalize();var o=n.clone().cross(i).normalize();this.makeBasis(i,o,n)}return this},r.prototype.extractBasis=function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},r.prototype.makeBasis=function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},r.prototype.extractRotation=function(e){var t=this.elements,n=e.elements,i=1/Gh.setFromMatrixColumn(e,0).length(),o=1/Gh.setFromMatrixColumn(e,1).length(),a=1/Gh.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},r.prototype.makeRotationFromQuaternion=function(e){return this.compose(sW,e,lW)},r.prototype.lookAt=function(e,t,n){var i=this.elements;return xo.subVectors(e,t),xo.lengthSq()===0&&(xo.z=1),xo.normalize(),bc.crossVectors(n,xo),bc.lengthSq()===0&&(Math.abs(n.z)===1?xo.x+=1e-4:xo.z+=1e-4,xo.normalize(),bc.crossVectors(n,xo)),bc.normalize(),Vy.crossVectors(xo,bc),i[0]=bc.x,i[4]=Vy.x,i[8]=xo.x,i[1]=bc.y,i[5]=Vy.y,i[9]=xo.y,i[2]=bc.z,i[6]=Vy.z,i[10]=xo.z,this},r.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},r.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},r.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,o=this.elements,a=n[0],s=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],p=n[2],m=n[6],g=n[10],y=n[14],v=n[3],x=n[7],b=n[11],w=n[15],_=i[0],P=i[4],S=i[8],E=i[12],C=i[1],k=i[5],T=i[9],O=i[13],I=i[2],F=i[6],N=i[10],Y=i[14],U=i[3],$=i[7],J=i[11],G=i[15];return o[0]=a*_+s*C+l*I+c*U,o[4]=a*P+s*k+l*F+c*$,o[8]=a*S+s*T+l*N+c*J,o[12]=a*E+s*O+l*Y+c*G,o[1]=u*_+h*C+d*I+f*U,o[5]=u*P+h*k+d*F+f*$,o[9]=u*S+h*T+d*N+f*J,o[13]=u*E+h*O+d*Y+f*G,o[2]=p*_+m*C+g*I+y*U,o[6]=p*P+m*k+g*F+y*$,o[10]=p*S+m*T+g*N+y*J,o[14]=p*E+m*O+g*Y+y*G,o[3]=v*_+x*C+b*I+w*U,o[7]=v*P+x*k+b*F+w*$,o[11]=v*S+x*T+b*N+w*J,o[15]=v*E+x*O+b*Y+w*G,this},r.prototype.multiplyScalar=function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},r.prototype.determinant=function(){var e=this.elements,t=e[0],n=e[4],i=e[8],o=e[12],a=e[1],s=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],p=e[3],m=e[7],g=e[11],y=e[15];return p*(+o*l*h-i*c*h-o*s*d+n*c*d+i*s*f-n*l*f)+m*(+t*l*f-t*c*d+o*a*d-i*a*f+i*c*u-o*l*u)+g*(+t*c*h-t*s*f-o*a*h+n*a*f+o*s*u-n*c*u)+y*(-i*s*u-t*l*h+t*s*d+i*a*h-n*a*d+n*l*u)},r.prototype.transpose=function(){var e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},r.prototype.setPosition=function(e,t,n){var i=this.elements;return e instanceof X?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this},r.prototype.invert=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],y=e[15],v=h*g*c-m*d*c+m*l*f-s*g*f-h*l*y+s*d*y,x=p*d*c-u*g*c-p*l*f+a*g*f+u*l*y-a*d*y,b=u*m*c-p*h*c+p*s*f-a*m*f-u*s*y+a*h*y,w=p*h*l-u*m*l-p*s*d+a*m*d+u*s*g-a*h*g,_=t*v+n*x+i*b+o*w;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var P=1/_;return e[0]=v*P,e[1]=(m*d*o-h*g*o-m*i*f+n*g*f+h*i*y-n*d*y)*P,e[2]=(s*g*o-m*l*o+m*i*c-n*g*c-s*i*y+n*l*y)*P,e[3]=(h*l*o-s*d*o-h*i*c+n*d*c+s*i*f-n*l*f)*P,e[4]=x*P,e[5]=(u*g*o-p*d*o+p*i*f-t*g*f-u*i*y+t*d*y)*P,e[6]=(p*l*o-a*g*o-p*i*c+t*g*c+a*i*y-t*l*y)*P,e[7]=(a*d*o-u*l*o+u*i*c-t*d*c-a*i*f+t*l*f)*P,e[8]=b*P,e[9]=(p*h*o-u*m*o-p*n*f+t*m*f+u*n*y-t*h*y)*P,e[10]=(a*m*o-p*s*o+p*n*c-t*m*c-a*n*y+t*s*y)*P,e[11]=(u*s*o-a*h*o-u*n*c+t*h*c+a*n*f-t*s*f)*P,e[12]=w*P,e[13]=(u*m*i-p*h*i+p*n*d-t*m*d-u*n*g+t*h*g)*P,e[14]=(p*s*i-a*m*i-p*n*l+t*m*l+a*n*g-t*s*g)*P,e[15]=(a*h*i-u*s*i+u*n*l-t*h*l-a*n*d+t*s*d)*P,this},r.prototype.scale=function(e){var t=this.elements,n=e.x,i=e.y,o=e.z;return t[0]*=n,t[4]*=i,t[8]*=o,t[1]*=n,t[5]*=i,t[9]*=o,t[2]*=n,t[6]*=i,t[10]*=o,t[3]*=n,t[7]*=i,t[11]*=o,this},r.prototype.getMaxScaleOnAxis=function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))},r.prototype.makeTranslation=function(e,t,n){var i;return typeof e=="object"?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,(i=e.z)!==null&&i!==void 0?i:0,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this},r.prototype.makeRotationX=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this},r.prototype.makeRotationY=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this},r.prototype.makeRotationZ=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this},r.prototype.makeRotationAxis=function(e,t){var n=Math.cos(t),i=Math.sin(t),o=1-n,a=e.x,s=e.y,l=e.z,c=o*a,u=o*s;return this.set(c*a+n,c*s-i*l,c*l+i*s,0,c*s+i*l,u*s+n,u*l-i*a,0,c*l-i*s,u*l+i*a,o*l*l+n,0,0,0,0,1),this},r.prototype.makeScale=function(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this},r.prototype.makeShear=function(e,t,n,i,o,a){return this.set(1,n,o,0,e,1,a,0,t,i,1,0,0,0,0,1),this},r.prototype.compose=function(e,t,n){var i=this.elements,o=t.x,a=t.y,s=t.z,l=t.w,c=o+o,u=a+a,h=s+s,d=o*c,f=o*u,p=o*h,m=a*u,g=a*h,y=s*h,v=l*c,x=l*u,b=l*h,w=n.x,_=n.y,P=n.z;return i[0]=(1-(m+y))*w,i[1]=(f+b)*w,i[2]=(p-x)*w,i[3]=0,i[4]=(f-b)*_,i[5]=(1-(d+y))*_,i[6]=(g+v)*_,i[7]=0,i[8]=(p+x)*P,i[9]=(g-v)*P,i[10]=(1-(d+m))*P,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},r.prototype.decompose=function(e,t,n){var i=this.elements,o=Gh.set(i[0],i[1],i[2]).length(),a=Gh.set(i[4],i[5],i[6]).length(),s=Gh.set(i[8],i[9],i[10]).length(),l=this.determinant();l<0&&(o=-o),e.x=i[12],e.y=i[13],e.z=i[14],Ta.copy(this);var c=1/o,u=1/a,h=1/s;return Ta.elements[0]*=c,Ta.elements[1]*=c,Ta.elements[2]*=c,Ta.elements[4]*=u,Ta.elements[5]*=u,Ta.elements[6]*=u,Ta.elements[8]*=h,Ta.elements[9]*=h,Ta.elements[10]*=h,t.setFromRotationMatrix(Ta),n.x=o,n.y=a,n.z=s,this},r.prototype.equals=function(e){for(var t=this.elements,n=e.elements,i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0},r.prototype.fromArray=function(e,t){t===void 0&&(t=0);for(var n=0;n<16;n++)this.elements[n]=e[n+t];return this},r.prototype.toArray=function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e},r.IDENTITY=Object.freeze(new r),r})(),Gh=new X,Ta=new Ue,sW=new X(0,0,0),lW=new X(1,1,1),bc=new X,Vy=new X,xo=new X,_t=(function(){function r(e,t){e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.min=e==null?new X(1/0,1/0,1/0):new X(e.x,e.y,e.z),this.max=t==null?new X(-1/0,-1/0,-1/0):new X(t.x,t.y,t.z)}return r.prototype.set=function(e,t){return this.min.copy(e),this.max.copy(t),this},r.prototype.setFromArray=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t+=3)this.expandByPoint(i1.fromArray(e,t));return this},r.prototype.setFromPoints=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},r.prototype.setFromCenterAndSize=function(e,t){var n=i1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this},r.prototype.clone=function(){return new r().copy(this)},r.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},r.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},r.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},r.prototype.getCenter=function(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},r.prototype.getSize=function(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},Object.defineProperty(r.prototype,"center",{get:function(){return this.isEmpty()?new X(0,0,0):new X(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){return this.isEmpty()?new X(0,0,0):new X(0,0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),r.prototype.expandByPoint=function(e){return!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.z)?this:(this.min.min(e),this.max.max(e),this)},r.prototype.expandByVector=function(e){return this.min.sub(e),this.max.add(e),this},r.prototype.expandByScalar=function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},r.prototype.containsPoint=function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)},r.prototype.containsBox=function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},r.prototype.getParameter=function(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},r.prototype.intersectsBox=function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)},r.prototype.intersectsPlane=function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant},r.prototype.clampPoint=function(e,t){return t.copy(e).clamp(this.min,this.max)},r.prototype.distanceToPoint=function(e){return this.clampPoint(e,i1).distanceTo(e)},r.prototype.intersect=function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},r.prototype.union=function(e){return this.min.min(e.min),this.max.max(e.max),this},r.prototype.applyMatrix4=function(e){return this.isEmpty()?this:(dl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),dl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),dl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),dl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),dl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),dl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),dl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),dl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(dl),this)},r.prototype.translate=function(e){return this.min.add(e),this.max.add(e),this},r.prototype.equals=function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},r})(),dl=[new X,new X,new X,new X,new X,new X,new X,new X],i1=new X,RI=new vn,Bt=(function(){function r(e,t){e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.min=e==null?new vn(1/0,1/0):new vn(e.x,e.y),this.max=t==null?new vn(-1/0,-1/0):new vn(t.x,t.y)}return r.prototype.set=function(e,t){return this.min.copy(e),this.max.copy(t),this},r.prototype.setFromPoints=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},r.prototype.setFromCenterAndSize=function(e,t){var n=RI.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this},r.prototype.clone=function(){return new r().copy(this)},r.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},r.prototype.makeEmpty=function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},r.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y},r.prototype.getCenter=function(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},r.prototype.getSize=function(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},Object.defineProperty(r.prototype,"center",{get:function(){return this.isEmpty()?new vn(0,0):new vn(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){return this.isEmpty()?new vn(0,0):new vn(0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),r.prototype.expandByPoint=function(e){return!Number.isFinite(e.x)||!Number.isFinite(e.y)?this:(this.min.min(e),this.max.max(e),this)},r.prototype.expandByVector=function(e){return this.min.sub(e),this.max.add(e),this},r.prototype.expandByScalar=function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},r.prototype.containsPoint=function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)},r.prototype.containsBox=function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},r.prototype.getParameter=function(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},r.prototype.intersectsBox=function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)},r.prototype.clampPoint=function(e,t){return t.copy(e).clamp(this.min,this.max)},r.prototype.distanceToPoint=function(e){return this.clampPoint(e,RI).distanceTo(e)},r.prototype.intersect=function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},r.prototype.union=function(e){return this.min.min(e.min),this.max.max(e.max),this},r.prototype.translate=function(e){return this.min.add(e),this.max.add(e),this},r.prototype.equals=function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},r})(),FI=new X,cW=new X,uW=new ny,Rw=(function(){function r(e,t){e===void 0&&(e=new X(1,0,0)),t===void 0&&(t=0),this.normal=e,this.constant=t}return r.prototype.set=function(e,t){return this.normal.copy(e),this.constant=t,this},r.prototype.setComponents=function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},r.prototype.setFromNormalAndCoplanarPoint=function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},r.prototype.setFromCoplanarPoints=function(e,t,n){var i=FI.subVectors(n,t).cross(cW.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this},r.prototype.copy=function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},r.prototype.normalize=function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},r.prototype.negate=function(){return this.constant*=-1,this.normal.negate(),this},r.prototype.distanceToPoint=function(e){return this.normal.dot(e)+this.constant},r.prototype.projectPoint=function(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))},r.prototype.intersectsBox=function(e){return e.intersectsPlane(this)},r.prototype.coplanarPoint=function(e){return e.copy(this.normal).multiplyScalar(-this.constant)},r.prototype.applyMatrix4=function(e,t){var n=t||uW.getNormalMatrix(e),i=this.coplanarPoint(FI).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(o),this},r.prototype.translate=function(e){return this.constant-=e.dot(this.normal),this},r.prototype.equals=function(e){return e.normal.equals(this.normal)&&e.constant===this.constant},r.prototype.clone=function(){return new r().copy(this)},r})(),hW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),re=(function(r){hW(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.clone=function(){return new e(this.x,this.y)},e.pointArrayToNumberArray=function(t){var n=new Array(t.length*2);return t.forEach(function(i,o){i.toArray(n,o*2)}),n},e})(vn),dW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),D=(function(r){dW(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e.pointArrayToNumberArray=function(t,n){n===void 0&&(n=!0);var i=n?3:2,o=new Array(t.length*i);return t.forEach(function(a,s){a.toArray(o,s*i)}),o},e})(X);function U4(r){var e=r.length;if(e<3)return 0;for(var t=0,n=0,i=e-1;n<e;i=n++){var o=r[i],a=r[n];t+=o.x*a.y-a.x*o.y}return t*.5}function fW(r){return Math.abs(U4(r))}function pW(r){var e,t,n=r.length;if(n<3)return 0;for(var i=0,o=0,a=0,s=0,l=n-1;s<n;l=s++){var c=r[l],u=r[s],h=c.x,d=c.y,f=(e=c.z)!==null&&e!==void 0?e:0,p=u.x,m=u.y,g=(t=u.z)!==null&&t!==void 0?t:0;i+=(f+g)*(d-m),o+=(h+p)*(f-g),a+=(d+m)*(h-p)}return .5*Math.hypot(i,o,a)}function mW(r){return r.length<3?0:fW(r)}function V4(r){return r.length<3?0:pW(r)}function gW(r){var e,t=r;return{x:r.x,y:r.y,z:(e=t.z)!==null&&e!==void 0?e:0}}function yW(r,e){var t,n;r.x+=e.x,r.y+=e.y,r.z=((t=r.z)!==null&&t!==void 0?t:0)+((n=e.z)!==null&&n!==void 0?n:0)}function vW(r,e,t){t===void 0&&(t=!1);for(var n=r.x,i=r.y,o=!1,a=e.length,s=0,l=a-1;s<a;l=s++){var c=e[s].x,u=e[s].y,h=e[l].x,d=e[l].y,f=u>i!=d>i;t&&(f=u>=i!=d>=i);var p=f&&n<(h-c)*(i-u)/(d-u)+c;p&&(o=!o)}return o}function bW(r,e){if(r.length===0||e.length===0)return!1;var t=new Bt().setFromPoints(r),n=new Bt().setFromPoints(e);if(!t.intersectsBox(n))return!1;for(var i=0;i<r.length;){if(Qn.isPointInPolygon(r[i],e,!0))return!0;i<r.length-1&&du.equalPoint2d(r[i+1],r[i])&&++i,++i}return!1}var Qn={applyOffsetToPoint3d:yW,isPointInPolygon:vW,isPolygonIntersect:bW,point2dToPoint3d:gW},Fd=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},km=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},Hy=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))};function H4(r,e){e===void 0&&(e="Uniform");var t=r.length;if(t===0)return[];if(t===1)return[0];var n=t-1;if(e==="Uniform")return new Array(t).fill(0).map(function(d,f){return f/n});for(var i=[0],o=0,a=1;a<=n;a++){var s=r[a][0]-r[a-1][0],l=r[a][1]-r[a-1][1],c=r[a][2]-r[a-1][2],u=Math.sqrt(s*s+l*l+c*c),h=e==="SqrtChord"?Math.sqrt(u):u;o+=h,i.push(o)}return o<1e-12?new Array(t).fill(0).map(function(d,f){return f/n}):i.map(function(d){return d/o})}function G4(r,e){for(var t=e.length-1,n=r,i=t+n+1,o=new Array(i+1).fill(0),a=e[e.length-1],s=i-n;s<=i;s++)o[s]=a;for(var l=1;l<=t-n;l++){for(var c=0,s=l;s<l+n;s++)c+=e[s];o[l+n]=c/n}return o}function Gy(r,e){var t,n;try{for(var i=Fd(r),o=i.next();!o.done;o=i.next()){var a=o.value;if(a.col===e)return a.value}}catch(s){t={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return 0}function BI(r,e){for(var t=0;t<r.length;t++)if(r[t].col===e)return t;return-1}function xW(r,e){for(var t,n,i,o,a,s,l,c,u,h,d=r.length,f=r.map(function(Ce){return Ce.map(function(Z){return{col:Z.col,value:Z.value}})}),p=e.map(function(Ce){return Ce.slice()}),m=0;m<d;m++){for(var g=-1,y=1e-12,v=m;v<d;v++){var x=Math.abs(Gy(f[v],m));x>y&&(y=x,g=v)}if(g<0)throw new Error("Interpolation matrix is singular.");if(g!==m){var b=f[m];f[m]=f[g],f[g]=b;try{for(var w=(t=void 0,Fd(p)),_=w.next();!_.done;_=w.next()){var P=_.value,S=P[m];P[m]=P[g],P[g]=S}}catch(Ce){t={error:Ce}}finally{try{_&&!_.done&&(n=w.return)&&n.call(w)}finally{if(t)throw t.error}}}for(var E=Gy(f[m],m),v=m+1;v<d;v++){var C=BI(f[v],m);if(!(C<0)){var k=f[v][C].value/E;if(!(Math.abs(k)<1e-14)){try{for(var T=(i=void 0,Fd(f[v])),O=T.next();!O.done;O=T.next()){var I=O.value;I.col>m&&(I.value-=k*Gy(f[m],I.col))}}catch(Z){i={error:Z}}finally{try{O&&!O.done&&(o=T.return)&&o.call(T)}finally{if(i)throw i.error}}try{for(var F=(a=void 0,Fd(f[m])),N=F.next();!N.done;N=F.next()){var Y=N.value;Y.col<=m||Y.value===0||BI(f[v],Y.col)<0&&f[v].push({col:Y.col,value:-k*Y.value})}}catch(Z){a={error:Z}}finally{try{N&&!N.done&&(s=F.return)&&s.call(F)}finally{if(a)throw a.error}}f[v][C].value=0;try{for(var U=(l=void 0,Fd(p)),$=U.next();!$.done;$=U.next()){var P=$.value;P[v]-=k*P[m]}}catch(Z){l={error:Z}}finally{try{$&&!$.done&&(c=U.return)&&c.call(U)}finally{if(l)throw l.error}}}}}}for(var J=p.map(function(){return new Array(d).fill(0)}),v=d-1;v>=0;v--)for(var G=Gy(f[v],v),oe=0;oe<p.length;oe++){var le=p[oe][v];try{for(var Ie=(u=void 0,Fd(f[v])),xe=Ie.next();!xe.done;xe=Ie.next()){var I=xe.value;I.col>v&&(le-=I.value*J[oe][I.col])}}catch(Z){u={error:Z}}finally{try{xe&&!xe.done&&(h=Ie.return)&&h.call(Ie)}finally{if(u)throw u.error}}J[oe][v]=le/G}return J}function wW(r,e,t){var n=t.length-e-2;if(r>=t[n+1])return n;for(var i=e,o=t.length-e-2;i<=o;){var a=i+o>>1;if(r<t[a])o=a-1;else if(r>=t[a+1])i=a+1;else return a}return e}function W4(r,e,t,n,i){var o,a,s,l,c,u;if(t===void 0&&(t="Uniform"),r.length===0)return{controlPoints:[],knots:[],weights:[]};var h=r.map(function(xe){var Ce;return[xe[0],xe[1],(Ce=xe[2])!==null&&Ce!==void 0?Ce:0]}),d=!!n,f=!!i,p=(d?1:0)+(f?1:0),m=h.length-1,g=m+p;if(g<e)throw new Error("Not enough points to interpolate a curve of this degree.");var y=H4(h,t),v=y.slice();d&&v.unshift(y[0]),f&&v.push(y[y.length-1]);var x=G4(e,v),b=g+1,w=[],_=[],P=[],S=[];if(d){var E=x[e+1]-x[0],C=E!==0?e/E:0;w.push([{col:0,value:-C},{col:1,value:C}]),_.push((o=n==null?void 0:n[0])!==null&&o!==void 0?o:0),P.push((a=n==null?void 0:n[1])!==null&&a!==void 0?a:0),S.push((s=n==null?void 0:n[2])!==null&&s!==void 0?s:0)}w.push([{col:0,value:1}]),_.push(h[0][0]),P.push(h[0][1]),S.push(h[0][2]);for(var k=1;k<=m-1;k++){for(var T=y[k],O=[],I=wW(T,e,x),F=Math.max(0,I-e),N=Math.min(g,I),Y=F;Y<=N;Y++){var U=au(Y,e,T,x);U!==0&&O.push({col:Y,value:U})}w.push(O),_.push(h[k][0]),P.push(h[k][1]),S.push(h[k][2])}if(w.push([{col:g,value:1}]),_.push(h[m][0]),P.push(h[m][1]),S.push(h[m][2]),f){var E=x[g+e+1]-x[g],C=E!==0?e/E:0;w.push([{col:g-1,value:-C},{col:g,value:C}]),_.push((l=i==null?void 0:i[0])!==null&&l!==void 0?l:0),P.push((c=i==null?void 0:i[1])!==null&&c!==void 0?c:0),S.push((u=i==null?void 0:i[2])!==null&&u!==void 0?u:0)}for(var $=km(xW(w,[_,P,S]),3),J=$[0],G=$[1],oe=$[2],le=new Array(b),k=0;k<b;k++)le[k]=[J[k],G[k],oe[k]];var Ie=new Array(b).fill(1);return{controlPoints:le,knots:x,weights:Ie}}function au(r,e,t,n){if(e===0)return t>=n[r]&&t<n[r+1]?1:0;var i=n[r+e]-n[r],o=n[r+e+1]-n[r+1],a=i>1e-10?(t-n[r])/i:0,s=o>1e-10?(n[r+e+1]-t)/o:0;return a*au(r,e-1,t,n)+s*au(r+1,e-1,t,n)}function Hm(r,e,t,n,i){var o=n.length-1,a=e;if(r=Math.max(t[a],Math.min(t[o+1],r)),Math.abs(r-t[o+1])<1e-8)return Hy([],km(n[o]),!1);if(Math.abs(r-t[a])<1e-8)return Hy([],km(n[0]),!1);for(var s=[0,0,0],l=0,c=0;c<=o;c++){var u=au(c,a,r,t),h=i[c]*u;s[0]+=n[c][0]*h,s[1]+=n[c][1]*h,s[2]+=n[c][2]*h,l+=h}if(Math.abs(l)<1e-10){var d=t[t.length-a-1];if(Math.abs(r-d)<1e-8)return Hy([],km(n[o]),!1);if(Math.abs(r-t[a])<1e-8)return Hy([],km(n[0]),!1)}return Math.abs(l)>=1e-10&&(s[0]/=l,s[1]/=l,s[2]/=l),s}function mE(r,e,t,n){if(e===0)return 0;var i=n[r+e]-n[r],o=n[r+e+1]-n[r+1],a=0;return i>1e-10&&(a+=e/i*au(r,e-1,t,n)),o>1e-10&&(a-=e/o*au(r+1,e-1,t,n)),a}function _W(r,e,t,n){if(e<=1)return 0;var i=n[r+e]-n[r],o=n[r+e+1]-n[r+1],a=0;return i>1e-10&&(a+=e/i*mE(r,e-1,t,n)),o>1e-10&&(a-=e/o*mE(r+1,e-1,t,n)),a}function SW(r,e,t,n,i){var o=n.length-1,a=e,s=t[a],l=t[o+1];r=Math.max(s,Math.min(l,r));for(var c=[0,0,0],u=[0,0,0],h=[0,0,0],d=0,f=0,p=0,m=0;m<=o;m++){var g=au(m,a,r,t),y=mE(m,a,r,t),v=_W(m,a,r,t),x=i[m],b=x*g,w=x*y,_=x*v,P=n[m];c[0]+=b*P[0],c[1]+=b*P[1],c[2]+=b*P[2],u[0]+=w*P[0],u[1]+=w*P[1],u[2]+=w*P[2],h[0]+=_*P[0],h[1]+=_*P[1],h[2]+=_*P[2],d+=b,f+=w,p+=_}if(Math.abs(d)<1e-10){var S=Hm(r,e,t,n,i);return{point:S,deriv1:[0,0,0],deriv2:[0,0,0]}}var E=d*d,C=[c[0]/d,c[1]/d,c[2]/d],k=[(u[0]*d-c[0]*f)/E,(u[1]*d-c[1]*f)/E,(u[2]*d-c[2]*f)/E],T=h[0]*d-c[0]*p,O=h[1]*d-c[1]*p,I=h[2]*d-c[2]*p,F=[T/E-2*f*k[0]/d,O/E-2*f*k[1]/d,I/E-2*f*k[2]/d];return{point:C,deriv1:k,deriv2:F}}function PW(r,e){var t=r[0],n=r[1],i=e[0],o=e[1],a=t*t+n*n;return a<1e-20?0:(t*o-n*i)/Math.pow(a,1.5)}function $4(r,e,t,n){for(var i=r,o=e[i],a=e[e.length-i-1],s=0,l=1e3,c=(a-o)/l,u=Hm(o,r,e,t,n),h=1;h<=l;h++){var d=o+h*c,f=Hm(d,r,e,t,n),p=f[0]-u[0],m=f[1]-u[1],g=f[2]-u[2];s+=Math.sqrt(p*p+m*m+g*g),u=f}var y=Hm(a,r,e,t,n),v=y[0]-u[0],x=y[1]-u[1],b=y[2]-u[2];return s+=Math.sqrt(v*v+x*x+b*b),s}var R0=new Ue,NI=new X,EW=new X,MW=new X,o1=new D,X4=new X;function kW(r){return new Ue().setFromExtrusionDirection(new X(r.x,r.y,r.z))}function If(r){return F0(new X,r)}function F0(r,e){return R0.setFromExtrusionDirection(X4.set(e.x,e.y,e.z)),R0.extractBasis(NI,EW,MW),r.copy(NI),r}function Ei(r,e){return iA(new D,r,e)}function iA(r,e,t){var n,i;return t.x===0&&t.y===0&&t.z===1?(r.set(e.x,e.y,(n=e.z)!==null&&n!==void 0?n:0),r):(R0.setFromExtrusionDirection(X4.set(t.x,t.y,t.z)),r.set(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0),r.applyMatrix4(R0),r)}function To(r,e){var t;return new D(r.x,r.y,(t=r.z)!==null&&t!==void 0?t:0).applyMatrix4(kW(e).invert())}function zl(r,e,t){var n,i,o=To(r,t),a=To(e,t);return o1.set(a.x-o.x,a.y-o.y,((n=a.z)!==null&&n!==void 0?n:0)-((i=o.z)!==null&&i!==void 0?i:0)),Te.normalizeAngle(Math.atan2(o1.y,o1.x))}function oA(r,e,t){var n=r.x,i=r.y,o=e.x,a=e.y,s=t.x,l=t.y,c=2*(n*(a-l)+o*(l-i)+s*(i-a));if(Le.equalToZero(c))return null;var u=((n*n+i*i)*(a-l)+(o*o+a*a)*(l-i)+(s*s+l*l)*(i-a))/c,h=((n*n+i*i)*(s-o)+(o*o+a*a)*(n-s)+(s*s+l*l)*(o-n))/c,d=Math.hypot(u-n,h-i);return!Number.isFinite(d)||Le.isNonPositive(d)?null:{center:new re(u,h),radius:d}}function zI(r,e,t){var n,i,o,a=r.x,s=r.y,l=(n=r.z)!==null&&n!==void 0?n:0,c=new X(e.x-a,e.y-s,((i=e.z)!==null&&i!==void 0?i:0)-l),u=new X(t.x-a,t.y-s,((o=t.z)!==null&&o!==void 0?o:0)-l),h=new X().crossVectors(c,u),d=h.lengthSq();if(d<tn*tn)return null;var f=c.lengthSq(),p=u.lengthSq(),m=new X().crossVectors(h,c).multiplyScalar(p).add(new X().crossVectors(u,h).multiplyScalar(f)).multiplyScalar(1/(2*d)),g=new D(a+m.x,s+m.y,l+m.z),y=Math.hypot(g.x-a,g.y-s,g.z-l);return!Number.isFinite(y)||Le.isNonPositive(y)?null:{center:g,radius:y}}function tu(r,e){return Math.atan2(e.y-r.y,e.x-r.x)}function Qs(r,e){return Math.hypot(e.x-r.x,e.y-r.y)}function Y4(r,e,t){if(Le.isNonPositive(e))return null;var n=t.x-r.x,i=t.y-r.y,o=Math.hypot(n,i);if(Le.isNonPositive(o))return null;var a=e/o;return new re(r.x+n*a,r.y+i*a)}var AW=1e-8;function q4(r,e,t,n){var i=Math.abs(Qs(r,e)-t);return i<=(n??Math.max(tn,t*1e-5))}function K4(r,e,t,n,i){return i===void 0&&(i=AW),Math.abs(r.x-t.x)<=i&&Math.abs(r.y-t.y)<=i&&Math.abs(e-n)<=i}function Z4(r,e,t,n){var i=Math.max(1e-18,Math.abs(t)*1e-9);return r<t-i?!0:r>t+i?!1:e>n}function jI(r,e,t,n){n===void 0&&(n=!1);var i=oA(r,e,t);if(!i)return null;var o=tu(i.center,r),a=tu(i.center,e),s=tu(i.center,t),l=!Te.isAngleOnCcwSweep(o,a,s);return n&&(l=!l),wt.fromMathAngles(i.center,i.radius,o,s,l)}function aA(r,e){return!Number.isFinite(e)||Le.isNonPositive(e)?null:new wt(r,e,0,lt,!1)}function CW(r,e){var t=Qs(r,e);return Le.isNonPositive(t)?null:aA({x:(r.x+e.x)/2,y:(r.y+e.y)/2},t/2)}function TW(r,e,t){var n=oA(r,e,t);return n?aA(n.center,n.radius):null}function IW(r,e,t){var n=Qs(t,r);if(Le.isNonPositive(n))return null;var i=tu(t,r),o=tu(t,e),a=Te.normalizeAngle(o-i);return wt.fromMathAngles(t,n,i,o,a>Math.PI)}function ry(r,e,t,n){var i=Qs(r,e),o=Qs(r,t);if(Le.isNonPositive(i)||Le.isNonPositive(o))return null;var a=Math.max(tn,i*tn);return Math.abs(i-o)>a?null:wt.fromMathAngles(r,i,tu(r,e),tu(r,t),n)}function LW(r,e,t,n){var i=Qs(r,e);if(Le.isNonPositive(i))return null;var o=Y4(r,i,t);return o?ry(r,e,o,n):null}function J4(r,e,t){var n=Qs(r,e),i=Math.abs(t);if(Le.isNonPositive(n)||Le.isNonPositive(i)||!Le.great(lt-i,0))return null;var o=t<0,a=tu(r,e),s=o?a-i:a+i;return wt.fromMathAngles(r,n,a,s,o)}function OW(r,e,t){var n=Qs(r,e),i=Math.abs(t);if(Le.isNonPositive(n)||Le.isNonPositive(i)||Le.great(i,2*n))return null;var o=Math.max(-1,Math.min(1,i/(2*n))),a=2*Math.asin(o);return J4(r,e,t>=0?a:-a)}function DW(r,e,t){var n=Qs(r,e),i=Math.abs(t);if(Le.isNonPositive(n)||Le.isNonPositive(i)||!Le.great(lt-i,0))return null;var o=Math.sin(i/2);if(Le.equalToZero(o))return null;var a=n/(2*o),s=a*a-n*n/4;if(Le.less(s,0))return null;var l=Math.sqrt(Math.max(0,s)),c=(r.x+e.x)/2,u=(r.y+e.y)/2,h=e.x-r.x,d=e.y-r.y,f=-d/n,p=h/n,m=t>=0,g=m&&i<=Math.PI||!m&&i>Math.PI,y=g?1:-1,v={x:c+f*l*y,y:u+p*l*y};return ry(v,r,e,!m)}function RW(r,e,t){var n=Math.cos(t),i=Math.sin(t),o=e.x-r.x,a=e.y-r.y,s=-i,l=n,c=2*(o*s+a*l);if(Le.equalToZero(c))return null;var u=(o*o+a*a)/c;if(!Number.isFinite(u))return null;var h={x:r.x+s*u,y:r.y+l*u},d=r.x-h.x,f=r.y-h.y,p=d*i-f*n;return Le.equalToZero(p)?null:ry(h,r,e,p<0)}function FW(r,e,t){var n=Math.abs(t),i=Qs(r,e);if(Le.isNonPositive(n)||Le.isNonPositive(i)||Le.great(i,2*n))return null;var o=(r.x+e.x)/2,a=(r.y+e.y)/2,s=e.x-r.x,l=e.y-r.y,c=-l/i,u=s/i,h=Math.sqrt(Math.max(0,n*n-i*i/4)),d=t>=0?1:-1,f={x:o+c*h*d,y:a+u*h*d};return ry(f,r,e,t<0)}var Q4=(function(){function r(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(r.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),r})(),BW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),sA=(function(r){BW(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.translate=function(t){return this.transform(new ny().makeTranslation(t.x,t.y))},Object.defineProperty(e.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),e})(Q4),NW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),up=(function(r){NW(e,r);function e(){var t=r.call(this)||this;return t.arcLengthDivisions=100,t}return Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPoint(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPoint(1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.getLength()},enumerable:!1,configurable:!0}),e.prototype.getPoint=function(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")},e.prototype.getPointAt=function(t){var n=this.getUtoTmapping(t);return this.getPoint(n)},e.prototype.getPoints=function(t){t===void 0&&(t=5);for(var n=[],i=0;i<=t;i++)n.push(this.getPoint(i/t));return n},e.prototype.getSpacedPoints=function(t){t===void 0&&(t=5);for(var n=[],i=0;i<=t;i++)n.push(this.getPointAt(i/t));return n},e.prototype.getLength=function(){var t=this.getLengths();return t[t.length-1]},e.prototype.getLengths=function(t){t===void 0&&(t=this.arcLengthDivisions);var n=[],i,o=this.getPoint(0),a=0;n.push(0);for(var s=1;s<=t;s++)i=this.getPoint(s/t),a+=i.distanceTo(o),n.push(a),o=i;return n},e.prototype.getUtoTmapping=function(t,n){var i=this.getLengths(),o=0,a=i.length,s;n?s=n:s=t*i[a-1];for(var l=0,c=a-1,u;l<=c;)if(o=Math.floor(l+(c-l)/2),u=i[o]-s,u<0)l=o+1;else if(u>0)c=o-1;else{c=o;break}if(o=c,i[o]===s)return o/(a-1);var h=i[o],d=i[o+1],f=d-h,p=(s-h)/f,m=(o+p)/(a-1);return m},e.prototype.getTangent=function(t){var n=1e-4,i=t-n,o=t+n;i<0&&(i=0),o>1&&(o=1);var a=this.getPoint(i),s=this.getPoint(o),l=new re;return l.copy(s).sub(a).normalize(),l},e.prototype.getTangentAt=function(t){var n=this.getUtoTmapping(t);return this.getTangent(n)},e})(sA),zW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),B0=function(){return B0=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},B0.apply(this,arguments)},Wy=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},$y=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},Xy=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},wt=(function(r){zW(e,r);function e(t,n,i,o,a){var s=r.call(this)||this,l=+(t!==void 0)+ +(n!==void 0)+ +(i!==void 0)+ +(o!==void 0)+ +(a!==void 0);if(l==3)typeof t=="object"&&typeof n=="object"&&typeof i=="object"?s.createByThreePoints(t,n,i):s.createByStartEndPointsAndBulge(t,n,i);else if(l==5){var c=t;s.center=new re(c.x,c.y),s.radius=n,s._clockwise=a,s._startAngle=s._clockwise?s._mirrorAngle(Te.normalizeAngle(i)):Te.normalizeAngle(i),s._endAngle=s._clockwise?s._mirrorAngle(Te.normalizeAngle(o)):Te.normalizeAngle(o)}else throw qi.ILLEGAL_PARAMETERS;return s}return e.fromMathAngles=function(t,n,i,o,a){var s=new e(t,n,Te.normalizeAngle(i),Te.normalizeAngle(o),!1);return s._clockwise=a,s._boundingBoxNeedsUpdate=!0,s},e.computeCircumcircle=function(t,n,i){return oA(t,n,i)},e.projectPoint=function(t,n,i){return Y4(t,n,i)},e.pointLiesOnCircle=function(t,n,i,o){return q4(t,n,i,o)},e.sameCircle=function(t,n,i,o,a){return K4(t,n,i,o,a)},e.isBetterDistanceAlign=function(t,n,i,o){return Z4(t,n,i,o)},e.tryCreateByThreePoints=function(t,n,i,o){return o===void 0&&(o=!1),jI(t,n,i,o)},e.tryCreateCircle=function(t,n){return aA(t,n)},e.tryCreateCircleByDiameter=function(t,n){return CW(t,n)},e.tryCreateCircleByThreePoints=function(t,n,i){return TW(t,n,i)},e.tryCreateShorterArc=function(t,n,i){return IW(t,n,i)},e.tryCreateByCenterStartEnd=function(t,n,i,o){return ry(t,n,i,o)},e.tryCreateByCenterStartProjectedEnd=function(t,n,i,o){return LW(t,n,i,o)},e.tryCreateByCenterStartSweep=function(t,n,i){return J4(t,n,i)},e.tryCreateByCenterStartChord=function(t,n,i){return OW(t,n,i)},e.tryCreateByStartEndAngle=function(t,n,i){return DW(t,n,i)},e.tryCreateByStartEndDirection=function(t,n,i){return RW(t,n,i)},e.tryCreateByStartEndRadius=function(t,n,i){return FW(t,n,i)},e.prototype.createByThreePoints=function(t,n,i){var o=jI(t,n,i);if(!o)throw qi.ILLEGAL_PARAMETERS;this.center=o.center,this.radius=o.radius,this._clockwise=o._clockwise,this._startAngle=o._startAngle,this._endAngle=o._endAngle,this._boundingBoxNeedsUpdate=!0},e.prototype.createByStartEndPointsAndBulge=function(t,n,i){var o,a,s;i<0?(o=Math.atan(-i)*4,a=new vn(t),s=new vn(n)):(o=Math.atan(i)*4,a=new vn(n),s=new vn(t));var l=new vn().subVectors(s,a),c=l.length(),u=new vn().addVectors(a,l.multiplyScalar(.5)),h=Math.abs(c/2/Math.tan(o/2)),d=l.normalize(),f=i<0?-Math.PI/2:Math.PI/2,p=new vn(d.x*Math.cos(f)-d.y*Math.sin(f),d.y*Math.cos(f)+d.x*Math.sin(f)),m;o<Math.PI?i<0?m=u.add(p.multiplyScalar(h)):m=u.add(p.multiplyScalar(-h)):i<0?m=u.add(p.multiplyScalar(-h)):m=u.add(p.multiplyScalar(h)),i<0?(this._startAngle=Math.atan2(a.y-m.y,a.x-m.x),this._endAngle=Math.atan2(s.y-m.y,s.x-m.x)):(this._startAngle=Math.atan2(s.y-m.y,s.x-m.x),this._endAngle=Math.atan2(a.y-m.y,a.x-m.x)),this._clockwise=i<0,this.center=m,this.radius=s.sub(m).length()},Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new re(t.x,t.y),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){this._radius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle},set:function(t){this._startAngle=this._clockwise?this._mirrorAngle(Te.normalizeAngle(t)):Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle},set:function(t){var n=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(n):n,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),e.prototype._mirrorAngle=function(t){var n=t*180/Math.PI,i=(360-n)%360;return i*Math.PI/180},e.prototype._getInternalAngle=function(t){return this._clockwise?this._mirrorAngle(t):t},Object.defineProperty(e.prototype,"deltaAngle",{get:function(){var t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return this.clockwise?Te.normalizeAngle(t-n):Te.normalizeAngle(n-t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this._clockwise},set:function(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this.endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){var t=this._getInternalAngle(this.startAngle),n=this._clockwise?Te.normalizeAngle(t-this.deltaAngle/2):Te.normalizeAngle(t+this.deltaAngle/2),i=this._clockwise?this._mirrorAngle(n):n;return this.getPointAtAngle(i)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){var t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return Math.abs(n-t)/Math.PI%2==0},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t,n,i=[this.startPoint,this.endPoint],o=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var a=Wy(o),s=a.next();!s.done;s=a.next()){var l=s.value,c=this._getInternalAngle(l);Te.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&i.push(this.getPointAtAngle(l))}}catch(d){t={error:d}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}var u=i.map(function(d){return d.x}),h=i.map(function(d){return d.y});return new Bt(new re(Math.min.apply(Math,Xy([],$y(u),!1)),Math.min.apply(Math,Xy([],$y(h),!1))),new re(Math.max.apply(Math,Xy([],$y(u),!1)),Math.max.apply(Math,Xy([],$y(h),!1))))},Object.defineProperty(e.prototype,"length",{get:function(){return Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),e.prototype.transform=function(t){var n=this,i=t,o=this.center.clone().applyMatrix2d(i),a=this.startPoint.clone().applyMatrix2d(i);if(this.closed)return this.center=o,this.radius=o.distanceTo(a),this._startAngle=Math.atan2(a.y-o.y,a.x-o.x),this._endAngle=this._startAngle,this._clockwise=i.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var s=this.midPoint.clone().applyMatrix2d(i),l=this.endPoint.clone().applyMatrix2d(i),c=new e(a,s,l),u=i.determinant()<0?!this.clockwise:this.clockwise,h=function(d){var f=Te.normalizeAngle(d);return u?n._mirrorAngle(f):f};return this.center=c.center,this.radius=c.radius,this.clockwise=u,this.startAngle=h(Math.atan2(a.y-c.center.y,a.x-c.center.x)),this.endAngle=h(Math.atan2(l.y-c.center.y,l.x-c.center.x)),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)},e.prototype.getPointAtAngle=function(t){var n=this._getInternalAngle(t),i=this.center.x+this.radius*Math.cos(n),o=this.center.y+this.radius*Math.sin(n);return new re(i,o)},e.prototype.getQuadrantPoints=function(){var t,n,i=[],o=this._getInternalAngle(this.startAngle),a=this._getInternalAngle(this.endAngle),s=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var l=Wy(s),c=l.next();!c.done;c=l.next()){var u=c.value,h=this._getInternalAngle(u);Te.isBetweenAngle(h,o,a,this.clockwise)&&i.push(this.getPointAtAngle(u))}}catch(d){t={error:d}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return i},e.prototype.nearestPoint=function(t){var n=new re(t.x,t.y),i=n.x-this.center.x,o=n.y-this.center.y,a=Math.hypot(i,o);if(a<1e-12)return this.startPoint.clone();var s=Math.atan2(o,i),l=this.clockwise?this._mirrorAngle(Te.normalizeAngle(s)):Te.normalizeAngle(s),c=this._getInternalAngle(l),u=this._getInternalAngle(this.startAngle),h=this._getInternalAngle(this.endAngle);if(Te.isBetweenAngle(c,u,h,this.clockwise))return this.getPointAtAngle(l);var d=n.distanceToSquared(this.startPoint),f=n.distanceToSquared(this.endPoint);return d<=f?this.startPoint.clone():this.endPoint.clone()},e.prototype.inwardAlignment=function(t,n){var i=n.x-t.x,o=n.y-t.y;if(i*i+o*o<1e-24)return 0;var a=this.radius>0?this.radius:1,s=Math.max(1e-16,1e-12*a*a),l=this.startPoint.distanceToSquared(t)<=s,c=this.endPoint.distanceToSquared(t)<=s;if(!l&&!c)return 0;var u=this.getPoints(8);if(u.length<3)return 0;var h=l&&!c?u[1]:u[u.length-2],d=h.x-t.x,f=h.y-t.y,p=Math.hypot(d,f);return p>1e-18?(i*d+o*f)/p:0},e.prototype.perpendicularPoints=function(t){var n,i,o=new re(t.x,t.y),a=o.x-this.center.x,s=o.y-this.center.y,l=Math.hypot(a,s);if(l<1e-12)return[];var c=a/l,u=s/l,h=[new re(this.center.x+c*this.radius,this.center.y+u*this.radius),new re(this.center.x-c*this.radius,this.center.y-u*this.radius)],d=[],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var m=Wy(h),g=m.next();!g.done;g=m.next()){var y=g.value,v=Math.atan2(y.y-this.center.y,y.x-this.center.x),x=this.clockwise?this._mirrorAngle(Te.normalizeAngle(v)):Te.normalizeAngle(v),b=this._getInternalAngle(x);(this.closed||Te.isBetweenAngle(b,f,p,this.clockwise))&&d.push(y)}}catch(w){n={error:w}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}return d},e.prototype.tangentPoints=function(t){var n,i,o=[],a=t.x-this.center.x,s=t.y-this.center.y,l=Math.hypot(a,s),c=this.radius;if(l<c)return o;var u=Math.acos(c/l),h=Math.atan2(s,a),d=[h+u,h-u],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var m=Wy(d),g=m.next();!g.done;g=m.next()){var y=g.value,v=this.clockwise?this._mirrorAngle(Te.normalizeAngle(y)):Te.normalizeAngle(y),x=this._getInternalAngle(v);(this.closed||Te.isBetweenAngle(x,f,p,this.clockwise))&&o.push(this.getPointAtAngle(v))}}catch(b){n={error:b}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}return o},e.prototype.getPoints=function(t){t===void 0&&(t=100);var n=[],i=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(i=lt,o=0),this.clockwise)for(var a=0;a<=t;a++){var s=o-i*(a/t),l=this._clockwise?this._mirrorAngle(s):s,c=this.getPointAtAngle(l);n.push(new re(c.x,c.y))}else for(var a=0;a<=t;a++){var s=o+i*(a/t),l=this._clockwise?this._mirrorAngle(s):s,c=this.getPointAtAngle(l);n.push(new re(c.x,c.y))}return n},e.prototype.tessellate=function(t){var n,i=this.closed?lt:this.deltaAngle,o=e.segmentCount(this.radius,i,B0(B0({},t),{minSegments:(n=t==null?void 0:t.minSegments)!==null&&n!==void 0?n:this.closed?8:3}));return this.getPoints(o)},e.resolveCircleSides=function(t){return t==null||!Number.isFinite(t)?e.DEFAULT_CIRCLE_SIDES:Tf(Math.round(t),e.MIN_CIRCLE_SIDES,e.MAX_CIRCLE_SIDES)},e.resolveTessellateOptions=function(t){var n,i=e.resolveCircleSides(t==null?void 0:t.circleSides),o=Math.max(1,Math.round((n=t==null?void 0:t.maxSegments)!==null&&n!==void 0?n:i));return{deviation:t==null?void 0:t.deviation,circleSides:i,minSegments:t==null?void 0:t.minSegments,maxSegments:o}},e.chordDeviationFromRadius=function(t,n){n===void 0&&(n=e.DEFAULT_CIRCLE_SIDES);var i=Math.abs(t),o=e.resolveCircleSides(n);return i<=tn?tn:Math.max(tn,i*(1-Math.cos(Math.PI/o)))},e.segmentCount=function(t,n,i){var o,a,s=e.resolveTessellateOptions(i),l=Math.abs(n),c=l>=lt-1e-8,u=Math.max(1,Math.round((o=s.minSegments)!==null&&o!==void 0?o:c?8:3)),h=Math.max(u,s.maxSegments),d=Math.abs(t);if(d<=tn||l<=tn)return u;var f=(a=s.deviation)!==null&&a!==void 0?a:e.chordDeviationFromRadius(d,s.circleSides),p=1-f/d;if(!Number.isFinite(p)||p>=1)return h;if(p<=-1)return u;var m=2*Math.acos(p);return m<=tn?h:Tf(Math.ceil(l/m),u,h)},e.DEFAULT_CIRCLE_SIDES=100,e.MIN_CIRCLE_SIDES=8,e.MAX_CIRCLE_SIDES=2e4,e})(up),gE=function(){return gE=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},gE.apply(this,arguments)},jW=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Yy=1e-6;function e5(r,e){if(l$(r)){var t=VW(r,e);return t?[t]:[]}var n=i5(r),i=n.numberOfVertices;if(i<2)return[];var o=u$(n,e);return o?[o]:[]}function UW(r){return i5(r)}function VW(r,e){var t,n,i=HW(r);if(i.length===0)return null;var o=[];try{for(var a=jW(i),s=a.next();!s.done;s=a.next()){var l=s.value,c=WW(l,e);if(!c)return null;o.push(c)}}catch(f){t={error:f}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}var u=GW(r),h=qW(o,u,r.closed,e);if(h.length<2)return null;var d=new Sn;return h.forEach(function(f,p){d.addVertexAt(p,{x:f.x,y:f.y})}),d.closed=r.closed,d}function HW(r){for(var e,t=[],n=r.numberOfVertices,i=r.closed?n:n-1,o=0;o<i;o++){var a=r.vertices[o],s=r.vertices[(o+1)%n];Le.isPositive(Math.abs((e=a.bulge)!==null&&e!==void 0?e:0))?t.push({kind:"arc",arc:new wt(a,s,a.bulge)}):t.push({kind:"line",start:new re(a.x,a.y),end:new re(s.x,s.y)})}return t}function GW(r){for(var e=[],t=0;t<r.numberOfVertices;t++)e.push(r.getPointAt(t));return e}function WW(r,e){if(r.kind==="line"){var t=YW(r.start,r.end,e);return t?gE({kind:"line"},t):null}var n=$W(r.arc,r.arc.startPoint,r.arc.endPoint,e);return n?{kind:"arc",arc:n}:null}function $W(r,e,t,n){var i=XW(r,e,t,n),o=r.radius+i;return Le.isNonPositive(o)?null:new wt(r.center,o,r.startAngle,r.endAngle,r.clockwise)}function XW(r,e,t,n){var i=t.x-e.x,o=t.y-e.y,a=Math.hypot(i,o);if(Le.isNonPositive(a))return r.clockwise?-n:n;var s=-o/a,l=i/a,c=r.center.x-(e.x+t.x)/2,u=r.center.y-(e.y+t.y)/2,h=c*s+u*l>0;return h?-n:n}function YW(r,e,t){var n=e.x-r.x,i=e.y-r.y,o=Math.hypot(n,i);if(Le.isNonPositive(o))return null;var a=-i/o*t,s=n/o*t;return{start:new re(r.x+a,r.y+s),end:new re(e.x+a,e.y+s),dx:n,dy:i}}function qW(r,e,t,n){var i,o,a,s=r.length;if(s===0)return[];for(var l=KW(r,e,t,n),c=[(o=(i=l[0].nextSegmentStart)===null||i===void 0?void 0:i.clone())!==null&&o!==void 0?o:l[0].point.clone()],u=0;u<s;u++){var h=r[u],d=u===s-1&&!t?{point:t$(h)}:l[(u+1)%s];if(u>0&&l[u].filletPoints&&l[u].filletPoints.forEach(function(y){return c.push(y.clone())}),h.kind==="arc")for(var f=(a=l[u].nextSegmentStart)!==null&&a!==void 0?a:l[u].point,p=d.point,m=ZW(h.arc,f,p,Math.max(16,32)),g=1;g<m.length;g++)c.push(m[g]);else c.push(d.point.clone())}return o5(c)}function KW(r,e,t,n){for(var i=r.length,o=[],a=0;a<i;a++)a===0?o.push(t?UI(r[i-1],r[0],e[0],n):{point:e$(r[0])}):o.push(UI(r[a-1],r[a],e[a],n));return o}function ZW(r,e,t,n){for(var i=r.nearestPoint(e),o=r.nearestPoint(t),a=yE(r,i),s=yE(r,o),l=QW(r,a,s),c=[],u=0;u<=n;u++){var h=u/n,d=r.clockwise?a-l*h:a+l*h;c.push(r.getPointAtAngle(JW(r,d)))}return c}function yE(r,e){return Math.atan2(e.y-r.center.y,e.x-r.center.x)}function JW(r,e){var t=Te.normalizeAngle(e);return r.clockwise?vE(t):t}function vE(r){var e=r*180/Math.PI;return(360-e)%360*(Math.PI/180)}function QW(r,e,t){if(r.clockwise){var n=e-t;return Le.isNonPositive(n)&&(n+=lt),n}var i=t-e;return Le.isNonPositive(i)&&(i+=lt),i}function e$(r){return r.kind==="line"?r.start.clone():r.arc.startPoint.clone()}function t$(r){return r.kind==="line"?r.end.clone():r.arc.endPoint.clone()}function UI(r,e,t,n){return r.kind==="line"&&e.kind==="line"?{point:bE({start:r.start,end:r.end,dx:r.dx,dy:r.dy},{start:e.start,end:e.end,dx:e.dx,dy:e.dy})}:r.kind==="line"&&e.kind==="arc"?VI(r,e.arc,t,n,!0):r.kind==="arc"&&e.kind==="line"?VI(e,r.arc,t,n,!1):r.kind==="arc"&&e.kind==="arc"?n$(r.arc,e.arc,t,n):{point:t.clone()}}function n$(r,e,t,n){var i=r5(r.endPoint,e.startPoint),o=s$(r,e),a=o.filter(function(u){return N0(r,u)&&N0(e,u)});if(a.length>0)return{point:n5(a,i)};var s=r.endPoint.clone(),l=e.startPoint.clone(),c=t5(t,Math.abs(n),s,l);return{point:s,filletPoints:c,nextSegmentStart:l}}function VI(r,e,t,n,i){var o=r5(i?r.end:r.start,i?e.startPoint:e.endPoint),a=a$(r,e,o);if(i$(r,a)&&N0(e,a))return{point:a};var s=r$(r,t,n),l=i?e.startPoint.clone():e.endPoint.clone(),c=t5(t,Math.abs(n),i?s:l,i?l:s);return i?{point:s,filletPoints:c,nextSegmentStart:l}:{point:l,filletPoints:c,nextSegmentStart:s}}function r$(r,e,t){var n=Math.hypot(r.dx,r.dy),i=-r.dy/n*t,o=r.dx/n*t;return new re(e.x+i,e.y+o)}function i$(r,e){var t=Math.hypot(r.dx,r.dy);if(Le.isNonPositive(t))return!1;var n=r.dx/t,i=r.dy/t,o=e.x-r.start.x,a=e.y-r.start.y,s=Math.abs(o*i-a*n);return Le.equalToZero(s)}function t5(r,e,t,n){var i=Math.atan2(t.y-r.y,t.x-r.x),o=Math.atan2(n.y-r.y,n.x-r.x),a=o$(i,o);if(Le.equalToZero(Math.abs(a)))return[];for(var s=[],l=Math.max(2,Math.ceil(Math.abs(a)/Math.PI*16)),c=1;c<l;c++){var u=c/l,h=i+a*u;s.push(new re(r.x+e*Math.cos(h),r.y+e*Math.sin(h)))}return s}function o$(r,e){for(var t=e-r;t>Math.PI;)t-=lt;for(;t<=-Math.PI;)t+=lt;return t}function a$(r,e,t){var n=Math.hypot(r.dx,r.dy);if(Le.isNonPositive(n))return t.clone();var i=r.dx/n,o=r.dy/n,a=r.start.x-e.center.x,s=r.start.y-e.center.y,l=2*(a*i+s*o),c=a*a+s*s-e.radius*e.radius,u=l*l-4*c;if(u<0)return t.clone();var h=Math.sqrt(u),d=[(-l-h)/2,(-l+h)/2].map(function(p){return new re(r.start.x+i*p,r.start.y+o*p)}),f=d.filter(function(p){return N0(e,p)});return n5(f.length>0?f:d,t)}function N0(r,e){var t=Math.abs(Math.hypot(e.x-r.center.x,e.y-r.center.y)-r.radius);if(Le.isPositive(t))return!1;var n=yE(r,e),i=r.clockwise?vE(Te.normalizeAngle(r.startAngle)):Te.normalizeAngle(r.startAngle),o=r.clockwise?vE(Te.normalizeAngle(r.endAngle)):Te.normalizeAngle(r.endAngle);return Te.isBetweenAngle(n,i,o,r.clockwise)}function s$(r,e){var t=e.center.x-r.center.x,n=e.center.y-r.center.y,i=Math.hypot(t,n);if(Le.isNonPositive(i))return[];var o=r.radius+e.radius,a=Math.abs(r.radius-e.radius);if(i>o+Yy)return[];if(i<a-Yy)return[];var s=(r.radius*r.radius-e.radius*e.radius+i*i)/(2*i),l=r.radius*r.radius-s*s;if(l<-Yy)return[];var c=r.center.x+s*t/i,u=r.center.y+s*n/i;if(l<=Yy)return[new re(c,u)];var h=Math.sqrt(l),d=-n*h/i,f=t*h/i;return[new re(c+d,u+f),new re(c-d,u-f)]}function n5(r,e){for(var t=r[0],n=t.distanceToSquared(e),i=1;i<r.length;i++){var o=r[i].distanceToSquared(e);o<n&&(t=r[i],n=o)}return t.clone()}function r5(r,e){return new re((r.x+e.x)/2,(r.y+e.y)/2)}function l$(r){for(var e,t=r.numberOfVertices,n=r.closed?t:t-1,i=0;i<n;i++){var o=r.vertices[i];if(Le.isPositive(Math.abs((e=o.bulge)!==null&&e!==void 0?e:0)))return!0}return!1}function i5(r){var e=c$(r.vertices.map(function(t){return new re(t.x,t.y)}),r.closed);return e.length===r.numberOfVertices?r:new Sn(e.map(function(t){return{x:t.x,y:t.y}}),r.closed)}function c$(r,e){var t=o5(r);if(!e||t.length<2)return t;var n=t[0],i=t[t.length-1];return Le.isNonPositive(Math.hypot(n.x-i.x,n.y-i.y))&&t.pop(),t}function o5(r){var e=[];return r.forEach(function(t){var n=e[e.length-1];(!n||Le.isPositive(Math.hypot(n.x-t.x,n.y-t.y)))&&e.push(new re(t.x,t.y))}),e}function u$(r,e){for(var t=[],n=0;n<r.numberOfVertices;n++)t.push(r.getPointAt(n));var i=h$(t,r.closed,e);if(i.length===0)return null;var o=[];if(r.closed){if(i.length<2)return null;for(var a=i.length,n=0;n<a;n++){var s=i[(n-1+a)%a],l=i[n];o.push(bE(s,l))}}else{o.push(i[0].start);for(var n=1;n<i.length;n++)o.push(bE(i[n-1],i[n]));o.push(i[i.length-1].end)}var c=new Sn;return o.forEach(function(u,h){c.addVertexAt(h,{x:u.x,y:u.y})}),c.closed=r.closed,c}function h$(r,e,t){for(var n=[],i=e?r.length:r.length-1,o=0;o<i;o++){var a=r[o],s=r[e?(o+1)%r.length:o+1],l=s.x-a.x,c=s.y-a.y,u=Math.hypot(l,c);if(!Le.isNonPositive(u)){var h=-c/u*t,d=l/u*t;n.push({start:new re(a.x+h,a.y+d),end:new re(s.x+h,s.y+d),dx:l,dy:c})}}return n}function bE(r,e){var t=r.dx*e.dy-r.dy*e.dx;if(Le.equalToZero(t))return new re((r.end.x+e.start.x)/2,(r.end.y+e.start.y)/2);var n=e.start.x-r.start.x,i=e.start.y-r.start.y,o=(n*e.dy-i*e.dx)/t;return new re(r.start.x+o*r.dx,r.start.y+o*r.dy)}var d$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),xE=function(){return xE=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},xE.apply(this,arguments)},Sn=(function(r){d$(e,r);function e(t,n){t===void 0&&(t=null),n===void 0&&(n=!1);var i=r.call(this)||this;return i._vertices=t||new Array,i._closed=n,i}return Object.defineProperty(e.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numberOfVertices",{get:function(){return this._vertices.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){this._closed=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){if(this.numberOfVertices>0){var t=this._vertices[0];return new re(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){var t=this.numberOfVertices;if(t>0)if(this.closed){var n=this._vertices[0];return new re(n.x,n.y)}else{var n=this._vertices[t-1];return new re(n.x,n.y)}throw new Error("End point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){for(var t=0,n=this._vertices.length,i=0;i<n;++i){var o=this._vertices[i],a=null;if(i<n-1?a=this._vertices[i+1]:i==n-1&&this.closed&&(a=this._vertices[0]),a)if(o.bulge){var s=new wt(o,a,o.bulge);t+=s.length}else t+=new re(o.x,o.y).distanceTo(a)}return t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){if(!this._closed||this._vertices.length<3)return 0;var t=this.getPoints(128);return mW(t)},enumerable:!1,configurable:!0}),e.prototype.addVertexAt=function(t,n){t<=0?this._vertices.unshift(n):this._vertices.splice(t,0,n),this._boundingBoxNeedsUpdate=!0},e.prototype.removeVertexAt=function(t){if(t<0||t>=this._vertices.length)throw new Error("Index ".concat(t," is out of bounds. Valid range is 0 to ").concat(this._vertices.length-1,"."));this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0},e.prototype.reset=function(t,n){t?n!==void 0&&n>=0&&n<this._vertices.length&&(this._vertices=this._vertices.slice(0,n),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)},e.prototype.getPointAt=function(t){var n=this._vertices[t];return new re(n.x,n.y)},e.prototype.calculateBoundingBox=function(){var t=this.getPoints(100);return new Bt().setFromPoints(t)},e.prototype.transform=function(t){var n=t.determinant()<0;return this._vertices.forEach(function(i){var o=new re(i).applyMatrix2d(t);i.x=o.x,i.y=o.y,n&&i.bulge!=null&&(i.bulge=-i.bulge)}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._vertices.map(function(t){return xE({},t)}),this._closed)},e.prototype.getPoints3d=function(t,n){var i=[],o=this.getPoints(t);return o.forEach(function(a){return i.push(new D().set(a.x,a.y,n))}),i},e.prototype.getPoints=function(t){for(var n=[],i=this._vertices.length,o=0;o<i;++o){var a=this._vertices[o];if(a.bulge){var s=null;if(o<i-1?s=this._vertices[o+1]:o==i-1&&this.closed&&(s=this._vertices[0]),s)for(var l=new wt(a,s,a.bulge),c=l.getPoints(t),u=c.length,h=0;h<u;++h){var d=c[h];n.push(new re(d.x,d.y))}}else n.push(new re(a.x,a.y)),o==i-1&&this.closed&&n.push(n[0])}return n},e.prototype.tessellate=function(t){for(var n=[],i=this._vertices.length,o=0;o<i;++o){var a=this._vertices[o];if(a.bulge){var s=null;if(o<i-1?s=this._vertices[o+1]:o===i-1&&this.closed&&(s=this._vertices[0]),s)for(var l=new wt(a,s,a.bulge),c=l.tessellate(t),u=0;u<c.length;++u)HI(n,c[u])}else HI(n,a),o===i-1&&this.closed&&n.length>0&&n.push(n[0].clone())}return n},e.prototype.offset=function(t){return e5(this,t)},e})(up);function HI(r,e){var t=r[r.length-1];if(t){var n=t.x-e.x,i=t.y-e.y;if(n*n+i*i<=tn*tn)return}r.push(new re(e.x,e.y))}function a5(r,e,t){var n=Math.hypot(e.x,e.y);if(Le.isNonPositive(n))return null;var i=-e.y/n*t,o=e.x/n*t;return new D(r.x+i,r.y+o,r.z)}function f$(r,e,t){var n;if(r.length<2)return null;var i=UW(new Sn(r.map(function(a){return{x:a.x,y:a.y}}),e)),o=e5(i,t);return(n=o[0])!==null&&n!==void 0?n:null}var z0=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},of=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))};function p$(r,e,t,n){if(r.length<2||Le.equalToZero(t))return null;var i=l5(r,n),o=i.points,a=i.tangents;if(o.length<2)return null;var s=a??m$(o,e),l=g$(o,s,t),c=e?v$(l):y$(l);if(c.length<2)return null;var u=new Sn;return c.forEach(function(h,d){u.addVertexAt(d,{x:h.x,y:h.y})}),u.closed=e,u}function m$(r,e){for(var t=r.length,n=new Array(t),i=0;i<t;i++){var o=0,a=0;if(e){var s=r[(i-1+t)%t],l=r[(i+1)%t];o=l.x-s.x,a=l.y-s.y}else i===0?(o=r[1].x-r[0].x,a=r[1].y-r[0].y):i===t-1?(o=r[t-1].x-r[t-2].x,a=r[t-1].y-r[t-2].y):(o=r[i+1].x-r[i-1].x,a=r[i+1].y-r[i-1].y);var c=Math.hypot(o,a);Le.isNonPositive(c)?n[i]=new re(1,0):n[i]=new re(o/c,a/c)}return n}function g$(r,e,t){return r.map(function(n,i){var o=e[i],a=-o.y*t,s=o.x*t;return new re(n.x+a,n.y+s)})}function y$(r){var e=j0(r);if(e.length<3)return e;for(;;){var t=s5(e,!1);if(!t||(e=j0(of(of(of([],z0(e.slice(0,t.segmentA+1)),!1),[t.point],!1),z0(e.slice(t.segmentB+1)),!1)),e.length<2))break}return e}function v$(r){var e=j0(r);if(e.length<4)return e;for(;;){var t=s5(e,!0);if(!t||(e=j0(of(of(of([],z0(e.slice(0,t.segmentA+1)),!1),[t.point],!1),z0(e.slice(t.segmentB+1)),!1)),e.length<3))break}return e}function s5(r,e){var t=e?r.length:r.length-1;if(t<2)return null;for(var n=0;n<t;n++)for(var i=r[n],o=r[(n+1)%r.length],a=n+1;a<t;a++)if(!b$(n,a,t,e)){var s=r[a],l=r[(a+1)%r.length],c=x$(i,o,s,l);if(c)return{point:c,segmentA:n,segmentB:a}}return null}function b$(r,e,t,n){return!!(e===r||e===r+1||n&&r===0&&e===t-1)}function x$(r,e,t,n){var i=e.x-r.x,o=e.y-r.y,a=n.x-t.x,s=n.y-t.y,l=i*s-o*a;if(Le.equalToZero(l))return null;var c=t.x-r.x,u=t.y-r.y,h=(c*s-u*a)/l,d=(c*o-u*i)/l,f=du.equalPointTol;return h<-f||h>1+f||d<-f||d>1+f?null:new re(r.x+h*i,r.y+h*o)}function l5(r,e){var t=[],n=[],i=e!=null&&e.length===r.length;return r.forEach(function(o,a){var s=t[t.length-1];if((!s||Le.isPositive(Math.hypot(s.x-o.x,s.y-o.y)))&&(t.push(new re(o.x,o.y)),i)){var l=e[a];n.push(new re(l.x,l.y))}}),{points:t,tangents:i?n:void 0}}function j0(r){return l5(r).points}var w$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Qa=(function(r){w$(e,r);function e(){var t=r.call(this)||this;return t._loops=[],t}return e.prototype.add=function(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(e.prototype,"loops",{get:function(){return this._loops},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outter",{get:function(){if(this._loops.length>0)return this._loops[0]},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t=this.outter;return t?t.box:new Bt},e.prototype.transform=function(t){return this._loops.forEach(function(n){n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){var t=new e;return this._loops.forEach(function(n){t.add(n.clone())}),t},e.prototype.getPoints=function(t){for(var n=[],i=0;i<this.loops.length;++i){var o=this.loops[i],a=o.getPoints(t);n.push(a)}return n},e.prototype.tessellate=function(t){return this.loops.map(function(n){return n.tessellate(t)})},e.prototype.buildHierarchy=function(t){for(var n,i=this.tessellate(t),o=this.calculateBoundaryBoxes(i),a=this.sortBoundaryBoxesByAreas(o),s=new Map,l=a.length,c=0;c<l;c++)s.set(a[c],{index:a[c],children:[]});for(var u={index:-1,children:[]},c=0;c<l;c++){for(var h=a[c],d=i[h],f=o[h],p=c+1;p<l;p++){var m=a[p],g=i[m],y=o[m];if(y.containsBox(f)&&Qn.isPointInPolygon(d[0],g)){(n=s.get(m))===null||n===void 0||n.children.push(s.get(h));break}}p===l&&u.children.push(s.get(h))}return u},Object.defineProperty(e.prototype,"area",{get:function(){if(this._loops.length===0)return 0;for(var t=0,n=0;n<this._loops.length;n++){var i=this._loops[n],o=i.getPoints(128),a=U4(o);n===0?t+=Math.abs(a):t-=Math.abs(a)}return t},enumerable:!1,configurable:!0}),e.prototype.calculateBoundaryBoxes=function(t){var n=[];return t.forEach(function(i){n.push(new Bt().setFromPoints(i))}),n},e.prototype.sortBoundaryBoxesByAreas=function(t){var n=[];t.forEach(function(o,a){var s=o.size,l=s.width*s.height;n.push({area:l,index:a})}),n.sort(function(o,a){return o.area-a.area});var i=[];return n.forEach(function(o){i.push(o.index)}),i},e})(sA),_$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),S$=(function(r){_$(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.translate=function(t){return this.transform(new Ue().makeTranslation(t.x,t.y,t.z))},Object.defineProperty(e.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),e})(Q4),P$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),hh=(function(r){P$(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.tessellateParametricCurve=function(t,n,i,o){var a=Math.max(2,Math.round(o.maxSegments)),s=Math.max(1,Math.round(o.minSegments)),l=Math.max(0,o.deviation)*Math.max(0,o.deviation);if(!Number.isFinite(t)||!Number.isFinite(n))return[i(0)];if(Math.abs(n-t)<=tn)return[i(t)];for(var c=Math.min(a,Math.max(2,s+1)),u=Math.min(a,Math.max(c,8)),h=M$(t,n,u),d=[],f=0;f<h.length;f++)d.push(i(h[f]));for(var p=d.length,m=0;m<8&&p<a;m++){for(var g=[],f=0;f<h.length-1&&!(p>=a);f++){var y=(h[f]+h[f+1])/2,v=i(y);p++,E$(v,d[f],d[f+1])>l&&g.push({index:f,t:y,point:v})}if(g.length===0)break;var x=k$(h,d,g);h=x.params,d.length=0;for(var f=0;f<x.points.length;f++)d.push(x.points[f])}return d},e})(S$);function E$(r,e,t){var n=t.x-e.x,i=t.y-e.y,o=t.z-e.z,a=r.x-e.x,s=r.y-e.y,l=r.z-e.z,c=n*n+i*i+o*o;if(c<=tn*tn)return a*a+s*s+l*l;var u=Tf((a*n+s*i+l*o)/c,0,1),h=a-n*u,d=s-i*u,f=l-o*u;return h*h+d*d+f*f}function M$(r,e,t){if(t<=1)return[r];for(var n=[],i=0;i<t;i++)n.push(i===t-1?e:r+(e-r)*i/(t-1));return n}function k$(r,e,t){for(var n=[],i=[],o=0,a=0;a<r.length;a++)for(n.push(r[a]),i.push(e[a]);o<t.length&&t[o].index===a;)n.push(t[o].t),i.push(t[o].point),o++;return{params:n,points:i}}var A$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),U0=function(){return U0=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},U0.apply(this,arguments)},a1=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},gr=(function(r){A$(e,r);function e(t,n,i,o,a,s){s===void 0&&(s=X.X_AXIS);var l=r.call(this)||this;return l.center=t,l.radius=n,l.startAngle=i,l.endAngle=o,l.normal=a,l.refVec=s,(o-i)%lt==0?(l.startAngle=0,l.endAngle=lt):(l.startAngle=i,l.endAngle=o),l}return e.computeCenterPoint=function(t,n,i){var o,a;return(a=(o=zI(t,i,n))===null||o===void 0?void 0:o.center)!==null&&a!==void 0?a:null},e.tryCreateByThreePoints=function(t,n,i){var o,a,s,l=zI(t,i,n);if(!l)return null;var c=l.center,u=l.radius,h=new X(t.x-c.x,t.y-c.y,((o=t.z)!==null&&o!==void 0?o:0)-c.z),d=new X(i.x-c.x,i.y-c.y,((a=i.z)!==null&&a!==void 0?a:0)-c.z),f=new X(n.x-c.x,n.y-c.y,((s=n.z)!==null&&s!==void 0?s:0)-c.z);if(h.lengthSq()===0||f.lengthSq()===0)return null;var p=new X().crossVectors(h,f);if(p.lengthSq()===0&&(p.crossVectors(h,d),p.lengthSq()===0))return null;p.normalize();var m=h.clone().normalize(),g=new X().crossVectors(p,m),y=function(x){return Te.normalizeAngle(Math.atan2(x.dot(g),x.dot(m)))};Te.isAngleOnCcwSweep(0,y(d),y(f))||(p.negate(),g.negate());var v=y(f);return Le.equalToZero(v)&&(v=lt),new e(c,u,0,v,p,m)},e.createByThreePoints=function(t,n,i){return e.tryCreateByThreePoints(t,n,i)},Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new D(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._startAngle},set:function(t){this._startAngle=Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._endAngle},set:function(t){this._endAngle=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deltaAngle",{get:function(){return Te.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal},set:function(t){this._normal=new X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refVec",{get:function(){return this._refVec},set:function(t){this._refVec=new X(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){var t=this.startAngle,n=this.deltaAngle;this.closed&&(t=0,n=lt);var i=t+n*.5;return this.getPointAtAngle(i)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){return this.closed?Math.PI*this.radius*this.radius:0},enumerable:!1,configurable:!0}),e.prototype.nearestPoint=function(t){var n=new X(t.x,t.y,t.z||0),i=this.center,o=this.normal,a=n.clone().sub(i),s=a.dot(o),l=n.clone().sub(o.clone().multiplyScalar(s)),c=l.clone().sub(i);if(c.lengthSq()===0)return this.startPoint.clone();c.normalize().multiplyScalar(this.radius);var u=i.clone().add(c),h=this.getAngle(u.clone()),d=this.startAngle,f=this.deltaAngle,p=Te.normalizeAngle(h-d);p<0&&(p=0),p>f&&(p=f);var m=this.getPointAtAngle(d+p),g=m.distanceTo(n),y=this.startPoint.distanceTo(n),v=this.endPoint.distanceTo(n);return y<g&&y<=v?this.startPoint.clone():v<g&&v<y?this.endPoint.clone():m},e.prototype.tangentPoints=function(t){var n,i,o=[],a=new X(t.x,t.y,t.z||0),s=this.center,l=this.normal,c=this.radius,u=a.clone().sub(s),h=u.dot(l),d=a.clone().sub(l.clone().multiplyScalar(h)),f=s.clone(),p=d.clone().sub(f),m=p.length();if(m<c)return o;var g=Math.acos(c/m),y=this.getAngle(d.clone()),v=[y+g,y-g];try{for(var x=a1(v),b=x.next();!b.done;b=x.next()){var w=b.value,_=Te.normalizeAngle(w-this.startAngle);_>=0&&_<=this.deltaAngle&&o.push(this.getPointAtAngle(this.startAngle+_))}}catch(P){n={error:P}}finally{try{b&&!b.done&&(i=x.return)&&i.call(x)}finally{if(n)throw n.error}}return o},e.prototype.perpendicularPoints=function(t){var n,i,o=[],a=new X(t.x,t.y,t.z||0),s=this.center,l=this.normal,c=this.radius,u=a.clone().sub(s),h=u.dot(l),d=a.clone().sub(l.clone().multiplyScalar(h)),f=d.clone().sub(s);if(f.lengthSq()<1e-24)return o;f.normalize();var p=[s.clone().add(f.clone().multiplyScalar(c)),s.clone().sub(f.clone().multiplyScalar(c))];try{for(var m=a1(p),g=m.next();!g.done;g=m.next()){var y=g.value,v=this.getAngle(y.clone()),x=Te.normalizeAngle(v-this.startAngle);x>=0&&x<=this.deltaAngle&&o.push(new D(y.x,y.y,y.z||0))}}catch(b){n={error:b}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}return o},e.prototype.nearestTangentPoint=function(t){var n=this.tangentPoints(t);if(n.length===0)return null;var i=new D(t.x,t.y,t.z||0);return n.length===1||n[0].distanceTo(i)<n[1].distanceTo(i)?n[0]:n[1]},e.prototype.calculateBoundingBox=function(){for(var t,n,i=[this.startAngle,this.endAngle],o=0;o<2*Math.PI;o+=Math.PI/2)Te.isBetweenAngle(o,this.startAngle,this.endAngle)&&i.push(o);var a=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=a1(i),f=d.next();!f.done;f=d.next()){var p=f.value,m=this.getPointAtAngle(p);m.x<a&&(a=m.x),m.y<s&&(s=m.y),m.z<l&&(l=m.z),m.x>c&&(c=m.x),m.y>u&&(u=m.y),m.z>h&&(h=m.z)}}catch(g){t={error:g}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}return new _t({x:a,y:s,z:l},{x:c,y:u,z:h})},Object.defineProperty(e.prototype,"closed",{get:function(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(t){var n=[],i=this.deltaAngle,o=this.startAngle;this.closed&&(i=lt,o=0);for(var a=0;a<=t;a++){var s=o+i*(a/t),l=this.getPointAtAngle(s);n.push(l)}return n},e.prototype.tessellate=function(t){var n,i=this.closed?lt:this.deltaAngle,o=e.segmentCount(this.radius,i,U0(U0({},t),{minSegments:(n=t==null?void 0:t.minSegments)!==null&&n!==void 0?n:this.closed?8:3}));return this.getPoints(o)},e.segmentCount=function(t,n,i){return wt.segmentCount(t,n,i)},e.prototype.transform=function(t){var n=this.center.clone().applyMatrix4(t),i=this.startPoint.clone().applyMatrix4(t),o=this.endPoint.clone().applyMatrix4(t),a=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),s=new X(i).sub(n).normalize(),l=n.distanceTo(i),c=new X().crossVectors(new X(i).sub(n),new X(a).sub(n)).normalize();c.lengthSq()===0&&(c=this.normal.clone().transformDirection(t));var u=function(h){var d=new X(h).sub(n);return Math.atan2(d.dot(GI.crossVectors(c,s)),d.dot(s))};return this.center=n,this.radius=l,this.normal=c,this.refVec=s,this.startAngle=0,this.endAngle=this.closed?lt:u(o),this._boundingBoxNeedsUpdate=!0,this},e.prototype.copy=function(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},e.prototype.clone=function(){return new e(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)},e.prototype.getAngle=function(t){return t.sub(this.center),Math.atan2(t.dot(GI.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))},e.prototype.getPointAtAngle=function(t){var n=this.normal,i=this.refVec,o={x:n.y*i.z-n.z*i.y,y:n.z*i.x-n.x*i.z,z:n.x*i.y-n.y*i.x},a=this.center,s=this.radius;return new D(a.x+s*(i.x*Math.cos(t)+o.x*Math.sin(t)),a.y+s*(i.y*Math.cos(t)+o.y*Math.sin(t)),a.z+s*(i.z*Math.cos(t)+o.z*Math.sin(t)))},Object.defineProperty(e.prototype,"plane",{get:function(){var t=new X(this.center).distanceTo(rA);return new Rw(this.normal,t)},enumerable:!1,configurable:!0}),e.prototype.offset=function(t){var n=this.radius+t;return n<=0?null:new e(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)},e})(hh),GI=new X,C$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Is=(function(r){C$(e,r);function e(t,n,i,o,a,s,l){o===void 0&&(o=0),a===void 0&&(a=lt),s===void 0&&(s=!1),l===void 0&&(l=0);var c=r.call(this)||this;return c.center=t,c.majorAxisRadius=n,c.minorAxisRadius=i,(a-o)%lt==0?(c.startAngle=0,c.endAngle=lt):(c.startAngle=o,c.endAngle=a),c.clockwise=s,c.rotation=l,c}return Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new D(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._startAngle},set:function(t){this._startAngle=Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._endAngle},set:function(t){this._endAngle=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this._clockwise},set:function(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deltaAngle",{get:function(){return Te.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){for(var t=100,n=1/0,i=1/0,o=-1/0,a=-1/0,s=0;s<=t;s++){var l=this.getPoint(s/t);n=Math.min(n,l.x),i=Math.min(i,l.y),o=Math.max(o,l.x),a=Math.max(a,l.y)}return new Bt({x:n,y:i},{x:o,y:a})},Object.defineProperty(e.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),e.prototype.getPoint=function(t){for(var n=Math.PI*2,i=this.endAngle-this.startAngle,o=Math.abs(i)<Number.EPSILON;i<0;)i+=n;for(;i>n;)i-=n;i<Number.EPSILON&&(o?i=0:i=n),this.clockwise===!0&&!o&&(i===n?i=-n:i=i-n);var a=this.startAngle+t*i,s=this.center.x+this.majorAxisRadius*Math.cos(a),l=this.center.y+this.minorAxisRadius*Math.sin(a);if(this.rotation!==0){var c=Math.cos(this.rotation),u=Math.sin(this.rotation),h=s-this.center.x,d=l-this.center.y;s=h*c-d*u+this.center.x,l=h*u+d*c+this.center.y}return new re(s,l)},e.prototype.transform=function(t){var n=t,i=new re(this.center).applyMatrix2d(n),o=new D(i.x,i.y,this.center.z),a=this.getPointAtAngle(0).clone().applyMatrix2d(n),s=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),l=new re(a).sub(i),c=new re(s).sub(i),u=l.length(),h=c.length(),d=Math.atan2(l.y,l.x),f=l.clone().normalize(),p=c.clone().normalize(),m=function(v){var x=new re(v).sub(i),b=x.dot(f),w=x.dot(p);return Te.normalizeAngle(Math.atan2(w/h,b/u))},g=n.determinant()<0?!this.clockwise:this.clockwise,y=this.closed?new e(o,u,h,0,lt,g,d):new e(o,u,h,m(this.startPoint.clone().applyMatrix2d(n)),m(this.endPoint.clone().applyMatrix2d(n)),g,d);return this.center=y.center,this.majorAxisRadius=y.majorAxisRadius,this.minorAxisRadius=y.minorAxisRadius,this._startAngle=y._startAngle,this._endAngle=y._endAngle,this._clockwise=y._clockwise,this.rotation=y.rotation,this._boundingBoxNeedsUpdate=!0,this},e.prototype.getPointAtAngle=function(t){return this.getPoint(this.closed?t/lt:Te.normalizeAngle(t-this.startAngle)/this.deltaAngle)},e.prototype.copy=function(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},e.prototype.clone=function(){return new e(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)},e.prototype.getFocusPoints=function(){var t=Math.max(this.majorAxisRadius,this.minorAxisRadius),n=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(t-n<1e-9)return[];var i=Math.sqrt(t*t-n*n),o=Math.cos(this.rotation),a=Math.sin(this.rotation),s=this.majorAxisRadius>=this.minorAxisRadius,l=s?o:-a,c=s?a:o;return[new re(this.center.x-i*l,this.center.y-i*c),new re(this.center.x+i*l,this.center.y+i*c)]},e.prototype.getQuadrantPoints=function(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]},e.prototype.nearestPoint=function(t){for(var n=new re(t.x,t.y),i=this.getPoint(0),o=n.distanceToSquared(i),a=72,s=1;s<=a;s++){var l=this.getPoint(s/a),c=n.distanceToSquared(l);c<o&&(o=c,i=l)}return i},e.prototype.tangentPoints=function(t){var n=this,i=this._projectPointToLocal(t),o=this._findSnapAngles(i,function(a,s,l,c){var u=-n.majorAxisRadius*c,h=n.minorAxisRadius*l;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype.perpendicularPoints=function(t){var n=this,i=this._projectPointToLocal(t),o=this._findSnapAngles(i,function(a,s,l,c){var u=n.minorAxisRadius*l,h=n.majorAxisRadius*c;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype._projectPointToLocal=function(t){var n=t.x-this.center.x,i=t.y-this.center.y,o=Math.cos(-this.rotation),a=Math.sin(-this.rotation);return{x:n*o-i*a,y:n*a+i*o}},e.prototype._findSnapAngles=function(t,n,i){i===void 0&&(i=144);for(var o=this.majorAxisRadius,a=this.minorAxisRadius,s=this.startAngle,l=this.deltaAngle,c=[],u=function(b){var w=Math.cos(b),_=Math.sin(b);return n(o*w,a*_,w,_)},h=s,d=u(h),f=1;f<=i;f++){var p=s+l*f/i,m=u(p);if(Math.abs(d)<1e-10&&c.push(h),d*m<0){for(var g=h,y=p,v=0;v<32;v++){var x=(g+y)/2;u(g)*u(x)<=0?y=x:g=x}c.push((g+y)/2)}h=p,d=m}return c},e})(up),T$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),V0=function(){return V0=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},V0.apply(this,arguments)},I$=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},qa=(function(r){T$(e,r);function e(t,n,i,o,a,s,l){s===void 0&&(s=0),l===void 0&&(l=lt);var c=r.call(this)||this;c.center=t,c.normal=n,c.majorAxis=i,c.majorAxisRadius=o,c.minorAxisRadius=a;var u=Math.abs(l-s);return Math.abs(u-lt)<1e-10||Math.abs(u-2*lt)<1e-10?(c.startAngle=0,c.endAngle=lt):(c.startAngle=s,c.endAngle=l),c}return Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new D(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._startAngle},set:function(t){this._startAngle=Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._endAngle},set:function(t){this._endAngle=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deltaAngle",{get:function(){var t=this.endAngle-this.startAngle;return Math.abs(t-lt)<1e-10?lt:Te.normalizeAngle(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal},set:function(t){this._normal=new X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorAxis",{get:function(){return this._majorAxis},set:function(t){this._majorAxis=new X(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorAxis",{get:function(){return new X().crossVectors(this.normal,this.majorAxis).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){var t=this.startAngle,n=this.deltaAngle;(this.closed||Math.abs(n-lt)<1e-10)&&(t=0,n=lt);var i=t+n/2;return this.getPointAtAngle(i)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCircular",{get:function(){return Le.equal(this.majorAxisRadius,this.minorAxisRadius)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);for(var t=1e3,n=this.deltaAngle/t,i=0,o=this.getPointAtAngle(this.startAngle),a=1;a<=t;a++){var s=this.startAngle+a*n,l=this.getPointAtAngle(s),c=l.x-o.x,u=l.y-o.y,h=l.z-o.z;i+=Math.sqrt(c*c+u*u+h*h),o=l}return i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){return Math.abs(this.deltaAngle-lt)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t,n;if(this.majorAxis.equals(X.X_AXIS)||this.majorAxis.equals(X.Y_AXIS)||this.majorAxis.isParallelTo(X.X_AXIS)||this.majorAxis.isParallelTo(X.Y_AXIS)){for(var i=[this.startAngle,this.endAngle],o=0;o<2*Math.PI;o+=Math.PI/2)Te.isBetweenAngle(o,this.startAngle,this.endAngle)&&i.push(o);var a=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=I$(i),f=d.next();!f.done;f=d.next()){var p=f.value,m=this.getPointAtAngle(p);m.x<a&&(a=m.x),m.y<s&&(s=m.y),m.z<l&&(l=m.z),m.x>c&&(c=m.x),m.y>u&&(u=m.y),m.z>h&&(h=m.z)}}catch(y){t={error:y}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}return new _t({x:a,y:s,z:l},{x:c,y:u,z:h})}else{for(var g=100,a=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0,o=0;o<=g;o++){var p=this.startAngle+this.deltaAngle*(o/g),m=this.getPointAtAngle(p);a=Math.min(a,m.x),s=Math.min(s,m.y),l=Math.min(l,m.z),c=Math.max(c,m.x),u=Math.max(u,m.y),h=Math.max(h,m.z)}return new _t({x:a,y:s,z:l},{x:c,y:u,z:h})}},Object.defineProperty(e.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(t){t===void 0&&(t=100);var n=[],i=this.deltaAngle,o=this.startAngle;this.closed&&(i=lt,o=0);for(var a=0;a<=t;a++){var s=o+i*(a/t),l=this.getPointAtAngle(s);n.push(l)}return n},e.prototype.tessellate=function(t){var n=this,i,o,a=wt.resolveTessellateOptions(t),s=this.closed?lt:this.deltaAngle,l=Math.max(this.majorAxisRadius,this.minorAxisRadius),c=Math.abs(s)>=lt-1e-8,u=(i=a.minSegments)!==null&&i!==void 0?i:c?8:3;if(this.isCircular){var h=gr.segmentCount(l,s,V0(V0({},t),{minSegments:u}));return this.getPoints(h)}var d=(o=a.deviation)!==null&&o!==void 0?o:wt.chordDeviationFromRadius(l,a.circleSides),f=this.closed?0:this.startAngle;return hh.tessellateParametricCurve(f,f+s,function(p){return n.getPointAtAngle(p)},{deviation:Math.max(tn,d),minSegments:u,maxSegments:a.maxSegments})},e.prototype.getPointAtAngle=function(t){var n=Math.cos(t),i=Math.sin(t),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(i),a=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(o);return new D(this.center.x+a.x,this.center.y+a.y,this.center.z+a.z)},e.prototype.nearestPoint=function(t,n){n===void 0&&(n=72);for(var i=new D(t.x,t.y,t.z||0),o=this.getPointAtAngle(this.startAngle),a=i.distanceToSquared(o),s=1;s<=n;s++){var l=this.startAngle+this.deltaAngle*s/n,c=this.getPointAtAngle(l),u=i.distanceToSquared(c);u<a&&(a=u,o=c)}var h=i.distanceToSquared(this.startPoint),d=i.distanceToSquared(this.endPoint);return h<a&&h<=d?this.startPoint.clone():d<a&&d<h?this.endPoint.clone():o.clone()},e.prototype.tangentPoints=function(t){var n=this,i=this._projectPointToLocalPlane(t),o=this._findSnapParameterAngles(function(a,s,l,c){var u=-n.majorAxisRadius*c,h=n.minorAxisRadius*l;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype.perpendicularPoints=function(t){var n=this,i=this._projectPointToLocalPlane(t),o=this._findSnapParameterAngles(function(a,s,l,c){var u=n.minorAxisRadius*l,h=n.majorAxisRadius*c;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype._projectPointToLocalPlane=function(t){var n=new D(t.x,t.y,t.z||0),i=new X(n).sub(this.center),o=i.dot(this.normal);return i.sub(this.normal.clone().multiplyScalar(o)),{x:i.dot(this.majorAxis),y:i.dot(this.minorAxis)}},e.prototype._findSnapParameterAngles=function(t,n){n===void 0&&(n=144);for(var i=this.majorAxisRadius,o=this.minorAxisRadius,a=this.startAngle,s=this.deltaAngle,l=[],c=function(x){var b=Math.cos(x),w=Math.sin(x);return t(i*b,o*w,b,w)},u=a,h=c(u),d=1;d<=n;d++){var f=a+s*d/n,p=c(f);if(Math.abs(h)<1e-10&&l.push(u),h*p<0){for(var m=u,g=f,y=0;y<32;y++){var v=(m+g)/2;c(m)*c(v)<=0?g=v:m=v}l.push((m+g)/2)}u=f,h=p}return l},e.prototype.contains=function(t){var n=new X(t).sub(this.center),i=n.dot(this.majorAxis),o=n.dot(this.minorAxis),a=i/this.majorAxisRadius,s=o/this.minorAxisRadius;return a*a+s*s<=1},e.prototype.transform=function(t){var n=t,i=this.center.clone().applyMatrix4(n),o=this.getPointAtAngle(0).clone().applyMatrix4(n),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),s=new X(o).sub(i),l=new X(a).sub(i),c=s.length(),u=l.length(),h=s.clone().normalize(),d=new X().crossVectors(s,l).normalize(),f=new X().crossVectors(d,h).normalize();f.dot(l)<0&&(d.negate(),f=new X().crossVectors(d,h).normalize());var p=function(g){var y=new X(g).sub(i),v=y.dot(h),x=y.dot(f);return Te.normalizeAngle(Math.atan2(x/u,v/c))},m=this.closed?new e(i,d,h,c,u,0,lt):new e(i,d,h,c,u,p(this.startPoint.clone().applyMatrix4(n)),p(this.endPoint.clone().applyMatrix4(n)));return this.center=m.center,this.normal=m.normal,this.majorAxis=m.majorAxis,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._endAngle,this._boundingBoxNeedsUpdate=!0,this},e.prototype.copy=function(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},e.prototype.clone=function(){return new e(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)},Object.defineProperty(e.prototype,"plane",{get:function(){var t=new X(this.center).distanceTo(rA);return new Rw(this.normal,t)},enumerable:!1,configurable:!0}),e.prototype.offset=function(t){var n=this.majorAxisRadius+t,i=this.minorAxisRadius+t;return n<=0||i<=0?null:new e(this.center,this.normal,this.majorAxis,n,i,this.startAngle,this.endAngle)},e})(hh),L$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Pi=(function(r){L$(e,r);function e(t,n){var i=r.call(this)||this;return i._start=new re(t),i._end=new re(n),i}return Object.defineProperty(e.prototype,"startPoint",{get:function(){return this._start},set:function(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._end},set:function(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(){return[this.startPoint,this.endPoint]},Object.defineProperty(e.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t=new re(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),n=new re(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new Bt(t,n)},e.prototype.transform=function(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(e.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.copy=function(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._start.clone(),this._end.clone())},e.prototype.project=function(t){var n=this._end.x-this._start.x,i=this._end.y-this._start.y,o=n*n+i*i;if(o<1e-18)return this._start.clone();var a=((t.x-this._start.x)*n+(t.y-this._start.y)*i)/o;return a=Math.max(0,Math.min(1,a)),new re(this._start.x+a*n,this._start.y+a*i)},e.prototype.nearestPoint=function(t){return this.project(t)},e})(up),O$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Ai=(function(r){O$(e,r);function e(t,n){var i=r.call(this)||this;return i._start=new D(t),i._end=new D(n),i}return Object.defineProperty(e.prototype,"startPoint",{get:function(){return this._start},set:function(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._end},set:function(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return new X().subVectors(this.endPoint,this.startPoint).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){return new D((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)},enumerable:!1,configurable:!0}),e.prototype.nearestPoint=function(t){return this.project(t)},Object.defineProperty(e.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),e.prototype.isPointOnLine=function(t){var n=this.project(t),i=1e-6;return n.distanceTo(t)<i},e.prototype.at=function(t,n){return this.delta(n).multiplyScalar(t).add(this._start)},e.prototype.atLength=function(t,n){if(n===void 0&&(n=!1),n){var i=this.delta(vu).normalize();return new D(this._start).addScaledVector(i,t)}else{var i=this.delta(vu).normalize();return new D(this._end).addScaledVector(i,t)}},e.prototype.extend=function(t,n){if(n===void 0&&(n=!1),n){var i=vu.subVectors(this._start,this._end).normalize();this._start=new D(this._start).addScaledVector(i,t)}else{var i=this.delta(vu).normalize();this._end=new D(this._end).addScaledVector(i,t)}return this._boundingBoxNeedsUpdate=!0,this},e.prototype.closestPointToPointParameter=function(t,n){WI.subVectors(t,this._start),qy.subVectors(this.endPoint,this.startPoint);var i=qy.dot(qy),o=qy.dot(WI),a=o/i;return n&&(a=Te.clamp(a,0,1)),a},e.prototype.closestPointToPoint=function(t,n,i){var o=this.closestPointToPointParameter(t,n);return this.delta(i).multiplyScalar(o).add(this._start)},e.prototype.delta=function(t){return t.subVectors(this._end,this._start)},e.prototype.distanceSq=function(){return this._start.distanceToSquared(this._end)},e.prototype.distance=function(){return this._start.distanceTo(this._end)},e.prototype.project=function(t){var n=this.direction,i=vu.subVectors(t,this.startPoint),o=i.dot(n);return new D().copy(n).multiplyScalar(o).add(this.startPoint)},e.prototype.perpPoint=function(t){var n=this.direction,i=this.startPoint,o=vu.subVectors(t,i),a=o.dot(n),s=vu.copy(n).multiplyScalar(a);return new D().addVectors(i,s)},e.prototype.calculateBoundingBox=function(){var t=new D(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),n=new D(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 _t(t,n)},e.prototype.transform=function(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(e.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.copy=function(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._start.clone(),this._end.clone())},e.prototype.offset=function(t){var n=this.startPoint,i=this.endPoint,o=Math.hypot(i.x-n.x,i.y-n.y);if(o===0)return this.clone();var a=new X(i.x-n.x,i.y-n.y,0).normalize(),s=new X(-a.y,a.x,0);return new e(new D(n.x+s.x*t,n.y+s.y*t,n.z),new D(i.x+s.x*t,i.y+s.y*t,i.z))},e})(hh),vu=new X,WI=new X,qy=new X,D$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),s1=(function(){function r(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}return r.prototype.init=function(e,t,n,i){this.c0=e,this.c1=n,this.c2=-3*e+3*t-2*n-i,this.c3=2*e-2*t+n+i},r.prototype.initCatmullRom=function(e,t,n,i,o){this.init(t,n,o*(n-e),o*(i-t))},r.prototype.initNonuniformCatmullRom=function(e,t,n,i,o,a,s){var l=(t-e)/o-(n-e)/(o+a)+(n-t)/a,c=(n-t)/a-(i-t)/(a+s)+(i-n)/s;l*=a,c*=a,this.init(t,n,l,c)},r.prototype.calc=function(e){var t=e*e,n=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*n},r})(),c5=(function(r){D$(e,r);function e(t,n,i,o){t===void 0&&(t=[]),n===void 0&&(n=!1),i===void 0&&(i="centripetal"),o===void 0&&(o=.5);var a=r.call(this)||this;return a.isCatmullRomCurve3d=!0,a.type="CatmullRomCurve3d",a._tmp=new X,a._px=new s1,a._py=new s1,a._pz=new s1,a._points=t.map(function(s){return new D(s)}),a._closed=n,a._curveType=i,a._tension=o,a}return Object.defineProperty(e.prototype,"points",{get:function(){return this._points},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"curveType",{get:function(){return this._curveType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._tension},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this._points.length>0?this._points[0]:new D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){if(this._points.length<2)return 0;for(var t=0,n=1;n<this._points.length;n++)t+=this._points[n-1].distanceTo(this._points[n]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t},enumerable:!1,configurable:!0}),e.prototype.getPoint=function(t,n){n===void 0&&(n=new D);var i=n,o=this._points,a=o.length;if(a===0)return i.set(0,0,0);if(a===1)return i.copy(o[0]);var s=(a-(this._closed?0:1))*t,l=Math.floor(s),c=s-l;this._closed?l+=l>0?0:(Math.floor(Math.abs(l)/a)+1)*a:c===0&&l===a-1&&(l=a-2,c=1);var u,h;this._closed||l>0?u=o[(l-1)%a]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),u=new D(this._tmp.x,this._tmp.y,this._tmp.z));var d=o[l%a],f=o[(l+1)%a];if(this._closed||l+2<a?h=o[(l+2)%a]:(this._tmp.subVectors(o[a-1],o[a-2]).add(o[a-1]),h=new D(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var p=this._curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),p),g=Math.pow(d.distanceToSquared(f),p),y=Math.pow(f.distanceToSquared(h),p);g<1e-4&&(g=1),m<1e-4&&(m=g),y<1e-4&&(y=g),this._px.initNonuniformCatmullRom(u.x,d.x,f.x,h.x,m,g,y),this._py.initNonuniformCatmullRom(u.y,d.y,f.y,h.y,m,g,y),this._pz.initNonuniformCatmullRom(u.z,d.z,f.z,h.z,m,g,y)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(u.x,d.x,f.x,h.x,this._tension),this._py.initCatmullRom(u.y,d.y,f.y,h.y,this._tension),this._pz.initCatmullRom(u.z,d.z,f.z,h.z,this._tension));return i.set(this._px.calc(c),this._py.calc(c),this._pz.calc(c)),i},e.prototype.getPoints=function(t){for(var n=[],i=0;i<=t;i++)n.push(this.getPoint(i/t));return n},e.prototype.setPoints=function(t){this._points=t.map(function(n){return new D(n)}),this._boundingBoxNeedsUpdate=!0},e.prototype.setClosed=function(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)},e.prototype.setCurveType=function(t){this._curveType=t},e.prototype.setTension=function(t){this._tension=t},e.prototype.clone=function(){return new e(this._points.map(function(t){return t.clone()}),this._closed,this._curveType,this._tension)},e.prototype.transform=function(t){return this._points=this._points.map(function(n){var i=new D;return i.copy(n),i.applyMatrix4(t),i}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new _t;var t=new _t;return this._points.forEach(function(n){t.expandByPoint(n)}),t},e})(hh),Xd=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},Yd=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))};function $I(r,e){var t,n,i=r.x-e[0],o=r.y-e[1],a=((t=r.z)!==null&&t!==void 0?t:0)-((n=e[2])!==null&&n!==void 0?n:0);return i*i+o*o+a*a}var Wo=(function(){function r(e,t,n,i){this._degree=e,this._knots=Yd([],Xd(t),!1),this._controlPoints=n.map(function(o){return{x:o.x,y:o.y,z:o.z}}),this._weights=i?Yd([],Xd(i),!1):new Array(n.length).fill(1)}return r.prototype.degree=function(){return this._degree},r.prototype.knots=function(){return Yd([],Xd(this._knots),!1)},r.prototype.controlPoints=function(){return this._controlPoints.map(function(e){return{x:e.x,y:e.y,z:e.z}})},r.prototype.weights=function(){return Yd([],Xd(this._weights),!1)},r.prototype.clone=function(){return new r(this._degree,this._knots,this._controlPoints,this._weights)},r.prototype.point=function(e){return this.evaluate(e).point},r.prototype.evaluate=function(e){var t=this._controlPoints.map(function(n){return[n.x,n.y,n.z]});return SW(e,this._degree,this._knots,t,this._weights)},r.prototype.signedPlanarCurvatureAt=function(e){var t=this.evaluate(e);return PW(t.deriv1,t.deriv2)},r.prototype.getOffsetSamplePath2d=function(e,t){var n=this;t===void 0&&(t=512);for(var i=Math.abs(e),o=this.getParameterRange(),a=o.start,s=o.end,l=this.length(),c=Math.max(64,Math.ceil(l/Math.max(i*.2,1e-6))),u=R$(a,s,Math.min(c,t)),h=0;h<8&&u.length<t;h++){for(var d=[],f=0;f<u.length-1;f++){var p=u[f],m=u[f+1],g=(p+m)/2,y=Math.max(Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(m)),Math.abs(this.signedPlanarCurvatureAt(g)));i*y>.85&&d.push(g)}if(d.length===0)break;if(u=F$(u,d),u.length>t){u=u.slice(0,t);break}}var v=[],x=[];return u.forEach(function(b){var w=n.evaluate(b);v.push(new re(w.point[0],w.point[1]));var _=w.deriv1[0],P=w.deriv1[1],S=Math.hypot(_,P);x.push(S>1e-10?new re(_/S,P/S):new re(1,0))}),{points:v,tangents:x}},r.prototype.length=function(){var e=this._controlPoints.map(function(t){return[t.x,t.y,t.z]});return $4(this._degree,this._knots,e,this._weights)},r.byKnotsControlPointsWeights=function(e,t,n,i){return new r(e,t,n,i)},r.byPoints=function(e,t,n,i,o){n===void 0&&(n="Uniform");var a=W4(e,t,n,i,o),s=a.controlPoints.map(function(l){return{x:l[0],y:l[1],z:l[2]}});return new r(t,a.knots,s,a.weights)},r.prototype.getParameterRange=function(){var e=this._knots[this._degree],t=this._knots[this._knots.length-this._degree-1];return{start:e,end:t}},r.prototype.getPoints=function(e){for(var t=[],n=this.getParameterRange(),i=n.start,o=n.end,a=0;a<=e;a++){var s=i+(o-i)*(a/e);t.push(this.point(s))}return t},r.prototype.isClosed=function(e){e===void 0&&(e=1e-6);var t=this.getParameterRange(),n=t.start,i=t.end,o=this.point(n),a=this.point(i),s=o[0]-a[0],l=o[1]-a[1],c=o[2]-a[2];return Math.sqrt(s*s+l*l+c*c)<e},r.createFitPointsForClosedCurve=function(e){if(e.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");var t=new c5(e,!0,"centripetal"),n=Math.max(50,e.length*2);return t.getPoints(n)},r.prototype.nearestPoint=function(e,t){var n;t===void 0&&(t=64);for(var i=this.getParameterRange(),o=i.start,a=i.end,s=this.point(o),l=$I(e,s),c=0;c<=t;c++){var u=o+(a-o)*c/t,h=this.point(u),d=$I(e,h);d<l&&(l=d,s=h)}return{x:s[0],y:s[1],z:(n=s[2])!==null&&n!==void 0?n:0}},r.createClosedCurve=function(e,t,n){n===void 0&&(n="Chord");var i=this.createFitPointsForClosedCurve(e),o=i.map(function(a){return[a.x,a.y,a.z]});return r.byPoints(o,t,n)},r})();function R$(r,e,t){if(t<2)return[r,e];for(var n=[],i=0;i<t;i++)n.push(i===t-1?e:r+(e-r)*i/(t-1));return n}function F$(r,e){var t=Yd(Yd([],Xd(r),!1),Xd(e),!1).sort(function(i,o){return i-o}),n=[];return t.forEach(function(i){var o=n[n.length-1];(o===void 0||Math.abs(o-i)>1e-10)&&n.push(i)}),n}function XI(r){var e,t,n;if(!r)return!1;var i=(e=r.x)!==null&&e!==void 0?e:0,o=(t=r.y)!==null&&t!==void 0?t:0,a=(n=r.z)!==null&&n!==void 0?n:0;return i*i+o*o+a*a>1e-20}function B$(r,e,t){var n=r??0;return n<1&&t>0&&e>0&&(n=t-e-1),n<1&&(n=3),n=Math.min(n,e-1),Math.max(1,n)}function N$(r,e,t){var n=r??0;n<1&&(n=3);var i=e+t-1;return n=Math.min(n,i),Math.max(1,n)}function z$(r,e){if(!(!r||r.length!==e))return r}var j$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),YI=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},qI=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},KI=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},_i=(function(r){j$(e,r);function e(t,n,i,o,a,s){var l=r.call(this)||this,c=arguments.length;if(l._degree=3,l._closed=!1,Array.isArray(n)){if(c<2||c>5)throw qi.ILLEGAL_PARAMETERS;l._controlPoints=t;var f=void 0,p=3,m=!1;if(c>=3&&(Array.isArray(i)?(f=i,c>=4&&(p=o||3),c>=5&&(m=a)):i!==void 0&&(p=i||3,c>=4&&(m=o))),i===void 0&&c>=4&&(p=o||3,c>=5&&(m=a)),l._degree=p,l._closed=m,l._controlPoints.length<l._degree+1)throw qi.ILLEGAL_PARAMETERS;l._nurbsCurve=Wo.byKnotsControlPointsWeights(l._degree,n,l._controlPoints,f)}else{if(c<2||c>6)throw qi.ILLEGAL_PARAMETERS;l._fitPoints=t,l._knotParameterization=n,c>=3&&(l._degree=i||3);var u=typeof o=="boolean";c>=4&&u&&(l._closed=o),u?(c>=5&&(l._startTangent=a),c>=6&&(l._endTangent=s)):(c>=4&&(l._startTangent=o),c>=5&&(l._endTangent=a)),l._closed&&(l._startTangent=void 0,l._endTangent=void 0);var h=(l._startTangent?1:0)+(l._endTangent?1:0);if(l._fitPoints.length+h<l._degree+1)throw qi.ILLEGAL_PARAMETERS;if(l._closed)l._nurbsCurve=Wo.createClosedCurve(l._fitPoints,l._degree,l._knotParameterization);else{var d=l.toNurbsPoints(l._fitPoints);l._nurbsCurve=Wo.byPoints(d,l._degree,l._knotParameterization,l._startTangent?l.toNurbsPoint(l._startTangent):void 0,l._endTangent?l.toNurbsPoint(l._endTangent):void 0)}l._controlPoints=l.toGePoints(l._nurbsCurve.controlPoints().map(function(g){return[g.x,g.y,g.z||0]}))}return l}return e.prototype.buildCurve=function(){if(this._fitPoints&&this._knotParameterization){if(this._closed){var t=Wo.createFitPointsForClosedCurve(this._fitPoints),n=this.toNurbsPoints(t);this._nurbsCurve=Wo.byPoints(n,this._degree,this._knotParameterization)}else{var n=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Wo.byPoints(n,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(function(a){return[a.x,a.y,a.z||0]}))}else if(this._controlPoints)if(this._closed){var t=Wo.createFitPointsForClosedCurve(this._controlPoints),n=this.toNurbsPoints(t);this._nurbsCurve=Wo.byPoints(n,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(function(l){return[l.x,l.y,l.z||0]}))}else{var i=this._nurbsCurve.knots(),o=this._nurbsCurve.weights();this._nurbsCurve=Wo.byKnotsControlPointsWeights(this._degree,i,this._controlPoints,o)}},e.prototype.setClosed=function(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())},Object.defineProperty(e.prototype,"degree",{get:function(){return this._degree},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"knotParameterization",{get:function(){return this._knotParameterization},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controlPoints",{get:function(){return this._controlPoints.map(Qn.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fitPoints",{get:function(){var t;return(t=this._fitPoints)===null||t===void 0?void 0:t.map(Qn.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"knots",{get:function(){return qI([],YI(this._nurbsCurve.knots()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weights",{get:function(){return qI([],YI(this._nurbsCurve.weights()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){var t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),i=t[n],o=this._nurbsCurve.point(i);return new D(o[0],o[1],o[2])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){var t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),i=t[t.length-n-1],o=this._nurbsCurve.point(i);return new D(o[0],o[1],o[2])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._nurbsCurve.length()},enumerable:!1,configurable:!0}),e.prototype.nearestPoint=function(t,n){n===void 0&&(n=64);var i=this._nurbsCurve.nearestPoint(t,n);return new D(i.x,i.y,i.z||0)},e.prototype.evaluateAt=function(t){var n=this._nurbsCurve.point(t);return new D(n[0],n[1],n[2])},e.prototype.getFitPointAt=function(t){if(!this._fitPoints)throw new Error("No fit points in this spline");var n=this._fitPoints.length,i=t<0||t>=n?n-1:t,o=this._fitPoints[i];return Qn.point2dToPoint3d(o)},e.prototype.getControlPointAt=function(t){var n=this._controlPoints.length,i=t<0||t>=n?n-1:t;return this._controlPoints[i]},Object.defineProperty(e.prototype,"isFitPointSpline",{get:function(){return!!(this._fitPoints&&this._fitPoints.length>0&&this._knotParameterization)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isControlPointSpline",{get:function(){return!this.isFitPointSpline},enumerable:!1,configurable:!0}),e.prototype.getGripPoints=function(){return this.isFitPointSpline?this._fitPoints.map(function(t){var n;return new D(t.x,t.y,(n=t.z)!==null&&n!==void 0?n:0)}):this._controlPoints.map(function(t){var n;return new D(t.x,t.y,(n=t.z)!==null&&n!==void 0?n:0)})},e.prototype.moveGripPointsAt=function(t,n){return this.isFitPointSpline?(this.moveFitPointsAt(t,n),this):(this.moveControlPointsAt(t,n),this)},e.prototype.moveFitPointsAt=function(t,n){var i,o;if(this._fitPoints){try{for(var a=KI(t),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(!Number.isInteger(l)||l<0)){var c=this._fitPoints[l];c&&Qn.applyOffsetToPoint3d(c,n)}}}catch(u){i={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}},e.prototype.moveControlPointsAt=function(t,n){var i,o;try{for(var a=KI(t),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(!Number.isInteger(l)||l<0)){var c=this.getControlPointAt(l);c&&Qn.applyOffsetToPoint3d(c,n)}}}catch(u){i={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}this.rebuildAfterControlPointMutation()},e.prototype.rebuildAfterControlPointMutation=function(){var t=this._nurbsCurve.knots(),n=this._nurbsCurve.weights();this.isFitPointSpline&&(this._fitPoints=void 0,this._knotParameterization=void 0,this._startTangent=void 0,this._endTangent=void 0),this._nurbsCurve=Wo.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,n.length>0?n:void 0),this._boundingBoxNeedsUpdate=!0},e.prototype.getOffsetSamplePath2d=function(t){return this._nurbsCurve.getOffsetSamplePath2d(t)},e.prototype.getPoints=function(t){t===void 0&&(t=100);for(var n=this._nurbsCurve,i=[],o=n.knots(),a=this._nurbsCurve.degree(),s=o[a],l=o[o.length-a-1],c=(l-s)/(t-1),u=0;u<t;u++){var h=u===t-1?l:s+u*c,d=n.point(h);i.push(new D(d[0],d[1],d[2]))}return i},e.prototype.tessellate=function(t){var n=this,i,o,a=wt.resolveTessellateOptions(t),s=this._nurbsCurve.knots(),l=this._nurbsCurve.degree();if(s.length<l+2)return[this.startPoint.clone(),this.endPoint.clone()];var c=s[l],u=s[s.length-l-1],h=a.circleSides,d=Math.abs(this.length),f=(i=a.deviation)!==null&&i!==void 0?i:Math.max(tn,d<=tn?tn:d/(2*h*h));return hh.tessellateParametricCurve(c,u,function(p){return n.evaluateAt(p)},{deviation:f,minSegments:(o=a.minSegments)!==null&&o!==void 0?o:this.closed?8:2,maxSegments:a.maxSegments})},e.prototype.getCurvePoints=function(t,n){for(var i=[],o=t.knots(),a=t.degree(),s=o[a],l=o[o.length-a-1],c=(l-s)/(n-1),u=0;u<n;u++){var h=s+u*c;i.push(t.point(h))}return i},e.prototype.calculateBoundingBox=function(){var t=this.getPoints(100);return new _t().setFromPoints(t)},Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){this.setClosed(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){if(!this._closed)return 0;var t=this.getPoints(128);return V4(t)},enumerable:!1,configurable:!0}),e.prototype.transform=function(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(function(o){return new D(o).applyMatrix4(t)}),this._startTangent&&(this._startTangent=new D(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new D(this._endTangent).transformDirection(t)),this.buildCurve();else{var n=this._nurbsCurve.knots(),i=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(function(o){return new D(o).applyMatrix4(t)}),this._nurbsCurve=Wo.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,i.length>0?i:void 0)}return this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return this._fitPoints&&this._knotParameterization?new e(this._fitPoints.map(Qn.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?Qn.point2dToPoint3d(this._startTangent):void 0,this._endTangent?Qn.point2dToPoint3d(this._endTangent):void 0):new e(this._controlPoints.map(Qn.point2dToPoint3d),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)},e.prototype.toNurbsPoints=function(t){var n=new Array(t.length);return t.forEach(function(i,o){n[o]=[i.x,i.y,i.z||0]}),n},e.prototype.toGePoints=function(t){var n=new Array(t.length);return t.forEach(function(i,o){n[o]={x:i[0],y:i[1],z:i[2]}}),n},e.prototype.toNurbsPoint=function(t){return[t.x,t.y,t.z||0]},e.createClosedSpline=function(t,n,i){if(n===void 0&&(n="Uniform"),i===void 0&&(i=3),t.length<i+1)throw new Error("At least ".concat(i+1," points are required for a degree ").concat(i," closed spline"));return new e(t,n,i,!0)},e.fromControlPoints=function(t,n,i,o,a){if(t.length<2||n.length<2)return null;var s=B$(o,t.length,n.length);if(t.length<s+1)return null;try{return new e(t,n,z$(i,t.length),s,a)}catch{return null}},e.fromFitPoints=function(t,n,i,o,a,s){if(t.length<2)return null;var l=XI(a),c=XI(s),u=(l?1:0)+(c?1:0),h=N$(i,t.length,u);if(t.length+u<h+1)return null;try{return l||c?new e(t,n,h,o,l?a:void 0,c?s:void 0):new e(t,n,h,o)}catch{return null}},e.fromDwgSplineEdge=function(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0){var n=t.controlPoints.map(Qn.point2dToPoint3d),i=!0,o=t.controlPoints.map(function(s){return s.weight==null&&(i=!1),s.weight||1});return e.fromControlPoints(n,t.knots,i?o:void 0,t.degree,!1)}if(t.numberOfFitData>0){var a=t.fitDatum.map(Qn.point2dToPoint3d);return e.fromFitPoints(a,"Uniform",t.degree,!1,t.startTangent?Qn.point2dToPoint3d(t.startTangent):void 0,t.endTangent?Qn.point2dToPoint3d(t.endTangent):void 0)}return null},e})(hh),U$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),l1=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},c1=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},Wl=(function(r){U$(e,r);function e(t){t===void 0&&(t=[]);var n=r.call(this)||this;return n._curves=t,n}return Object.defineProperty(e.prototype,"curves",{get:function(){return this._curves},enumerable:!1,configurable:!0}),e.buildFromEdges=function(t,n){if(n===void 0&&(n=.001),t.length===0)return[];for(var i=c1([],l1(t),!1),o=[],a=n*n,s=function(p,m){var g=p.x-m.x,y=p.y-m.y;return g*g+y*y<=a};i.length>0;){var l=[],c=i.shift();l.push(c);var u=e.getEdgeStartPoint(c),h=e.getEdgeEndPoint(c);if(!s(u,h))for(;i.length>0;){var d=e.findConnectingEdge(i,h,a);if(d.index<0)break;var f=i.splice(d.index,1)[0];if(d.reverse&&(f=e.reverseEdge(f)),l.push(f),h=e.getEdgeEndPoint(f),s(h,u))break}o.push(new e(l))}return o},e.prototype.add=function(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(e.prototype,"numberOfEdges",{get:function(){return this._curves.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){if(this._curves.length>0){var t=this._curves[0].startPoint;return new re(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.startPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){var t=0;return this._curves.forEach(function(n){t+=n.length}),t},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t=this.getPoints(100),n=new Bt;return n.setFromPoints(t),n},e.prototype.transform=function(t){var n=new Ue().set(t.elements[0],t.elements[3],0,t.elements[6],t.elements[1],t.elements[4],0,t.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(function(i){i instanceof _i?i.transform(n):i.transform(t)}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._curves.map(function(t){return t.clone()}))},Object.defineProperty(e.prototype,"closed",{get:function(){return!0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(t){var n=[];return this.curves.forEach(function(i){i.getPoints(t).forEach(function(o){n.push(new re(o.x,o.y))})}),n},e.prototype.tessellate=function(t){var n=[];return this._curves.forEach(function(i){V$(i,t).forEach(function(o){var a=n[n.length-1];a&&Math.pow(a.x-o.x,2)+Math.pow(a.y-o.y,2)<=tn*tn||n.push(new re(o.x,o.y))})}),n},e.findConnectingEdge=function(t,n,i){for(var o=-1,a=!1,s=Number.POSITIVE_INFINITY,l=0;l<t.length;l++){var c=t[l],u=e.getEdgeStartPoint(c),h=e.getEdgeEndPoint(c),d=n.x-u.x,f=n.y-u.y,p=d*d+f*f;p<s&&(s=p,o=l,a=!1);var m=n.x-h.x,g=n.y-h.y,y=m*m+g*g;y<s&&(s=y,o=l,a=!0)}return s>i?{index:-1,reverse:!1}:{index:o,reverse:a}},e.getEdgeStartPoint=function(t){var n=t.startPoint;return new re(n.x,n.y)},e.getEdgeEndPoint=function(t){var n=t.endPoint;return new re(n.x,n.y)},e.reverseEdge=function(t){return t instanceof Pi?new Pi(t.endPoint,t.startPoint):t instanceof wt?e.reverseCircArcEdge(t):t instanceof Is?new Is(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof _i?e.reverseSplineEdge(t):t},e.reverseCircArcEdge=function(t){var n=t.startPoint,i=t.endPoint,o=!t.clockwise,a=Math.atan2(i.y-t.center.y,i.x-t.center.x),s=Math.atan2(n.y-t.center.y,n.x-t.center.x),l=function(c){var u=Te.normalizeAngle(c);return o?Te.normalizeAngle(-u):u};return new wt(t.center,t.radius,l(a),l(s),o)},e.reverseSplineEdge=function(t){var n=c1([],l1(t.controlPoints),!1).reverse(),i=t.knots,o=i[0],a=i[i.length-1],s=i.map(function(u){return o+a-u}).reverse(),l=t.weights,c=l.length>0?c1([],l1(l),!1).reverse():void 0;return new _i(n,s,c,t.degree,t.closed)},e})(up);function V$(r,e){if(r instanceof Pi)return r.getPoints();if(r instanceof wt||r instanceof _i)return r.tessellate(e);var t=r.closed?lt:r.deltaAngle,n=wt.segmentCount(Math.max(r.majorAxisRadius,r.minorAxisRadius),t,e);return r.getPoints(n)}var Lo=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},mg=128,H0=96,Et=du.equalPointTol,lA=Et*8;function H$(r,e,t,n,i){var o,a,s,l;t===void 0&&(t=!1),n===void 0&&(n=!1);var c=ZI(r,t,i),u=ZI(e,n,i),h=[];try{for(var d=Lo(c),f=d.next();!f.done;f=d.next()){var p=f.value;try{for(var m=(s=void 0,Lo(u)),g=m.next();!g.done;g=m.next()){var y=g.value;cA(p,y)&&pA(h,d5(p,y))}}catch(v){s={error:v}}finally{try{g&&!g.done&&(l=m.return)&&l.call(m)}finally{if(s)throw s.error}}}}catch(v){o={error:v}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}return lX(h)}function G$(r,e){var t=W$(r);switch(t.kind){case"line":return t.line.transform(e),t;case"circArc":return t.arc.transform(e),t;case"ellipseArc":return t.arc.transform(e),t;case"spline":return t.spline.transform(e),t}}function W$(r){switch(r.kind){case"line":return{kind:"line",line:r.line.clone(),extent:r.extent,extendable:r.extendable};case"circArc":return{kind:"circArc",arc:r.arc.clone(),extendable:r.extendable};case"ellipseArc":return{kind:"ellipseArc",arc:r.arc.clone(),extendable:r.extendable};case"spline":return{kind:"spline",spline:r.spline.clone(),extendable:r.extendable}}}function ZI(r,e,t){var n,i,o=[];try{for(var a=Lo(r),s=a.next();!s.done;s=a.next()){var l=s.value,c=e&&l.extendable!==!1;switch(l.kind){case"line":{var u=q$(l.line,t);if(!u)break;var h=c?"unbounded":l.extent;o.push(hp(u.start,u.end,h));break}case"circArc":{var d=X$(l.arc,c);if(t&&!gg(d.normal,t.normal)){var f=Z$(d,t);(f==null?void 0:f.kind)==="circArc"?o.push(JI(f.arc,Bs(f.arc))):(f==null?void 0:f.kind)==="ellipseArc"?o.push(QI(f.arc,Ul(f.arc))):u1(o,u5(d,Bs(d)),Bs(d),t)}else{var f=K$(d,t);f&&o.push(JI(f,Bs(f)))}break}case"ellipseArc":{var d=Y$(l.arc,c);if(t&&!gg(d.normal,t.normal))u1(o,h5(d,Ul(d)),Ul(d),t);else{var f=J$(d,t);f&&o.push(QI(f,Ul(f)))}break}case"spline":{t?u1(o,l.spline.getPoints(mg),l.spline.closed,t):o.push($$(l.spline));break}}}}catch(p){n={error:p}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o}function hp(r,e,t){var n=new X().subVectors(e,r);return{kind:"line",start:r,dir:n,extent:t,box:t==="bounded"?new _t().setFromPoints([r,e]):void 0}}function JI(r,e){return{kind:"circArc",arc:r,full:e||Bs(r),box:r.box}}function QI(r,e){return{kind:"ellipseArc",arc:r,full:e||Ul(r),box:r.box}}function $$(r){var e,t,n=[],i=r.getPoints(mg);if(i.length>=2)for(var o=r.closed?i.length:i.length-1,a=0;a<o;a++){var s=i[a],l=i[(a+1)%i.length];s.distanceToSquared(l)<Et*Et||n.push(hp(s.clone(),l.clone(),"bounded"))}var c=new _t;try{for(var u=Lo(n),h=u.next();!h.done;h=u.next()){var d=h.value;d.box&&c.union(d.box)}}catch(f){e={error:f}}finally{try{h&&!h.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}return{kind:"spline",spline:r,samples:n,box:n.length>0?c:void 0}}function X$(r,e){return!e||Bs(r)?r:new gr(r.center,r.radius,0,lt,r.normal,r.refVec)}function Y$(r,e){return!e||Ul(r)?r:new qa(r.center,r.normal,r.majorAxis,r.majorAxisRadius,r.minorAxisRadius,0,lt)}function q$(r,e){if(!e)return{start:r.startPoint.clone(),end:r.endPoint.clone()};var t=jl(r.startPoint,e),n=jl(r.endPoint,e);return t.distanceToSquared(n)<Et*Et?null:{start:t,end:n}}function K$(r,e){if(!e)return r;var t=jl(r.center,e);return new gr(t,r.radius,r.startAngle,r.endAngle,e.normal.clone(),hA(r.refVec,e.normal))}function Z$(r,e){var t=jl(r.center,e),n=r.normal.clone();if(n.lengthSq()<Et*Et)return null;n.normalize();var i=e.normal.clone();if(i.lengthSq()<Et*Et)return null;i.normalize();var o=n.dot(i),a=Math.abs(o);if(a>1-1e-8)return{kind:"circArc",arc:new gr(t,r.radius,r.startAngle,r.endAngle,i,hA(r.refVec,i))};if(a<1e-8)return null;var s=new X().crossVectors(n,i);if(s.lengthSq()<Et*Et)return null;s.normalize();var l=new qa(t,i,s,r.radius,r.radius*a,0,lt);if(Bs(r))return{kind:"ellipseArc",arc:l};var c=jl(r.startPoint,e),u=jl(r.endPoint,e),h=jl(r.midPoint,e),d=af(l,c),f=af(l,u),p=af(l,h),m=Te.normalizeAngle(p-d),g=Te.normalizeAngle(f-d),y=m<=g||g<1e-8?d+g:d+g+lt;return{kind:"ellipseArc",arc:new qa(t,i,s,r.radius,r.radius*a,d,y)}}function J$(r,e){if(!e)return r;var t=jl(r.center,e),n=hA(r.majorAxis,e.normal);return n.lengthSq()<Et*Et?null:new qa(t,e.normal.clone(),n,r.majorAxisRadius,r.minorAxisRadius,r.startAngle,r.endAngle)}function u1(r,e,t,n){if(!(e.length<2))for(var i=n?e.map(function(c){return jl(c,n)}):e,o=t?i.length:i.length-1,a=0;a<o;a++){var s=i[a],l=i[(a+1)%i.length];s.distanceToSquared(l)<Et*Et||r.push(hp(s.clone(),l.clone(),"bounded"))}}function u5(r,e){return e||Bs(r)?new gr(r.center,r.radius,0,lt,r.normal,r.refVec).getPoints(H0):r.getPoints(H0)}function h5(r,e){return e||Ul(r)?new qa(r.center,r.normal,r.majorAxis,r.majorAxisRadius,r.minorAxisRadius,0,lt).getPoints(H0):r.getPoints(H0)}function cA(r,e){return!r.box||!e.box?!0:r.box.intersectsBox(e.box)}function d5(r,e){return r.kind==="spline"&&e.kind==="spline"?Q$(r,e):r.kind==="spline"?eL(r,e):e.kind==="spline"?eL(e,r):r.kind==="line"&&e.kind==="line"?f5(r,e):r.kind==="line"&&e.kind==="circArc"?G0(r,e.arc,e.full):e.kind==="line"&&r.kind==="circArc"?G0(e,r.arc,r.full):r.kind==="line"&&e.kind==="ellipseArc"?wE(r,e.arc,e.full):e.kind==="line"&&r.kind==="ellipseArc"?wE(e,r.arc,r.full):r.kind==="circArc"&&e.kind==="circArc"?iX(r.arc,r.full,e.arc,e.full):r.kind==="circArc"&&e.kind==="ellipseArc"?tL(r.arc,r.full,e.arc,e.full):r.kind==="ellipseArc"&&e.kind==="circArc"?tL(e.arc,e.full,r.arc,r.full):r.kind==="ellipseArc"&&e.kind==="ellipseArc"?aX(r.arc,r.full,e.arc,e.full):[]}function eL(r,e){var t,n,i=[];try{for(var o=Lo(r.samples),a=o.next();!a.done;a=o.next()){var s=a.value;cA(s,e)&&pA(i,d5(s,e))}}catch(l){t={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return eX(r.spline,i,e)}function Q$(r,e){var t,n,i,o,a,s,l=[];try{for(var c=Lo(r.samples),u=c.next();!u.done;u=c.next()){var h=u.value;try{for(var d=(i=void 0,Lo(e.samples)),f=d.next();!f.done;f=d.next()){var p=f.value;cA(h,p)&&pA(l,f5(h,p))}}catch(w){i={error:w}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(w){t={error:w}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}var m=[];try{for(var g=Lo(l),y=g.next();!y.done;y=g.next()){var v=y.value,x=r.spline.nearestPoint(v,mg),b=e.spline.nearestPoint(v,mg);x.distanceTo(b)<=lA&&m.push(x)}}catch(w){a={error:w}}finally{try{y&&!y.done&&(s=g.return)&&s.call(g)}finally{if(a)throw a.error}}return m}function eX(r,e,t){var n,i,o=[];try{for(var a=Lo(e),s=a.next();!s.done;s=a.next()){var l=s.value,c=r.nearestPoint(l,mg);tX(t,c)<=lA&&o.push(c)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o}function tX(r,e){if(r.kind==="line"){var t=r.dir.lengthSq();if(t<Et*Et)return Number.POSITIVE_INFINITY;var n=new X().subVectors(e,r.start).dot(r.dir)/t;return Lf(n,r.extent)?Of(r.start,r.dir,n).distanceTo(e):Number.POSITIVE_INFINITY}if(r.kind==="circArc"){if(!fA(e,r.arc)){var i=ca(r.arc.normal,r.arc.center),o=Math.abs(i.distanceToPoint(e)),a=Math.abs(e.distanceTo(r.arc.center)-r.arc.radius),s=Math.hypot(o,a);if(s>lA)return s}return fh(r.arc,dh(r.arc,e),r.full)?0:Number.POSITIVE_INFINITY}return r.kind==="ellipseArc"?Df(e,r.arc,r.full)?0:Math.abs(Fw(r.arc,e)):Number.POSITIVE_INFINITY}function f5(r,e){var t=r.dir,n=e.dir,i=t.lengthSq(),o=n.lengthSq();if(i<Et*Et||o<Et*Et)return[];var a=new X().subVectors(r.start,e.start),s=t.dot(t),l=t.dot(n),c=n.dot(n),u=t.dot(a),h=n.dot(a),d=s*c-l*l;if(Math.abs(d)<tn*tn*s*c)return[];var f=(l*h-c*u)/d,p=(s*h-l*u)/d;if(!Lf(f,r.extent)||!Lf(p,e.extent))return[];var m=Of(r.start,t,f),g=Of(e.start,n,p);return m.distanceTo(g)>Et?[]:[m]}function G0(r,e,t){var n=ca(e.normal,e.center),i=m5(r,n);return i==="coplanar"?nX(r,e,t):i?fA(i,e)?fh(e,dh(e,i),t)?[i]:[]:[]:[]}function nX(r,e,t){var n,i,o=new X().subVectors(r.start,e.center),a=r.dir.dot(r.dir);if(a<Et*Et)return[];var s=2*r.dir.dot(o),l=o.dot(o)-e.radius*e.radius,c=[];try{for(var u=Lo(y5(a,s,l)),h=u.next();!h.done;h=u.next()){var d=h.value;if(Lf(d,r.extent)){var f=Of(r.start,r.dir,d);fh(e,dh(e,f),t)&&c.push(f)}}}catch(p){n={error:p}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}return c}function wE(r,e,t){var n=ca(e.normal,e.center),i=m5(r,n);return i==="coplanar"?rX(r,e,t):i?Df(i,e,t)?[i]:[]:[]}function rX(r,e,t){var n,i,o=e.majorAxis,a=e.minorAxis,s=e.majorAxisRadius,l=e.minorAxisRadius;if(s<Et||l<Et)return[];var c=new X().subVectors(r.start,e.center),u=c.dot(o),h=c.dot(a),d=r.dir.dot(o),f=r.dir.dot(a),p=d*d/(s*s)+f*f/(l*l),m=2*u*d/(s*s)+2*h*f/(l*l),g=u*u/(s*s)+h*h/(l*l)-1,y=[];try{for(var v=Lo(y5(p,m,g)),x=v.next();!x.done;x=v.next()){var b=x.value;if(Lf(b,r.extent)){var w=Of(r.start,r.dir,b);dA(e,af(e,w),t)&&y.push(w)}}}catch(_){n={error:_}}finally{try{x&&!x.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}return y}function iX(r,e,t,n){if(gg(r.normal,t.normal)){var i=ca(r.normal,r.center);return Math.abs(i.distanceToPoint(t.center))>Et?[]:sX(oX(r,t),r,e,t,n)}var o=uA(ca(r.normal,r.center),ca(t.normal,t.center));if(!o)return[];var a=hp(o.point.clone(),new D().addVectors(o.point,o.dir),"unbounded"),s=G0(a,r,e);return s.filter(function(l){return fA(l,t)?fh(t,dh(t,l),n):!1})}function oX(r,e){var t=new X().subVectors(e.center,r.center),n=t.length(),i=r.radius,o=e.radius;if(n<Et&&Le.equal(i,o,Et))return[];if(n>i+o+Et)return[];if(n+Math.min(i,o)+Et<Math.max(i,o))return[];var a=n<Et?g5(r.normal):t.clone().normalize(),s=(i*i-o*o+n*n)/(2*Math.max(n,Et)),l=i*i-s*s,c=new D().copy(r.center).addScaledVector(a,s);if(l<-Et*Et)return[];if(l<Et*Et)return[c];var u=Math.sqrt(Math.max(0,l)),h=new X().crossVectors(r.normal,a).normalize();return[new D().copy(c).addScaledVector(h,u),new D().copy(c).addScaledVector(h,-u)]}function tL(r,e,t,n){if(!gg(r.normal,t.normal)){var i=uA(ca(r.normal,r.center),ca(t.normal,t.center));if(!i)return[];var o=hp(i.point.clone(),new D().addVectors(i.point,i.dir),"unbounded");return G0(o,r,e).filter(function(a){return Df(a,t,n)})}return p5(u5(r,e),Bs(r)||e,function(a){return Fw(t,a)},function(a){return fh(r,dh(r,a),e)&&Df(a,t,n)})}function aX(r,e,t,n){if(!gg(r.normal,t.normal)){var i=uA(ca(r.normal,r.center),ca(t.normal,t.center));if(!i)return[];var o=hp(i.point.clone(),new D().addVectors(i.point,i.dir),"unbounded");return wE(o,r,e).filter(function(a){return Df(a,t,n)})}return p5(h5(r,e),Ul(r)||e,function(a){return Fw(t,a)},function(a){return dA(r,af(r,a),e)&&Df(a,t,n)})}function p5(r,e,t,n){for(var i=[],o=e?r.length:r.length-1,a=0;a<o;a++){var s=r[a],l=r[(a+1)%r.length],c=t(s),u=t(l);if(Math.abs(c)<=Et){n(s)&&i.push(s.clone());continue}if(!(c*u>0)){for(var h=0,d=1,f=c,p=0;p<40;p++){var m=(h+d)/2,g=new D().lerpVectors(s,l,m),y=t(g);f*y<=0?d=m:(h=m,f=y)}var v=new D().lerpVectors(s,l,(h+d)/2);n(v)&&i.push(v)}}return i}function m5(r,e){var t=e.normal.dot(r.dir),n=e.distanceToPoint(r.start);if(Le.equalToZero(t,Et*Math.max(1,r.dir.length())))return Le.equalToZero(n,Et)?"coplanar":null;var i=-n/t;return Lf(i,r.extent)?Of(r.start,r.dir,i):null}function uA(r,e){var t=new X().crossVectors(r.normal,e.normal);if(t.lengthSq()<Et*Et)return null;t.normalize();var n=r.normal,i=e.normal,o=n.dot(n)*i.dot(i)-Math.pow(n.dot(i),2);if(Math.abs(o)<tn)return null;var a=-r.constant,s=-e.constant,l=(i.dot(i)*a-n.dot(i)*s)/o,c=(n.dot(n)*s-n.dot(i)*a)/o,u=new D().addScaledVector(n,l).addScaledVector(i,c);return{point:u,dir:t}}function Lf(r,e){return e==="unbounded"?!0:e==="ray"?r>=-Et:r>=-Et&&r<=1+Et}function Of(r,e,t){return new D().copy(r).addScaledVector(e,t)}function jl(r,e){var t=new D;return e.projectPoint(r,t),t}function hA(r,e){var t=r.clone().addScaledVector(e,-r.dot(e));return t.lengthSq()<Et*Et?g5(e):t.normalize()}function ca(r,e){return new Rw().setFromNormalAndCoplanarPoint(r,e)}function gg(r,e){return new X().crossVectors(r,e).lengthSq()<Et*Et}function dh(r,e){var t=new X().subVectors(e,r.center),n=new X().crossVectors(r.normal,r.refVec);return Math.atan2(t.dot(n),t.dot(r.refVec))}function af(r,e){var t=new X().subVectors(e,r.center),n=t.dot(r.majorAxis)/r.majorAxisRadius,i=t.dot(r.minorAxis)/r.minorAxisRadius;return Math.atan2(i,n)}function Bs(r){return r.closed||Math.abs(r.deltaAngle-lt)<1e-10}function Ul(r){return r.closed||Math.abs(r.endAngle-r.startAngle)<1e-10||Math.abs(r.deltaAngle-lt)<1e-10}function fh(r,e,t){if(t||Bs(r))return!0;var n=Te.normalizeAngle(e-r.startAngle);return n<=r.deltaAngle+1e-8}function dA(r,e,t){if(t||Ul(r))return!0;var n=Te.normalizeAngle(e-r.startAngle);return n<=r.deltaAngle+1e-8}function fA(r,e){var t=ca(e.normal,e.center);return Math.abs(t.distanceToPoint(r))>Et?!1:Math.abs(r.distanceTo(e.center)-e.radius)<=Et}function Fw(r,e){var t=new X().subVectors(e,r.center),n=t.dot(r.majorAxis)/r.majorAxisRadius,i=t.dot(r.minorAxis)/r.minorAxisRadius;return n*n+i*i-1}function Df(r,e,t){var n=ca(e.normal,e.center);return Math.abs(n.distanceToPoint(r))>Et||Math.abs(Fw(e,r))>1e-4?!1:dA(e,af(e,r),t)}function sX(r,e,t,n,i){return r.filter(function(o){return fh(e,dh(e,o),t)&&fh(n,dh(n,o),i)})}function g5(r){var e=Math.abs(r.x)<.9?X.X_AXIS:X.Y_AXIS,t=new X().crossVectors(r,e);return t.lengthSq()<Et*Et&&t.crossVectors(r,X.Z_AXIS),t.normalize()}function y5(r,e,t){if(Math.abs(r)<tn)return Math.abs(e)<tn?[]:[-t/e];var n=e*e-4*r*t;if(n<-Et)return[];if(n<Et)return[-e/(2*r)];var i=Math.sqrt(Math.max(0,n));return[(-e-i)/(2*r),(-e+i)/(2*r)]}function pA(r,e){var t,n;try{for(var i=Lo(e),o=i.next();!o.done;o=i.next()){var a=o.value;r.push(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}function lX(r){var e,t,n=[],i=function(l){if(n.some(function(c){return c.distanceTo(l)<=Et}))return"continue";n.push(l)};try{for(var o=Lo(r),a=o.next();!a.done;a=o.next()){var s=a.value;i(s)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return n}var nL=[{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}],Xi=(function(){function r(e){if(typeof e=="string"){var t=nL.find(function(n){return n.name===e});if(!t)throw new Error("Unknown DWG version name: ".concat(e));this.name=t.name,this.value=t.value;return}if(typeof e=="number"){var t=nL.find(function(i){return i.value===e});if(!t)throw new Error("Unknown DWG version value: ".concat(e));this.name=t.name,this.value=t.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}return Object.defineProperty(r.prototype,"capabilities",{get:function(){return r.capabilitiesFor(this.value)},enumerable:!1,configurable:!0}),Object.defineProperty(r,"latest",{get:function(){return new r("AC1032")},enumerable:!1,configurable:!0}),r.capabilitiesFor=function(e){var t=e>=19;return{supportsHandles:t,supportsSubclassMarkers:t,supportsClassesSection:t,supportsObjectsSection:t,supportsBlockRecordTable:t,supportsLwPolyline:t,supportsLineWeight:e>=23,supportsTrueColor:e>=25,supportsTransparency:e>=25,supportsUtf8CodePage:e>=27,supportsBlockRecordUnitsFlags:e>=27,supportsMLeader:e>=27,supportsHatchHeaderVars:e>=29}},r})();function dp(r){return r===999?"comment":r===5?"handle":r<=9||r===100||r===102?"string":r===105?"handle":r>=101&&r<=109?"string":r<=59?"double":r<=79?"int":r<=89?"string":r<=99?"int":r<=149?"double":r<=159?"string":r<=169?"long":r<=179?"int":r<=209?"string":r<=239?"double":r<=269?"long":r<=289?"int":r<=299?"bool":r<=309?"string":r<=319?"binary":r<=369?"handle":r<=389?"int":r<=399?"handle":r<=409?"int":r<=419?"string":r<=429?"int":r<=439?"string":r<=449||r<=459?"int":r<=469?"double":r<=479?"string":r===480||r===481?"handle":r===1004?"binary":r===1005?"handle":r>=1e3&&r<=1009?"string":r>=1010&&r<=1059?"double":r>=1060&&r<=1070||r===1071?"int":"string"}function v5(r){return r>=90&&r<=99||r>=420&&r<=429||r>=440&&r<=449||r>=450&&r<=459||r===1071}var W0;(function(r){r[r.UTF8=0]="UTF8",r[r.US_ASCII=1]="US_ASCII",r[r.ISO_8859_1=2]="ISO_8859_1",r[r.ISO_8859_2=3]="ISO_8859_2",r[r.ISO_8859_3=4]="ISO_8859_3",r[r.ISO_8859_4=5]="ISO_8859_4",r[r.ISO_8859_5=6]="ISO_8859_5",r[r.ISO_8859_6=7]="ISO_8859_6",r[r.ISO_8859_7=8]="ISO_8859_7",r[r.ISO_8859_8=9]="ISO_8859_8",r[r.ISO_8859_9=10]="ISO_8859_9",r[r.CP437=11]="CP437",r[r.CP850=12]="CP850",r[r.CP852=13]="CP852",r[r.CP855=14]="CP855",r[r.CP857=15]="CP857",r[r.CP860=16]="CP860",r[r.CP861=17]="CP861",r[r.CP863=18]="CP863",r[r.CP864=19]="CP864",r[r.CP865=20]="CP865",r[r.CP869=21]="CP869",r[r.CP932=22]="CP932",r[r.MACINTOSH=23]="MACINTOSH",r[r.BIG5=24]="BIG5",r[r.CP949=25]="CP949",r[r.JOHAB=26]="JOHAB",r[r.CP866=27]="CP866",r[r.ANSI_1250=28]="ANSI_1250",r[r.ANSI_1251=29]="ANSI_1251",r[r.ANSI_1252=30]="ANSI_1252",r[r.GB2312=31]="GB2312",r[r.ANSI_1253=32]="ANSI_1253",r[r.ANSI_1254=33]="ANSI_1254",r[r.ANSI_1255=34]="ANSI_1255",r[r.ANSI_1256=35]="ANSI_1256",r[r.ANSI_1257=36]="ANSI_1257",r[r.ANSI_874=37]="ANSI_874",r[r.ANSI_932=38]="ANSI_932",r[r.ANSI_936=39]="ANSI_936",r[r.ANSI_949=40]="ANSI_949",r[r.ANSI_950=41]="ANSI_950",r[r.ANSI_1361=42]="ANSI_1361",r[r.UTF16=43]="UTF16",r[r.ANSI_1258=44]="ANSI_1258",r[r.UNDEFINED=255]="UNDEFINED"})(W0||(W0={}));var cX=["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","euc-kr","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"],b5=function(r){return cX[r]},uX={cp949:"euc-kr",uhc:"euc-kr",euckr:"euc-kr",windows949:"euc-kr",ksc56011987:"euc-kr",cp936:"gbk"},x5=function(r){var e,t=r.toLowerCase().replace(/[_-]/g,"");return(e=uX[t])!==null&&e!==void 0?e:r},mA=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Am=250,_E=255,w5=127;function _5(r){var e=r??"";if(e.length<=Am)return[{code:1,value:e}];for(var t=[],n=0;e.length-n>Am;)t.push({code:3,value:e.slice(n,n+Am)}),n+=Am;return t.push({code:1,value:e.slice(n)}),t}function S5(r,e){var t,n,i=r??"";if(i.length===0)return[""];var o=new TextEncoder,a=[],s="",l=0;try{for(var c=mA(i),u=c.next();!u.done;u=c.next()){var h=u.value,d=o.encode(h).byteLength;if(d>e){s.length>0&&(a.push(s),s="",l=0),a.push(h);continue}l+d>e&&s.length>0?(a.push(s),s=h,l=d):(s+=h,l+=d)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}return s.length>0&&a.push(s),a}function P5(r,e){if(r.byteLength===0)return[r];for(var t=[],n=0;n<r.byteLength;n+=e)t.push(r.subarray(n,n+e));return t}function hX(r){return r<=127?1:3+(r<=65535?4:8)}function dX(r,e){var t,n,i=r??"";if(i.length===0)return[""];var o=[],a="",s=0;try{for(var l=mA(i),c=l.next();!c.done;c=l.next()){var u=c.value,h=u.codePointAt(0),d=hX(h);if(d>e){a.length>0&&(o.push(a),a="",s=0),o.push(u);continue}s+d>e&&a.length>0?(o.push(a),a=u,s=d):(a+=u,s+=d)}}catch(f){t={error:f}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return a.length>0&&o.push(a),o}function fX(r){for(var e,t,n=r??"",i=!1,o=0;o<n.length;o++)if(n.charCodeAt(o)>127){i=!0;break}if(!i)return n;var a="";try{for(var s=mA(n),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.codePointAt(0);if(u<=127)a+=c;else{var h=u.toString(16).toUpperCase();a+="\\U+"+(h.length<=4?h.padStart(4,"0"):h.padStart(8,"0"))}}}catch(d){e={error:d}}finally{try{l&&!l.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return a}function gA(r){var e=r??"";return!e.includes("\\U+")&&!e.includes("\\u+")?e:e.replace(/\\U\+([0-9A-Fa-f]{4,8})/gi,function(t,n){var i=Number.parseInt(n,16);if(!Number.isFinite(i)||i<0||i>1114111)return t;try{return String.fromCodePoint(i)}catch{return t}})}var h1=(function(){for(var r=`AutoCAD Binary DXF\r
|
|
1
|
+
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();const OG="modulepreload",DG=function(r,e){return new URL(r,e).href},TI={},Qg=function(e,t,n){let i=Promise.resolve();if(t&&t.length>0){let a=function(u){return Promise.all(u.map(h=>Promise.resolve(h).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const s=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=a(t.map(u=>{if(u=DG(u,n),u in TI)return;TI[u]=!0;const h=u.endsWith(".css"),d=h?'[rel="stylesheet"]':"";if(!!n)for(let m=s.length-1;m>=0;m--){const g=s[m];if(g.href===u&&(!h||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const p=document.createElement("link");if(p.rel=h?"stylesheet":OG,h||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),h)return new Promise((m,g)=>{p.addEventListener("load",m),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(a){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=a,window.dispatchEvent(s),!s.defaultPrevented)throw a}return i.then(a=>{for(const s of a||[])s.status==="rejected"&&o(s.reason);return e().catch(o)})},RG="HtmlPlugin",FG=["-chtml","chtml"];let Q_={};function BG(r,e){e&&(Q_={...Q_,...e});const t={...Q_};r.registerLazyPlugin({name:RG,triggers:[...FG],loader:async()=>{const{createHtmlPlugin:n}=await Qg(async()=>{const{createHtmlPlugin:i}=await import("./cad-html-plugin-sPFUE7nW.js");return{createHtmlPlugin:i}},[],import.meta.url);return n(t)}})}const NG="PdfPlugin",zG=["-cpdf","cpdf","ipdf"];function jG(r,e={}){const t=e.disableExport===!0,n=t?["ipdf"]:[...zG];r.registerLazyPlugin({name:NG,triggers:[...n],loader:async()=>{const{createPdfPlugin:i}=await Qg(async()=>{const{createPdfPlugin:o}=await import("./cad-pdf-plugin-BBOPzTrv.js");return{createPdfPlugin:o}},[],import.meta.url);return i({disableExport:t})}})}var na;(function(r){r[r.Invalid=-9999]="Invalid",r[r.Start=0]="Start",r[r.Text=1]="Text",r[r.AttributeTag=2]="AttributeTag",r[r.BlockName=2]="BlockName",r[r.ShapeName=2]="ShapeName",r[r.SymbolTableName=2]="SymbolTableName",r[r.SymbolTableRecordName=2]="SymbolTableRecordName",r[r.MlineStyleName=2]="MlineStyleName",r[r.AttributePrompt=3]="AttributePrompt",r[r.Description=3]="Description",r[r.DimPostString=3]="DimPostString",r[r.DimStyleName=3]="DimStyleName",r[r.LinetypeProse=3]="LinetypeProse",r[r.TextFontFile=3]="TextFontFile",r[r.CLShapeName=4]="CLShapeName",r[r.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",r[r.SymbolTableRecordComments=4]="SymbolTableRecordComments",r[r.TextBigFontFile=4]="TextBigFontFile",r[r.Handle=5]="Handle",r[r.DimensionBlock=5]="DimensionBlock",r[r.LinetypeName=6]="LinetypeName",r[r.DimBlk1=6]="DimBlk1",r[r.TextStyleName=7]="TextStyleName",r[r.DimBlk2=7]="DimBlk2",r[r.LayerName=8]="LayerName",r[r.CLShapeText=9]="CLShapeText",r[r.XCoordinate=10]="XCoordinate",r[r.YCoordinate=20]="YCoordinate",r[r.ZCoordinate=30]="ZCoordinate",r[r.Real=40]="Real",r[r.TxtSize=40]="TxtSize",r[r.ViewportHeight=40]="ViewportHeight",r[r.Angle=50]="Angle",r[r.ViewportSnapAngle=50]="ViewportSnapAngle",r[r.Visibility=60]="Visibility",r[r.Int16=70]="Int16",r[r.Int32=90]="Int32",r[r.Int64=160]="Int64",r[r.Int8=280]="Int8",r[r.Thickness=39]="Thickness",r[r.Elevation=38]="Elevation",r[r.LinetypeScale=48]="LinetypeScale",r[r.DashLength=49]="DashLength",r[r.MlineOffset=49]="MlineOffset",r[r.LinetypeElement=49]="LinetypeElement",r[r.NormalX=210]="NormalX",r[r.NormalY=220]="NormalY",r[r.NormalZ=230]="NormalZ",r[r.UcsOrg=110]="UcsOrg",r[r.UcsOrientationX=111]="UcsOrientationX",r[r.UcsOrientationY=112]="UcsOrientationY",r[r.ViewHeight=45]="ViewHeight",r[r.ViewWidth=41]="ViewWidth",r[r.ViewLensLength=42]="ViewLensLength",r[r.ViewFrontClip=43]="ViewFrontClip",r[r.ViewBackClip=44]="ViewBackClip",r[r.ViewBrightness=141]="ViewBrightness",r[r.ViewContrast=142]="ViewContrast",r[r.ViewMode=71]="ViewMode",r[r.ViewportActive=68]="ViewportActive",r[r.ViewportAspect=41]="ViewportAspect",r[r.ViewportGrid=76]="ViewportGrid",r[r.ViewportIcon=74]="ViewportIcon",r[r.ViewportNumber=69]="ViewportNumber",r[r.ViewportSnap=75]="ViewportSnap",r[r.ViewportSnapPair=78]="ViewportSnapPair",r[r.ViewportSnapStyle=77]="ViewportSnapStyle",r[r.ViewportTwist=51]="ViewportTwist",r[r.ViewportVisibility=67]="ViewportVisibility",r[r.ViewportZoom=73]="ViewportZoom",r[r.Color=62]="Color",r[r.ColorRgb=420]="ColorRgb",r[r.ColorName=430]="ColorName",r[r.LineWeight=370]="LineWeight",r[r.PlotStyleNameType=380]="PlotStyleNameType",r[r.PlotStyleNameId=390]="PlotStyleNameId",r[r.GradientObjType=450]="GradientObjType",r[r.GradientAngle=460]="GradientAngle",r[r.GradientName=470]="GradientName",r[r.GradientColCount=453]="GradientColCount",r[r.GradientPatType=451]="GradientPatType",r[r.GradientTintType=452]="GradientTintType",r[r.GradientShift=461]="GradientShift",r[r.GradientColVal=463]="GradientColVal",r[r.GradientTintVal=462]="GradientTintVal",r[r.SoftPointerId=330]="SoftPointerId",r[r.HardPointerId=340]="HardPointerId",r[r.SoftOwnershipId=350]="SoftOwnershipId",r[r.HardOwnershipId=360]="HardOwnershipId",r[r.ArbitraryHandle=320]="ArbitraryHandle",r[r.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",r[r.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",r[r.ExtendedDataControlString=1002]="ExtendedDataControlString",r[r.ExtendedDataLayerName=1003]="ExtendedDataLayerName",r[r.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",r[r.ExtendedDataHandle=1005]="ExtendedDataHandle",r[r.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",r[r.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",r[r.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",r[r.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",r[r.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",r[r.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",r[r.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",r[r.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",r[r.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",r[r.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",r[r.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",r[r.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",r[r.ExtendedDataReal=1040]="ExtendedDataReal",r[r.ExtendedDataDist=1041]="ExtendedDataDist",r[r.ExtendedDataScale=1042]="ExtendedDataScale",r[r.ExtendedDataInteger16=1070]="ExtendedDataInteger16",r[r.ExtendedDataInteger32=1071]="ExtendedDataInteger32",r[r.XTextString=300]="XTextString",r[r.XReal=140]="XReal",r[r.XInt16=170]="XInt16",r[r.XXInt16=270]="XXInt16",r[r.Subclass=100]="Subclass",r[r.ControlString=102]="ControlString",r[r.EmbeddedObjectStart=101]="EmbeddedObjectStart",r[r.End=-1]="End",r[r.FirstEntityId=-2]="FirstEntityId",r[r.HeaderId=-2]="HeaderId",r[r.XDataStart=-3]="XDataStart",r[r.Operator=-4]="Operator",r[r.PReactors=-5]="PReactors",r[r.XDictionary=-6]="XDictionary"})(na||(na={}));var Je;(function(r){r[r.ByColor=1]="ByColor",r[r.ByACI=2]="ByACI",r[r.ByLayer=3]="ByLayer",r[r.ByBlock=4]="ByBlock",r[r.None=0]="None"})(Je||(Je={}));var UG=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},VG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},II={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},e1=[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],Na=(function(){function r(){}return r.getColorByIndex=function(e){return e1[e]},r.getIndexByColor=function(e){for(var t=e1.length-1,n=1;n<t;++n)if(e1[n]===e)return n},r.getColorByName=function(e){return II[e.toLowerCase()]},r.getNameByColor=function(e){var t,n;try{for(var i=UG(Object.entries(II)),o=i.next();!o.done;o=i.next()){var a=VG(o.value,2),s=a[0],l=a[1];if(l===e)return s}}catch(c){t={error:c}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},r.getNameByIndex=function(e){var t=this.getColorByIndex(e);return this.getNameByColor(t)},r})(),HG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},nt=(function(){function r(e,t){e===void 0&&(e=Je.ByLayer),this._colorMethod=e,this._colorMethod==Je.ByColor&&t==null?this._value=16777215:this._colorMethod==Je.ByACI?t==null?this._value=8:t===0?this._colorMethod=Je.ByBlock:t===256?this._colorMethod=Je.ByLayer:this._value=Math.max(0,Math.min(t,256)):this._value=t}return Object.defineProperty(r.prototype,"colorMethod",{get:function(){return this._colorMethod},set:function(e){this._colorMethod=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"red",{get:function(){var e=this.RGB;return e!=null?e>>16&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"green",{get:function(){var e=this.RGB;return e!=null?e>>8&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blue",{get:function(){var e=this.RGB;return e!=null?e&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"RGB",{get:function(){switch(this._colorMethod){case Je.ByColor:case Je.ByBlock:case Je.ByLayer:return this._value;case Je.ByACI:return this._value?Na.getColorByIndex(this._value):this._value;default:return}},enumerable:!1,configurable:!0}),r.prototype.setRGB=function(e,t,n){var i=Math.max(0,Math.min(255,Math.round(e))),o=Math.max(0,Math.min(255,Math.round(t))),a=Math.max(0,Math.min(255,Math.round(n)));return this._value=i<<16|o<<8|a,this._colorMethod=Je.ByColor,this},r.prototype.setRGBValue=function(e){return e==null||!Number.isFinite(e)?(console.warn("Invalid RGB value:",e),this):(this._value=e&16777215,this._colorMethod=Je.ByColor,this)},r.prototype.setRGBFromCss=function(e){if(!e)return this;var t=e.trim().toLowerCase();if(t.startsWith("#")){var n=0,i=0,o=0;if(t.length===7)n=parseInt(t.substr(1,2),16),i=parseInt(t.substr(3,2),16),o=parseInt(t.substr(5,2),16);else if(t.length===4)n=parseInt(t[1]+t[1],16),i=parseInt(t[2]+t[2],16),o=parseInt(t[3]+t[3],16);else return console.warn("Invalid hex color:",e),this;return this.setRGB(n,i,o)}var a=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(a){var n=parseInt(a[1],10),i=parseInt(a[2],10),o=parseInt(a[3],10);return this.setRGB(n,i,o)}var s=Na.getColorByName(e);return s!==void 0?this.setRGBValue(s):(console.warn("Unknown CSS color string:",e),this)},r.prototype.setScalar=function(e){return this.setRGB(e,e,e)},Object.defineProperty(r.prototype,"hexColor",{get:function(){var e=this.RGB;if(e!=null){var t=e.toString(16).padStart(6,"0").toUpperCase();return"0x"+t}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cssColor",{get:function(){var e=this.RGB;if(e!=null)return"rgb(".concat(e>>16&255,",").concat(e>>8&255,",").concat(e&255,")")},enumerable:!1,configurable:!0}),r.prototype.cssColorAlpha=function(e){var t=this.RGB;if(t!=null)return"rgba(".concat(t>>16&255,",").concat(t>>8&255,",").concat(t&255,",").concat(e,")")},Object.defineProperty(r.prototype,"colorIndex",{get:function(){return this._colorMethod===Je.ByACI?this._value:this._colorMethod===Je.ByLayer?256:this._colorMethod===Je.ByBlock?0:void 0},set:function(e){if(e!=null){var t=Math.max(0,Math.min(256,Math.round(e)));t===0?(this._colorMethod=Je.ByBlock,this._value=void 0):t===256?(this._colorMethod=Je.ByLayer,this._value=void 0):(this._colorMethod=Je.ByACI,this._value=t)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByColor",{get:function(){return this._colorMethod===Je.ByColor},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByACI",{get:function(){return this._colorMethod===Je.ByACI},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isForeground",{get:function(){return this._colorMethod===Je.ByACI&&this._value===7},enumerable:!1,configurable:!0}),r.prototype.setForeground=function(){return this._colorMethod=Je.ByACI,this._value=7,this},Object.defineProperty(r.prototype,"isByLayer",{get:function(){return this._colorMethod===Je.ByLayer},enumerable:!1,configurable:!0}),r.prototype.setByLayer=function(e){return this._colorMethod=Je.ByLayer,e==null?this._value=256:this._value=e,this},Object.defineProperty(r.prototype,"isByBlock",{get:function(){return this._colorMethod===Je.ByBlock},enumerable:!1,configurable:!0}),r.prototype.setByBlock=function(e){return this._colorMethod=Je.ByBlock,e==null?this._value=0:this._value=e,this},Object.defineProperty(r.prototype,"colorName",{get:function(){switch(this._colorMethod){case Je.ByLayer:return"ByLayer";case Je.ByBlock:return"ByBlock";case Je.ByColor:return this._value?Na.getNameByColor(this._value):"";case Je.ByACI:return this._value?Na.getNameByIndex(this._value):"";default:return}},set:function(e){if(e){var t=Na.getColorByName(e);t!==void 0?(this._value=t,this._colorMethod=Je.ByColor):console.warn("Unknown color name:",e)}},enumerable:!1,configurable:!0}),r.prototype.clone=function(){var e=new r;return e._colorMethod=this._colorMethod,e._value=this._value,e},r.prototype.copy=function(e){return this._colorMethod=e._colorMethod,this._value=e._value,this},r.prototype.equals=function(e){return this._colorMethod===e._colorMethod&&this._value===e._value},r.prototype.toString=function(){switch(this._colorMethod){case Je.None:return"None";case Je.ByLayer:return"ByLayer";case Je.ByBlock:return"ByBlock";case Je.ByACI:return this._value!==void 0?String(this._value):"";case Je.ByColor:return this._value?"RGB:".concat(this.red,",").concat(this.green,",").concat(this.blue):"";default:return""}},r.fromString=function(e){if(e){var t=e.trim();if(/^none$/i.test(t))return new r(Je.None);if(/^bylayer$/i.test(t))return new r(Je.ByLayer);if(/^byblock$/i.test(t))return new r(Je.ByBlock);var n=t.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(n){var i=Number(n[1]),o=Number(n[2]),a=Number(n[3]),s=new r(Je.ByColor);return s.setRGB(i,o,a),s}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(t)){var l=HG(t.split(",").map(Number),3),i=l[0],o=l[1],a=l[2],s=new r(Je.ByColor);return s.setRGB(i,o,a),s}if(/^\d+$/.test(t)){var c=parseInt(t,10);return new r(Je.ByACI,c)}if(/^book\$/i.test(t)){var u=t.substring(t.indexOf("$")+1),h=Na.getColorByName(u);if(h!=null)return new r(Je.ByColor,h);console.warn("Unknown color book entry:",e);return}var d=Na.getColorByName(t);if(d!=null)return new r(Je.ByColor,d);console.warn("Unknown color name:",e)}},r})(),qi={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")}},GG=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},WG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},$G=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},Ft=(function(){function r(){this.listeners=[]}return Object.defineProperty(r.prototype,"listenerCount",{get:function(){return this.listeners.length},enumerable:!1,configurable:!0}),r.prototype.addEventListener=function(e){this.listeners.push(e)},r.prototype.removeEventListener=function(e){this.listeners=this.listeners.filter(function(t){return t!==e})},r.prototype.replaceEventListener=function(e){this.removeEventListener(e),this.addEventListener(e)},r.prototype.dispatch=function(e){for(var t,n,i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];try{for(var a=GG(this.listeners),s=a.next();!s.done;s=a.next()){var l=s.value,c=l;c.call.apply(c,$G([null,e],WG(i),!1))}}catch(u){t={error:u}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},r})(),fE=function(){return fE=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},fE.apply(this,arguments)},XG=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},YG=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},g4=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Rd(r){return r===null||typeof r!="object"?r:Array.isArray(r)?YG([],XG(r),!1):fE({},r)}function rf(r){if(r===null||typeof r!="object")return r;if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r))return r.map(rf);var e={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=rf(r[t]));return e}function Sa(r){for(var e,t,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];try{for(var o=g4(n),a=o.next();!a.done;a=o.next()){var s=a.value;if(s)for(var l in s)Object.prototype.hasOwnProperty.call(s,l)&&r[l]===void 0&&(r[l]=s[l])}}catch(c){e={error:c}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return r}function y4(r,e){return r!=null&&Object.prototype.hasOwnProperty.call(r,e)}function v4(r){return r==null?!0:Array.isArray(r)||typeof r=="string"?r.length===0:r instanceof Map||r instanceof Set?r.size===0:typeof r=="object"?Object.keys(r).length===0:!1}function Yc(r,e){var t,n;if(r===e)return!0;if(r==null||e==null)return r===e;if(typeof r!=typeof e)return!1;if(typeof r!="object")return r===e;if(Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)){if(r.length!==e.length)return!1;for(var i=0;i<r.length;i++)if(!Yc(r[i],e[i]))return!1;return!0}var o=Object.keys(r),a=Object.keys(e);if(o.length!==a.length)return!1;try{for(var s=g4(o),l=s.next();!l.done;l=s.next()){var c=l.value;if(!Object.prototype.hasOwnProperty.call(e,c)||!Yc(r[c],e[c]))return!1}}catch(u){t={error:u}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return!0}function qG(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Qb={exports:{}},KG=Qb.exports,LI;function ZG(){return LI||(LI=1,(function(r){(function(e,t){r.exports?r.exports=t():e.log=t()})(KG,function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],o={},a=null;function s(m,g){var y=m[g];if(typeof y.bind=="function")return y.bind(m);try{return Function.prototype.bind.call(y,m)}catch{return function(){return Function.prototype.apply.apply(y,[m,arguments])}}}function l(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(m){return m==="debug"&&(m="log"),typeof console===t?!1:m==="trace"&&n?l:console[m]!==void 0?s(console,m):console.log!==void 0?s(console,"log"):e}function u(){for(var m=this.getLevel(),g=0;g<i.length;g++){var y=i[g];this[y]=g<m?e:this.methodFactory(y,m,this.name)}if(this.log=this.debug,typeof console===t&&m<this.levels.SILENT)return"No console available for logging"}function h(m){return function(){typeof console!==t&&(u.call(this),this[m].apply(this,arguments))}}function d(m,g,y){return c(m)||h.apply(this,arguments)}function f(m,g){var y=this,v,x,b,w="loglevel";typeof m=="string"?w+=":"+m:typeof m=="symbol"&&(w=void 0);function _(k){var T=(i[k]||"silent").toUpperCase();if(!(typeof window===t||!w)){try{window.localStorage[w]=T;return}catch{}try{window.document.cookie=encodeURIComponent(w)+"="+T+";"}catch{}}}function P(){var k;if(!(typeof window===t||!w)){try{k=window.localStorage[w]}catch{}if(typeof k===t)try{var T=window.document.cookie,O=encodeURIComponent(w),I=T.indexOf(O+"=");I!==-1&&(k=/^([^;]+)/.exec(T.slice(I+O.length+1))[1])}catch{}return y.levels[k]===void 0&&(k=void 0),k}}function S(){if(!(typeof window===t||!w)){try{window.localStorage.removeItem(w)}catch{}try{window.document.cookie=encodeURIComponent(w)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function E(k){var T=k;if(typeof T=="string"&&y.levels[T.toUpperCase()]!==void 0&&(T=y.levels[T.toUpperCase()]),typeof T=="number"&&T>=0&&T<=y.levels.SILENT)return T;throw new TypeError("log.setLevel() called with invalid level: "+k)}y.name=m,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=g||d,y.getLevel=function(){return b??x??v},y.setLevel=function(k,T){return b=E(k),T!==!1&&_(b),u.call(y)},y.setDefaultLevel=function(k){x=E(k),P()||y.setLevel(k,!1)},y.resetLevel=function(){b=null,S(),u.call(y)},y.enableAll=function(k){y.setLevel(y.levels.TRACE,k)},y.disableAll=function(k){y.setLevel(y.levels.SILENT,k)},y.rebuild=function(){if(a!==y&&(v=E(a.getLevel())),u.call(y),a===y)for(var k in o)o[k].rebuild()},v=E(a?a.getLevel():"WARN");var C=P();C!=null&&(b=E(C)),u.call(y)}a=new f,a.getLogger=function(g){if(typeof g!="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var y=o[g];return y||(y=o[g]=new f(g,a.methodFactory)),y};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return o},a.default=a,a})})(Qb)),Qb.exports}var JG=ZG();const QG=qG(JG);var Ht=QG.getLogger("mlightcad");Ht.setDefaultLevel("warn");var pE=(function(){function r(e,t){this._changing=!1,this._pending=!1;var n=e||{};t&&Sa(n,t),this.attributes=n}return Object.defineProperty(r.prototype,"events",{get:function(){var e;return(e=this._events)!==null&&e!==void 0?e:this._events={attrChanged:new Ft,modelChanged:new Ft}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"changed",{get:function(){var e;return(e=this._changed)!==null&&e!==void 0?e:this._changed={}},enumerable:!1,configurable:!0}),r.prototype.get=function(e){return this.attributes[e]},r.prototype.set=function(e,t,n){var i,o,a,s;if(e==null)return this;var l;typeof e=="object"?(l=e,n=t):(l={},l[e]=t),n||(n={});var c=n.unset,u=n.silent,h=this._events;if(!c&&!this._changing&&(h===void 0||h.attrChanged.listenerCount===0&&h.modelChanged.listenerCount===0)){if(typeof e=="object"){var d=e;for(var f in d)this.attributes[f]=d[f]}else this.attributes[e]=t;return this}if(!c){var p=!0;for(var f in l)if(this.attributes[f]!==l[f]){p=!1;break}if(p)return this._changing||(this._previousAttributes=Rd(this.attributes),this._changed={}),this}var m=null,g=this._changing;this._changing=!0,g||(this._previousAttributes=Rd(this.attributes),this._changed={});var y=this.attributes,v=(i=this._changed)!==null&&i!==void 0?i:this._changed={},x=(o=this._previousAttributes)!==null&&o!==void 0?o:{};for(var f in l){if(t=l[f],!c&&y[f]===t){x[f]===t||Yc(x[f],t)?delete v[f]:v[f]=t;continue}Yc(y[f],t)||(m||(m=[])).push(f),Yc(x[f],t)?delete v[f]:v[f]=t,c?delete y[f]:y[f]=t}if(!u&&(m&&(this._pending=n),m))for(var b=0;b<m.length;b++)(a=this._events)===null||a===void 0||a.attrChanged.dispatch({object:this,attrName:m[b],attrValue:y[m[b]],options:n});if(g)return this;if(!u)for(;this._pending;)n=this._pending,this._pending=!1,(s=this._events)===null||s===void 0||s.modelChanged.dispatch({object:this,options:n});return this._pending=!1,this._changing=!1,this},r.prototype.has=function(e){return this.get(e)!=null},r.prototype.hasChanged=function(e){return e==null?!v4(this._changed):this._changed?y4(this._changed,e):!1},r.prototype.changedAttributes=function(e){var t;if(!e)return this.hasChanged()?Rd((t=this._changed)!==null&&t!==void 0?t:{}):{};var n=this._changing?this._previousAttributes:this.attributes,i={};for(var o in e){var a=e[o];Yc(n==null?void 0:n[o],a)||(i[o]=a)}return i},r.prototype.previous=function(e){var t;return e==null?null:(t=this._previousAttributes)===null||t===void 0?void 0:t[e]},r.prototype.previousAttributes=function(){var e;return Rd((e=this._previousAttributes)!==null&&e!==void 0?e:{})},r.prototype.clone=function(){var e=Rd(this.attributes);return new r(e)},r})(),eW=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},tW=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},ey=(function(){function r(){this.entries=new Map}return r.getInstance=function(){return r.instance||(r.instance=new r),r.instance},r.prototype.collect=function(e){this.entries.set(e.name,e)},r.prototype.printAll=function(){var e,t;try{for(var n=eW(this.entries),i=n.next();!i.done;i=n.next()){var o=tW(i.value,2),a=o[0],s=o[1];console.log("".concat(a,":")),console.log(s.format())}}catch(l){e={error:l}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.clear=function(){this.entries.clear()},r.prototype.getAll=function(){return Array.from(this.entries.values())},r.prototype.getEntry=function(e){return this.entries.get(e)},r.prototype.remove=function(e){return this.entries.delete(e)},r})(),Gr;(function(r){r[r.ByLayer=0]="ByLayer",r[r.ByBlock=1]="ByBlock",r[r.ByAlpha=2]="ByAlpha",r[r.ErrorValue=3]="ErrorValue"})(Gr||(Gr={}));var tr=(function(){function r(e){e!==void 0?(this._method=Gr.ByAlpha,this._alpha=r.clampAlpha(e)):(this._method=Gr.ByLayer,this._alpha=255)}return Object.defineProperty(r.prototype,"method",{get:function(){return this._method},set:function(e){this._method=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"alpha",{get:function(){return this._alpha},set:function(e){this._alpha=r.clampAlpha(e),this._method=Gr.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"percentage",{get:function(){if(this._method===Gr.ByAlpha)return Math.round((1-this._alpha/255)*100)},set:function(e){var t=Math.max(0,Math.min(100,e)),n=Math.round(255*(1-t/100));this.alpha=n},enumerable:!1,configurable:!0}),r.clampAlpha=function(e){return Math.max(0,Math.min(255,Math.floor(e)))},Object.defineProperty(r.prototype,"isByAlpha",{get:function(){return this._method===Gr.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByBlock",{get:function(){return this._method===Gr.ByBlock},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isByLayer",{get:function(){return this._method===Gr.ByLayer},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isClear",{get:function(){return this.isByAlpha&&this._alpha===0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSolid",{get:function(){return this.isByAlpha&&this._alpha===255},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isInvalid",{get:function(){return this._method===Gr.ErrorValue},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var e=this._method;return e<<24|this._alpha},r.prototype.clone=function(){var e=new r;return e._method=this._method,e._alpha=this._alpha,e},r.prototype.equals=function(e){return this._method===e._method&&this._alpha===e._alpha},r.prototype.toString=function(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()},r.fromString=function(e){var t=e.trim(),n=t.toLowerCase();if(n===""||n==="."||n==="use current"||n==="bylayer"){var i=new r;return i._method=Gr.ByLayer,i}if(n==="byblock"){var o=new r;return o._method=Gr.ByBlock,o}var a=Number(t);if(Number.isInteger(a)&&a>=0&&a<=255){var s=new r;return a<=90?s.percentage=a:s.alpha=a,s}var l=new r;return l._method=Gr.ErrorValue,l},r.deserialize=function(e){var t=e>>>24&255,n=e&255,i=t>=Gr.ByLayer&&t<=Gr.ErrorValue?t:Gr.ErrorValue,o=new r;return o._method=i,o._alpha=r.clampAlpha(n),o},r})(),nW=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(u){try{c(n.next(u))}catch(h){a(h)}}function l(u){try{c(n.throw(u))}catch(h){a(h)}}function c(u){u.done?o(u.value):i(u.value).then(s,l)}c((n=n.apply(r,e||[])).next())})},rW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},fg=50;function cp(){return new Promise(function(r){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return r()}):setTimeout(r,0)})}function ou(){return new Promise(function(r){if(typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"){var e=globalThis.requestAnimationFrame;e(function(){return e(function(){return r()})})}else setTimeout(r,0)})}var ty=(function(){function r(e){e===void 0&&(e=fg),this._budgetMs=e,this._lastYieldCompletedAt=r.now()}return Object.defineProperty(r.prototype,"budgetMs",{get:function(){return this._budgetMs},enumerable:!1,configurable:!0}),r.prototype.maybeYield=function(){return nW(this,arguments,void 0,function(e){var t;return e===void 0&&(e=cp),rW(this,function(n){switch(n.label){case 0:return t=r.now(),t-this._lastYieldCompletedAt<this._budgetMs?[2,!1]:[4,e()];case 1:return n.sent(),this._lastYieldCompletedAt=r.now(),[2,!0]}})})},r.prototype.mark=function(){this._lastYieldCompletedAt=r.now()},r.now=function(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()},r})(),t1=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(u){try{c(n.next(u))}catch(h){a(h)}}function l(u){try{c(n.throw(u))}catch(h){a(h)}}function c(u){u.done?o(u.value):i(u.value).then(s,l)}c((n=n.apply(r,e||[])).next())})},Uy=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},b4=(function(){function r(e){this.name=e}return r.prototype.run=function(e){throw new Error("run() must be implemented by subclass")},r})(),x4=(function(){function r(){this.tasks=[],this.onProgress=function(){},this.onComplete=function(){},this.onError=function(){return!1}}return r.prototype.scheduleTask=function(e){return t1(this,void 0,void 0,function(){return Uy(this,function(t){switch(t.label){case 0:return[4,cp()];case 1:return t.sent(),[2,e()]}})})},r.prototype.addTask=function(e){this.tasks.push(e)},r.prototype.setProgressCallback=function(e){this.onProgress=e},r.prototype.setCompleteCallback=function(e){this.onComplete=e},r.prototype.setErrorCallback=function(e){this.onError=e},r.prototype.run=function(e){return t1(this,void 0,void 0,function(){var t,n,i,o,a,s,l=this;return Uy(this,function(c){switch(c.label){case 0:t=this.tasks.length,n=e,i=function(u){var h,d,f;return Uy(this,function(p){switch(p.label){case 0:h=o.tasks[u],p.label=1;case 1:return p.trys.push([1,3,,4]),[4,o.scheduleTask(function(){return t1(l,void 0,void 0,function(){var m;return Uy(this,function(g){switch(g.label){case 0:return[4,h.run(n)];case 1:return m=g.sent(),this.onProgress((u+1)/t,h),[2,m]}})})})];case 2:return n=p.sent(),[3,4];case 3:return d=p.sent(),f=o.onError({error:d,taskIndex:u,task:h}),f?[2,{value:Promise.reject(d)}]:[3,4];case 4:return[2]}})},o=this,a=0,c.label=1;case 1:return a<t?[5,i(a)]:[3,4];case 2:if(s=c.sent(),typeof s=="object")return[2,s.value];c.label=3;case 3:return a++,[3,1];case 4:return this.onComplete(n),[2]}})})},r})(),ui=["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"],OI=1234567,Jk=Math.PI/180,Qk=180/Math.PI;function w4(){var r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=ui[r&255]+ui[r>>8&255]+ui[r>>16&255]+ui[r>>24&255]+"-"+ui[e&255]+ui[e>>8&255]+"-"+ui[e>>16&15|64]+ui[e>>24&255]+"-"+ui[t&63|128]+ui[t>>8&255]+"-"+ui[t>>16&255]+ui[t>>24&255]+ui[n&255]+ui[n>>8&255]+ui[n>>16&255]+ui[n>>24&255];return i.toLowerCase()}function Tf(r,e,t){return Math.max(e,Math.min(t,r))}function eA(r,e){return(r%e+e)%e}function _4(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function S4(r,e,t){return r!==e?(t-r)/(e-r):0}function tA(r,e,t){return(1-t)*r+t*e}function P4(r,e,t,n){return tA(r,e,1-Math.exp(-t*n))}function E4(r,e){return e===void 0&&(e=1),e-Math.abs(eA(r,e*2)-e)}function M4(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function k4(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function A4(r,e){return r+Math.floor(Math.random()*(e-r+1))}function C4(r,e){return r+Math.random()*(e-r)}function T4(r){return r*(.5-Math.random())}function I4(r){r!==void 0&&(OI=r);var e=OI+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function L4(r){return r*Jk}function O4(r){return r*Qk}function D4(r){return(r&r-1)===0&&r!==0}function R4(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function F4(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function th(r){var e=Math.PI*2;return(r%e+e)%e}function B4(r,e,t){return r>e&&r<t||r>t&&r<e}function N4(r,e,t,n){return n===void 0&&(n=!1),r=th(r),e=th(e),t=th(t),n?e>t?r<=e&&r>=t:r<=e||r>=t:e<t?r>=e&&r<=t:r>=e||r<=t}function z4(r,e,t){var n=th(t-r),i=th(e-r);return i<=n+1e-7}function nA(r){return r=Math.abs(r),r<1?0:Math.ceil(Math.log10(Math.abs(r)+1))}function j4(r,e){e===void 0&&(e=1e-7);var t=nA(r);return Math.max(Math.pow(10,t)*e,e)}var Te={DEG2RAD:Jk,RAD2DEG:Qk,generateUUID:w4,clamp:Tf,euclideanModulo:eA,mapLinear:_4,inverseLerp:S4,lerp:tA,damp:P4,pingpong:E4,smoothstep:M4,smootherstep:k4,randInt:A4,randFloat:C4,randFloatSpread:T4,seededRandom:I4,degToRad:L4,radToDeg:O4,isPowerOfTwo:D4,ceilPowerOfTwo:R4,floorPowerOfTwo:F4,normalizeAngle:th,isBetween:B4,isBetweenAngle:N4,isAngleOnCcwSweep:z4,intPartLength:nA,relativeEps:j4},iW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},vn=(function(){function r(e,t){this.x=0,this.y=0;var n=+(e!==void 0)+ +(t!==void 0);if(n!==0){if(n===1&&e instanceof Array){this.x=e[0],this.y=e[1];return}if(n===1){var i=e,o=i.x,a=i.y;this.x=o,this.y=a;return}if(n===2){this.x=e,this.y=t;return}throw qi.ILLEGAL_PARAMETERS}}return Object.defineProperty(r.prototype,"width",{get:function(){return this.x},set:function(e){this.x=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this.y},set:function(e){this.y=e},enumerable:!1,configurable:!0}),r.prototype.set=function(e,t){return this.x=e,this.y=t,this},r.prototype.setScalar=function(e){return this.x=e,this.y=e,this},r.prototype.setX=function(e){return this.x=e,this},r.prototype.setY=function(e){return this.y=e,this},r.prototype.setComponent=function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},r.prototype.getComponent=function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},r.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},r.prototype.addScalar=function(e){return this.x+=e,this.y+=e,this},r.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},r.prototype.addScaledVector=function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},r.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this},r.prototype.subScalar=function(e){return this.x-=e,this.y-=e,this},r.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},r.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this},r.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this},r.prototype.divide=function(e){return this.x/=e.x,this.y/=e.y,this},r.prototype.divideScalar=function(e){return this.multiplyScalar(1/e)},r.prototype.applyMatrix2d=function(e){var t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this},r.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},r.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},r.prototype.clamp=function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},r.prototype.clampScalar=function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},r.prototype.clampLength=function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},r.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},r.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},r.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},r.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},r.prototype.dot=function(e){return this.x*e.x+this.y*e.y},r.prototype.cross=function(e){return this.x*e.y-this.y*e.x},r.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)},r.prototype.normalize=function(){return this.divideScalar(this.length()||1)},r.prototype.angle=function(){var e=Math.atan2(-this.y,-this.x)+Math.PI;return e},r.prototype.angleTo=function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,n)))},r.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},r.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},r.prototype.manhattanDistanceTo=function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},r.prototype.setLength=function(e){return this.normalize().multiplyScalar(e)},r.prototype.lerp=function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},r.prototype.lerpVectors=function(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this},r.prototype.equals=function(e){return e.x===this.x&&e.y===this.y},r.prototype.fromArray=function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this},r.prototype.toArray=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e},r.prototype.rotateAround=function(e,t){var n=Math.cos(t),i=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*i+e.x,this.y=o*i+a*n+e.y,this},r.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this},r.prototype.relativeEps=function(e){return e===void 0&&(e=1e-7),Math.min(Te.relativeEps(this.x,e),Te.relativeEps(this.y,e))},r.prototype[Symbol.iterator]=function(){return iW(this,function(e){switch(e.label){case 0:return[4,this.x];case 1:return e.sent(),[4,this.y];case 2:return e.sent(),[2]}})},r.EMPTY=Object.freeze(new r(0,0)),r})(),ny=(function(){function r(e,t,n,i,o,a,s,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!=null&&t!=null&&n!=null&&i!=null&&o!=null&&a!=null&&s!=null&&l!=null&&c!=null&&this.set(e,t,n,i,o,a,s,l,c)}return r.prototype.set=function(e,t,n,i,o,a,s,l,c){var u=this.elements;return u[0]=e,u[1]=i,u[2]=s,u[3]=t,u[4]=o,u[5]=l,u[6]=n,u[7]=a,u[8]=c,this},r.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},r.prototype.copy=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},r.prototype.extractBasis=function(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this},r.prototype.setFromMatrix4=function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},r.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},r.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},r.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,o=this.elements,a=n[0],s=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],p=n[8],m=i[0],g=i[3],y=i[6],v=i[1],x=i[4],b=i[7],w=i[2],_=i[5],P=i[8];return o[0]=a*m+s*v+l*w,o[3]=a*g+s*x+l*_,o[6]=a*y+s*b+l*P,o[1]=c*m+u*v+h*w,o[4]=c*g+u*x+h*_,o[7]=c*y+u*b+h*P,o[2]=d*m+f*v+p*w,o[5]=d*g+f*x+p*_,o[8]=d*y+f*b+p*P,this},r.prototype.multiplyScalar=function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},r.prototype.determinant=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*s*c-n*o*u+n*s*l+i*o*c-i*a*l},r.prototype.invert=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=u*a-s*c,d=s*l-u*o,f=c*o-a*l,p=t*h+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);var m=1/p;return e[0]=h*m,e[1]=(i*c-u*n)*m,e[2]=(s*n-i*a)*m,e[3]=d*m,e[4]=(u*t-i*l)*m,e[5]=(i*o-s*t)*m,e[6]=f*m,e[7]=(n*l-c*t)*m,e[8]=(a*t-n*o)*m,this},r.prototype.transpose=function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},r.prototype.getNormalMatrix=function(e){return this.setFromMatrix4(e).invert().transpose()},r.prototype.transposeIntoArray=function(e){var t=this.elements;return e.elements[0]=t[0],e.elements[1]=t[3],e.elements[2]=t[6],e.elements[3]=t[1],e.elements[4]=t[4],e.elements[5]=t[7],e.elements[6]=t[2],e.elements[7]=t[5],e.elements[8]=t[8],this},r.prototype.setUvTransform=function(e,t,n,i,o,a,s){var l=Math.cos(o),c=Math.sin(o);return this.set(n*l,n*c,-n*(l*a+c*s)+a+e,-i*c,i*l,-i*(-c*a+l*s)+s+t,0,0,1),this},r.prototype.scale=function(e,t){return this.premultiply(n1.makeScale(e,t)),this},r.prototype.rotate=function(e){return this.premultiply(n1.makeRotation(-e)),this},r.prototype.translate=function(e,t){return this.premultiply(n1.makeTranslation(e,t)),this},r.prototype.makeTranslation=function(e,t){return e instanceof vn?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this},r.prototype.makeRotation=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this},r.prototype.makeScale=function(e,t){return this.set(e,0,0,0,t,0,0,0,1),this},r.prototype.equals=function(e){for(var t=this.elements,n=e.elements,i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0},r.prototype.fromArray=function(e,t){t===void 0&&(t=0);for(var n=0;n<9;n++)this.elements[n]=e[n+t];return this},r.prototype.toArray=function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e},r.prototype.clone=function(){return new r().fromArray(this.elements)},r.IDENTITY=Object.freeze(new r),r})(),n1=new ny,tn=1e-6,lt=2*Math.PI,rA={x:0,y:0,z:0},Le=(function(){function r(){this.equalPointTol=tn,this.equalVectorTol=tn}return r.prototype.clone=function(){var e=new r;return e.equalPointTol=this.equalPointTol,e.equalVectorTol=this.equalVectorTol,e},r.prototype.equalPoint2d=function(e,t){return new vn(e).sub(t).length()<this.equalPointTol},r.prototype.equalPoint3d=function(e,t){return new X(e).sub(t).length()<this.equalPointTol},r.equalToZero=function(e,t){return t===void 0&&(t=tn),e<t&&e>-t},r.equal=function(e,t,n){return n===void 0&&(n=tn),Math.abs(e-t)<n},r.great=function(e,t,n){return n===void 0&&(n=tn),e-t>n},r.less=function(e,t,n){return n===void 0&&(n=tn),e-t<n},r.isPositive=function(e,t){return t===void 0&&(t=tn),e>t},r.isNonPositive=function(e,t){return t===void 0&&(t=tn),e<=t},r})(),du=new Le,oW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},pg=(function(){function r(e,t,n,i){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),i===void 0&&(i=1),this._x=e,this._y=t,this._z=n,this._w=i}return r.slerpFlat=function(e,t,n,i,o,a,s){var l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3],d=o[a+0],f=o[a+1],p=o[a+2],m=o[a+3];if(s===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(s===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(h!==m||l!==d||c!==f||u!==p){var g=1-s,y=l*d+c*f+u*p+h*m,v=y>=0?1:-1,x=1-y*y;if(x>Number.EPSILON){var b=Math.sqrt(x),w=Math.atan2(b,y*v);g=Math.sin(g*w)/b,s=Math.sin(s*w)/b}var _=s*v;if(l=l*g+d*_,c=c*g+f*_,u=u*g+p*_,h=h*g+m*_,g===1-s){var P=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=P,c*=P,u*=P,h*=P}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h},r.multiplyQuaternionsFlat=function(e,t,n,i,o,a){var s=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=o[a],d=o[a+1],f=o[a+2],p=o[a+3];return e[t]=s*p+u*h+l*f-c*d,e[t+1]=l*p+u*d+c*h-s*f,e[t+2]=c*p+u*f+s*d-l*h,e[t+3]=u*p-s*h-l*d-c*f,e},Object.defineProperty(r.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"w",{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()},enumerable:!1,configurable:!0}),r.prototype.set=function(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this},r.prototype.clone=function(){return new r(this._x,this._y,this._z,this._w)},r.prototype.copy=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},r.prototype.setFromEuler=function(e,t){t===void 0&&(t=!0);var n=e.x,i=e.y,o=e.z,a=e.order,s=Math.cos,l=Math.sin,c=s(n/2),u=s(i/2),h=s(o/2),d=l(n/2),f=l(i/2),p=l(o/2);switch(a){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this},r.prototype.setFromAxisAngle=function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this},r.prototype.setFromRotationMatrix=function(e){var t=e.elements,n=t[0],i=t[4],o=t[8],a=t[1],s=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+s+h;if(d>0){var f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(o-c)*f,this._z=(a-i)*f}else if(n>s&&n>h){var f=2*Math.sqrt(1+n-s-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(o+c)/f}else if(s>h){var f=2*Math.sqrt(1+s-n-h);this._w=(o-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+u)/f}else{var f=2*Math.sqrt(1+h-n-s);this._w=(a-i)/f,this._x=(o+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this},r.prototype.setFromUnitVectors=function(e,t){var n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()},r.prototype.angleTo=function(e){return 2*Math.acos(Math.abs(Tf(this.dot(e),-1,1)))},r.prototype.rotateTowards=function(e,t){var n=this.angleTo(e);if(n===0)return this;var i=Math.min(1,t/n);return this.slerp(e,i),this},r.prototype.identity=function(){return this.set(0,0,0,1)},r.prototype.invert=function(){return this.conjugate()},r.prototype.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},r.prototype.dot=function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},r.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},r.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},r.prototype.normalize=function(){var e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this},r.prototype.multiply=function(e){return this.multiplyQuaternions(this,e)},r.prototype.premultiply=function(e){return this.multiplyQuaternions(e,this)},r.prototype.multiplyQuaternions=function(e,t){var n=e._x,i=e._y,o=e._z,a=e._w,s=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+a*s+i*c-o*l,this._y=i*u+a*l+o*s-n*c,this._z=o*u+a*c+n*l-i*s,this._w=a*u-n*s-i*l-o*c,this._onChangeCallback(),this},r.prototype.slerp=function(e,t){if(t===0)return this;if(t===1)return this.copy(e);var n=this._x,i=this._y,o=this._z,a=this._w,s=a*e._w+n*e._x+i*e._y+o*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=o,this;var l=1-s*s;if(l<=Number.EPSILON){var c=1-t;return this._w=c*a+t*this._w,this._x=c*n+t*this._x,this._y=c*i+t*this._y,this._z=c*o+t*this._z,this.normalize(),this}var u=Math.sqrt(l),h=Math.atan2(u,s),d=Math.sin((1-t)*h)/u,f=Math.sin(t*h)/u;return this._w=a*d+this._w*f,this._x=n*d+this._x*f,this._y=i*d+this._y*f,this._z=o*d+this._z*f,this._onChangeCallback(),this},r.prototype.slerpQuaternions=function(e,t,n){return this.copy(e).slerp(t,n)},r.prototype.random=function(){var e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),o*Math.sin(t),o*Math.cos(t))},r.prototype.equals=function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},r.prototype.fromArray=function(e,t){return t===void 0&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},r.prototype.toArray=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},r.prototype.toJSON=function(){return this.toArray()},r.prototype._onChange=function(e){return this._onChangeCallback=e,this},r.prototype._onChangeCallback=function(){},r.prototype[Symbol.iterator]=function(){return oW(this,function(e){switch(e.label){case 0:return[4,this._x];case 1:return e.sent(),[4,this._y];case 2:return e.sent(),[4,this._z];case 3:return e.sent(),[4,this._w];case 4:return e.sent(),[2]}})},r})(),aW=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},X=(function(){function r(e,t,n){this.x=0,this.y=0,this.z=0;var i=+(e!==void 0)+ +(t!==void 0)+ +(n!==void 0);if(i!==0){if(i===1&&e instanceof Array){this.x=e[0],this.y=e[1],this.z=e[2];return}if(i===1){var o=e,a=o.x,s=o.y,l=o.z;this.x=a,this.y=s,this.z=l||0;return}if(i===3){this.x=e,this.y=t,this.z=n;return}throw qi.ILLEGAL_PARAMETERS}}return r.prototype.set=function(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this},r.prototype.setScalar=function(e){return this.x=e,this.y=e,this.z=e,this},r.prototype.setX=function(e){return this.x=e,this},r.prototype.setY=function(e){return this.y=e,this},r.prototype.setZ=function(e){return this.z=e,this},r.prototype.setComponent=function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},r.prototype.getComponent=function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},r.prototype.clone=function(){return new r(this.x,this.y,this.z)},r.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z||0,this},r.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z||0,this},r.prototype.addScalar=function(e){return this.x+=e,this.y+=e,this.z+=e,this},r.prototype.addVectors=function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},r.prototype.addScaledVector=function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},r.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},r.prototype.subScalar=function(e){return this.x-=e,this.y-=e,this.z-=e,this},r.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},r.prototype.multiply=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},r.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this},r.prototype.multiplyVectors=function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},r.prototype.applyEuler=function(e){return this.applyQuaternion(DI.setFromEuler(e))},r.prototype.applyAxisAngle=function(e,t){return this.applyQuaternion(DI.setFromAxisAngle(e,t))},r.prototype.applyMatrix3=function(e){var t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*i,this.y=o[1]*t+o[4]*n+o[7]*i,this.z=o[2]*t+o[5]*n+o[8]*i,this},r.prototype.applyNormalMatrix=function(e){return this.applyMatrix3(e).normalize()},r.prototype.applyMatrix4=function(e){var t=this.x,n=this.y,i=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*i+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*i+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*i+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*i+o[14])*a,this},r.prototype.applyQuaternion=function(e){var t=this.x,n=this.y,i=this.z,o=e.x,a=e.y,s=e.z,l=e.w,c=2*(a*i-s*n),u=2*(s*t-o*i),h=2*(o*n-a*t);return this.x=t+l*c+a*h-s*u,this.y=n+l*u+s*c-o*h,this.z=i+l*h+o*u-a*c,this},r.prototype.transformDirection=function(e){var t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i,this.y=o[1]*t+o[5]*n+o[9]*i,this.z=o[2]*t+o[6]*n+o[10]*i,this.normalize()},r.prototype.divide=function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},r.prototype.divideScalar=function(e){return this.multiplyScalar(1/e)},r.prototype.min=function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},r.prototype.max=function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},r.prototype.clamp=function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},r.prototype.clampScalar=function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},r.prototype.clampLength=function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},r.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},r.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},r.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},r.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},r.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},r.prototype.isParallelTo=function(e){var t=this.dot(e),n=this.length(),i=e.length();return Math.abs(t)===n*i},r.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},r.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},r.prototype.normalize=function(){return this.divideScalar(this.length()||1)},r.prototype.setLength=function(e){return this.normalize().multiplyScalar(e)},r.prototype.lerp=function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},r.prototype.lerpVectors=function(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this},r.prototype.cross=function(e){return this.crossVectors(this,e)},r.prototype.crossVectors=function(e,t){var n=e.x,i=e.y,o=e.z,a=t.x,s=t.y,l=t.z;return this.x=i*l-o*s,this.y=o*a-n*l,this.z=n*s-i*a,this},r.prototype.projectOnVector=function(e){var t=e.lengthSq();if(t===0)return this.set(0,0,0);var n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)},r.prototype.projectOnPlane=function(e){return r1.copy(this).projectOnVector(e),this.sub(r1)},r.prototype.reflect=function(e){return this.sub(r1.copy(e).multiplyScalar(2*this.dot(e)))},r.prototype.angleTo=function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,n)))},r.prototype.distanceTo=function(e){return Math.sqrt(this.distanceToSquared(e))},r.prototype.distanceToSquared=function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i},r.prototype.manhattanDistanceTo=function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},r.prototype.setFromMatrixPosition=function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},r.prototype.setFromMatrixScale=function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this},r.prototype.setFromMatrixColumn=function(e,t){return this.fromArray(e.elements,t*4)},r.prototype.setFromMatrix3Column=function(e,t){return this.fromArray(e.elements,t*3)},r.prototype.equals=function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},r.prototype.fromArray=function(e,t){return t===void 0&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},r.prototype.toArray=function(e,t){return e===void 0&&(e=[]),t===void 0&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},r.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},r.prototype.randomDirection=function(){var e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this},r.prototype[Symbol.iterator]=function(){return aW(this,function(e){switch(e.label){case 0:return[4,this.x];case 1:return e.sent(),[4,this.y];case 2:return e.sent(),[4,this.z];case 3:return e.sent(),[2]}})},r.ORIGIN=Object.freeze(new r(0,0,0)),r.X_AXIS=Object.freeze(new r(1,0,0)),r.NEGATIVE_X_AXIS=Object.freeze(new r(-1,0,0)),r.Y_AXIS=Object.freeze(new r(0,1,0)),r.NEGATIVE_Y_AXIS=Object.freeze(new r(0,-1,0)),r.Z_AXIS=Object.freeze(new r(0,0,1)),r.NEGATIVE_Z_AXIS=Object.freeze(new r(0,0,-1)),r})(),r1=new X,DI=new pg,Ue=(function(){function r(e,t,n,i,o,a,s,l,c,u,h,d,f,p,m,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!=null&&t!=null&&n!=null&&i!=null&&o!=null&&a!=null&&s!=null&&l!=null&&c!=null&&u!=null&&h!=null&&d!=null&&f!=null&&p!=null&&m!=null&&g!=null&&this.set(e,t,n,i,o,a,s,l,c,u,h,d,f,p,m,g)}return r.makeTranslation=function(e,t,n){return new r().makeTranslation(e,t,n)},r.prototype.set=function(e,t,n,i,o,a,s,l,c,u,h,d,f,p,m,g){var y=this.elements;return y[0]=e,y[4]=t,y[8]=n,y[12]=i,y[1]=o,y[5]=a,y[9]=s,y[13]=l,y[2]=c,y[6]=u,y[10]=h,y[14]=d,y[3]=f,y[7]=p,y[11]=m,y[15]=g,this},r.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},r.prototype.clone=function(){return new r().fromArray(this.elements)},r.prototype.copy=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},r.prototype.copyPosition=function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},r.prototype.setFromMatrix3=function(e){var t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this},r.prototype.setFromExtrusionDirection=function(e){var t=Math.hypot(e.x,e.y,e.z);if(!Number.isFinite(t)||t<1e-12)return this.identity(),this;var n=Math.abs(t-1)>1e-6?e.clone().multiplyScalar(1/t):e;if(du.equalPoint3d(n,X.Z_AXIS))this.identity();else{var i=new X(1,0,0);Math.abs(n.x)<1/64&&Math.abs(n.y)<1/64?i.crossVectors(X.Y_AXIS,n).normalize():i.crossVectors(X.Z_AXIS,n).normalize();var o=n.clone().cross(i).normalize();this.makeBasis(i,o,n)}return this},r.prototype.extractBasis=function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},r.prototype.makeBasis=function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},r.prototype.extractRotation=function(e){var t=this.elements,n=e.elements,i=1/Gh.setFromMatrixColumn(e,0).length(),o=1/Gh.setFromMatrixColumn(e,1).length(),a=1/Gh.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},r.prototype.makeRotationFromQuaternion=function(e){return this.compose(sW,e,lW)},r.prototype.lookAt=function(e,t,n){var i=this.elements;return xo.subVectors(e,t),xo.lengthSq()===0&&(xo.z=1),xo.normalize(),bc.crossVectors(n,xo),bc.lengthSq()===0&&(Math.abs(n.z)===1?xo.x+=1e-4:xo.z+=1e-4,xo.normalize(),bc.crossVectors(n,xo)),bc.normalize(),Vy.crossVectors(xo,bc),i[0]=bc.x,i[4]=Vy.x,i[8]=xo.x,i[1]=bc.y,i[5]=Vy.y,i[9]=xo.y,i[2]=bc.z,i[6]=Vy.z,i[10]=xo.z,this},r.prototype.multiply=function(e){return this.multiplyMatrices(this,e)},r.prototype.premultiply=function(e){return this.multiplyMatrices(e,this)},r.prototype.multiplyMatrices=function(e,t){var n=e.elements,i=t.elements,o=this.elements,a=n[0],s=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],p=n[2],m=n[6],g=n[10],y=n[14],v=n[3],x=n[7],b=n[11],w=n[15],_=i[0],P=i[4],S=i[8],E=i[12],C=i[1],k=i[5],T=i[9],O=i[13],I=i[2],F=i[6],N=i[10],Y=i[14],U=i[3],$=i[7],J=i[11],G=i[15];return o[0]=a*_+s*C+l*I+c*U,o[4]=a*P+s*k+l*F+c*$,o[8]=a*S+s*T+l*N+c*J,o[12]=a*E+s*O+l*Y+c*G,o[1]=u*_+h*C+d*I+f*U,o[5]=u*P+h*k+d*F+f*$,o[9]=u*S+h*T+d*N+f*J,o[13]=u*E+h*O+d*Y+f*G,o[2]=p*_+m*C+g*I+y*U,o[6]=p*P+m*k+g*F+y*$,o[10]=p*S+m*T+g*N+y*J,o[14]=p*E+m*O+g*Y+y*G,o[3]=v*_+x*C+b*I+w*U,o[7]=v*P+x*k+b*F+w*$,o[11]=v*S+x*T+b*N+w*J,o[15]=v*E+x*O+b*Y+w*G,this},r.prototype.multiplyScalar=function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},r.prototype.determinant=function(){var e=this.elements,t=e[0],n=e[4],i=e[8],o=e[12],a=e[1],s=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],p=e[3],m=e[7],g=e[11],y=e[15];return p*(+o*l*h-i*c*h-o*s*d+n*c*d+i*s*f-n*l*f)+m*(+t*l*f-t*c*d+o*a*d-i*a*f+i*c*u-o*l*u)+g*(+t*c*h-t*s*f-o*a*h+n*a*f+o*s*u-n*c*u)+y*(-i*s*u-t*l*h+t*s*d+i*a*h-n*a*d+n*l*u)},r.prototype.transpose=function(){var e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},r.prototype.setPosition=function(e,t,n){var i=this.elements;return e instanceof X?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this},r.prototype.invert=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],y=e[15],v=h*g*c-m*d*c+m*l*f-s*g*f-h*l*y+s*d*y,x=p*d*c-u*g*c-p*l*f+a*g*f+u*l*y-a*d*y,b=u*m*c-p*h*c+p*s*f-a*m*f-u*s*y+a*h*y,w=p*h*l-u*m*l-p*s*d+a*m*d+u*s*g-a*h*g,_=t*v+n*x+i*b+o*w;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var P=1/_;return e[0]=v*P,e[1]=(m*d*o-h*g*o-m*i*f+n*g*f+h*i*y-n*d*y)*P,e[2]=(s*g*o-m*l*o+m*i*c-n*g*c-s*i*y+n*l*y)*P,e[3]=(h*l*o-s*d*o-h*i*c+n*d*c+s*i*f-n*l*f)*P,e[4]=x*P,e[5]=(u*g*o-p*d*o+p*i*f-t*g*f-u*i*y+t*d*y)*P,e[6]=(p*l*o-a*g*o-p*i*c+t*g*c+a*i*y-t*l*y)*P,e[7]=(a*d*o-u*l*o+u*i*c-t*d*c-a*i*f+t*l*f)*P,e[8]=b*P,e[9]=(p*h*o-u*m*o-p*n*f+t*m*f+u*n*y-t*h*y)*P,e[10]=(a*m*o-p*s*o+p*n*c-t*m*c-a*n*y+t*s*y)*P,e[11]=(u*s*o-a*h*o-u*n*c+t*h*c+a*n*f-t*s*f)*P,e[12]=w*P,e[13]=(u*m*i-p*h*i+p*n*d-t*m*d-u*n*g+t*h*g)*P,e[14]=(p*s*i-a*m*i-p*n*l+t*m*l+a*n*g-t*s*g)*P,e[15]=(a*h*i-u*s*i+u*n*l-t*h*l-a*n*d+t*s*d)*P,this},r.prototype.scale=function(e){var t=this.elements,n=e.x,i=e.y,o=e.z;return t[0]*=n,t[4]*=i,t[8]*=o,t[1]*=n,t[5]*=i,t[9]*=o,t[2]*=n,t[6]*=i,t[10]*=o,t[3]*=n,t[7]*=i,t[11]*=o,this},r.prototype.getMaxScaleOnAxis=function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))},r.prototype.makeTranslation=function(e,t,n){var i;return typeof e=="object"?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,(i=e.z)!==null&&i!==void 0?i:0,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this},r.prototype.makeRotationX=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this},r.prototype.makeRotationY=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this},r.prototype.makeRotationZ=function(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this},r.prototype.makeRotationAxis=function(e,t){var n=Math.cos(t),i=Math.sin(t),o=1-n,a=e.x,s=e.y,l=e.z,c=o*a,u=o*s;return this.set(c*a+n,c*s-i*l,c*l+i*s,0,c*s+i*l,u*s+n,u*l-i*a,0,c*l-i*s,u*l+i*a,o*l*l+n,0,0,0,0,1),this},r.prototype.makeScale=function(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this},r.prototype.makeShear=function(e,t,n,i,o,a){return this.set(1,n,o,0,e,1,a,0,t,i,1,0,0,0,0,1),this},r.prototype.compose=function(e,t,n){var i=this.elements,o=t.x,a=t.y,s=t.z,l=t.w,c=o+o,u=a+a,h=s+s,d=o*c,f=o*u,p=o*h,m=a*u,g=a*h,y=s*h,v=l*c,x=l*u,b=l*h,w=n.x,_=n.y,P=n.z;return i[0]=(1-(m+y))*w,i[1]=(f+b)*w,i[2]=(p-x)*w,i[3]=0,i[4]=(f-b)*_,i[5]=(1-(d+y))*_,i[6]=(g+v)*_,i[7]=0,i[8]=(p+x)*P,i[9]=(g-v)*P,i[10]=(1-(d+m))*P,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},r.prototype.decompose=function(e,t,n){var i=this.elements,o=Gh.set(i[0],i[1],i[2]).length(),a=Gh.set(i[4],i[5],i[6]).length(),s=Gh.set(i[8],i[9],i[10]).length(),l=this.determinant();l<0&&(o=-o),e.x=i[12],e.y=i[13],e.z=i[14],Ta.copy(this);var c=1/o,u=1/a,h=1/s;return Ta.elements[0]*=c,Ta.elements[1]*=c,Ta.elements[2]*=c,Ta.elements[4]*=u,Ta.elements[5]*=u,Ta.elements[6]*=u,Ta.elements[8]*=h,Ta.elements[9]*=h,Ta.elements[10]*=h,t.setFromRotationMatrix(Ta),n.x=o,n.y=a,n.z=s,this},r.prototype.equals=function(e){for(var t=this.elements,n=e.elements,i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0},r.prototype.fromArray=function(e,t){t===void 0&&(t=0);for(var n=0;n<16;n++)this.elements[n]=e[n+t];return this},r.prototype.toArray=function(e,t){e===void 0&&(e=[]),t===void 0&&(t=0);var n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e},r.IDENTITY=Object.freeze(new r),r})(),Gh=new X,Ta=new Ue,sW=new X(0,0,0),lW=new X(1,1,1),bc=new X,Vy=new X,xo=new X,_t=(function(){function r(e,t){e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.min=e==null?new X(1/0,1/0,1/0):new X(e.x,e.y,e.z),this.max=t==null?new X(-1/0,-1/0,-1/0):new X(t.x,t.y,t.z)}return r.prototype.set=function(e,t){return this.min.copy(e),this.max.copy(t),this},r.prototype.setFromArray=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t+=3)this.expandByPoint(i1.fromArray(e,t));return this},r.prototype.setFromPoints=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},r.prototype.setFromCenterAndSize=function(e,t){var n=i1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this},r.prototype.clone=function(){return new r().copy(this)},r.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},r.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},r.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},r.prototype.getCenter=function(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},r.prototype.getSize=function(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},Object.defineProperty(r.prototype,"center",{get:function(){return this.isEmpty()?new X(0,0,0):new X(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){return this.isEmpty()?new X(0,0,0):new X(0,0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),r.prototype.expandByPoint=function(e){return!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.z)?this:(this.min.min(e),this.max.max(e),this)},r.prototype.expandByVector=function(e){return this.min.sub(e),this.max.add(e),this},r.prototype.expandByScalar=function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},r.prototype.containsPoint=function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)},r.prototype.containsBox=function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},r.prototype.getParameter=function(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},r.prototype.intersectsBox=function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)},r.prototype.intersectsPlane=function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant},r.prototype.clampPoint=function(e,t){return t.copy(e).clamp(this.min,this.max)},r.prototype.distanceToPoint=function(e){return this.clampPoint(e,i1).distanceTo(e)},r.prototype.intersect=function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},r.prototype.union=function(e){return this.min.min(e.min),this.max.max(e.max),this},r.prototype.applyMatrix4=function(e){return this.isEmpty()?this:(dl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),dl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),dl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),dl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),dl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),dl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),dl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),dl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(dl),this)},r.prototype.translate=function(e){return this.min.add(e),this.max.add(e),this},r.prototype.equals=function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},r})(),dl=[new X,new X,new X,new X,new X,new X,new X,new X],i1=new X,RI=new vn,Bt=(function(){function r(e,t){e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.min=e==null?new vn(1/0,1/0):new vn(e.x,e.y),this.max=t==null?new vn(-1/0,-1/0):new vn(t.x,t.y)}return r.prototype.set=function(e,t){return this.min.copy(e),this.max.copy(t),this},r.prototype.setFromPoints=function(e){this.makeEmpty();for(var t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this},r.prototype.setFromCenterAndSize=function(e,t){var n=RI.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this},r.prototype.clone=function(){return new r().copy(this)},r.prototype.copy=function(e){return this.min.copy(e.min),this.max.copy(e.max),this},r.prototype.makeEmpty=function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},r.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y},r.prototype.getCenter=function(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},r.prototype.getSize=function(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},Object.defineProperty(r.prototype,"center",{get:function(){return this.isEmpty()?new vn(0,0):new vn(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){return this.isEmpty()?new vn(0,0):new vn(0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),r.prototype.expandByPoint=function(e){return!Number.isFinite(e.x)||!Number.isFinite(e.y)?this:(this.min.min(e),this.max.max(e),this)},r.prototype.expandByVector=function(e){return this.min.sub(e),this.max.add(e),this},r.prototype.expandByScalar=function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},r.prototype.containsPoint=function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)},r.prototype.containsBox=function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},r.prototype.getParameter=function(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},r.prototype.intersectsBox=function(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)},r.prototype.clampPoint=function(e,t){return t.copy(e).clamp(this.min,this.max)},r.prototype.distanceToPoint=function(e){return this.clampPoint(e,RI).distanceTo(e)},r.prototype.intersect=function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},r.prototype.union=function(e){return this.min.min(e.min),this.max.max(e.max),this},r.prototype.translate=function(e){return this.min.add(e),this.max.add(e),this},r.prototype.equals=function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},r})(),FI=new X,cW=new X,uW=new ny,Rw=(function(){function r(e,t){e===void 0&&(e=new X(1,0,0)),t===void 0&&(t=0),this.normal=e,this.constant=t}return r.prototype.set=function(e,t){return this.normal.copy(e),this.constant=t,this},r.prototype.setComponents=function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},r.prototype.setFromNormalAndCoplanarPoint=function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},r.prototype.setFromCoplanarPoints=function(e,t,n){var i=FI.subVectors(n,t).cross(cW.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this},r.prototype.copy=function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},r.prototype.normalize=function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},r.prototype.negate=function(){return this.constant*=-1,this.normal.negate(),this},r.prototype.distanceToPoint=function(e){return this.normal.dot(e)+this.constant},r.prototype.projectPoint=function(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))},r.prototype.intersectsBox=function(e){return e.intersectsPlane(this)},r.prototype.coplanarPoint=function(e){return e.copy(this.normal).multiplyScalar(-this.constant)},r.prototype.applyMatrix4=function(e,t){var n=t||uW.getNormalMatrix(e),i=this.coplanarPoint(FI).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(o),this},r.prototype.translate=function(e){return this.constant-=e.dot(this.normal),this},r.prototype.equals=function(e){return e.normal.equals(this.normal)&&e.constant===this.constant},r.prototype.clone=function(){return new r().copy(this)},r})(),hW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),re=(function(r){hW(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.clone=function(){return new e(this.x,this.y)},e.pointArrayToNumberArray=function(t){var n=new Array(t.length*2);return t.forEach(function(i,o){i.toArray(n,o*2)}),n},e})(vn),dW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),D=(function(r){dW(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e.pointArrayToNumberArray=function(t,n){n===void 0&&(n=!0);var i=n?3:2,o=new Array(t.length*i);return t.forEach(function(a,s){a.toArray(o,s*i)}),o},e})(X);function U4(r){var e=r.length;if(e<3)return 0;for(var t=0,n=0,i=e-1;n<e;i=n++){var o=r[i],a=r[n];t+=o.x*a.y-a.x*o.y}return t*.5}function fW(r){return Math.abs(U4(r))}function pW(r){var e,t,n=r.length;if(n<3)return 0;for(var i=0,o=0,a=0,s=0,l=n-1;s<n;l=s++){var c=r[l],u=r[s],h=c.x,d=c.y,f=(e=c.z)!==null&&e!==void 0?e:0,p=u.x,m=u.y,g=(t=u.z)!==null&&t!==void 0?t:0;i+=(f+g)*(d-m),o+=(h+p)*(f-g),a+=(d+m)*(h-p)}return .5*Math.hypot(i,o,a)}function mW(r){return r.length<3?0:fW(r)}function V4(r){return r.length<3?0:pW(r)}function gW(r){var e,t=r;return{x:r.x,y:r.y,z:(e=t.z)!==null&&e!==void 0?e:0}}function yW(r,e){var t,n;r.x+=e.x,r.y+=e.y,r.z=((t=r.z)!==null&&t!==void 0?t:0)+((n=e.z)!==null&&n!==void 0?n:0)}function vW(r,e,t){t===void 0&&(t=!1);for(var n=r.x,i=r.y,o=!1,a=e.length,s=0,l=a-1;s<a;l=s++){var c=e[s].x,u=e[s].y,h=e[l].x,d=e[l].y,f=u>i!=d>i;t&&(f=u>=i!=d>=i);var p=f&&n<(h-c)*(i-u)/(d-u)+c;p&&(o=!o)}return o}function bW(r,e){if(r.length===0||e.length===0)return!1;var t=new Bt().setFromPoints(r),n=new Bt().setFromPoints(e);if(!t.intersectsBox(n))return!1;for(var i=0;i<r.length;){if(Qn.isPointInPolygon(r[i],e,!0))return!0;i<r.length-1&&du.equalPoint2d(r[i+1],r[i])&&++i,++i}return!1}var Qn={applyOffsetToPoint3d:yW,isPointInPolygon:vW,isPolygonIntersect:bW,point2dToPoint3d:gW},Fd=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},km=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},Hy=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))};function H4(r,e){e===void 0&&(e="Uniform");var t=r.length;if(t===0)return[];if(t===1)return[0];var n=t-1;if(e==="Uniform")return new Array(t).fill(0).map(function(d,f){return f/n});for(var i=[0],o=0,a=1;a<=n;a++){var s=r[a][0]-r[a-1][0],l=r[a][1]-r[a-1][1],c=r[a][2]-r[a-1][2],u=Math.sqrt(s*s+l*l+c*c),h=e==="SqrtChord"?Math.sqrt(u):u;o+=h,i.push(o)}return o<1e-12?new Array(t).fill(0).map(function(d,f){return f/n}):i.map(function(d){return d/o})}function G4(r,e){for(var t=e.length-1,n=r,i=t+n+1,o=new Array(i+1).fill(0),a=e[e.length-1],s=i-n;s<=i;s++)o[s]=a;for(var l=1;l<=t-n;l++){for(var c=0,s=l;s<l+n;s++)c+=e[s];o[l+n]=c/n}return o}function Gy(r,e){var t,n;try{for(var i=Fd(r),o=i.next();!o.done;o=i.next()){var a=o.value;if(a.col===e)return a.value}}catch(s){t={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return 0}function BI(r,e){for(var t=0;t<r.length;t++)if(r[t].col===e)return t;return-1}function xW(r,e){for(var t,n,i,o,a,s,l,c,u,h,d=r.length,f=r.map(function(Ce){return Ce.map(function(Z){return{col:Z.col,value:Z.value}})}),p=e.map(function(Ce){return Ce.slice()}),m=0;m<d;m++){for(var g=-1,y=1e-12,v=m;v<d;v++){var x=Math.abs(Gy(f[v],m));x>y&&(y=x,g=v)}if(g<0)throw new Error("Interpolation matrix is singular.");if(g!==m){var b=f[m];f[m]=f[g],f[g]=b;try{for(var w=(t=void 0,Fd(p)),_=w.next();!_.done;_=w.next()){var P=_.value,S=P[m];P[m]=P[g],P[g]=S}}catch(Ce){t={error:Ce}}finally{try{_&&!_.done&&(n=w.return)&&n.call(w)}finally{if(t)throw t.error}}}for(var E=Gy(f[m],m),v=m+1;v<d;v++){var C=BI(f[v],m);if(!(C<0)){var k=f[v][C].value/E;if(!(Math.abs(k)<1e-14)){try{for(var T=(i=void 0,Fd(f[v])),O=T.next();!O.done;O=T.next()){var I=O.value;I.col>m&&(I.value-=k*Gy(f[m],I.col))}}catch(Z){i={error:Z}}finally{try{O&&!O.done&&(o=T.return)&&o.call(T)}finally{if(i)throw i.error}}try{for(var F=(a=void 0,Fd(f[m])),N=F.next();!N.done;N=F.next()){var Y=N.value;Y.col<=m||Y.value===0||BI(f[v],Y.col)<0&&f[v].push({col:Y.col,value:-k*Y.value})}}catch(Z){a={error:Z}}finally{try{N&&!N.done&&(s=F.return)&&s.call(F)}finally{if(a)throw a.error}}f[v][C].value=0;try{for(var U=(l=void 0,Fd(p)),$=U.next();!$.done;$=U.next()){var P=$.value;P[v]-=k*P[m]}}catch(Z){l={error:Z}}finally{try{$&&!$.done&&(c=U.return)&&c.call(U)}finally{if(l)throw l.error}}}}}}for(var J=p.map(function(){return new Array(d).fill(0)}),v=d-1;v>=0;v--)for(var G=Gy(f[v],v),oe=0;oe<p.length;oe++){var le=p[oe][v];try{for(var Ie=(u=void 0,Fd(f[v])),xe=Ie.next();!xe.done;xe=Ie.next()){var I=xe.value;I.col>v&&(le-=I.value*J[oe][I.col])}}catch(Z){u={error:Z}}finally{try{xe&&!xe.done&&(h=Ie.return)&&h.call(Ie)}finally{if(u)throw u.error}}J[oe][v]=le/G}return J}function wW(r,e,t){var n=t.length-e-2;if(r>=t[n+1])return n;for(var i=e,o=t.length-e-2;i<=o;){var a=i+o>>1;if(r<t[a])o=a-1;else if(r>=t[a+1])i=a+1;else return a}return e}function W4(r,e,t,n,i){var o,a,s,l,c,u;if(t===void 0&&(t="Uniform"),r.length===0)return{controlPoints:[],knots:[],weights:[]};var h=r.map(function(xe){var Ce;return[xe[0],xe[1],(Ce=xe[2])!==null&&Ce!==void 0?Ce:0]}),d=!!n,f=!!i,p=(d?1:0)+(f?1:0),m=h.length-1,g=m+p;if(g<e)throw new Error("Not enough points to interpolate a curve of this degree.");var y=H4(h,t),v=y.slice();d&&v.unshift(y[0]),f&&v.push(y[y.length-1]);var x=G4(e,v),b=g+1,w=[],_=[],P=[],S=[];if(d){var E=x[e+1]-x[0],C=E!==0?e/E:0;w.push([{col:0,value:-C},{col:1,value:C}]),_.push((o=n==null?void 0:n[0])!==null&&o!==void 0?o:0),P.push((a=n==null?void 0:n[1])!==null&&a!==void 0?a:0),S.push((s=n==null?void 0:n[2])!==null&&s!==void 0?s:0)}w.push([{col:0,value:1}]),_.push(h[0][0]),P.push(h[0][1]),S.push(h[0][2]);for(var k=1;k<=m-1;k++){for(var T=y[k],O=[],I=wW(T,e,x),F=Math.max(0,I-e),N=Math.min(g,I),Y=F;Y<=N;Y++){var U=au(Y,e,T,x);U!==0&&O.push({col:Y,value:U})}w.push(O),_.push(h[k][0]),P.push(h[k][1]),S.push(h[k][2])}if(w.push([{col:g,value:1}]),_.push(h[m][0]),P.push(h[m][1]),S.push(h[m][2]),f){var E=x[g+e+1]-x[g],C=E!==0?e/E:0;w.push([{col:g-1,value:-C},{col:g,value:C}]),_.push((l=i==null?void 0:i[0])!==null&&l!==void 0?l:0),P.push((c=i==null?void 0:i[1])!==null&&c!==void 0?c:0),S.push((u=i==null?void 0:i[2])!==null&&u!==void 0?u:0)}for(var $=km(xW(w,[_,P,S]),3),J=$[0],G=$[1],oe=$[2],le=new Array(b),k=0;k<b;k++)le[k]=[J[k],G[k],oe[k]];var Ie=new Array(b).fill(1);return{controlPoints:le,knots:x,weights:Ie}}function au(r,e,t,n){if(e===0)return t>=n[r]&&t<n[r+1]?1:0;var i=n[r+e]-n[r],o=n[r+e+1]-n[r+1],a=i>1e-10?(t-n[r])/i:0,s=o>1e-10?(n[r+e+1]-t)/o:0;return a*au(r,e-1,t,n)+s*au(r+1,e-1,t,n)}function Hm(r,e,t,n,i){var o=n.length-1,a=e;if(r=Math.max(t[a],Math.min(t[o+1],r)),Math.abs(r-t[o+1])<1e-8)return Hy([],km(n[o]),!1);if(Math.abs(r-t[a])<1e-8)return Hy([],km(n[0]),!1);for(var s=[0,0,0],l=0,c=0;c<=o;c++){var u=au(c,a,r,t),h=i[c]*u;s[0]+=n[c][0]*h,s[1]+=n[c][1]*h,s[2]+=n[c][2]*h,l+=h}if(Math.abs(l)<1e-10){var d=t[t.length-a-1];if(Math.abs(r-d)<1e-8)return Hy([],km(n[o]),!1);if(Math.abs(r-t[a])<1e-8)return Hy([],km(n[0]),!1)}return Math.abs(l)>=1e-10&&(s[0]/=l,s[1]/=l,s[2]/=l),s}function mE(r,e,t,n){if(e===0)return 0;var i=n[r+e]-n[r],o=n[r+e+1]-n[r+1],a=0;return i>1e-10&&(a+=e/i*au(r,e-1,t,n)),o>1e-10&&(a-=e/o*au(r+1,e-1,t,n)),a}function _W(r,e,t,n){if(e<=1)return 0;var i=n[r+e]-n[r],o=n[r+e+1]-n[r+1],a=0;return i>1e-10&&(a+=e/i*mE(r,e-1,t,n)),o>1e-10&&(a-=e/o*mE(r+1,e-1,t,n)),a}function SW(r,e,t,n,i){var o=n.length-1,a=e,s=t[a],l=t[o+1];r=Math.max(s,Math.min(l,r));for(var c=[0,0,0],u=[0,0,0],h=[0,0,0],d=0,f=0,p=0,m=0;m<=o;m++){var g=au(m,a,r,t),y=mE(m,a,r,t),v=_W(m,a,r,t),x=i[m],b=x*g,w=x*y,_=x*v,P=n[m];c[0]+=b*P[0],c[1]+=b*P[1],c[2]+=b*P[2],u[0]+=w*P[0],u[1]+=w*P[1],u[2]+=w*P[2],h[0]+=_*P[0],h[1]+=_*P[1],h[2]+=_*P[2],d+=b,f+=w,p+=_}if(Math.abs(d)<1e-10){var S=Hm(r,e,t,n,i);return{point:S,deriv1:[0,0,0],deriv2:[0,0,0]}}var E=d*d,C=[c[0]/d,c[1]/d,c[2]/d],k=[(u[0]*d-c[0]*f)/E,(u[1]*d-c[1]*f)/E,(u[2]*d-c[2]*f)/E],T=h[0]*d-c[0]*p,O=h[1]*d-c[1]*p,I=h[2]*d-c[2]*p,F=[T/E-2*f*k[0]/d,O/E-2*f*k[1]/d,I/E-2*f*k[2]/d];return{point:C,deriv1:k,deriv2:F}}function PW(r,e){var t=r[0],n=r[1],i=e[0],o=e[1],a=t*t+n*n;return a<1e-20?0:(t*o-n*i)/Math.pow(a,1.5)}function $4(r,e,t,n){for(var i=r,o=e[i],a=e[e.length-i-1],s=0,l=1e3,c=(a-o)/l,u=Hm(o,r,e,t,n),h=1;h<=l;h++){var d=o+h*c,f=Hm(d,r,e,t,n),p=f[0]-u[0],m=f[1]-u[1],g=f[2]-u[2];s+=Math.sqrt(p*p+m*m+g*g),u=f}var y=Hm(a,r,e,t,n),v=y[0]-u[0],x=y[1]-u[1],b=y[2]-u[2];return s+=Math.sqrt(v*v+x*x+b*b),s}var R0=new Ue,NI=new X,EW=new X,MW=new X,o1=new D,X4=new X;function kW(r){return new Ue().setFromExtrusionDirection(new X(r.x,r.y,r.z))}function If(r){return F0(new X,r)}function F0(r,e){return R0.setFromExtrusionDirection(X4.set(e.x,e.y,e.z)),R0.extractBasis(NI,EW,MW),r.copy(NI),r}function Ei(r,e){return iA(new D,r,e)}function iA(r,e,t){var n,i;return t.x===0&&t.y===0&&t.z===1?(r.set(e.x,e.y,(n=e.z)!==null&&n!==void 0?n:0),r):(R0.setFromExtrusionDirection(X4.set(t.x,t.y,t.z)),r.set(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0),r.applyMatrix4(R0),r)}function To(r,e){var t;return new D(r.x,r.y,(t=r.z)!==null&&t!==void 0?t:0).applyMatrix4(kW(e).invert())}function zl(r,e,t){var n,i,o=To(r,t),a=To(e,t);return o1.set(a.x-o.x,a.y-o.y,((n=a.z)!==null&&n!==void 0?n:0)-((i=o.z)!==null&&i!==void 0?i:0)),Te.normalizeAngle(Math.atan2(o1.y,o1.x))}function oA(r,e,t){var n=r.x,i=r.y,o=e.x,a=e.y,s=t.x,l=t.y,c=2*(n*(a-l)+o*(l-i)+s*(i-a));if(Le.equalToZero(c))return null;var u=((n*n+i*i)*(a-l)+(o*o+a*a)*(l-i)+(s*s+l*l)*(i-a))/c,h=((n*n+i*i)*(s-o)+(o*o+a*a)*(n-s)+(s*s+l*l)*(o-n))/c,d=Math.hypot(u-n,h-i);return!Number.isFinite(d)||Le.isNonPositive(d)?null:{center:new re(u,h),radius:d}}function zI(r,e,t){var n,i,o,a=r.x,s=r.y,l=(n=r.z)!==null&&n!==void 0?n:0,c=new X(e.x-a,e.y-s,((i=e.z)!==null&&i!==void 0?i:0)-l),u=new X(t.x-a,t.y-s,((o=t.z)!==null&&o!==void 0?o:0)-l),h=new X().crossVectors(c,u),d=h.lengthSq();if(d<tn*tn)return null;var f=c.lengthSq(),p=u.lengthSq(),m=new X().crossVectors(h,c).multiplyScalar(p).add(new X().crossVectors(u,h).multiplyScalar(f)).multiplyScalar(1/(2*d)),g=new D(a+m.x,s+m.y,l+m.z),y=Math.hypot(g.x-a,g.y-s,g.z-l);return!Number.isFinite(y)||Le.isNonPositive(y)?null:{center:g,radius:y}}function tu(r,e){return Math.atan2(e.y-r.y,e.x-r.x)}function Qs(r,e){return Math.hypot(e.x-r.x,e.y-r.y)}function Y4(r,e,t){if(Le.isNonPositive(e))return null;var n=t.x-r.x,i=t.y-r.y,o=Math.hypot(n,i);if(Le.isNonPositive(o))return null;var a=e/o;return new re(r.x+n*a,r.y+i*a)}var AW=1e-8;function q4(r,e,t,n){var i=Math.abs(Qs(r,e)-t);return i<=(n??Math.max(tn,t*1e-5))}function K4(r,e,t,n,i){return i===void 0&&(i=AW),Math.abs(r.x-t.x)<=i&&Math.abs(r.y-t.y)<=i&&Math.abs(e-n)<=i}function Z4(r,e,t,n){var i=Math.max(1e-18,Math.abs(t)*1e-9);return r<t-i?!0:r>t+i?!1:e>n}function jI(r,e,t,n){n===void 0&&(n=!1);var i=oA(r,e,t);if(!i)return null;var o=tu(i.center,r),a=tu(i.center,e),s=tu(i.center,t),l=!Te.isAngleOnCcwSweep(o,a,s);return n&&(l=!l),wt.fromMathAngles(i.center,i.radius,o,s,l)}function aA(r,e){return!Number.isFinite(e)||Le.isNonPositive(e)?null:new wt(r,e,0,lt,!1)}function CW(r,e){var t=Qs(r,e);return Le.isNonPositive(t)?null:aA({x:(r.x+e.x)/2,y:(r.y+e.y)/2},t/2)}function TW(r,e,t){var n=oA(r,e,t);return n?aA(n.center,n.radius):null}function IW(r,e,t){var n=Qs(t,r);if(Le.isNonPositive(n))return null;var i=tu(t,r),o=tu(t,e),a=Te.normalizeAngle(o-i);return wt.fromMathAngles(t,n,i,o,a>Math.PI)}function ry(r,e,t,n){var i=Qs(r,e),o=Qs(r,t);if(Le.isNonPositive(i)||Le.isNonPositive(o))return null;var a=Math.max(tn,i*tn);return Math.abs(i-o)>a?null:wt.fromMathAngles(r,i,tu(r,e),tu(r,t),n)}function LW(r,e,t,n){var i=Qs(r,e);if(Le.isNonPositive(i))return null;var o=Y4(r,i,t);return o?ry(r,e,o,n):null}function J4(r,e,t){var n=Qs(r,e),i=Math.abs(t);if(Le.isNonPositive(n)||Le.isNonPositive(i)||!Le.great(lt-i,0))return null;var o=t<0,a=tu(r,e),s=o?a-i:a+i;return wt.fromMathAngles(r,n,a,s,o)}function OW(r,e,t){var n=Qs(r,e),i=Math.abs(t);if(Le.isNonPositive(n)||Le.isNonPositive(i)||Le.great(i,2*n))return null;var o=Math.max(-1,Math.min(1,i/(2*n))),a=2*Math.asin(o);return J4(r,e,t>=0?a:-a)}function DW(r,e,t){var n=Qs(r,e),i=Math.abs(t);if(Le.isNonPositive(n)||Le.isNonPositive(i)||!Le.great(lt-i,0))return null;var o=Math.sin(i/2);if(Le.equalToZero(o))return null;var a=n/(2*o),s=a*a-n*n/4;if(Le.less(s,0))return null;var l=Math.sqrt(Math.max(0,s)),c=(r.x+e.x)/2,u=(r.y+e.y)/2,h=e.x-r.x,d=e.y-r.y,f=-d/n,p=h/n,m=t>=0,g=m&&i<=Math.PI||!m&&i>Math.PI,y=g?1:-1,v={x:c+f*l*y,y:u+p*l*y};return ry(v,r,e,!m)}function RW(r,e,t){var n=Math.cos(t),i=Math.sin(t),o=e.x-r.x,a=e.y-r.y,s=-i,l=n,c=2*(o*s+a*l);if(Le.equalToZero(c))return null;var u=(o*o+a*a)/c;if(!Number.isFinite(u))return null;var h={x:r.x+s*u,y:r.y+l*u},d=r.x-h.x,f=r.y-h.y,p=d*i-f*n;return Le.equalToZero(p)?null:ry(h,r,e,p<0)}function FW(r,e,t){var n=Math.abs(t),i=Qs(r,e);if(Le.isNonPositive(n)||Le.isNonPositive(i)||Le.great(i,2*n))return null;var o=(r.x+e.x)/2,a=(r.y+e.y)/2,s=e.x-r.x,l=e.y-r.y,c=-l/i,u=s/i,h=Math.sqrt(Math.max(0,n*n-i*i/4)),d=t>=0?1:-1,f={x:o+c*h*d,y:a+u*h*d};return ry(f,r,e,t<0)}var Q4=(function(){function r(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(r.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),r})(),BW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),sA=(function(r){BW(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.translate=function(t){return this.transform(new ny().makeTranslation(t.x,t.y))},Object.defineProperty(e.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),e})(Q4),NW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),up=(function(r){NW(e,r);function e(){var t=r.call(this)||this;return t.arcLengthDivisions=100,t}return Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPoint(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPoint(1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.getLength()},enumerable:!1,configurable:!0}),e.prototype.getPoint=function(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")},e.prototype.getPointAt=function(t){var n=this.getUtoTmapping(t);return this.getPoint(n)},e.prototype.getPoints=function(t){t===void 0&&(t=5);for(var n=[],i=0;i<=t;i++)n.push(this.getPoint(i/t));return n},e.prototype.getSpacedPoints=function(t){t===void 0&&(t=5);for(var n=[],i=0;i<=t;i++)n.push(this.getPointAt(i/t));return n},e.prototype.getLength=function(){var t=this.getLengths();return t[t.length-1]},e.prototype.getLengths=function(t){t===void 0&&(t=this.arcLengthDivisions);var n=[],i,o=this.getPoint(0),a=0;n.push(0);for(var s=1;s<=t;s++)i=this.getPoint(s/t),a+=i.distanceTo(o),n.push(a),o=i;return n},e.prototype.getUtoTmapping=function(t,n){var i=this.getLengths(),o=0,a=i.length,s;n?s=n:s=t*i[a-1];for(var l=0,c=a-1,u;l<=c;)if(o=Math.floor(l+(c-l)/2),u=i[o]-s,u<0)l=o+1;else if(u>0)c=o-1;else{c=o;break}if(o=c,i[o]===s)return o/(a-1);var h=i[o],d=i[o+1],f=d-h,p=(s-h)/f,m=(o+p)/(a-1);return m},e.prototype.getTangent=function(t){var n=1e-4,i=t-n,o=t+n;i<0&&(i=0),o>1&&(o=1);var a=this.getPoint(i),s=this.getPoint(o),l=new re;return l.copy(s).sub(a).normalize(),l},e.prototype.getTangentAt=function(t){var n=this.getUtoTmapping(t);return this.getTangent(n)},e})(sA),zW=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),B0=function(){return B0=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},B0.apply(this,arguments)},Wy=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},$y=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},Xy=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},wt=(function(r){zW(e,r);function e(t,n,i,o,a){var s=r.call(this)||this,l=+(t!==void 0)+ +(n!==void 0)+ +(i!==void 0)+ +(o!==void 0)+ +(a!==void 0);if(l==3)typeof t=="object"&&typeof n=="object"&&typeof i=="object"?s.createByThreePoints(t,n,i):s.createByStartEndPointsAndBulge(t,n,i);else if(l==5){var c=t;s.center=new re(c.x,c.y),s.radius=n,s._clockwise=a,s._startAngle=s._clockwise?s._mirrorAngle(Te.normalizeAngle(i)):Te.normalizeAngle(i),s._endAngle=s._clockwise?s._mirrorAngle(Te.normalizeAngle(o)):Te.normalizeAngle(o)}else throw qi.ILLEGAL_PARAMETERS;return s}return e.fromMathAngles=function(t,n,i,o,a){var s=new e(t,n,Te.normalizeAngle(i),Te.normalizeAngle(o),!1);return s._clockwise=a,s._boundingBoxNeedsUpdate=!0,s},e.computeCircumcircle=function(t,n,i){return oA(t,n,i)},e.projectPoint=function(t,n,i){return Y4(t,n,i)},e.pointLiesOnCircle=function(t,n,i,o){return q4(t,n,i,o)},e.sameCircle=function(t,n,i,o,a){return K4(t,n,i,o,a)},e.isBetterDistanceAlign=function(t,n,i,o){return Z4(t,n,i,o)},e.tryCreateByThreePoints=function(t,n,i,o){return o===void 0&&(o=!1),jI(t,n,i,o)},e.tryCreateCircle=function(t,n){return aA(t,n)},e.tryCreateCircleByDiameter=function(t,n){return CW(t,n)},e.tryCreateCircleByThreePoints=function(t,n,i){return TW(t,n,i)},e.tryCreateShorterArc=function(t,n,i){return IW(t,n,i)},e.tryCreateByCenterStartEnd=function(t,n,i,o){return ry(t,n,i,o)},e.tryCreateByCenterStartProjectedEnd=function(t,n,i,o){return LW(t,n,i,o)},e.tryCreateByCenterStartSweep=function(t,n,i){return J4(t,n,i)},e.tryCreateByCenterStartChord=function(t,n,i){return OW(t,n,i)},e.tryCreateByStartEndAngle=function(t,n,i){return DW(t,n,i)},e.tryCreateByStartEndDirection=function(t,n,i){return RW(t,n,i)},e.tryCreateByStartEndRadius=function(t,n,i){return FW(t,n,i)},e.prototype.createByThreePoints=function(t,n,i){var o=jI(t,n,i);if(!o)throw qi.ILLEGAL_PARAMETERS;this.center=o.center,this.radius=o.radius,this._clockwise=o._clockwise,this._startAngle=o._startAngle,this._endAngle=o._endAngle,this._boundingBoxNeedsUpdate=!0},e.prototype.createByStartEndPointsAndBulge=function(t,n,i){var o,a,s;i<0?(o=Math.atan(-i)*4,a=new vn(t),s=new vn(n)):(o=Math.atan(i)*4,a=new vn(n),s=new vn(t));var l=new vn().subVectors(s,a),c=l.length(),u=new vn().addVectors(a,l.multiplyScalar(.5)),h=Math.abs(c/2/Math.tan(o/2)),d=l.normalize(),f=i<0?-Math.PI/2:Math.PI/2,p=new vn(d.x*Math.cos(f)-d.y*Math.sin(f),d.y*Math.cos(f)+d.x*Math.sin(f)),m;o<Math.PI?i<0?m=u.add(p.multiplyScalar(h)):m=u.add(p.multiplyScalar(-h)):i<0?m=u.add(p.multiplyScalar(-h)):m=u.add(p.multiplyScalar(h)),i<0?(this._startAngle=Math.atan2(a.y-m.y,a.x-m.x),this._endAngle=Math.atan2(s.y-m.y,s.x-m.x)):(this._startAngle=Math.atan2(s.y-m.y,s.x-m.x),this._endAngle=Math.atan2(a.y-m.y,a.x-m.x)),this._clockwise=i<0,this.center=m,this.radius=s.sub(m).length()},Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new re(t.x,t.y),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){this._radius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle},set:function(t){this._startAngle=this._clockwise?this._mirrorAngle(Te.normalizeAngle(t)):Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle},set:function(t){var n=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(n):n,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),e.prototype._mirrorAngle=function(t){var n=t*180/Math.PI,i=(360-n)%360;return i*Math.PI/180},e.prototype._getInternalAngle=function(t){return this._clockwise?this._mirrorAngle(t):t},Object.defineProperty(e.prototype,"deltaAngle",{get:function(){var t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return this.clockwise?Te.normalizeAngle(t-n):Te.normalizeAngle(n-t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this._clockwise},set:function(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this.endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){var t=this._getInternalAngle(this.startAngle),n=this._clockwise?Te.normalizeAngle(t-this.deltaAngle/2):Te.normalizeAngle(t+this.deltaAngle/2),i=this._clockwise?this._mirrorAngle(n):n;return this.getPointAtAngle(i)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){var t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return Math.abs(n-t)/Math.PI%2==0},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t,n,i=[this.startPoint,this.endPoint],o=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var a=Wy(o),s=a.next();!s.done;s=a.next()){var l=s.value,c=this._getInternalAngle(l);Te.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&i.push(this.getPointAtAngle(l))}}catch(d){t={error:d}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}var u=i.map(function(d){return d.x}),h=i.map(function(d){return d.y});return new Bt(new re(Math.min.apply(Math,Xy([],$y(u),!1)),Math.min.apply(Math,Xy([],$y(h),!1))),new re(Math.max.apply(Math,Xy([],$y(u),!1)),Math.max.apply(Math,Xy([],$y(h),!1))))},Object.defineProperty(e.prototype,"length",{get:function(){return Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),e.prototype.transform=function(t){var n=this,i=t,o=this.center.clone().applyMatrix2d(i),a=this.startPoint.clone().applyMatrix2d(i);if(this.closed)return this.center=o,this.radius=o.distanceTo(a),this._startAngle=Math.atan2(a.y-o.y,a.x-o.x),this._endAngle=this._startAngle,this._clockwise=i.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var s=this.midPoint.clone().applyMatrix2d(i),l=this.endPoint.clone().applyMatrix2d(i),c=new e(a,s,l),u=i.determinant()<0?!this.clockwise:this.clockwise,h=function(d){var f=Te.normalizeAngle(d);return u?n._mirrorAngle(f):f};return this.center=c.center,this.radius=c.radius,this.clockwise=u,this.startAngle=h(Math.atan2(a.y-c.center.y,a.x-c.center.x)),this.endAngle=h(Math.atan2(l.y-c.center.y,l.x-c.center.x)),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)},e.prototype.getPointAtAngle=function(t){var n=this._getInternalAngle(t),i=this.center.x+this.radius*Math.cos(n),o=this.center.y+this.radius*Math.sin(n);return new re(i,o)},e.prototype.getQuadrantPoints=function(){var t,n,i=[],o=this._getInternalAngle(this.startAngle),a=this._getInternalAngle(this.endAngle),s=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var l=Wy(s),c=l.next();!c.done;c=l.next()){var u=c.value,h=this._getInternalAngle(u);Te.isBetweenAngle(h,o,a,this.clockwise)&&i.push(this.getPointAtAngle(u))}}catch(d){t={error:d}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return i},e.prototype.nearestPoint=function(t){var n=new re(t.x,t.y),i=n.x-this.center.x,o=n.y-this.center.y,a=Math.hypot(i,o);if(a<1e-12)return this.startPoint.clone();var s=Math.atan2(o,i),l=this.clockwise?this._mirrorAngle(Te.normalizeAngle(s)):Te.normalizeAngle(s),c=this._getInternalAngle(l),u=this._getInternalAngle(this.startAngle),h=this._getInternalAngle(this.endAngle);if(Te.isBetweenAngle(c,u,h,this.clockwise))return this.getPointAtAngle(l);var d=n.distanceToSquared(this.startPoint),f=n.distanceToSquared(this.endPoint);return d<=f?this.startPoint.clone():this.endPoint.clone()},e.prototype.inwardAlignment=function(t,n){var i=n.x-t.x,o=n.y-t.y;if(i*i+o*o<1e-24)return 0;var a=this.radius>0?this.radius:1,s=Math.max(1e-16,1e-12*a*a),l=this.startPoint.distanceToSquared(t)<=s,c=this.endPoint.distanceToSquared(t)<=s;if(!l&&!c)return 0;var u=this.getPoints(8);if(u.length<3)return 0;var h=l&&!c?u[1]:u[u.length-2],d=h.x-t.x,f=h.y-t.y,p=Math.hypot(d,f);return p>1e-18?(i*d+o*f)/p:0},e.prototype.perpendicularPoints=function(t){var n,i,o=new re(t.x,t.y),a=o.x-this.center.x,s=o.y-this.center.y,l=Math.hypot(a,s);if(l<1e-12)return[];var c=a/l,u=s/l,h=[new re(this.center.x+c*this.radius,this.center.y+u*this.radius),new re(this.center.x-c*this.radius,this.center.y-u*this.radius)],d=[],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var m=Wy(h),g=m.next();!g.done;g=m.next()){var y=g.value,v=Math.atan2(y.y-this.center.y,y.x-this.center.x),x=this.clockwise?this._mirrorAngle(Te.normalizeAngle(v)):Te.normalizeAngle(v),b=this._getInternalAngle(x);(this.closed||Te.isBetweenAngle(b,f,p,this.clockwise))&&d.push(y)}}catch(w){n={error:w}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}return d},e.prototype.tangentPoints=function(t){var n,i,o=[],a=t.x-this.center.x,s=t.y-this.center.y,l=Math.hypot(a,s),c=this.radius;if(l<c)return o;var u=Math.acos(c/l),h=Math.atan2(s,a),d=[h+u,h-u],f=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var m=Wy(d),g=m.next();!g.done;g=m.next()){var y=g.value,v=this.clockwise?this._mirrorAngle(Te.normalizeAngle(y)):Te.normalizeAngle(y),x=this._getInternalAngle(v);(this.closed||Te.isBetweenAngle(x,f,p,this.clockwise))&&o.push(this.getPointAtAngle(v))}}catch(b){n={error:b}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}return o},e.prototype.getPoints=function(t){t===void 0&&(t=100);var n=[],i=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(i=lt,o=0),this.clockwise)for(var a=0;a<=t;a++){var s=o-i*(a/t),l=this._clockwise?this._mirrorAngle(s):s,c=this.getPointAtAngle(l);n.push(new re(c.x,c.y))}else for(var a=0;a<=t;a++){var s=o+i*(a/t),l=this._clockwise?this._mirrorAngle(s):s,c=this.getPointAtAngle(l);n.push(new re(c.x,c.y))}return n},e.prototype.tessellate=function(t){var n,i=this.closed?lt:this.deltaAngle,o=e.segmentCount(this.radius,i,B0(B0({},t),{minSegments:(n=t==null?void 0:t.minSegments)!==null&&n!==void 0?n:this.closed?8:3}));return this.getPoints(o)},e.resolveCircleSides=function(t){return t==null||!Number.isFinite(t)?e.DEFAULT_CIRCLE_SIDES:Tf(Math.round(t),e.MIN_CIRCLE_SIDES,e.MAX_CIRCLE_SIDES)},e.resolveTessellateOptions=function(t){var n,i=e.resolveCircleSides(t==null?void 0:t.circleSides),o=Math.max(1,Math.round((n=t==null?void 0:t.maxSegments)!==null&&n!==void 0?n:i));return{deviation:t==null?void 0:t.deviation,circleSides:i,minSegments:t==null?void 0:t.minSegments,maxSegments:o}},e.chordDeviationFromRadius=function(t,n){n===void 0&&(n=e.DEFAULT_CIRCLE_SIDES);var i=Math.abs(t),o=e.resolveCircleSides(n);return i<=tn?tn:Math.max(tn,i*(1-Math.cos(Math.PI/o)))},e.segmentCount=function(t,n,i){var o,a,s=e.resolveTessellateOptions(i),l=Math.abs(n),c=l>=lt-1e-8,u=Math.max(1,Math.round((o=s.minSegments)!==null&&o!==void 0?o:c?8:3)),h=Math.max(u,s.maxSegments),d=Math.abs(t);if(d<=tn||l<=tn)return u;var f=(a=s.deviation)!==null&&a!==void 0?a:e.chordDeviationFromRadius(d,s.circleSides),p=1-f/d;if(!Number.isFinite(p)||p>=1)return h;if(p<=-1)return u;var m=2*Math.acos(p);return m<=tn?h:Tf(Math.ceil(l/m),u,h)},e.DEFAULT_CIRCLE_SIDES=100,e.MIN_CIRCLE_SIDES=8,e.MAX_CIRCLE_SIDES=2e4,e})(up),gE=function(){return gE=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},gE.apply(this,arguments)},jW=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Yy=1e-6;function e5(r,e){if(l$(r)){var t=VW(r,e);return t?[t]:[]}var n=i5(r),i=n.numberOfVertices;if(i<2)return[];var o=u$(n,e);return o?[o]:[]}function UW(r){return i5(r)}function VW(r,e){var t,n,i=HW(r);if(i.length===0)return null;var o=[];try{for(var a=jW(i),s=a.next();!s.done;s=a.next()){var l=s.value,c=WW(l,e);if(!c)return null;o.push(c)}}catch(f){t={error:f}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}var u=GW(r),h=qW(o,u,r.closed,e);if(h.length<2)return null;var d=new Sn;return h.forEach(function(f,p){d.addVertexAt(p,{x:f.x,y:f.y})}),d.closed=r.closed,d}function HW(r){for(var e,t=[],n=r.numberOfVertices,i=r.closed?n:n-1,o=0;o<i;o++){var a=r.vertices[o],s=r.vertices[(o+1)%n];Le.isPositive(Math.abs((e=a.bulge)!==null&&e!==void 0?e:0))?t.push({kind:"arc",arc:new wt(a,s,a.bulge)}):t.push({kind:"line",start:new re(a.x,a.y),end:new re(s.x,s.y)})}return t}function GW(r){for(var e=[],t=0;t<r.numberOfVertices;t++)e.push(r.getPointAt(t));return e}function WW(r,e){if(r.kind==="line"){var t=YW(r.start,r.end,e);return t?gE({kind:"line"},t):null}var n=$W(r.arc,r.arc.startPoint,r.arc.endPoint,e);return n?{kind:"arc",arc:n}:null}function $W(r,e,t,n){var i=XW(r,e,t,n),o=r.radius+i;return Le.isNonPositive(o)?null:new wt(r.center,o,r.startAngle,r.endAngle,r.clockwise)}function XW(r,e,t,n){var i=t.x-e.x,o=t.y-e.y,a=Math.hypot(i,o);if(Le.isNonPositive(a))return r.clockwise?-n:n;var s=-o/a,l=i/a,c=r.center.x-(e.x+t.x)/2,u=r.center.y-(e.y+t.y)/2,h=c*s+u*l>0;return h?-n:n}function YW(r,e,t){var n=e.x-r.x,i=e.y-r.y,o=Math.hypot(n,i);if(Le.isNonPositive(o))return null;var a=-i/o*t,s=n/o*t;return{start:new re(r.x+a,r.y+s),end:new re(e.x+a,e.y+s),dx:n,dy:i}}function qW(r,e,t,n){var i,o,a,s=r.length;if(s===0)return[];for(var l=KW(r,e,t,n),c=[(o=(i=l[0].nextSegmentStart)===null||i===void 0?void 0:i.clone())!==null&&o!==void 0?o:l[0].point.clone()],u=0;u<s;u++){var h=r[u],d=u===s-1&&!t?{point:t$(h)}:l[(u+1)%s];if(u>0&&l[u].filletPoints&&l[u].filletPoints.forEach(function(y){return c.push(y.clone())}),h.kind==="arc")for(var f=(a=l[u].nextSegmentStart)!==null&&a!==void 0?a:l[u].point,p=d.point,m=ZW(h.arc,f,p,Math.max(16,32)),g=1;g<m.length;g++)c.push(m[g]);else c.push(d.point.clone())}return o5(c)}function KW(r,e,t,n){for(var i=r.length,o=[],a=0;a<i;a++)a===0?o.push(t?UI(r[i-1],r[0],e[0],n):{point:e$(r[0])}):o.push(UI(r[a-1],r[a],e[a],n));return o}function ZW(r,e,t,n){for(var i=r.nearestPoint(e),o=r.nearestPoint(t),a=yE(r,i),s=yE(r,o),l=QW(r,a,s),c=[],u=0;u<=n;u++){var h=u/n,d=r.clockwise?a-l*h:a+l*h;c.push(r.getPointAtAngle(JW(r,d)))}return c}function yE(r,e){return Math.atan2(e.y-r.center.y,e.x-r.center.x)}function JW(r,e){var t=Te.normalizeAngle(e);return r.clockwise?vE(t):t}function vE(r){var e=r*180/Math.PI;return(360-e)%360*(Math.PI/180)}function QW(r,e,t){if(r.clockwise){var n=e-t;return Le.isNonPositive(n)&&(n+=lt),n}var i=t-e;return Le.isNonPositive(i)&&(i+=lt),i}function e$(r){return r.kind==="line"?r.start.clone():r.arc.startPoint.clone()}function t$(r){return r.kind==="line"?r.end.clone():r.arc.endPoint.clone()}function UI(r,e,t,n){return r.kind==="line"&&e.kind==="line"?{point:bE({start:r.start,end:r.end,dx:r.dx,dy:r.dy},{start:e.start,end:e.end,dx:e.dx,dy:e.dy})}:r.kind==="line"&&e.kind==="arc"?VI(r,e.arc,t,n,!0):r.kind==="arc"&&e.kind==="line"?VI(e,r.arc,t,n,!1):r.kind==="arc"&&e.kind==="arc"?n$(r.arc,e.arc,t,n):{point:t.clone()}}function n$(r,e,t,n){var i=r5(r.endPoint,e.startPoint),o=s$(r,e),a=o.filter(function(u){return N0(r,u)&&N0(e,u)});if(a.length>0)return{point:n5(a,i)};var s=r.endPoint.clone(),l=e.startPoint.clone(),c=t5(t,Math.abs(n),s,l);return{point:s,filletPoints:c,nextSegmentStart:l}}function VI(r,e,t,n,i){var o=r5(i?r.end:r.start,i?e.startPoint:e.endPoint),a=a$(r,e,o);if(i$(r,a)&&N0(e,a))return{point:a};var s=r$(r,t,n),l=i?e.startPoint.clone():e.endPoint.clone(),c=t5(t,Math.abs(n),i?s:l,i?l:s);return i?{point:s,filletPoints:c,nextSegmentStart:l}:{point:l,filletPoints:c,nextSegmentStart:s}}function r$(r,e,t){var n=Math.hypot(r.dx,r.dy),i=-r.dy/n*t,o=r.dx/n*t;return new re(e.x+i,e.y+o)}function i$(r,e){var t=Math.hypot(r.dx,r.dy);if(Le.isNonPositive(t))return!1;var n=r.dx/t,i=r.dy/t,o=e.x-r.start.x,a=e.y-r.start.y,s=Math.abs(o*i-a*n);return Le.equalToZero(s)}function t5(r,e,t,n){var i=Math.atan2(t.y-r.y,t.x-r.x),o=Math.atan2(n.y-r.y,n.x-r.x),a=o$(i,o);if(Le.equalToZero(Math.abs(a)))return[];for(var s=[],l=Math.max(2,Math.ceil(Math.abs(a)/Math.PI*16)),c=1;c<l;c++){var u=c/l,h=i+a*u;s.push(new re(r.x+e*Math.cos(h),r.y+e*Math.sin(h)))}return s}function o$(r,e){for(var t=e-r;t>Math.PI;)t-=lt;for(;t<=-Math.PI;)t+=lt;return t}function a$(r,e,t){var n=Math.hypot(r.dx,r.dy);if(Le.isNonPositive(n))return t.clone();var i=r.dx/n,o=r.dy/n,a=r.start.x-e.center.x,s=r.start.y-e.center.y,l=2*(a*i+s*o),c=a*a+s*s-e.radius*e.radius,u=l*l-4*c;if(u<0)return t.clone();var h=Math.sqrt(u),d=[(-l-h)/2,(-l+h)/2].map(function(p){return new re(r.start.x+i*p,r.start.y+o*p)}),f=d.filter(function(p){return N0(e,p)});return n5(f.length>0?f:d,t)}function N0(r,e){var t=Math.abs(Math.hypot(e.x-r.center.x,e.y-r.center.y)-r.radius);if(Le.isPositive(t))return!1;var n=yE(r,e),i=r.clockwise?vE(Te.normalizeAngle(r.startAngle)):Te.normalizeAngle(r.startAngle),o=r.clockwise?vE(Te.normalizeAngle(r.endAngle)):Te.normalizeAngle(r.endAngle);return Te.isBetweenAngle(n,i,o,r.clockwise)}function s$(r,e){var t=e.center.x-r.center.x,n=e.center.y-r.center.y,i=Math.hypot(t,n);if(Le.isNonPositive(i))return[];var o=r.radius+e.radius,a=Math.abs(r.radius-e.radius);if(i>o+Yy)return[];if(i<a-Yy)return[];var s=(r.radius*r.radius-e.radius*e.radius+i*i)/(2*i),l=r.radius*r.radius-s*s;if(l<-Yy)return[];var c=r.center.x+s*t/i,u=r.center.y+s*n/i;if(l<=Yy)return[new re(c,u)];var h=Math.sqrt(l),d=-n*h/i,f=t*h/i;return[new re(c+d,u+f),new re(c-d,u-f)]}function n5(r,e){for(var t=r[0],n=t.distanceToSquared(e),i=1;i<r.length;i++){var o=r[i].distanceToSquared(e);o<n&&(t=r[i],n=o)}return t.clone()}function r5(r,e){return new re((r.x+e.x)/2,(r.y+e.y)/2)}function l$(r){for(var e,t=r.numberOfVertices,n=r.closed?t:t-1,i=0;i<n;i++){var o=r.vertices[i];if(Le.isPositive(Math.abs((e=o.bulge)!==null&&e!==void 0?e:0)))return!0}return!1}function i5(r){var e=c$(r.vertices.map(function(t){return new re(t.x,t.y)}),r.closed);return e.length===r.numberOfVertices?r:new Sn(e.map(function(t){return{x:t.x,y:t.y}}),r.closed)}function c$(r,e){var t=o5(r);if(!e||t.length<2)return t;var n=t[0],i=t[t.length-1];return Le.isNonPositive(Math.hypot(n.x-i.x,n.y-i.y))&&t.pop(),t}function o5(r){var e=[];return r.forEach(function(t){var n=e[e.length-1];(!n||Le.isPositive(Math.hypot(n.x-t.x,n.y-t.y)))&&e.push(new re(t.x,t.y))}),e}function u$(r,e){for(var t=[],n=0;n<r.numberOfVertices;n++)t.push(r.getPointAt(n));var i=h$(t,r.closed,e);if(i.length===0)return null;var o=[];if(r.closed){if(i.length<2)return null;for(var a=i.length,n=0;n<a;n++){var s=i[(n-1+a)%a],l=i[n];o.push(bE(s,l))}}else{o.push(i[0].start);for(var n=1;n<i.length;n++)o.push(bE(i[n-1],i[n]));o.push(i[i.length-1].end)}var c=new Sn;return o.forEach(function(u,h){c.addVertexAt(h,{x:u.x,y:u.y})}),c.closed=r.closed,c}function h$(r,e,t){for(var n=[],i=e?r.length:r.length-1,o=0;o<i;o++){var a=r[o],s=r[e?(o+1)%r.length:o+1],l=s.x-a.x,c=s.y-a.y,u=Math.hypot(l,c);if(!Le.isNonPositive(u)){var h=-c/u*t,d=l/u*t;n.push({start:new re(a.x+h,a.y+d),end:new re(s.x+h,s.y+d),dx:l,dy:c})}}return n}function bE(r,e){var t=r.dx*e.dy-r.dy*e.dx;if(Le.equalToZero(t))return new re((r.end.x+e.start.x)/2,(r.end.y+e.start.y)/2);var n=e.start.x-r.start.x,i=e.start.y-r.start.y,o=(n*e.dy-i*e.dx)/t;return new re(r.start.x+o*r.dx,r.start.y+o*r.dy)}var d$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),xE=function(){return xE=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},xE.apply(this,arguments)},Sn=(function(r){d$(e,r);function e(t,n){t===void 0&&(t=null),n===void 0&&(n=!1);var i=r.call(this)||this;return i._vertices=t||new Array,i._closed=n,i}return Object.defineProperty(e.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numberOfVertices",{get:function(){return this._vertices.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){this._closed=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){if(this.numberOfVertices>0){var t=this._vertices[0];return new re(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){var t=this.numberOfVertices;if(t>0)if(this.closed){var n=this._vertices[0];return new re(n.x,n.y)}else{var n=this._vertices[t-1];return new re(n.x,n.y)}throw new Error("End point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){for(var t=0,n=this._vertices.length,i=0;i<n;++i){var o=this._vertices[i],a=null;if(i<n-1?a=this._vertices[i+1]:i==n-1&&this.closed&&(a=this._vertices[0]),a)if(o.bulge){var s=new wt(o,a,o.bulge);t+=s.length}else t+=new re(o.x,o.y).distanceTo(a)}return t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){if(!this._closed||this._vertices.length<3)return 0;var t=this.getPoints(128);return mW(t)},enumerable:!1,configurable:!0}),e.prototype.addVertexAt=function(t,n){t<=0?this._vertices.unshift(n):this._vertices.splice(t,0,n),this._boundingBoxNeedsUpdate=!0},e.prototype.removeVertexAt=function(t){if(t<0||t>=this._vertices.length)throw new Error("Index ".concat(t," is out of bounds. Valid range is 0 to ").concat(this._vertices.length-1,"."));this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0},e.prototype.reset=function(t,n){t?n!==void 0&&n>=0&&n<this._vertices.length&&(this._vertices=this._vertices.slice(0,n),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)},e.prototype.getPointAt=function(t){var n=this._vertices[t];return new re(n.x,n.y)},e.prototype.calculateBoundingBox=function(){var t=this.getPoints(100);return new Bt().setFromPoints(t)},e.prototype.transform=function(t){var n=t.determinant()<0;return this._vertices.forEach(function(i){var o=new re(i).applyMatrix2d(t);i.x=o.x,i.y=o.y,n&&i.bulge!=null&&(i.bulge=-i.bulge)}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._vertices.map(function(t){return xE({},t)}),this._closed)},e.prototype.getPoints3d=function(t,n){var i=[],o=this.getPoints(t);return o.forEach(function(a){return i.push(new D().set(a.x,a.y,n))}),i},e.prototype.getPoints=function(t){for(var n=[],i=this._vertices.length,o=0;o<i;++o){var a=this._vertices[o];if(a.bulge){var s=null;if(o<i-1?s=this._vertices[o+1]:o==i-1&&this.closed&&(s=this._vertices[0]),s)for(var l=new wt(a,s,a.bulge),c=l.getPoints(t),u=c.length,h=0;h<u;++h){var d=c[h];n.push(new re(d.x,d.y))}}else n.push(new re(a.x,a.y)),o==i-1&&this.closed&&n.push(n[0])}return n},e.prototype.tessellate=function(t){for(var n=[],i=this._vertices.length,o=0;o<i;++o){var a=this._vertices[o];if(a.bulge){var s=null;if(o<i-1?s=this._vertices[o+1]:o===i-1&&this.closed&&(s=this._vertices[0]),s)for(var l=new wt(a,s,a.bulge),c=l.tessellate(t),u=0;u<c.length;++u)HI(n,c[u])}else HI(n,a),o===i-1&&this.closed&&n.length>0&&n.push(n[0].clone())}return n},e.prototype.offset=function(t){return e5(this,t)},e})(up);function HI(r,e){var t=r[r.length-1];if(t){var n=t.x-e.x,i=t.y-e.y;if(n*n+i*i<=tn*tn)return}r.push(new re(e.x,e.y))}function a5(r,e,t){var n=Math.hypot(e.x,e.y);if(Le.isNonPositive(n))return null;var i=-e.y/n*t,o=e.x/n*t;return new D(r.x+i,r.y+o,r.z)}function f$(r,e,t){var n;if(r.length<2)return null;var i=UW(new Sn(r.map(function(a){return{x:a.x,y:a.y}}),e)),o=e5(i,t);return(n=o[0])!==null&&n!==void 0?n:null}var z0=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},of=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))};function p$(r,e,t,n){if(r.length<2||Le.equalToZero(t))return null;var i=l5(r,n),o=i.points,a=i.tangents;if(o.length<2)return null;var s=a??m$(o,e),l=g$(o,s,t),c=e?v$(l):y$(l);if(c.length<2)return null;var u=new Sn;return c.forEach(function(h,d){u.addVertexAt(d,{x:h.x,y:h.y})}),u.closed=e,u}function m$(r,e){for(var t=r.length,n=new Array(t),i=0;i<t;i++){var o=0,a=0;if(e){var s=r[(i-1+t)%t],l=r[(i+1)%t];o=l.x-s.x,a=l.y-s.y}else i===0?(o=r[1].x-r[0].x,a=r[1].y-r[0].y):i===t-1?(o=r[t-1].x-r[t-2].x,a=r[t-1].y-r[t-2].y):(o=r[i+1].x-r[i-1].x,a=r[i+1].y-r[i-1].y);var c=Math.hypot(o,a);Le.isNonPositive(c)?n[i]=new re(1,0):n[i]=new re(o/c,a/c)}return n}function g$(r,e,t){return r.map(function(n,i){var o=e[i],a=-o.y*t,s=o.x*t;return new re(n.x+a,n.y+s)})}function y$(r){var e=j0(r);if(e.length<3)return e;for(;;){var t=s5(e,!1);if(!t||(e=j0(of(of(of([],z0(e.slice(0,t.segmentA+1)),!1),[t.point],!1),z0(e.slice(t.segmentB+1)),!1)),e.length<2))break}return e}function v$(r){var e=j0(r);if(e.length<4)return e;for(;;){var t=s5(e,!0);if(!t||(e=j0(of(of(of([],z0(e.slice(0,t.segmentA+1)),!1),[t.point],!1),z0(e.slice(t.segmentB+1)),!1)),e.length<3))break}return e}function s5(r,e){var t=e?r.length:r.length-1;if(t<2)return null;for(var n=0;n<t;n++)for(var i=r[n],o=r[(n+1)%r.length],a=n+1;a<t;a++)if(!b$(n,a,t,e)){var s=r[a],l=r[(a+1)%r.length],c=x$(i,o,s,l);if(c)return{point:c,segmentA:n,segmentB:a}}return null}function b$(r,e,t,n){return!!(e===r||e===r+1||n&&r===0&&e===t-1)}function x$(r,e,t,n){var i=e.x-r.x,o=e.y-r.y,a=n.x-t.x,s=n.y-t.y,l=i*s-o*a;if(Le.equalToZero(l))return null;var c=t.x-r.x,u=t.y-r.y,h=(c*s-u*a)/l,d=(c*o-u*i)/l,f=du.equalPointTol;return h<-f||h>1+f||d<-f||d>1+f?null:new re(r.x+h*i,r.y+h*o)}function l5(r,e){var t=[],n=[],i=e!=null&&e.length===r.length;return r.forEach(function(o,a){var s=t[t.length-1];if((!s||Le.isPositive(Math.hypot(s.x-o.x,s.y-o.y)))&&(t.push(new re(o.x,o.y)),i)){var l=e[a];n.push(new re(l.x,l.y))}}),{points:t,tangents:i?n:void 0}}function j0(r){return l5(r).points}var w$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Qa=(function(r){w$(e,r);function e(){var t=r.call(this)||this;return t._loops=[],t}return e.prototype.add=function(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(e.prototype,"loops",{get:function(){return this._loops},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outter",{get:function(){if(this._loops.length>0)return this._loops[0]},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t=this.outter;return t?t.box:new Bt},e.prototype.transform=function(t){return this._loops.forEach(function(n){n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){var t=new e;return this._loops.forEach(function(n){t.add(n.clone())}),t},e.prototype.getPoints=function(t){for(var n=[],i=0;i<this.loops.length;++i){var o=this.loops[i],a=o.getPoints(t);n.push(a)}return n},e.prototype.tessellate=function(t){return this.loops.map(function(n){return n.tessellate(t)})},e.prototype.buildHierarchy=function(t){for(var n,i=this.tessellate(t),o=this.calculateBoundaryBoxes(i),a=this.sortBoundaryBoxesByAreas(o),s=new Map,l=a.length,c=0;c<l;c++)s.set(a[c],{index:a[c],children:[]});for(var u={index:-1,children:[]},c=0;c<l;c++){for(var h=a[c],d=i[h],f=o[h],p=c+1;p<l;p++){var m=a[p],g=i[m],y=o[m];if(y.containsBox(f)&&Qn.isPointInPolygon(d[0],g)){(n=s.get(m))===null||n===void 0||n.children.push(s.get(h));break}}p===l&&u.children.push(s.get(h))}return u},Object.defineProperty(e.prototype,"area",{get:function(){if(this._loops.length===0)return 0;for(var t=0,n=0;n<this._loops.length;n++){var i=this._loops[n],o=i.getPoints(128),a=U4(o);n===0?t+=Math.abs(a):t-=Math.abs(a)}return t},enumerable:!1,configurable:!0}),e.prototype.calculateBoundaryBoxes=function(t){var n=[];return t.forEach(function(i){n.push(new Bt().setFromPoints(i))}),n},e.prototype.sortBoundaryBoxesByAreas=function(t){var n=[];t.forEach(function(o,a){var s=o.size,l=s.width*s.height;n.push({area:l,index:a})}),n.sort(function(o,a){return o.area-a.area});var i=[];return n.forEach(function(o){i.push(o.index)}),i},e})(sA),_$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),S$=(function(r){_$(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.translate=function(t){return this.transform(new Ue().makeTranslation(t.x,t.y,t.z))},Object.defineProperty(e.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),e})(Q4),P$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),hh=(function(r){P$(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.tessellateParametricCurve=function(t,n,i,o){var a=Math.max(2,Math.round(o.maxSegments)),s=Math.max(1,Math.round(o.minSegments)),l=Math.max(0,o.deviation)*Math.max(0,o.deviation);if(!Number.isFinite(t)||!Number.isFinite(n))return[i(0)];if(Math.abs(n-t)<=tn)return[i(t)];for(var c=Math.min(a,Math.max(2,s+1)),u=Math.min(a,Math.max(c,8)),h=M$(t,n,u),d=[],f=0;f<h.length;f++)d.push(i(h[f]));for(var p=d.length,m=0;m<8&&p<a;m++){for(var g=[],f=0;f<h.length-1&&!(p>=a);f++){var y=(h[f]+h[f+1])/2,v=i(y);p++,E$(v,d[f],d[f+1])>l&&g.push({index:f,t:y,point:v})}if(g.length===0)break;var x=k$(h,d,g);h=x.params,d.length=0;for(var f=0;f<x.points.length;f++)d.push(x.points[f])}return d},e})(S$);function E$(r,e,t){var n=t.x-e.x,i=t.y-e.y,o=t.z-e.z,a=r.x-e.x,s=r.y-e.y,l=r.z-e.z,c=n*n+i*i+o*o;if(c<=tn*tn)return a*a+s*s+l*l;var u=Tf((a*n+s*i+l*o)/c,0,1),h=a-n*u,d=s-i*u,f=l-o*u;return h*h+d*d+f*f}function M$(r,e,t){if(t<=1)return[r];for(var n=[],i=0;i<t;i++)n.push(i===t-1?e:r+(e-r)*i/(t-1));return n}function k$(r,e,t){for(var n=[],i=[],o=0,a=0;a<r.length;a++)for(n.push(r[a]),i.push(e[a]);o<t.length&&t[o].index===a;)n.push(t[o].t),i.push(t[o].point),o++;return{params:n,points:i}}var A$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),U0=function(){return U0=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},U0.apply(this,arguments)},a1=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},gr=(function(r){A$(e,r);function e(t,n,i,o,a,s){s===void 0&&(s=X.X_AXIS);var l=r.call(this)||this;return l.center=t,l.radius=n,l.startAngle=i,l.endAngle=o,l.normal=a,l.refVec=s,(o-i)%lt==0?(l.startAngle=0,l.endAngle=lt):(l.startAngle=i,l.endAngle=o),l}return e.computeCenterPoint=function(t,n,i){var o,a;return(a=(o=zI(t,i,n))===null||o===void 0?void 0:o.center)!==null&&a!==void 0?a:null},e.tryCreateByThreePoints=function(t,n,i){var o,a,s,l=zI(t,i,n);if(!l)return null;var c=l.center,u=l.radius,h=new X(t.x-c.x,t.y-c.y,((o=t.z)!==null&&o!==void 0?o:0)-c.z),d=new X(i.x-c.x,i.y-c.y,((a=i.z)!==null&&a!==void 0?a:0)-c.z),f=new X(n.x-c.x,n.y-c.y,((s=n.z)!==null&&s!==void 0?s:0)-c.z);if(h.lengthSq()===0||f.lengthSq()===0)return null;var p=new X().crossVectors(h,f);if(p.lengthSq()===0&&(p.crossVectors(h,d),p.lengthSq()===0))return null;p.normalize();var m=h.clone().normalize(),g=new X().crossVectors(p,m),y=function(x){return Te.normalizeAngle(Math.atan2(x.dot(g),x.dot(m)))};Te.isAngleOnCcwSweep(0,y(d),y(f))||(p.negate(),g.negate());var v=y(f);return Le.equalToZero(v)&&(v=lt),new e(c,u,0,v,p,m)},e.createByThreePoints=function(t,n,i){return e.tryCreateByThreePoints(t,n,i)},Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new D(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._startAngle},set:function(t){this._startAngle=Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._endAngle},set:function(t){this._endAngle=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deltaAngle",{get:function(){return Te.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal},set:function(t){this._normal=new X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refVec",{get:function(){return this._refVec},set:function(t){this._refVec=new X(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){var t=this.startAngle,n=this.deltaAngle;this.closed&&(t=0,n=lt);var i=t+n*.5;return this.getPointAtAngle(i)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){return this.closed?Math.PI*this.radius*this.radius:0},enumerable:!1,configurable:!0}),e.prototype.nearestPoint=function(t){var n=new X(t.x,t.y,t.z||0),i=this.center,o=this.normal,a=n.clone().sub(i),s=a.dot(o),l=n.clone().sub(o.clone().multiplyScalar(s)),c=l.clone().sub(i);if(c.lengthSq()===0)return this.startPoint.clone();c.normalize().multiplyScalar(this.radius);var u=i.clone().add(c),h=this.getAngle(u.clone()),d=this.startAngle,f=this.deltaAngle,p=Te.normalizeAngle(h-d);p<0&&(p=0),p>f&&(p=f);var m=this.getPointAtAngle(d+p),g=m.distanceTo(n),y=this.startPoint.distanceTo(n),v=this.endPoint.distanceTo(n);return y<g&&y<=v?this.startPoint.clone():v<g&&v<y?this.endPoint.clone():m},e.prototype.tangentPoints=function(t){var n,i,o=[],a=new X(t.x,t.y,t.z||0),s=this.center,l=this.normal,c=this.radius,u=a.clone().sub(s),h=u.dot(l),d=a.clone().sub(l.clone().multiplyScalar(h)),f=s.clone(),p=d.clone().sub(f),m=p.length();if(m<c)return o;var g=Math.acos(c/m),y=this.getAngle(d.clone()),v=[y+g,y-g];try{for(var x=a1(v),b=x.next();!b.done;b=x.next()){var w=b.value,_=Te.normalizeAngle(w-this.startAngle);_>=0&&_<=this.deltaAngle&&o.push(this.getPointAtAngle(this.startAngle+_))}}catch(P){n={error:P}}finally{try{b&&!b.done&&(i=x.return)&&i.call(x)}finally{if(n)throw n.error}}return o},e.prototype.perpendicularPoints=function(t){var n,i,o=[],a=new X(t.x,t.y,t.z||0),s=this.center,l=this.normal,c=this.radius,u=a.clone().sub(s),h=u.dot(l),d=a.clone().sub(l.clone().multiplyScalar(h)),f=d.clone().sub(s);if(f.lengthSq()<1e-24)return o;f.normalize();var p=[s.clone().add(f.clone().multiplyScalar(c)),s.clone().sub(f.clone().multiplyScalar(c))];try{for(var m=a1(p),g=m.next();!g.done;g=m.next()){var y=g.value,v=this.getAngle(y.clone()),x=Te.normalizeAngle(v-this.startAngle);x>=0&&x<=this.deltaAngle&&o.push(new D(y.x,y.y,y.z||0))}}catch(b){n={error:b}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}return o},e.prototype.nearestTangentPoint=function(t){var n=this.tangentPoints(t);if(n.length===0)return null;var i=new D(t.x,t.y,t.z||0);return n.length===1||n[0].distanceTo(i)<n[1].distanceTo(i)?n[0]:n[1]},e.prototype.calculateBoundingBox=function(){for(var t,n,i=[this.startAngle,this.endAngle],o=0;o<2*Math.PI;o+=Math.PI/2)Te.isBetweenAngle(o,this.startAngle,this.endAngle)&&i.push(o);var a=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=a1(i),f=d.next();!f.done;f=d.next()){var p=f.value,m=this.getPointAtAngle(p);m.x<a&&(a=m.x),m.y<s&&(s=m.y),m.z<l&&(l=m.z),m.x>c&&(c=m.x),m.y>u&&(u=m.y),m.z>h&&(h=m.z)}}catch(g){t={error:g}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}return new _t({x:a,y:s,z:l},{x:c,y:u,z:h})},Object.defineProperty(e.prototype,"closed",{get:function(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(t){var n=[],i=this.deltaAngle,o=this.startAngle;this.closed&&(i=lt,o=0);for(var a=0;a<=t;a++){var s=o+i*(a/t),l=this.getPointAtAngle(s);n.push(l)}return n},e.prototype.tessellate=function(t){var n,i=this.closed?lt:this.deltaAngle,o=e.segmentCount(this.radius,i,U0(U0({},t),{minSegments:(n=t==null?void 0:t.minSegments)!==null&&n!==void 0?n:this.closed?8:3}));return this.getPoints(o)},e.segmentCount=function(t,n,i){return wt.segmentCount(t,n,i)},e.prototype.transform=function(t){var n=this.center.clone().applyMatrix4(t),i=this.startPoint.clone().applyMatrix4(t),o=this.endPoint.clone().applyMatrix4(t),a=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),s=new X(i).sub(n).normalize(),l=n.distanceTo(i),c=new X().crossVectors(new X(i).sub(n),new X(a).sub(n)).normalize();c.lengthSq()===0&&(c=this.normal.clone().transformDirection(t));var u=function(h){var d=new X(h).sub(n);return Math.atan2(d.dot(GI.crossVectors(c,s)),d.dot(s))};return this.center=n,this.radius=l,this.normal=c,this.refVec=s,this.startAngle=0,this.endAngle=this.closed?lt:u(o),this._boundingBoxNeedsUpdate=!0,this},e.prototype.copy=function(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},e.prototype.clone=function(){return new e(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)},e.prototype.getAngle=function(t){return t.sub(this.center),Math.atan2(t.dot(GI.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))},e.prototype.getPointAtAngle=function(t){var n=this.normal,i=this.refVec,o={x:n.y*i.z-n.z*i.y,y:n.z*i.x-n.x*i.z,z:n.x*i.y-n.y*i.x},a=this.center,s=this.radius;return new D(a.x+s*(i.x*Math.cos(t)+o.x*Math.sin(t)),a.y+s*(i.y*Math.cos(t)+o.y*Math.sin(t)),a.z+s*(i.z*Math.cos(t)+o.z*Math.sin(t)))},Object.defineProperty(e.prototype,"plane",{get:function(){var t=new X(this.center).distanceTo(rA);return new Rw(this.normal,t)},enumerable:!1,configurable:!0}),e.prototype.offset=function(t){var n=this.radius+t;return n<=0?null:new e(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)},e})(hh),GI=new X,C$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Is=(function(r){C$(e,r);function e(t,n,i,o,a,s,l){o===void 0&&(o=0),a===void 0&&(a=lt),s===void 0&&(s=!1),l===void 0&&(l=0);var c=r.call(this)||this;return c.center=t,c.majorAxisRadius=n,c.minorAxisRadius=i,(a-o)%lt==0?(c.startAngle=0,c.endAngle=lt):(c.startAngle=o,c.endAngle=a),c.clockwise=s,c.rotation=l,c}return Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new D(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._startAngle},set:function(t){this._startAngle=Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._endAngle},set:function(t){this._endAngle=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this._clockwise},set:function(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deltaAngle",{get:function(){return Te.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){for(var t=100,n=1/0,i=1/0,o=-1/0,a=-1/0,s=0;s<=t;s++){var l=this.getPoint(s/t);n=Math.min(n,l.x),i=Math.min(i,l.y),o=Math.max(o,l.x),a=Math.max(a,l.y)}return new Bt({x:n,y:i},{x:o,y:a})},Object.defineProperty(e.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),e.prototype.getPoint=function(t){for(var n=Math.PI*2,i=this.endAngle-this.startAngle,o=Math.abs(i)<Number.EPSILON;i<0;)i+=n;for(;i>n;)i-=n;i<Number.EPSILON&&(o?i=0:i=n),this.clockwise===!0&&!o&&(i===n?i=-n:i=i-n);var a=this.startAngle+t*i,s=this.center.x+this.majorAxisRadius*Math.cos(a),l=this.center.y+this.minorAxisRadius*Math.sin(a);if(this.rotation!==0){var c=Math.cos(this.rotation),u=Math.sin(this.rotation),h=s-this.center.x,d=l-this.center.y;s=h*c-d*u+this.center.x,l=h*u+d*c+this.center.y}return new re(s,l)},e.prototype.transform=function(t){var n=t,i=new re(this.center).applyMatrix2d(n),o=new D(i.x,i.y,this.center.z),a=this.getPointAtAngle(0).clone().applyMatrix2d(n),s=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),l=new re(a).sub(i),c=new re(s).sub(i),u=l.length(),h=c.length(),d=Math.atan2(l.y,l.x),f=l.clone().normalize(),p=c.clone().normalize(),m=function(v){var x=new re(v).sub(i),b=x.dot(f),w=x.dot(p);return Te.normalizeAngle(Math.atan2(w/h,b/u))},g=n.determinant()<0?!this.clockwise:this.clockwise,y=this.closed?new e(o,u,h,0,lt,g,d):new e(o,u,h,m(this.startPoint.clone().applyMatrix2d(n)),m(this.endPoint.clone().applyMatrix2d(n)),g,d);return this.center=y.center,this.majorAxisRadius=y.majorAxisRadius,this.minorAxisRadius=y.minorAxisRadius,this._startAngle=y._startAngle,this._endAngle=y._endAngle,this._clockwise=y._clockwise,this.rotation=y.rotation,this._boundingBoxNeedsUpdate=!0,this},e.prototype.getPointAtAngle=function(t){return this.getPoint(this.closed?t/lt:Te.normalizeAngle(t-this.startAngle)/this.deltaAngle)},e.prototype.copy=function(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},e.prototype.clone=function(){return new e(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)},e.prototype.getFocusPoints=function(){var t=Math.max(this.majorAxisRadius,this.minorAxisRadius),n=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(t-n<1e-9)return[];var i=Math.sqrt(t*t-n*n),o=Math.cos(this.rotation),a=Math.sin(this.rotation),s=this.majorAxisRadius>=this.minorAxisRadius,l=s?o:-a,c=s?a:o;return[new re(this.center.x-i*l,this.center.y-i*c),new re(this.center.x+i*l,this.center.y+i*c)]},e.prototype.getQuadrantPoints=function(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]},e.prototype.nearestPoint=function(t){for(var n=new re(t.x,t.y),i=this.getPoint(0),o=n.distanceToSquared(i),a=72,s=1;s<=a;s++){var l=this.getPoint(s/a),c=n.distanceToSquared(l);c<o&&(o=c,i=l)}return i},e.prototype.tangentPoints=function(t){var n=this,i=this._projectPointToLocal(t),o=this._findSnapAngles(i,function(a,s,l,c){var u=-n.majorAxisRadius*c,h=n.minorAxisRadius*l;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype.perpendicularPoints=function(t){var n=this,i=this._projectPointToLocal(t),o=this._findSnapAngles(i,function(a,s,l,c){var u=n.minorAxisRadius*l,h=n.majorAxisRadius*c;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype._projectPointToLocal=function(t){var n=t.x-this.center.x,i=t.y-this.center.y,o=Math.cos(-this.rotation),a=Math.sin(-this.rotation);return{x:n*o-i*a,y:n*a+i*o}},e.prototype._findSnapAngles=function(t,n,i){i===void 0&&(i=144);for(var o=this.majorAxisRadius,a=this.minorAxisRadius,s=this.startAngle,l=this.deltaAngle,c=[],u=function(b){var w=Math.cos(b),_=Math.sin(b);return n(o*w,a*_,w,_)},h=s,d=u(h),f=1;f<=i;f++){var p=s+l*f/i,m=u(p);if(Math.abs(d)<1e-10&&c.push(h),d*m<0){for(var g=h,y=p,v=0;v<32;v++){var x=(g+y)/2;u(g)*u(x)<=0?y=x:g=x}c.push((g+y)/2)}h=p,d=m}return c},e})(up),T$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),V0=function(){return V0=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},V0.apply(this,arguments)},I$=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},qa=(function(r){T$(e,r);function e(t,n,i,o,a,s,l){s===void 0&&(s=0),l===void 0&&(l=lt);var c=r.call(this)||this;c.center=t,c.normal=n,c.majorAxis=i,c.majorAxisRadius=o,c.minorAxisRadius=a;var u=Math.abs(l-s);return Math.abs(u-lt)<1e-10||Math.abs(u-2*lt)<1e-10?(c.startAngle=0,c.endAngle=lt):(c.startAngle=s,c.endAngle=l),c}return Object.defineProperty(e.prototype,"center",{get:function(){return this._center},set:function(t){this._center=new D(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(t){if(t<0)throw qi.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startAngle",{get:function(){return this._startAngle},set:function(t){this._startAngle=Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endAngle",{get:function(){return this._endAngle},set:function(t){this._endAngle=this.startAngle==0&&t==lt?t:Te.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deltaAngle",{get:function(){var t=this.endAngle-this.startAngle;return Math.abs(t-lt)<1e-10?lt:Te.normalizeAngle(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal},set:function(t){this._normal=new X(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorAxis",{get:function(){return this._majorAxis},set:function(t){this._majorAxis=new X(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorAxis",{get:function(){return new X().crossVectors(this.normal,this.majorAxis).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){var t=this.startAngle,n=this.deltaAngle;(this.closed||Math.abs(n-lt)<1e-10)&&(t=0,n=lt);var i=t+n/2;return this.getPointAtAngle(i)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCircular",{get:function(){return Le.equal(this.majorAxisRadius,this.minorAxisRadius)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);for(var t=1e3,n=this.deltaAngle/t,i=0,o=this.getPointAtAngle(this.startAngle),a=1;a<=t;a++){var s=this.startAngle+a*n,l=this.getPointAtAngle(s),c=l.x-o.x,u=l.y-o.y,h=l.z-o.z;i+=Math.sqrt(c*c+u*u+h*h),o=l}return i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){return Math.abs(this.deltaAngle-lt)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t,n;if(this.majorAxis.equals(X.X_AXIS)||this.majorAxis.equals(X.Y_AXIS)||this.majorAxis.isParallelTo(X.X_AXIS)||this.majorAxis.isParallelTo(X.Y_AXIS)){for(var i=[this.startAngle,this.endAngle],o=0;o<2*Math.PI;o+=Math.PI/2)Te.isBetweenAngle(o,this.startAngle,this.endAngle)&&i.push(o);var a=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0;try{for(var d=I$(i),f=d.next();!f.done;f=d.next()){var p=f.value,m=this.getPointAtAngle(p);m.x<a&&(a=m.x),m.y<s&&(s=m.y),m.z<l&&(l=m.z),m.x>c&&(c=m.x),m.y>u&&(u=m.y),m.z>h&&(h=m.z)}}catch(y){t={error:y}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}return new _t({x:a,y:s,z:l},{x:c,y:u,z:h})}else{for(var g=100,a=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,h=-1/0,o=0;o<=g;o++){var p=this.startAngle+this.deltaAngle*(o/g),m=this.getPointAtAngle(p);a=Math.min(a,m.x),s=Math.min(s,m.y),l=Math.min(l,m.z),c=Math.max(c,m.x),u=Math.max(u,m.y),h=Math.max(h,m.z)}return new _t({x:a,y:s,z:l},{x:c,y:u,z:h})}},Object.defineProperty(e.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(t){t===void 0&&(t=100);var n=[],i=this.deltaAngle,o=this.startAngle;this.closed&&(i=lt,o=0);for(var a=0;a<=t;a++){var s=o+i*(a/t),l=this.getPointAtAngle(s);n.push(l)}return n},e.prototype.tessellate=function(t){var n=this,i,o,a=wt.resolveTessellateOptions(t),s=this.closed?lt:this.deltaAngle,l=Math.max(this.majorAxisRadius,this.minorAxisRadius),c=Math.abs(s)>=lt-1e-8,u=(i=a.minSegments)!==null&&i!==void 0?i:c?8:3;if(this.isCircular){var h=gr.segmentCount(l,s,V0(V0({},t),{minSegments:u}));return this.getPoints(h)}var d=(o=a.deviation)!==null&&o!==void 0?o:wt.chordDeviationFromRadius(l,a.circleSides),f=this.closed?0:this.startAngle;return hh.tessellateParametricCurve(f,f+s,function(p){return n.getPointAtAngle(p)},{deviation:Math.max(tn,d),minSegments:u,maxSegments:a.maxSegments})},e.prototype.getPointAtAngle=function(t){var n=Math.cos(t),i=Math.sin(t),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(i),a=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(o);return new D(this.center.x+a.x,this.center.y+a.y,this.center.z+a.z)},e.prototype.nearestPoint=function(t,n){n===void 0&&(n=72);for(var i=new D(t.x,t.y,t.z||0),o=this.getPointAtAngle(this.startAngle),a=i.distanceToSquared(o),s=1;s<=n;s++){var l=this.startAngle+this.deltaAngle*s/n,c=this.getPointAtAngle(l),u=i.distanceToSquared(c);u<a&&(a=u,o=c)}var h=i.distanceToSquared(this.startPoint),d=i.distanceToSquared(this.endPoint);return h<a&&h<=d?this.startPoint.clone():d<a&&d<h?this.endPoint.clone():o.clone()},e.prototype.tangentPoints=function(t){var n=this,i=this._projectPointToLocalPlane(t),o=this._findSnapParameterAngles(function(a,s,l,c){var u=-n.majorAxisRadius*c,h=n.minorAxisRadius*l;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype.perpendicularPoints=function(t){var n=this,i=this._projectPointToLocalPlane(t),o=this._findSnapParameterAngles(function(a,s,l,c){var u=n.minorAxisRadius*l,h=n.majorAxisRadius*c;return(a-i.x)*h-(s-i.y)*u});return o.map(function(a){return n.getPointAtAngle(a)})},e.prototype._projectPointToLocalPlane=function(t){var n=new D(t.x,t.y,t.z||0),i=new X(n).sub(this.center),o=i.dot(this.normal);return i.sub(this.normal.clone().multiplyScalar(o)),{x:i.dot(this.majorAxis),y:i.dot(this.minorAxis)}},e.prototype._findSnapParameterAngles=function(t,n){n===void 0&&(n=144);for(var i=this.majorAxisRadius,o=this.minorAxisRadius,a=this.startAngle,s=this.deltaAngle,l=[],c=function(x){var b=Math.cos(x),w=Math.sin(x);return t(i*b,o*w,b,w)},u=a,h=c(u),d=1;d<=n;d++){var f=a+s*d/n,p=c(f);if(Math.abs(h)<1e-10&&l.push(u),h*p<0){for(var m=u,g=f,y=0;y<32;y++){var v=(m+g)/2;c(m)*c(v)<=0?g=v:m=v}l.push((m+g)/2)}u=f,h=p}return l},e.prototype.contains=function(t){var n=new X(t).sub(this.center),i=n.dot(this.majorAxis),o=n.dot(this.minorAxis),a=i/this.majorAxisRadius,s=o/this.minorAxisRadius;return a*a+s*s<=1},e.prototype.transform=function(t){var n=t,i=this.center.clone().applyMatrix4(n),o=this.getPointAtAngle(0).clone().applyMatrix4(n),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),s=new X(o).sub(i),l=new X(a).sub(i),c=s.length(),u=l.length(),h=s.clone().normalize(),d=new X().crossVectors(s,l).normalize(),f=new X().crossVectors(d,h).normalize();f.dot(l)<0&&(d.negate(),f=new X().crossVectors(d,h).normalize());var p=function(g){var y=new X(g).sub(i),v=y.dot(h),x=y.dot(f);return Te.normalizeAngle(Math.atan2(x/u,v/c))},m=this.closed?new e(i,d,h,c,u,0,lt):new e(i,d,h,c,u,p(this.startPoint.clone().applyMatrix4(n)),p(this.endPoint.clone().applyMatrix4(n)));return this.center=m.center,this.normal=m.normal,this.majorAxis=m.majorAxis,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._endAngle,this._boundingBoxNeedsUpdate=!0,this},e.prototype.copy=function(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},e.prototype.clone=function(){return new e(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)},Object.defineProperty(e.prototype,"plane",{get:function(){var t=new X(this.center).distanceTo(rA);return new Rw(this.normal,t)},enumerable:!1,configurable:!0}),e.prototype.offset=function(t){var n=this.majorAxisRadius+t,i=this.minorAxisRadius+t;return n<=0||i<=0?null:new e(this.center,this.normal,this.majorAxis,n,i,this.startAngle,this.endAngle)},e})(hh),L$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Pi=(function(r){L$(e,r);function e(t,n){var i=r.call(this)||this;return i._start=new re(t),i._end=new re(n),i}return Object.defineProperty(e.prototype,"startPoint",{get:function(){return this._start},set:function(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._end},set:function(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(){return[this.startPoint,this.endPoint]},Object.defineProperty(e.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t=new re(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),n=new re(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new Bt(t,n)},e.prototype.transform=function(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(e.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.copy=function(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._start.clone(),this._end.clone())},e.prototype.project=function(t){var n=this._end.x-this._start.x,i=this._end.y-this._start.y,o=n*n+i*i;if(o<1e-18)return this._start.clone();var a=((t.x-this._start.x)*n+(t.y-this._start.y)*i)/o;return a=Math.max(0,Math.min(1,a)),new re(this._start.x+a*n,this._start.y+a*i)},e.prototype.nearestPoint=function(t){return this.project(t)},e})(up),O$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Ai=(function(r){O$(e,r);function e(t,n){var i=r.call(this)||this;return i._start=new D(t),i._end=new D(n),i}return Object.defineProperty(e.prototype,"startPoint",{get:function(){return this._start},set:function(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._end},set:function(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return new X().subVectors(this.endPoint,this.startPoint).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midPoint",{get:function(){return new D((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)},enumerable:!1,configurable:!0}),e.prototype.nearestPoint=function(t){return this.project(t)},Object.defineProperty(e.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),e.prototype.isPointOnLine=function(t){var n=this.project(t),i=1e-6;return n.distanceTo(t)<i},e.prototype.at=function(t,n){return this.delta(n).multiplyScalar(t).add(this._start)},e.prototype.atLength=function(t,n){if(n===void 0&&(n=!1),n){var i=this.delta(vu).normalize();return new D(this._start).addScaledVector(i,t)}else{var i=this.delta(vu).normalize();return new D(this._end).addScaledVector(i,t)}},e.prototype.extend=function(t,n){if(n===void 0&&(n=!1),n){var i=vu.subVectors(this._start,this._end).normalize();this._start=new D(this._start).addScaledVector(i,t)}else{var i=this.delta(vu).normalize();this._end=new D(this._end).addScaledVector(i,t)}return this._boundingBoxNeedsUpdate=!0,this},e.prototype.closestPointToPointParameter=function(t,n){WI.subVectors(t,this._start),qy.subVectors(this.endPoint,this.startPoint);var i=qy.dot(qy),o=qy.dot(WI),a=o/i;return n&&(a=Te.clamp(a,0,1)),a},e.prototype.closestPointToPoint=function(t,n,i){var o=this.closestPointToPointParameter(t,n);return this.delta(i).multiplyScalar(o).add(this._start)},e.prototype.delta=function(t){return t.subVectors(this._end,this._start)},e.prototype.distanceSq=function(){return this._start.distanceToSquared(this._end)},e.prototype.distance=function(){return this._start.distanceTo(this._end)},e.prototype.project=function(t){var n=this.direction,i=vu.subVectors(t,this.startPoint),o=i.dot(n);return new D().copy(n).multiplyScalar(o).add(this.startPoint)},e.prototype.perpPoint=function(t){var n=this.direction,i=this.startPoint,o=vu.subVectors(t,i),a=o.dot(n),s=vu.copy(n).multiplyScalar(a);return new D().addVectors(i,s)},e.prototype.calculateBoundingBox=function(){var t=new D(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),n=new D(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 _t(t,n)},e.prototype.transform=function(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(e.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.copy=function(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._start.clone(),this._end.clone())},e.prototype.offset=function(t){var n=this.startPoint,i=this.endPoint,o=Math.hypot(i.x-n.x,i.y-n.y);if(o===0)return this.clone();var a=new X(i.x-n.x,i.y-n.y,0).normalize(),s=new X(-a.y,a.x,0);return new e(new D(n.x+s.x*t,n.y+s.y*t,n.z),new D(i.x+s.x*t,i.y+s.y*t,i.z))},e})(hh),vu=new X,WI=new X,qy=new X,D$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),s1=(function(){function r(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}return r.prototype.init=function(e,t,n,i){this.c0=e,this.c1=n,this.c2=-3*e+3*t-2*n-i,this.c3=2*e-2*t+n+i},r.prototype.initCatmullRom=function(e,t,n,i,o){this.init(t,n,o*(n-e),o*(i-t))},r.prototype.initNonuniformCatmullRom=function(e,t,n,i,o,a,s){var l=(t-e)/o-(n-e)/(o+a)+(n-t)/a,c=(n-t)/a-(i-t)/(a+s)+(i-n)/s;l*=a,c*=a,this.init(t,n,l,c)},r.prototype.calc=function(e){var t=e*e,n=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*n},r})(),c5=(function(r){D$(e,r);function e(t,n,i,o){t===void 0&&(t=[]),n===void 0&&(n=!1),i===void 0&&(i="centripetal"),o===void 0&&(o=.5);var a=r.call(this)||this;return a.isCatmullRomCurve3d=!0,a.type="CatmullRomCurve3d",a._tmp=new X,a._px=new s1,a._py=new s1,a._pz=new s1,a._points=t.map(function(s){return new D(s)}),a._closed=n,a._curveType=i,a._tension=o,a}return Object.defineProperty(e.prototype,"points",{get:function(){return this._points},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"curveType",{get:function(){return this._curveType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tension",{get:function(){return this._tension},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){return this._points.length>0?this._points[0]:new D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){if(this._points.length<2)return 0;for(var t=0,n=1;n<this._points.length;n++)t+=this._points[n-1].distanceTo(this._points[n]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t},enumerable:!1,configurable:!0}),e.prototype.getPoint=function(t,n){n===void 0&&(n=new D);var i=n,o=this._points,a=o.length;if(a===0)return i.set(0,0,0);if(a===1)return i.copy(o[0]);var s=(a-(this._closed?0:1))*t,l=Math.floor(s),c=s-l;this._closed?l+=l>0?0:(Math.floor(Math.abs(l)/a)+1)*a:c===0&&l===a-1&&(l=a-2,c=1);var u,h;this._closed||l>0?u=o[(l-1)%a]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),u=new D(this._tmp.x,this._tmp.y,this._tmp.z));var d=o[l%a],f=o[(l+1)%a];if(this._closed||l+2<a?h=o[(l+2)%a]:(this._tmp.subVectors(o[a-1],o[a-2]).add(o[a-1]),h=new D(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var p=this._curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(d),p),g=Math.pow(d.distanceToSquared(f),p),y=Math.pow(f.distanceToSquared(h),p);g<1e-4&&(g=1),m<1e-4&&(m=g),y<1e-4&&(y=g),this._px.initNonuniformCatmullRom(u.x,d.x,f.x,h.x,m,g,y),this._py.initNonuniformCatmullRom(u.y,d.y,f.y,h.y,m,g,y),this._pz.initNonuniformCatmullRom(u.z,d.z,f.z,h.z,m,g,y)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(u.x,d.x,f.x,h.x,this._tension),this._py.initCatmullRom(u.y,d.y,f.y,h.y,this._tension),this._pz.initCatmullRom(u.z,d.z,f.z,h.z,this._tension));return i.set(this._px.calc(c),this._py.calc(c),this._pz.calc(c)),i},e.prototype.getPoints=function(t){for(var n=[],i=0;i<=t;i++)n.push(this.getPoint(i/t));return n},e.prototype.setPoints=function(t){this._points=t.map(function(n){return new D(n)}),this._boundingBoxNeedsUpdate=!0},e.prototype.setClosed=function(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)},e.prototype.setCurveType=function(t){this._curveType=t},e.prototype.setTension=function(t){this._tension=t},e.prototype.clone=function(){return new e(this._points.map(function(t){return t.clone()}),this._closed,this._curveType,this._tension)},e.prototype.transform=function(t){return this._points=this._points.map(function(n){var i=new D;return i.copy(n),i.applyMatrix4(t),i}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new _t;var t=new _t;return this._points.forEach(function(n){t.expandByPoint(n)}),t},e})(hh),Xd=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},Yd=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))};function $I(r,e){var t,n,i=r.x-e[0],o=r.y-e[1],a=((t=r.z)!==null&&t!==void 0?t:0)-((n=e[2])!==null&&n!==void 0?n:0);return i*i+o*o+a*a}var Wo=(function(){function r(e,t,n,i){this._degree=e,this._knots=Yd([],Xd(t),!1),this._controlPoints=n.map(function(o){return{x:o.x,y:o.y,z:o.z}}),this._weights=i?Yd([],Xd(i),!1):new Array(n.length).fill(1)}return r.prototype.degree=function(){return this._degree},r.prototype.knots=function(){return Yd([],Xd(this._knots),!1)},r.prototype.controlPoints=function(){return this._controlPoints.map(function(e){return{x:e.x,y:e.y,z:e.z}})},r.prototype.weights=function(){return Yd([],Xd(this._weights),!1)},r.prototype.clone=function(){return new r(this._degree,this._knots,this._controlPoints,this._weights)},r.prototype.point=function(e){return this.evaluate(e).point},r.prototype.evaluate=function(e){var t=this._controlPoints.map(function(n){return[n.x,n.y,n.z]});return SW(e,this._degree,this._knots,t,this._weights)},r.prototype.signedPlanarCurvatureAt=function(e){var t=this.evaluate(e);return PW(t.deriv1,t.deriv2)},r.prototype.getOffsetSamplePath2d=function(e,t){var n=this;t===void 0&&(t=512);for(var i=Math.abs(e),o=this.getParameterRange(),a=o.start,s=o.end,l=this.length(),c=Math.max(64,Math.ceil(l/Math.max(i*.2,1e-6))),u=R$(a,s,Math.min(c,t)),h=0;h<8&&u.length<t;h++){for(var d=[],f=0;f<u.length-1;f++){var p=u[f],m=u[f+1],g=(p+m)/2,y=Math.max(Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(m)),Math.abs(this.signedPlanarCurvatureAt(g)));i*y>.85&&d.push(g)}if(d.length===0)break;if(u=F$(u,d),u.length>t){u=u.slice(0,t);break}}var v=[],x=[];return u.forEach(function(b){var w=n.evaluate(b);v.push(new re(w.point[0],w.point[1]));var _=w.deriv1[0],P=w.deriv1[1],S=Math.hypot(_,P);x.push(S>1e-10?new re(_/S,P/S):new re(1,0))}),{points:v,tangents:x}},r.prototype.length=function(){var e=this._controlPoints.map(function(t){return[t.x,t.y,t.z]});return $4(this._degree,this._knots,e,this._weights)},r.byKnotsControlPointsWeights=function(e,t,n,i){return new r(e,t,n,i)},r.byPoints=function(e,t,n,i,o){n===void 0&&(n="Uniform");var a=W4(e,t,n,i,o),s=a.controlPoints.map(function(l){return{x:l[0],y:l[1],z:l[2]}});return new r(t,a.knots,s,a.weights)},r.prototype.getParameterRange=function(){var e=this._knots[this._degree],t=this._knots[this._knots.length-this._degree-1];return{start:e,end:t}},r.prototype.getPoints=function(e){for(var t=[],n=this.getParameterRange(),i=n.start,o=n.end,a=0;a<=e;a++){var s=i+(o-i)*(a/e);t.push(this.point(s))}return t},r.prototype.isClosed=function(e){e===void 0&&(e=1e-6);var t=this.getParameterRange(),n=t.start,i=t.end,o=this.point(n),a=this.point(i),s=o[0]-a[0],l=o[1]-a[1],c=o[2]-a[2];return Math.sqrt(s*s+l*l+c*c)<e},r.createFitPointsForClosedCurve=function(e){if(e.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");var t=new c5(e,!0,"centripetal"),n=Math.max(50,e.length*2);return t.getPoints(n)},r.prototype.nearestPoint=function(e,t){var n;t===void 0&&(t=64);for(var i=this.getParameterRange(),o=i.start,a=i.end,s=this.point(o),l=$I(e,s),c=0;c<=t;c++){var u=o+(a-o)*c/t,h=this.point(u),d=$I(e,h);d<l&&(l=d,s=h)}return{x:s[0],y:s[1],z:(n=s[2])!==null&&n!==void 0?n:0}},r.createClosedCurve=function(e,t,n){n===void 0&&(n="Chord");var i=this.createFitPointsForClosedCurve(e),o=i.map(function(a){return[a.x,a.y,a.z]});return r.byPoints(o,t,n)},r})();function R$(r,e,t){if(t<2)return[r,e];for(var n=[],i=0;i<t;i++)n.push(i===t-1?e:r+(e-r)*i/(t-1));return n}function F$(r,e){var t=Yd(Yd([],Xd(r),!1),Xd(e),!1).sort(function(i,o){return i-o}),n=[];return t.forEach(function(i){var o=n[n.length-1];(o===void 0||Math.abs(o-i)>1e-10)&&n.push(i)}),n}function XI(r){var e,t,n;if(!r)return!1;var i=(e=r.x)!==null&&e!==void 0?e:0,o=(t=r.y)!==null&&t!==void 0?t:0,a=(n=r.z)!==null&&n!==void 0?n:0;return i*i+o*o+a*a>1e-20}function B$(r,e,t){var n=r??0;return n<1&&t>0&&e>0&&(n=t-e-1),n<1&&(n=3),n=Math.min(n,e-1),Math.max(1,n)}function N$(r,e,t){var n=r??0;n<1&&(n=3);var i=e+t-1;return n=Math.min(n,i),Math.max(1,n)}function z$(r,e){if(!(!r||r.length!==e))return r}var j$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),YI=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},qI=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},KI=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},_i=(function(r){j$(e,r);function e(t,n,i,o,a,s){var l=r.call(this)||this,c=arguments.length;if(l._degree=3,l._closed=!1,Array.isArray(n)){if(c<2||c>5)throw qi.ILLEGAL_PARAMETERS;l._controlPoints=t;var f=void 0,p=3,m=!1;if(c>=3&&(Array.isArray(i)?(f=i,c>=4&&(p=o||3),c>=5&&(m=a)):i!==void 0&&(p=i||3,c>=4&&(m=o))),i===void 0&&c>=4&&(p=o||3,c>=5&&(m=a)),l._degree=p,l._closed=m,l._controlPoints.length<l._degree+1)throw qi.ILLEGAL_PARAMETERS;l._nurbsCurve=Wo.byKnotsControlPointsWeights(l._degree,n,l._controlPoints,f)}else{if(c<2||c>6)throw qi.ILLEGAL_PARAMETERS;l._fitPoints=t,l._knotParameterization=n,c>=3&&(l._degree=i||3);var u=typeof o=="boolean";c>=4&&u&&(l._closed=o),u?(c>=5&&(l._startTangent=a),c>=6&&(l._endTangent=s)):(c>=4&&(l._startTangent=o),c>=5&&(l._endTangent=a)),l._closed&&(l._startTangent=void 0,l._endTangent=void 0);var h=(l._startTangent?1:0)+(l._endTangent?1:0);if(l._fitPoints.length+h<l._degree+1)throw qi.ILLEGAL_PARAMETERS;if(l._closed)l._nurbsCurve=Wo.createClosedCurve(l._fitPoints,l._degree,l._knotParameterization);else{var d=l.toNurbsPoints(l._fitPoints);l._nurbsCurve=Wo.byPoints(d,l._degree,l._knotParameterization,l._startTangent?l.toNurbsPoint(l._startTangent):void 0,l._endTangent?l.toNurbsPoint(l._endTangent):void 0)}l._controlPoints=l.toGePoints(l._nurbsCurve.controlPoints().map(function(g){return[g.x,g.y,g.z||0]}))}return l}return e.prototype.buildCurve=function(){if(this._fitPoints&&this._knotParameterization){if(this._closed){var t=Wo.createFitPointsForClosedCurve(this._fitPoints),n=this.toNurbsPoints(t);this._nurbsCurve=Wo.byPoints(n,this._degree,this._knotParameterization)}else{var n=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Wo.byPoints(n,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(function(a){return[a.x,a.y,a.z||0]}))}else if(this._controlPoints)if(this._closed){var t=Wo.createFitPointsForClosedCurve(this._controlPoints),n=this.toNurbsPoints(t);this._nurbsCurve=Wo.byPoints(n,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(function(l){return[l.x,l.y,l.z||0]}))}else{var i=this._nurbsCurve.knots(),o=this._nurbsCurve.weights();this._nurbsCurve=Wo.byKnotsControlPointsWeights(this._degree,i,this._controlPoints,o)}},e.prototype.setClosed=function(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())},Object.defineProperty(e.prototype,"degree",{get:function(){return this._degree},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"knotParameterization",{get:function(){return this._knotParameterization},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controlPoints",{get:function(){return this._controlPoints.map(Qn.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fitPoints",{get:function(){var t;return(t=this._fitPoints)===null||t===void 0?void 0:t.map(Qn.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"knots",{get:function(){return qI([],YI(this._nurbsCurve.knots()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weights",{get:function(){return qI([],YI(this._nurbsCurve.weights()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){var t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),i=t[n],o=this._nurbsCurve.point(i);return new D(o[0],o[1],o[2])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){var t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),i=t[t.length-n-1],o=this._nurbsCurve.point(i);return new D(o[0],o[1],o[2])},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._nurbsCurve.length()},enumerable:!1,configurable:!0}),e.prototype.nearestPoint=function(t,n){n===void 0&&(n=64);var i=this._nurbsCurve.nearestPoint(t,n);return new D(i.x,i.y,i.z||0)},e.prototype.evaluateAt=function(t){var n=this._nurbsCurve.point(t);return new D(n[0],n[1],n[2])},e.prototype.getFitPointAt=function(t){if(!this._fitPoints)throw new Error("No fit points in this spline");var n=this._fitPoints.length,i=t<0||t>=n?n-1:t,o=this._fitPoints[i];return Qn.point2dToPoint3d(o)},e.prototype.getControlPointAt=function(t){var n=this._controlPoints.length,i=t<0||t>=n?n-1:t;return this._controlPoints[i]},Object.defineProperty(e.prototype,"isFitPointSpline",{get:function(){return!!(this._fitPoints&&this._fitPoints.length>0&&this._knotParameterization)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isControlPointSpline",{get:function(){return!this.isFitPointSpline},enumerable:!1,configurable:!0}),e.prototype.getGripPoints=function(){return this.isFitPointSpline?this._fitPoints.map(function(t){var n;return new D(t.x,t.y,(n=t.z)!==null&&n!==void 0?n:0)}):this._controlPoints.map(function(t){var n;return new D(t.x,t.y,(n=t.z)!==null&&n!==void 0?n:0)})},e.prototype.moveGripPointsAt=function(t,n){return this.isFitPointSpline?(this.moveFitPointsAt(t,n),this):(this.moveControlPointsAt(t,n),this)},e.prototype.moveFitPointsAt=function(t,n){var i,o;if(this._fitPoints){try{for(var a=KI(t),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(!Number.isInteger(l)||l<0)){var c=this._fitPoints[l];c&&Qn.applyOffsetToPoint3d(c,n)}}}catch(u){i={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}},e.prototype.moveControlPointsAt=function(t,n){var i,o;try{for(var a=KI(t),s=a.next();!s.done;s=a.next()){var l=s.value;if(!(!Number.isInteger(l)||l<0)){var c=this.getControlPointAt(l);c&&Qn.applyOffsetToPoint3d(c,n)}}}catch(u){i={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}this.rebuildAfterControlPointMutation()},e.prototype.rebuildAfterControlPointMutation=function(){var t=this._nurbsCurve.knots(),n=this._nurbsCurve.weights();this.isFitPointSpline&&(this._fitPoints=void 0,this._knotParameterization=void 0,this._startTangent=void 0,this._endTangent=void 0),this._nurbsCurve=Wo.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,n.length>0?n:void 0),this._boundingBoxNeedsUpdate=!0},e.prototype.getOffsetSamplePath2d=function(t){return this._nurbsCurve.getOffsetSamplePath2d(t)},e.prototype.getPoints=function(t){t===void 0&&(t=100);for(var n=this._nurbsCurve,i=[],o=n.knots(),a=this._nurbsCurve.degree(),s=o[a],l=o[o.length-a-1],c=(l-s)/(t-1),u=0;u<t;u++){var h=u===t-1?l:s+u*c,d=n.point(h);i.push(new D(d[0],d[1],d[2]))}return i},e.prototype.tessellate=function(t){var n=this,i,o,a=wt.resolveTessellateOptions(t),s=this._nurbsCurve.knots(),l=this._nurbsCurve.degree();if(s.length<l+2)return[this.startPoint.clone(),this.endPoint.clone()];var c=s[l],u=s[s.length-l-1],h=a.circleSides,d=Math.abs(this.length),f=(i=a.deviation)!==null&&i!==void 0?i:Math.max(tn,d<=tn?tn:d/(2*h*h));return hh.tessellateParametricCurve(c,u,function(p){return n.evaluateAt(p)},{deviation:f,minSegments:(o=a.minSegments)!==null&&o!==void 0?o:this.closed?8:2,maxSegments:a.maxSegments})},e.prototype.getCurvePoints=function(t,n){for(var i=[],o=t.knots(),a=t.degree(),s=o[a],l=o[o.length-a-1],c=(l-s)/(n-1),u=0;u<n;u++){var h=s+u*c;i.push(t.point(h))}return i},e.prototype.calculateBoundingBox=function(){var t=this.getPoints(100);return new _t().setFromPoints(t)},Object.defineProperty(e.prototype,"closed",{get:function(){return this._closed},set:function(t){this.setClosed(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"area",{get:function(){if(!this._closed)return 0;var t=this.getPoints(128);return V4(t)},enumerable:!1,configurable:!0}),e.prototype.transform=function(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(function(o){return new D(o).applyMatrix4(t)}),this._startTangent&&(this._startTangent=new D(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new D(this._endTangent).transformDirection(t)),this.buildCurve();else{var n=this._nurbsCurve.knots(),i=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(function(o){return new D(o).applyMatrix4(t)}),this._nurbsCurve=Wo.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,i.length>0?i:void 0)}return this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return this._fitPoints&&this._knotParameterization?new e(this._fitPoints.map(Qn.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?Qn.point2dToPoint3d(this._startTangent):void 0,this._endTangent?Qn.point2dToPoint3d(this._endTangent):void 0):new e(this._controlPoints.map(Qn.point2dToPoint3d),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)},e.prototype.toNurbsPoints=function(t){var n=new Array(t.length);return t.forEach(function(i,o){n[o]=[i.x,i.y,i.z||0]}),n},e.prototype.toGePoints=function(t){var n=new Array(t.length);return t.forEach(function(i,o){n[o]={x:i[0],y:i[1],z:i[2]}}),n},e.prototype.toNurbsPoint=function(t){return[t.x,t.y,t.z||0]},e.createClosedSpline=function(t,n,i){if(n===void 0&&(n="Uniform"),i===void 0&&(i=3),t.length<i+1)throw new Error("At least ".concat(i+1," points are required for a degree ").concat(i," closed spline"));return new e(t,n,i,!0)},e.fromControlPoints=function(t,n,i,o,a){if(t.length<2||n.length<2)return null;var s=B$(o,t.length,n.length);if(t.length<s+1)return null;try{return new e(t,n,z$(i,t.length),s,a)}catch{return null}},e.fromFitPoints=function(t,n,i,o,a,s){if(t.length<2)return null;var l=XI(a),c=XI(s),u=(l?1:0)+(c?1:0),h=N$(i,t.length,u);if(t.length+u<h+1)return null;try{return l||c?new e(t,n,h,o,l?a:void 0,c?s:void 0):new e(t,n,h,o)}catch{return null}},e.fromDwgSplineEdge=function(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0){var n=t.controlPoints.map(Qn.point2dToPoint3d),i=!0,o=t.controlPoints.map(function(s){return s.weight==null&&(i=!1),s.weight||1});return e.fromControlPoints(n,t.knots,i?o:void 0,t.degree,!1)}if(t.numberOfFitData>0){var a=t.fitDatum.map(Qn.point2dToPoint3d);return e.fromFitPoints(a,"Uniform",t.degree,!1,t.startTangent?Qn.point2dToPoint3d(t.startTangent):void 0,t.endTangent?Qn.point2dToPoint3d(t.endTangent):void 0)}return null},e})(hh),U$=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),l1=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return o},c1=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},Wl=(function(r){U$(e,r);function e(t){t===void 0&&(t=[]);var n=r.call(this)||this;return n._curves=t,n}return Object.defineProperty(e.prototype,"curves",{get:function(){return this._curves},enumerable:!1,configurable:!0}),e.buildFromEdges=function(t,n){if(n===void 0&&(n=.001),t.length===0)return[];for(var i=c1([],l1(t),!1),o=[],a=n*n,s=function(p,m){var g=p.x-m.x,y=p.y-m.y;return g*g+y*y<=a};i.length>0;){var l=[],c=i.shift();l.push(c);var u=e.getEdgeStartPoint(c),h=e.getEdgeEndPoint(c);if(!s(u,h))for(;i.length>0;){var d=e.findConnectingEdge(i,h,a);if(d.index<0)break;var f=i.splice(d.index,1)[0];if(d.reverse&&(f=e.reverseEdge(f)),l.push(f),h=e.getEdgeEndPoint(f),s(h,u))break}o.push(new e(l))}return o},e.prototype.add=function(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(e.prototype,"numberOfEdges",{get:function(){return this._curves.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startPoint",{get:function(){if(this._curves.length>0){var t=this._curves[0].startPoint;return new re(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endPoint",{get:function(){return this.startPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){var t=0;return this._curves.forEach(function(n){t+=n.length}),t},enumerable:!1,configurable:!0}),e.prototype.calculateBoundingBox=function(){var t=this.getPoints(100),n=new Bt;return n.setFromPoints(t),n},e.prototype.transform=function(t){var n=new Ue().set(t.elements[0],t.elements[3],0,t.elements[6],t.elements[1],t.elements[4],0,t.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(function(i){i instanceof _i?i.transform(n):i.transform(t)}),this._boundingBoxNeedsUpdate=!0,this},e.prototype.clone=function(){return new e(this._curves.map(function(t){return t.clone()}))},Object.defineProperty(e.prototype,"closed",{get:function(){return!0},enumerable:!1,configurable:!0}),e.prototype.getPoints=function(t){var n=[];return this.curves.forEach(function(i){i.getPoints(t).forEach(function(o){n.push(new re(o.x,o.y))})}),n},e.prototype.tessellate=function(t){var n=[];return this._curves.forEach(function(i){V$(i,t).forEach(function(o){var a=n[n.length-1];a&&Math.pow(a.x-o.x,2)+Math.pow(a.y-o.y,2)<=tn*tn||n.push(new re(o.x,o.y))})}),n},e.findConnectingEdge=function(t,n,i){for(var o=-1,a=!1,s=Number.POSITIVE_INFINITY,l=0;l<t.length;l++){var c=t[l],u=e.getEdgeStartPoint(c),h=e.getEdgeEndPoint(c),d=n.x-u.x,f=n.y-u.y,p=d*d+f*f;p<s&&(s=p,o=l,a=!1);var m=n.x-h.x,g=n.y-h.y,y=m*m+g*g;y<s&&(s=y,o=l,a=!0)}return s>i?{index:-1,reverse:!1}:{index:o,reverse:a}},e.getEdgeStartPoint=function(t){var n=t.startPoint;return new re(n.x,n.y)},e.getEdgeEndPoint=function(t){var n=t.endPoint;return new re(n.x,n.y)},e.reverseEdge=function(t){return t instanceof Pi?new Pi(t.endPoint,t.startPoint):t instanceof wt?e.reverseCircArcEdge(t):t instanceof Is?new Is(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof _i?e.reverseSplineEdge(t):t},e.reverseCircArcEdge=function(t){var n=t.startPoint,i=t.endPoint,o=!t.clockwise,a=Math.atan2(i.y-t.center.y,i.x-t.center.x),s=Math.atan2(n.y-t.center.y,n.x-t.center.x),l=function(c){var u=Te.normalizeAngle(c);return o?Te.normalizeAngle(-u):u};return new wt(t.center,t.radius,l(a),l(s),o)},e.reverseSplineEdge=function(t){var n=c1([],l1(t.controlPoints),!1).reverse(),i=t.knots,o=i[0],a=i[i.length-1],s=i.map(function(u){return o+a-u}).reverse(),l=t.weights,c=l.length>0?c1([],l1(l),!1).reverse():void 0;return new _i(n,s,c,t.degree,t.closed)},e})(up);function V$(r,e){if(r instanceof Pi)return r.getPoints();if(r instanceof wt||r instanceof _i)return r.tessellate(e);var t=r.closed?lt:r.deltaAngle,n=wt.segmentCount(Math.max(r.majorAxisRadius,r.minorAxisRadius),t,e);return r.getPoints(n)}var Lo=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},mg=128,H0=96,Et=du.equalPointTol,lA=Et*8;function H$(r,e,t,n,i){var o,a,s,l;t===void 0&&(t=!1),n===void 0&&(n=!1);var c=ZI(r,t,i),u=ZI(e,n,i),h=[];try{for(var d=Lo(c),f=d.next();!f.done;f=d.next()){var p=f.value;try{for(var m=(s=void 0,Lo(u)),g=m.next();!g.done;g=m.next()){var y=g.value;cA(p,y)&&pA(h,d5(p,y))}}catch(v){s={error:v}}finally{try{g&&!g.done&&(l=m.return)&&l.call(m)}finally{if(s)throw s.error}}}}catch(v){o={error:v}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}return lX(h)}function G$(r,e){var t=W$(r);switch(t.kind){case"line":return t.line.transform(e),t;case"circArc":return t.arc.transform(e),t;case"ellipseArc":return t.arc.transform(e),t;case"spline":return t.spline.transform(e),t}}function W$(r){switch(r.kind){case"line":return{kind:"line",line:r.line.clone(),extent:r.extent,extendable:r.extendable};case"circArc":return{kind:"circArc",arc:r.arc.clone(),extendable:r.extendable};case"ellipseArc":return{kind:"ellipseArc",arc:r.arc.clone(),extendable:r.extendable};case"spline":return{kind:"spline",spline:r.spline.clone(),extendable:r.extendable}}}function ZI(r,e,t){var n,i,o=[];try{for(var a=Lo(r),s=a.next();!s.done;s=a.next()){var l=s.value,c=e&&l.extendable!==!1;switch(l.kind){case"line":{var u=q$(l.line,t);if(!u)break;var h=c?"unbounded":l.extent;o.push(hp(u.start,u.end,h));break}case"circArc":{var d=X$(l.arc,c);if(t&&!gg(d.normal,t.normal)){var f=Z$(d,t);(f==null?void 0:f.kind)==="circArc"?o.push(JI(f.arc,Bs(f.arc))):(f==null?void 0:f.kind)==="ellipseArc"?o.push(QI(f.arc,Ul(f.arc))):u1(o,u5(d,Bs(d)),Bs(d),t)}else{var f=K$(d,t);f&&o.push(JI(f,Bs(f)))}break}case"ellipseArc":{var d=Y$(l.arc,c);if(t&&!gg(d.normal,t.normal))u1(o,h5(d,Ul(d)),Ul(d),t);else{var f=J$(d,t);f&&o.push(QI(f,Ul(f)))}break}case"spline":{t?u1(o,l.spline.getPoints(mg),l.spline.closed,t):o.push($$(l.spline));break}}}}catch(p){n={error:p}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o}function hp(r,e,t){var n=new X().subVectors(e,r);return{kind:"line",start:r,dir:n,extent:t,box:t==="bounded"?new _t().setFromPoints([r,e]):void 0}}function JI(r,e){return{kind:"circArc",arc:r,full:e||Bs(r),box:r.box}}function QI(r,e){return{kind:"ellipseArc",arc:r,full:e||Ul(r),box:r.box}}function $$(r){var e,t,n=[],i=r.getPoints(mg);if(i.length>=2)for(var o=r.closed?i.length:i.length-1,a=0;a<o;a++){var s=i[a],l=i[(a+1)%i.length];s.distanceToSquared(l)<Et*Et||n.push(hp(s.clone(),l.clone(),"bounded"))}var c=new _t;try{for(var u=Lo(n),h=u.next();!h.done;h=u.next()){var d=h.value;d.box&&c.union(d.box)}}catch(f){e={error:f}}finally{try{h&&!h.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}return{kind:"spline",spline:r,samples:n,box:n.length>0?c:void 0}}function X$(r,e){return!e||Bs(r)?r:new gr(r.center,r.radius,0,lt,r.normal,r.refVec)}function Y$(r,e){return!e||Ul(r)?r:new qa(r.center,r.normal,r.majorAxis,r.majorAxisRadius,r.minorAxisRadius,0,lt)}function q$(r,e){if(!e)return{start:r.startPoint.clone(),end:r.endPoint.clone()};var t=jl(r.startPoint,e),n=jl(r.endPoint,e);return t.distanceToSquared(n)<Et*Et?null:{start:t,end:n}}function K$(r,e){if(!e)return r;var t=jl(r.center,e);return new gr(t,r.radius,r.startAngle,r.endAngle,e.normal.clone(),hA(r.refVec,e.normal))}function Z$(r,e){var t=jl(r.center,e),n=r.normal.clone();if(n.lengthSq()<Et*Et)return null;n.normalize();var i=e.normal.clone();if(i.lengthSq()<Et*Et)return null;i.normalize();var o=n.dot(i),a=Math.abs(o);if(a>1-1e-8)return{kind:"circArc",arc:new gr(t,r.radius,r.startAngle,r.endAngle,i,hA(r.refVec,i))};if(a<1e-8)return null;var s=new X().crossVectors(n,i);if(s.lengthSq()<Et*Et)return null;s.normalize();var l=new qa(t,i,s,r.radius,r.radius*a,0,lt);if(Bs(r))return{kind:"ellipseArc",arc:l};var c=jl(r.startPoint,e),u=jl(r.endPoint,e),h=jl(r.midPoint,e),d=af(l,c),f=af(l,u),p=af(l,h),m=Te.normalizeAngle(p-d),g=Te.normalizeAngle(f-d),y=m<=g||g<1e-8?d+g:d+g+lt;return{kind:"ellipseArc",arc:new qa(t,i,s,r.radius,r.radius*a,d,y)}}function J$(r,e){if(!e)return r;var t=jl(r.center,e),n=hA(r.majorAxis,e.normal);return n.lengthSq()<Et*Et?null:new qa(t,e.normal.clone(),n,r.majorAxisRadius,r.minorAxisRadius,r.startAngle,r.endAngle)}function u1(r,e,t,n){if(!(e.length<2))for(var i=n?e.map(function(c){return jl(c,n)}):e,o=t?i.length:i.length-1,a=0;a<o;a++){var s=i[a],l=i[(a+1)%i.length];s.distanceToSquared(l)<Et*Et||r.push(hp(s.clone(),l.clone(),"bounded"))}}function u5(r,e){return e||Bs(r)?new gr(r.center,r.radius,0,lt,r.normal,r.refVec).getPoints(H0):r.getPoints(H0)}function h5(r,e){return e||Ul(r)?new qa(r.center,r.normal,r.majorAxis,r.majorAxisRadius,r.minorAxisRadius,0,lt).getPoints(H0):r.getPoints(H0)}function cA(r,e){return!r.box||!e.box?!0:r.box.intersectsBox(e.box)}function d5(r,e){return r.kind==="spline"&&e.kind==="spline"?Q$(r,e):r.kind==="spline"?eL(r,e):e.kind==="spline"?eL(e,r):r.kind==="line"&&e.kind==="line"?f5(r,e):r.kind==="line"&&e.kind==="circArc"?G0(r,e.arc,e.full):e.kind==="line"&&r.kind==="circArc"?G0(e,r.arc,r.full):r.kind==="line"&&e.kind==="ellipseArc"?wE(r,e.arc,e.full):e.kind==="line"&&r.kind==="ellipseArc"?wE(e,r.arc,r.full):r.kind==="circArc"&&e.kind==="circArc"?iX(r.arc,r.full,e.arc,e.full):r.kind==="circArc"&&e.kind==="ellipseArc"?tL(r.arc,r.full,e.arc,e.full):r.kind==="ellipseArc"&&e.kind==="circArc"?tL(e.arc,e.full,r.arc,r.full):r.kind==="ellipseArc"&&e.kind==="ellipseArc"?aX(r.arc,r.full,e.arc,e.full):[]}function eL(r,e){var t,n,i=[];try{for(var o=Lo(r.samples),a=o.next();!a.done;a=o.next()){var s=a.value;cA(s,e)&&pA(i,d5(s,e))}}catch(l){t={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return eX(r.spline,i,e)}function Q$(r,e){var t,n,i,o,a,s,l=[];try{for(var c=Lo(r.samples),u=c.next();!u.done;u=c.next()){var h=u.value;try{for(var d=(i=void 0,Lo(e.samples)),f=d.next();!f.done;f=d.next()){var p=f.value;cA(h,p)&&pA(l,f5(h,p))}}catch(w){i={error:w}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(w){t={error:w}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}var m=[];try{for(var g=Lo(l),y=g.next();!y.done;y=g.next()){var v=y.value,x=r.spline.nearestPoint(v,mg),b=e.spline.nearestPoint(v,mg);x.distanceTo(b)<=lA&&m.push(x)}}catch(w){a={error:w}}finally{try{y&&!y.done&&(s=g.return)&&s.call(g)}finally{if(a)throw a.error}}return m}function eX(r,e,t){var n,i,o=[];try{for(var a=Lo(e),s=a.next();!s.done;s=a.next()){var l=s.value,c=r.nearestPoint(l,mg);tX(t,c)<=lA&&o.push(c)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o}function tX(r,e){if(r.kind==="line"){var t=r.dir.lengthSq();if(t<Et*Et)return Number.POSITIVE_INFINITY;var n=new X().subVectors(e,r.start).dot(r.dir)/t;return Lf(n,r.extent)?Of(r.start,r.dir,n).distanceTo(e):Number.POSITIVE_INFINITY}if(r.kind==="circArc"){if(!fA(e,r.arc)){var i=ca(r.arc.normal,r.arc.center),o=Math.abs(i.distanceToPoint(e)),a=Math.abs(e.distanceTo(r.arc.center)-r.arc.radius),s=Math.hypot(o,a);if(s>lA)return s}return fh(r.arc,dh(r.arc,e),r.full)?0:Number.POSITIVE_INFINITY}return r.kind==="ellipseArc"?Df(e,r.arc,r.full)?0:Math.abs(Fw(r.arc,e)):Number.POSITIVE_INFINITY}function f5(r,e){var t=r.dir,n=e.dir,i=t.lengthSq(),o=n.lengthSq();if(i<Et*Et||o<Et*Et)return[];var a=new X().subVectors(r.start,e.start),s=t.dot(t),l=t.dot(n),c=n.dot(n),u=t.dot(a),h=n.dot(a),d=s*c-l*l;if(Math.abs(d)<tn*tn*s*c)return[];var f=(l*h-c*u)/d,p=(s*h-l*u)/d;if(!Lf(f,r.extent)||!Lf(p,e.extent))return[];var m=Of(r.start,t,f),g=Of(e.start,n,p);return m.distanceTo(g)>Et?[]:[m]}function G0(r,e,t){var n=ca(e.normal,e.center),i=m5(r,n);return i==="coplanar"?nX(r,e,t):i?fA(i,e)?fh(e,dh(e,i),t)?[i]:[]:[]:[]}function nX(r,e,t){var n,i,o=new X().subVectors(r.start,e.center),a=r.dir.dot(r.dir);if(a<Et*Et)return[];var s=2*r.dir.dot(o),l=o.dot(o)-e.radius*e.radius,c=[];try{for(var u=Lo(y5(a,s,l)),h=u.next();!h.done;h=u.next()){var d=h.value;if(Lf(d,r.extent)){var f=Of(r.start,r.dir,d);fh(e,dh(e,f),t)&&c.push(f)}}}catch(p){n={error:p}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}return c}function wE(r,e,t){var n=ca(e.normal,e.center),i=m5(r,n);return i==="coplanar"?rX(r,e,t):i?Df(i,e,t)?[i]:[]:[]}function rX(r,e,t){var n,i,o=e.majorAxis,a=e.minorAxis,s=e.majorAxisRadius,l=e.minorAxisRadius;if(s<Et||l<Et)return[];var c=new X().subVectors(r.start,e.center),u=c.dot(o),h=c.dot(a),d=r.dir.dot(o),f=r.dir.dot(a),p=d*d/(s*s)+f*f/(l*l),m=2*u*d/(s*s)+2*h*f/(l*l),g=u*u/(s*s)+h*h/(l*l)-1,y=[];try{for(var v=Lo(y5(p,m,g)),x=v.next();!x.done;x=v.next()){var b=x.value;if(Lf(b,r.extent)){var w=Of(r.start,r.dir,b);dA(e,af(e,w),t)&&y.push(w)}}}catch(_){n={error:_}}finally{try{x&&!x.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}return y}function iX(r,e,t,n){if(gg(r.normal,t.normal)){var i=ca(r.normal,r.center);return Math.abs(i.distanceToPoint(t.center))>Et?[]:sX(oX(r,t),r,e,t,n)}var o=uA(ca(r.normal,r.center),ca(t.normal,t.center));if(!o)return[];var a=hp(o.point.clone(),new D().addVectors(o.point,o.dir),"unbounded"),s=G0(a,r,e);return s.filter(function(l){return fA(l,t)?fh(t,dh(t,l),n):!1})}function oX(r,e){var t=new X().subVectors(e.center,r.center),n=t.length(),i=r.radius,o=e.radius;if(n<Et&&Le.equal(i,o,Et))return[];if(n>i+o+Et)return[];if(n+Math.min(i,o)+Et<Math.max(i,o))return[];var a=n<Et?g5(r.normal):t.clone().normalize(),s=(i*i-o*o+n*n)/(2*Math.max(n,Et)),l=i*i-s*s,c=new D().copy(r.center).addScaledVector(a,s);if(l<-Et*Et)return[];if(l<Et*Et)return[c];var u=Math.sqrt(Math.max(0,l)),h=new X().crossVectors(r.normal,a).normalize();return[new D().copy(c).addScaledVector(h,u),new D().copy(c).addScaledVector(h,-u)]}function tL(r,e,t,n){if(!gg(r.normal,t.normal)){var i=uA(ca(r.normal,r.center),ca(t.normal,t.center));if(!i)return[];var o=hp(i.point.clone(),new D().addVectors(i.point,i.dir),"unbounded");return G0(o,r,e).filter(function(a){return Df(a,t,n)})}return p5(u5(r,e),Bs(r)||e,function(a){return Fw(t,a)},function(a){return fh(r,dh(r,a),e)&&Df(a,t,n)})}function aX(r,e,t,n){if(!gg(r.normal,t.normal)){var i=uA(ca(r.normal,r.center),ca(t.normal,t.center));if(!i)return[];var o=hp(i.point.clone(),new D().addVectors(i.point,i.dir),"unbounded");return wE(o,r,e).filter(function(a){return Df(a,t,n)})}return p5(h5(r,e),Ul(r)||e,function(a){return Fw(t,a)},function(a){return dA(r,af(r,a),e)&&Df(a,t,n)})}function p5(r,e,t,n){for(var i=[],o=e?r.length:r.length-1,a=0;a<o;a++){var s=r[a],l=r[(a+1)%r.length],c=t(s),u=t(l);if(Math.abs(c)<=Et){n(s)&&i.push(s.clone());continue}if(!(c*u>0)){for(var h=0,d=1,f=c,p=0;p<40;p++){var m=(h+d)/2,g=new D().lerpVectors(s,l,m),y=t(g);f*y<=0?d=m:(h=m,f=y)}var v=new D().lerpVectors(s,l,(h+d)/2);n(v)&&i.push(v)}}return i}function m5(r,e){var t=e.normal.dot(r.dir),n=e.distanceToPoint(r.start);if(Le.equalToZero(t,Et*Math.max(1,r.dir.length())))return Le.equalToZero(n,Et)?"coplanar":null;var i=-n/t;return Lf(i,r.extent)?Of(r.start,r.dir,i):null}function uA(r,e){var t=new X().crossVectors(r.normal,e.normal);if(t.lengthSq()<Et*Et)return null;t.normalize();var n=r.normal,i=e.normal,o=n.dot(n)*i.dot(i)-Math.pow(n.dot(i),2);if(Math.abs(o)<tn)return null;var a=-r.constant,s=-e.constant,l=(i.dot(i)*a-n.dot(i)*s)/o,c=(n.dot(n)*s-n.dot(i)*a)/o,u=new D().addScaledVector(n,l).addScaledVector(i,c);return{point:u,dir:t}}function Lf(r,e){return e==="unbounded"?!0:e==="ray"?r>=-Et:r>=-Et&&r<=1+Et}function Of(r,e,t){return new D().copy(r).addScaledVector(e,t)}function jl(r,e){var t=new D;return e.projectPoint(r,t),t}function hA(r,e){var t=r.clone().addScaledVector(e,-r.dot(e));return t.lengthSq()<Et*Et?g5(e):t.normalize()}function ca(r,e){return new Rw().setFromNormalAndCoplanarPoint(r,e)}function gg(r,e){return new X().crossVectors(r,e).lengthSq()<Et*Et}function dh(r,e){var t=new X().subVectors(e,r.center),n=new X().crossVectors(r.normal,r.refVec);return Math.atan2(t.dot(n),t.dot(r.refVec))}function af(r,e){var t=new X().subVectors(e,r.center),n=t.dot(r.majorAxis)/r.majorAxisRadius,i=t.dot(r.minorAxis)/r.minorAxisRadius;return Math.atan2(i,n)}function Bs(r){return r.closed||Math.abs(r.deltaAngle-lt)<1e-10}function Ul(r){return r.closed||Math.abs(r.endAngle-r.startAngle)<1e-10||Math.abs(r.deltaAngle-lt)<1e-10}function fh(r,e,t){if(t||Bs(r))return!0;var n=Te.normalizeAngle(e-r.startAngle);return n<=r.deltaAngle+1e-8}function dA(r,e,t){if(t||Ul(r))return!0;var n=Te.normalizeAngle(e-r.startAngle);return n<=r.deltaAngle+1e-8}function fA(r,e){var t=ca(e.normal,e.center);return Math.abs(t.distanceToPoint(r))>Et?!1:Math.abs(r.distanceTo(e.center)-e.radius)<=Et}function Fw(r,e){var t=new X().subVectors(e,r.center),n=t.dot(r.majorAxis)/r.majorAxisRadius,i=t.dot(r.minorAxis)/r.minorAxisRadius;return n*n+i*i-1}function Df(r,e,t){var n=ca(e.normal,e.center);return Math.abs(n.distanceToPoint(r))>Et||Math.abs(Fw(e,r))>1e-4?!1:dA(e,af(e,r),t)}function sX(r,e,t,n,i){return r.filter(function(o){return fh(e,dh(e,o),t)&&fh(n,dh(n,o),i)})}function g5(r){var e=Math.abs(r.x)<.9?X.X_AXIS:X.Y_AXIS,t=new X().crossVectors(r,e);return t.lengthSq()<Et*Et&&t.crossVectors(r,X.Z_AXIS),t.normalize()}function y5(r,e,t){if(Math.abs(r)<tn)return Math.abs(e)<tn?[]:[-t/e];var n=e*e-4*r*t;if(n<-Et)return[];if(n<Et)return[-e/(2*r)];var i=Math.sqrt(Math.max(0,n));return[(-e-i)/(2*r),(-e+i)/(2*r)]}function pA(r,e){var t,n;try{for(var i=Lo(e),o=i.next();!o.done;o=i.next()){var a=o.value;r.push(a)}}catch(s){t={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}function lX(r){var e,t,n=[],i=function(l){if(n.some(function(c){return c.distanceTo(l)<=Et}))return"continue";n.push(l)};try{for(var o=Lo(r),a=o.next();!a.done;a=o.next()){var s=a.value;i(s)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return n}var nL=[{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}],Xi=(function(){function r(e){if(typeof e=="string"){var t=nL.find(function(n){return n.name===e});if(!t)throw new Error("Unknown DWG version name: ".concat(e));this.name=t.name,this.value=t.value;return}if(typeof e=="number"){var t=nL.find(function(i){return i.value===e});if(!t)throw new Error("Unknown DWG version value: ".concat(e));this.name=t.name,this.value=t.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}return Object.defineProperty(r.prototype,"capabilities",{get:function(){return r.capabilitiesFor(this.value)},enumerable:!1,configurable:!0}),Object.defineProperty(r,"latest",{get:function(){return new r("AC1032")},enumerable:!1,configurable:!0}),r.capabilitiesFor=function(e){var t=e>=19;return{supportsHandles:t,supportsSubclassMarkers:t,supportsClassesSection:t,supportsObjectsSection:t,supportsBlockRecordTable:t,supportsLwPolyline:t,supportsLineWeight:e>=23,supportsTrueColor:e>=25,supportsTransparency:e>=25,supportsUtf8CodePage:e>=27,supportsBlockRecordUnitsFlags:e>=27,supportsMLeader:e>=27,supportsHatchHeaderVars:e>=29}},r})();function dp(r){return r===999?"comment":r===5?"handle":r<=9||r===100||r===102?"string":r===105?"handle":r>=101&&r<=109?"string":r<=59?"double":r<=79?"int":r<=89?"string":r<=99?"int":r<=149?"double":r<=159?"string":r<=169?"long":r<=179?"int":r<=209?"string":r<=239?"double":r<=269?"long":r<=289?"int":r<=299?"bool":r<=309?"string":r<=319?"binary":r<=369?"handle":r<=389?"int":r<=399?"handle":r<=409?"int":r<=419?"string":r<=429?"int":r<=439?"string":r<=449||r<=459?"int":r<=469?"double":r<=479?"string":r===480||r===481?"handle":r===1004?"binary":r===1005?"handle":r>=1e3&&r<=1009?"string":r>=1010&&r<=1059?"double":r>=1060&&r<=1070||r===1071?"int":"string"}function v5(r){return r>=90&&r<=99||r>=420&&r<=429||r>=440&&r<=449||r>=450&&r<=459||r===1071}var W0;(function(r){r[r.UTF8=0]="UTF8",r[r.US_ASCII=1]="US_ASCII",r[r.ISO_8859_1=2]="ISO_8859_1",r[r.ISO_8859_2=3]="ISO_8859_2",r[r.ISO_8859_3=4]="ISO_8859_3",r[r.ISO_8859_4=5]="ISO_8859_4",r[r.ISO_8859_5=6]="ISO_8859_5",r[r.ISO_8859_6=7]="ISO_8859_6",r[r.ISO_8859_7=8]="ISO_8859_7",r[r.ISO_8859_8=9]="ISO_8859_8",r[r.ISO_8859_9=10]="ISO_8859_9",r[r.CP437=11]="CP437",r[r.CP850=12]="CP850",r[r.CP852=13]="CP852",r[r.CP855=14]="CP855",r[r.CP857=15]="CP857",r[r.CP860=16]="CP860",r[r.CP861=17]="CP861",r[r.CP863=18]="CP863",r[r.CP864=19]="CP864",r[r.CP865=20]="CP865",r[r.CP869=21]="CP869",r[r.CP932=22]="CP932",r[r.MACINTOSH=23]="MACINTOSH",r[r.BIG5=24]="BIG5",r[r.CP949=25]="CP949",r[r.JOHAB=26]="JOHAB",r[r.CP866=27]="CP866",r[r.ANSI_1250=28]="ANSI_1250",r[r.ANSI_1251=29]="ANSI_1251",r[r.ANSI_1252=30]="ANSI_1252",r[r.GB2312=31]="GB2312",r[r.ANSI_1253=32]="ANSI_1253",r[r.ANSI_1254=33]="ANSI_1254",r[r.ANSI_1255=34]="ANSI_1255",r[r.ANSI_1256=35]="ANSI_1256",r[r.ANSI_1257=36]="ANSI_1257",r[r.ANSI_874=37]="ANSI_874",r[r.ANSI_932=38]="ANSI_932",r[r.ANSI_936=39]="ANSI_936",r[r.ANSI_949=40]="ANSI_949",r[r.ANSI_950=41]="ANSI_950",r[r.ANSI_1361=42]="ANSI_1361",r[r.UTF16=43]="UTF16",r[r.ANSI_1258=44]="ANSI_1258",r[r.UNDEFINED=255]="UNDEFINED"})(W0||(W0={}));var cX=["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","euc-kr","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"],b5=function(r){return cX[r]},uX={cp949:"euc-kr",uhc:"euc-kr",euckr:"euc-kr",windows949:"euc-kr",ksc56011987:"euc-kr",cp936:"gbk"},x5=function(r){var e,t=r.toLowerCase().replace(/[_-]/g,"");return(e=uX[t])!==null&&e!==void 0?e:r},mA=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Am=250,_E=255,w5=127;function _5(r){var e=r??"";if(e.length<=Am)return[{code:1,value:e}];for(var t=[],n=0;e.length-n>Am;)t.push({code:3,value:e.slice(n,n+Am)}),n+=Am;return t.push({code:1,value:e.slice(n)}),t}function S5(r,e){var t,n,i=r??"";if(i.length===0)return[""];var o=new TextEncoder,a=[],s="",l=0;try{for(var c=mA(i),u=c.next();!u.done;u=c.next()){var h=u.value,d=o.encode(h).byteLength;if(d>e){s.length>0&&(a.push(s),s="",l=0),a.push(h);continue}l+d>e&&s.length>0?(a.push(s),s=h,l=d):(s+=h,l+=d)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}return s.length>0&&a.push(s),a}function P5(r,e){if(r.byteLength===0)return[r];for(var t=[],n=0;n<r.byteLength;n+=e)t.push(r.subarray(n,n+e));return t}function hX(r){return r<=127?1:3+(r<=65535?4:8)}function dX(r,e){var t,n,i=r??"";if(i.length===0)return[""];var o=[],a="",s=0;try{for(var l=mA(i),c=l.next();!c.done;c=l.next()){var u=c.value,h=u.codePointAt(0),d=hX(h);if(d>e){a.length>0&&(o.push(a),a="",s=0),o.push(u);continue}s+d>e&&a.length>0?(o.push(a),a=u,s=d):(a+=u,s+=d)}}catch(f){t={error:f}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return a.length>0&&o.push(a),o}function fX(r){for(var e,t,n=r??"",i=!1,o=0;o<n.length;o++)if(n.charCodeAt(o)>127){i=!0;break}if(!i)return n;var a="";try{for(var s=mA(n),l=s.next();!l.done;l=s.next()){var c=l.value,u=c.codePointAt(0);if(u<=127)a+=c;else{var h=u.toString(16).toUpperCase();a+="\\U+"+(h.length<=4?h.padStart(4,"0"):h.padStart(8,"0"))}}}catch(d){e={error:d}}finally{try{l&&!l.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return a}function gA(r){var e=r??"";return!e.includes("\\U+")&&!e.includes("\\u+")?e:e.replace(/\\U\+([0-9A-Fa-f]{4,8})/gi,function(t,n){var i=Number.parseInt(n,16);if(!Number.isFinite(i)||i<0||i>1114111)return t;try{return String.fromCodePoint(i)}catch{return t}})}var h1=(function(){for(var r=`AutoCAD Binary DXF\r
|
|
2
2
|
`,e=new Uint8Array(22),t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e[20]=26,e[21]=0,e})(),pX=new TextDecoder("utf-8"),Rf=(function(){for(var r=new Int8Array(128),e=0;e<10;e++)r[48+e]=e;for(var e=0;e<6;e++)r[65+e]=10+e,r[97+e]=10+e;return r})();function E5(r){if(r.length<h1.length)return!1;for(var e=0;e<h1.length;e++)if(r[e]!==h1[e])return!1;return!0}function va(r){return r===32||r>=9&&r<=13}function $0(r){return va(r)||r===160||r===5760||r===8232||r===8233||r===8239||r===8287||r===12288||r===65279||r>=8192&&r<=8202}function mX(r,e,t){var n=t-e;if(n<=0)return"";if(n<=16){for(var i="",o=e;o<t;o++)i+=String.fromCharCode(r[o]);return i}for(var a=4096,s="",l=e;l<t;l+=a){var c=Math.min(l+a,t);s+=String.fromCharCode.apply(null,r.subarray(l,c))}return s}function jc(r,e,t,n,i){return n?i.decode(r.subarray(e,t)):mX(r,e,t)}function gX(r,e,t,n,i){if(n){var o=Number(jc(r,e,t,!0,i).trim());return Number.isFinite(o)?o:NaN}for(var a=e;a<t&&va(r[a]);)a++;if(a>=t)return NaN;var s=1,l=r[a];l===45?(s=-1,a++):l===43&&a++;for(var c=0,u=0;a<t;){var h=r[a];if(h>=48&&h<=57)c=c*10+(h-48),u++,a++;else break}if(u===0)return NaN;for(;a<t;){if(!va(r[a]))return NaN;a++}return s*c}var rL=(Number.MAX_SAFE_INTEGER-9)/10;function yX(r,e,t){for(var n=e;n<t&&va(r[n]);)n++;if(n>=t)return 0;var i=1,o=r[n];o===45?(i=-1,n++):o===43&&n++;for(var a=0,s=0,l=!1,c=!1;n<t;){var u=r[n];if(u<48||u>57)break;if(l=!0,n++,!(a===0&&u===48)){if(a>rL){c=!0;continue}a=a*10+(u-48)}}if(n<t&&r[n]===46)for(n++;n<t;){var u=r[n];if(u<48||u>57)break;if(l=!0,n++,a===0&&u===48){s--;continue}if(a>rL){c=!0;continue}a=a*10+(u-48),s--}if(n<t&&(r[n]===101||r[n]===69)){n++;var h=1,d=r[n];d===45?(h=-1,n++):d===43&&n++;for(var f=0,p=0;n<t;){var u=r[n];if(u<48||u>57)break;n++,p++,f<=1e4&&(f=f*10+(u-48))}if(p===0)return;s+=h*f}for(;n<t;){if(!va(r[n]))return;n++}if(!l)return 0;if(!c){if(a===0)return i*a;if(!(s>22||s<-22)){for(var m=1,g=s<0?-s:s,y=0;y<g;y++)m*=10;return i*(s<0?a/m:a*m)}}}function vX(r,e,t){for(var n=e;!(n>=t);){var i=r[n];if(i>=128)return;if(!va(i))break;n++}var o=1,a=r[n];if(a===45?(o=-1,n++):a===43&&n++,!(n<t&&r[n]>=128)){for(var s=0,l=0,c=!1;n<t;){var i=r[n];if(i<48||i>57)break;if(n++,c=!0,!(s===0&&i===48)){if(l>=15)return;s=s*10+(i-48),l++}}return c?o*s:0}}function bX(r,e,t){for(var n=e;n<t&&va(r[n]);)n++;var i=1,o=r[n];o===45?(i=-1,n++):o===43&&n++;for(var a=0,s=0,l=!1;n<t;){var c=r[n];if(c<48||c>57)break;if(n++,l=!0,!(a===0&&c===48)){if(s>=15)return;a=a*10+(c-48),s++}}for(;n<t;){if(!va(r[n]))return;n++}return l?i*a:0}function xX(r,e,t,n){if(!n){for(;e<t&&va(r[e]);)e++;for(;t>e&&va(r[t-1]);)t--;return e>=t?!1:!(t-e===1&&r[e]===48)}}function wX(r,e,t){for(;e<t&&$0(r.charCodeAt(e));)e++;for(;t>e&&$0(r.charCodeAt(t-1));)t--;for(var n=t-e>>>1,i=new Uint8Array(n),o=0;o<n;o++){var a=Rf[r.charCodeAt(e+o*2)&127],s=Rf[r.charCodeAt(e+o*2+1)&127];i[o]=a<<4|s}return i}function _X(r,e,t,n,i){for(;e<t&&va(r[e]);)e++;for(;t>e&&va(r[t-1]);)t--;if(n){var o=jc(r,e,t,!0,i);return wX(o,0,o.length)}for(var a=t-e>>>1,s=new Uint8Array(a),l=0;l<a;l++){var c=Rf[r[e+l*2]&127],u=Rf[r[e+l*2+1]&127];s[l]=c<<4|u}return s}function SX(r,e,t,n,i,o){var a=dp(r);if(a==="comment")return null;switch(a){case"string":return{code:r,type:a,value:gA(jc(e,t,n,i,o))};case"int":{var s=vX(e,t,n),l=s===void 0?parseInt(jc(e,t,n,i,o),10):s;return{code:r,type:a,value:Number.isFinite(l)?l:0}}case"long":{var s=bX(e,t,n);if(s!==void 0)return{code:r,type:a,value:s};var c=jc(e,t,n,i,o),l=Number(c);if(Number.isSafeInteger(l))return{code:r,type:a,value:l};try{return{code:r,type:a,value:BigInt(c.trim())}}catch{return{code:r,type:a,value:0}}}case"double":{var s=yX(e,t,n),l=s===void 0?Number(jc(e,t,n,i,o)):s;return{code:r,type:a,value:Number.isFinite(l)?l:0}}case"bool":{var s=xX(e,t,n,i);if(s!==void 0)return{code:r,type:a,value:s};var u=jc(e,t,n,i,o).trim();return{code:r,type:a,value:u!==""&&u!=="0"}}case"handle":{var h=jc(e,t,n,i,o);if(h.length===0)return{code:r,type:a,value:h};var d=h.charCodeAt(0),f=h.charCodeAt(h.length-1);return!$0(d)&&!$0(f)?{code:r,type:a,value:h}:{code:r,type:a,value:h.trim()}}case"binary":return{code:r,type:a,value:_X(e,t,n,i,o)};default:return null}}function PX(r){var e=r.toLowerCase().replace(/_/g,"-");return e==="utf-8"||e==="utf8"||e==="unicode-1-1-utf-8"}function SE(r,e){e===void 0&&(e="utf-8");var t=PX(e)?pX:new TextDecoder(e),n=r.length>=3&&r[0]===239&&r[1]===187&&r[2]===191?3:0,i=1,o,a=!1;function s(){if(!(n>=r.length)){for(var c=n,u=n,h=0;u<r.length;){var d=r[u];if(d===10||d===13)break;h|=d,u++}var f=u;return f<r.length&&r[f]===13&&f++,f<r.length&&r[f]===10&&f++,n=f,i++,{start:c,end:u,nonAscii:h>=128}}}function l(){for(;;){var c=s();if(c===void 0)return;var u=gX(r,c.start,c.end,c.nonAscii,t);if(!Number.isNaN(u)){if(u===999){if(s()===void 0)return;continue}var h=s();if(h===void 0)return;var d=SX(u,r,h.start,h.end,h.nonAscii,t);if(d)return d}}}return{kind:"ascii",next:function(){if(a){var c=o;return o=void 0,a=!1,c}return l()},peek:function(){return a||(o=l(),a=!0),o},position:function(){return{line:i,byteOffset:n}}}}function iL(r){return SE(r,"utf-8")}function M5(r){var e;if(!r)return null;var t=W0[r];return t===void 0?null:(e=b5(t))!==null&&e!==void 0?e:null}function EX(r,e){for(var t=yA(r,{encoding:"utf-8",legacyR12:e}),n=null,i=null,o=!1,a=null,s=t.next();s;s=t.next()){if(s.code===0&&s.type==="string"){var l=s.value;if(l==="SECTION"){var c=t.next();(c==null?void 0:c.code)===2&&c.type==="string"&&c.value==="HEADER"&&(o=!0),a=null;continue}if(l==="ENDSEC"&&o)return{version:n,encoding:i};a=null;continue}if(o){if(s.code===9&&s.type==="string"){a=s.value;continue}if(a==="$ACADVER"&&s.code===1&&s.type==="string")try{n=new Xi(s.value)}catch{}else a==="$DWGCODEPAGE"&&s.code===3&&s.type==="string"&&(i=M5(s.value));if(a!==null&&(a=null,n&&i))return{version:n,encoding:i}}}return{version:n,encoding:i}}function oL(r){return r.version&&!r.version.capabilities.supportsUtf8CodePage&&r.encoding?r.encoding:null}function k5(r){for(var e,t,n,i,o=65536,a=new TextDecoder("utf-8"),s=0,l="",c=null,u=null,h=!1;s<r.byteLength;){var d=Math.min(s+o,r.byteLength),f=r.slice(s,d);s=d;var p=l+a.decode(f,{stream:!0}),m=p.split(/\r?\n/);l=(e=m.pop())!==null&&e!==void 0?e:"";for(var g=0;g<m.length;g++){var y=m[g].trim();if(y==="SECTION"&&((t=m[g+2])===null||t===void 0?void 0:t.trim())==="HEADER")h=!0;else if(y==="ENDSEC"&&h)return{version:c,encoding:u};if(h&&y==="$ACADVER"){var v=(n=m[g+2])===null||n===void 0?void 0:n.trim();v&&(c=new Xi(v))}else if(h&&y==="$DWGCODEPAGE"){var v=(i=m[g+2])===null||i===void 0?void 0:i.trim();v&&(u=M5(v))}if(c&&u)return{version:c,encoding:u}}}return{version:c,encoding:u}}function MX(r){for(var e=r.trim(),t=e.length>>>1,n=new Uint8Array(t),i=0;i<t;i++){var o=Rf[e.charCodeAt(i*2)&127],a=Rf[e.charCodeAt(i*2+1)&127];n[i]=o<<4|a}return n}function kX(r,e){var t=dp(r);if(t==="comment")return null;switch(t){case"string":return{code:r,type:t,value:gA(e)};case"int":{var n=parseInt(e.trim(),10);return{code:r,type:t,value:Number.isFinite(n)?n:0}}case"long":{var i=e.trim(),n=Number(i);if(Number.isSafeInteger(n))return{code:r,type:t,value:n};try{return{code:r,type:t,value:BigInt(i)}}catch{return{code:r,type:t,value:0}}}case"double":{var n=Number(e.trim());return{code:r,type:t,value:Number.isFinite(n)?n:0}}case"bool":{var o=e.trim();return{code:r,type:t,value:o!=="0"&&o!==""}}case"handle":return{code:r,type:t,value:e.trim()};case"binary":return{code:r,type:t,value:MX(e)};default:return null}}function A5(r){var e=0,t=1,n,i=!1;function o(){if(!(e>=r.length)){for(var s=e;s<r.length;){var l=r.charCodeAt(s);if(l===10||l===13)break;s++}var c=r.slice(e,s);return s<r.length&&r.charCodeAt(s)===13&&s++,s<r.length&&r.charCodeAt(s)===10&&s++,e=s,t++,c}}function a(){for(;;){var s=o();if(s===void 0)return;var l=s.trim();if(l!==""){var c=o();if(c===void 0)return;var u=Number(l);if(Number.isFinite(u)&&u!==999){var h=kX(u,c);if(h)return h}}}}return{kind:"ascii",next:function(){if(i){var s=n;return n=void 0,i=!1,s}return a()},peek:function(){return i||(n=a(),i=!0),n},position:function(){return{line:t,byteOffset:e}}}}function AX(r){var e=BigInt(Number.MAX_SAFE_INTEGER),t=-e;return r>=t&&r<=e?Number(r):r}function yA(r,e){var t,n;e===void 0&&(e={});var i=(t=e.encoding)!==null&&t!==void 0?t:"utf-8",o=(n=e.legacyR12)!==null&&n!==void 0?n:!1,a=new TextDecoder(i),s=22,l=new DataView(r.buffer,r.byteOffset,r.byteLength),c=r.length>=s?s:r.length,u,h=!1;function d(){if(!(c>=r.length)){if(o){var w=r[c];if(w===void 0)return;if(w===255){if(c+3>r.length)return;c+=1;var _=r[c],P=r[c+1];return c+=2,P<<8|_}return c+=1,w}if(!(c+2>r.length)){var S=l.getUint16(c,!0);return c+=2,S}}}function f(){for(var w=c;c<r.length&&r[c]!==0;)c+=1;if(!(c>=r.length)){var _=r.subarray(w,c);return c+=1,a.decode(_)}}function p(){if(!(c+2>r.length)){var w=l.getInt16(c,!0);return c+=2,w}}function m(){if(!(c+4>r.length)){var w=l.getInt32(c,!0);return c+=4,w}}function g(){if(!(c+8>r.length)){var w=l.getBigInt64(c,!0);return c+=8,AX(w)}}function y(){if(!(c+8>r.length)){var w=l.getFloat64(c,!0);return c+=8,w}}function v(){if(!(c>=r.length)){var w=r[c];if(w!==void 0)return c+=1,w!==0}}function x(){if(!(c>=r.length)){var w=r[c];if(w!==void 0&&(c+=1,!(c+w>r.length))){var _=r.slice(c,c+w);return c+=w,_}}}function b(){for(;c<r.length;){var w=d();if(w===void 0)return;if(w===999){if(f()===void 0)return;continue}var _=dp(w);switch(_){case"string":{var P=f();return P===void 0?void 0:{code:w,type:"string",value:gA(P)}}case"int":{var S=v5(w)?m():p();return S===void 0?void 0:{code:w,type:"int",value:S}}case"long":{var S=g();return S===void 0?void 0:{code:w,type:"long",value:S}}case"double":{var S=y();return S===void 0?void 0:{code:w,type:"double",value:S}}case"bool":{var S=v();return S===void 0?void 0:{code:w,type:"bool",value:S}}case"handle":{var E=f();return E===void 0?void 0:{code:w,type:"handle",value:E}}case"binary":{var C=x();return C===void 0?void 0:{code:w,type:"binary",value:C}}case"comment":continue;default:f();continue}}}return{kind:"binary",next:function(){if(h){var w=u;return u=void 0,h=!1,w}return b()},peek:function(){return h||(u=b(),h=!0),u},position:function(){return{byteOffset:c}}}}function CX(r){for(var e=r.length,t=0;t<e;){var n=r[t];if(n<128){t++;continue}if(n<194)return!1;if(n<224){if(t+1>=e||(r[t+1]&192)!==128)return!1;t+=2;continue}if(n<240){if(t+2>=e)return!1;var i=r[t+1];if((i&192)!==128||n===224&&i<160||n===237&&i>=160||(r[t+2]&192)!==128)return!1;t+=3;continue}if(n<245){if(t+3>=e)return!1;var i=r[t+1];if((i&192)!==128||n===240&&i<144||n===244&&i>=144||(r[t+2]&192)!==128||(r[t+3]&192)!==128)return!1;t+=4;continue}return!1}return!0}function C5(r,e){var t;e===void 0&&(e={});var n=r instanceof Uint8Array?r:new Uint8Array(r),i=e.encoding?x5(e.encoding):void 0;if(E5(n)){var o=i,a=e.legacyR12;if(a==null){var s=22,l=n[s],c=n[s+1],u=n[s+2];l===0&&c===83?a=!0:a=!1}if(o==null){try{o=(t=oL(EX(n,a)))!==null&&t!==void 0?t:void 0}catch{}o=o??"utf-8"}return yA(n,{encoding:o,legacyR12:a})}if(i)return SE(n,i);if(CX(n))return iL(n);var h=null;try{var d=n.byteOffset===0&&n.byteLength===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);h=oL(k5(d))}catch{}return h?SE(n,h):iL(n)}var X0=function(){return X0=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},X0.apply(this,arguments)},Wh=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Zo;(function(r){r[r.Ok=0]="Ok",r[r.EndOfFile=1]="EndOfFile",r[r.EndOfObject=2]="EndOfObject",r[r.InvalidDxfCode=3]="InvalidDxfCode",r[r.BadDxfSequence=4]="BadDxfSequence",r[r.NotThatKindOfClass=5]="NotThatKindOfClass",r[r.WrongMode=6]="WrongMode"})(Zo||(Zo={}));var TX=(function(){for(var r=`AutoCAD Binary DXF\r
|
|
3
3
|
`,e=new Uint8Array(22),t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e[20]=26,e[21]=0,e})(),iy=(function(){function r(e){e===void 0&&(e={});var t,n;this._binaryLength=0,this._handseedValueLine=-1,this._pushed=[],this._status=Zo.Ok,this._errorMessage="",this._database=e.database,this._precision=Math.max(0,Math.min(16,(t=e.precision)!==null&&t!==void 0?t:16)),this._version=e.version instanceof Xi?e.version:e.version!=null?new Xi(e.version):void 0,this._outputFormat=(n=e.outputFormat)!==null&&n!==void 0?n:"ascii",this._lines=[],this._binaryChunks=[],this._handleMap=new Map,this._nextHandle=1,this._mode=e.reader?"read":"write",this._reader=e.reader,this._mode==="write"&&this._outputFormat==="binary"&&this.appendBinary(TX)}return r.forReading=function(e,t){return t===void 0&&(t={}),new r(X0(X0({},t),{reader:e}))},r.fromBuffer=function(e,t){return t===void 0&&(t={}),r.forReading(C5(e,{encoding:t.encoding}),t)},r.fromString=function(e,t){return t===void 0&&(t={}),r.forReading(A5(e),t)},Object.defineProperty(r.prototype,"mode",{get:function(){return this._mode},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"database",{get:function(){return this._database},set:function(e){this._database=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"precision",{get:function(){return this._precision},enumerable:!1,configurable:!0}),r.prototype.setPrecision=function(e){return this._precision=Math.max(0,Math.min(16,e)),this},Object.defineProperty(r.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"nextHandle",{get:function(){return this._nextHandle},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"filerStatus",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"errorMessage",{get:function(){return this._errorMessage},enumerable:!1,configurable:!0}),r.prototype.setVersion=function(e){return this._version=e instanceof Xi?e:new Xi(e),this},r.prototype.setError=function(e,t){return t===void 0&&(t=""),this._status=e,this._errorMessage=t,this},r.prototype.resetStatus=function(){return this._status=Zo.Ok,this._errorMessage="",this},r.prototype.toString=function(){if(this.assertWriteMode(),this._outputFormat==="binary")throw new Error("Use toBinary() for binary DXF output");return this._lines.join(`
|
|
4
4
|
`)+`
|
|
@@ -7817,4 +7817,4 @@ vBatchSlotId = slotId;`):e}function vF(r){if(r.includes("applyBatchHighlight(gl_
|
|
|
7817
7817
|
.${je}__group-body .${je}__item {
|
|
7818
7818
|
padding-left: 20px;
|
|
7819
7819
|
}
|
|
7820
|
-
`,document.head.appendChild(e)}class t3e{constructor(){this._center=new cE,this._defaultStore=this._center,this._showDefaultUi=!0,this._isCustom=!1}install(e,t={}){var n;this._docManager=e,this._host=t.host,this._showDefaultUi=t.showDefaultUi!==!1,this._placement=t.placement,t.enableBridge!==!1?((n=this._bridge)==null||n.uninstall(),this._bridge=new qOe(e,()=>this.center),this._bridge.install()):this._center.setActiveSession(e.activeSessionId),!this._isCustom&&this._showDefaultUi&&this.mountDefaultUi()}get placement(){return this._placement}setPlacement(e){var t;this._placement=e,(t=this._defaultUi)==null||t.setPlacement(e)}get center(){return this._center}get isCustom(){return this._isCustom}setCenter(e){var t,n;if(e==null){this.restoreDefault();return}this._center!==e&&(this.disposeDefaultUi(),this._isCustom?(n=(t=this._center).dispose)==null||n.call(t):this._defaultStore.dispose(),this._center=e,this._isCustom=!0,this._docManager&&this._center.setActiveSession(this._docManager.activeSessionId))}restoreDefault(){var e,t;if(!this._isCustom){this._showDefaultUi&&!this._defaultUi&&this.mountDefaultUi();return}(t=(e=this._center).dispose)==null||t.call(e),this._defaultStore=new cE,this._center=this._defaultStore,this._isCustom=!1,this._docManager&&this._center.setActiveSession(this._docManager.activeSessionId),this._showDefaultUi&&this.mountDefaultUi()}resolveHost(){var e,t;return this._host?this._host:((t=(e=this._docManager)==null?void 0:e.curView)==null?void 0:t.container)||document.body}mountDefaultUi(){this.disposeDefaultUi(),!(typeof document>"u")&&(this._defaultUi=new ZOe(this._center,this.resolveHost(),{placement:this._placement}))}disposeDefaultUi(){var e;(e=this._defaultUi)==null||e.dispose(),this._defaultUi=void 0}dispose(){var e,t,n;(e=this._bridge)==null||e.uninstall(),this._bridge=void 0,this.disposeDefaultUi(),(n=(t=this._center).dispose)==null||n.call(t),this._defaultStore=new cE,this._center=this._defaultStore,this._isCustom=!1,this._docManager=void 0,this._host=void 0,this._showDefaultUi=!0,this._placement=void 0}}const yG=new t3e;function n3e(r,e){yG.install(r,e)}function r3e(){yG.dispose()}function i3e(r){var e;const t=r.tables.blockTable,n=t.getAt(_n.PAPER_SPACE_NAME_PREFIX);if(n)return n.objectId;const i=(e=r.objects)==null?void 0:e.layout;if(!(i!=null&&i.newIterator))return;const o=t.modelSpace.objectId;let a;for(const s of i.newIterator()){const l=s.blockTableRecordId;if(!l||l===o)continue;const c=t.getIdAt(l);if(!(!c||!_n.isPaperSapceName(c.name))){if(s.tabSelected)return l;a||(a=l)}}return a}function o3e(r){const e=r.tables.blockTable.modelSpace.objectId;if(r.tilemode){r.currentSpaceId!==e&&(r.currentSpaceId=e);return}const t=i3e(r);t&&t!==r.currentSpaceId&&(r.currentSpaceId=t)}const a3e="https://cdn.jsdelivr.net/gh/mlightcad/cad-data",s3e="templates/acadiso.dxf",l3e={ARC:["A"],CIRCLE:["C"],ELLIPSE:["EL"],ERASE:["E"],DIMLINEAR:["DLI"],MEASUREDISTANCE:["DI","DIST"],MEASUREAREA:["AA","AREA"],MEASUREANGLE:["ANG"],"-HATCH":["-H"],IMAGEATTACH:["IAT"],"-INSERT":["I"],XATTACH:["XA"],LAYER:["LA"],"-LAYER":["-LA"],LINE:["L"],MLINE:["ML"],MTEXT:["T"],MOVE:["M"],OFFSET:["O"],COPY:["CO"],ROTATE:["RO"],OPEN:["OP"],PAN:["P"],POINT:["PO"],POLYGON:["POL"],PLINE:["PL"],RAY:["RA"],RECTANG:["REC"],REGEN:["RE"],SELECT:["SE"],SPLINE:["SPL"],XLINE:["XL"],ZOOM:["Z"],UNDO:["U"],REDO:["REDO"],READINGMODE:["RM"]},c3e="modern";class W{constructor(e={}){var t;this._sessions=[],this._nextSessionId=1,this._openFileProfiler=new dI,this._workersReady=null,this._nextOverlayId=1,this._presetFontsForOpenPromise=null,this._lastPresetFontsForOpen=[],this.events={documentToBeOpened:new Ft,documentCreated:new Ft,documentActivated:new Ft,documentToBeActivated:new Ft,documentToBeDestroyed:new Ft,documentDestroyed:new Ft,workersReady:new Ft},this._baseUrl=e.baseUrl??a3e,I1e(e.docsBaseUrl??xT),this._commandAliasOverrides=this.normalizeCommandAliasConfig(e.commandAliases),this._openDocumentDefaults=e.openDocumentDefaults,this._disableExport=e.disableExport===!0,e.useMainThreadDraw?bn.getInstance().setRenderMode("main"):bn.getInstance().setRenderMode("worker"),it.instance.setDefaultFonts(c3e),it.instance.lazyFontLoading=!0,it.instance.awaitFontsBeforeDraw=!0,bn.getInstance().setLazyFontLoading(!0),bn.getInstance().setAwaitFontsBeforeDraw(!0);const n=new lE,i=((t=e.container)==null?void 0:t.getBoundingClientRect())??{width:300,height:150},o=()=>{var u;if(e.autoResize){const h=e.container;if(h)return{width:Math.max(1,Math.floor(h.clientWidth)),height:Math.max(1,Math.floor(h.clientHeight))};const d=(u=e.container)==null?void 0:u.getBoundingClientRect();return{width:Math.max(1,Math.floor((d==null?void 0:d.width)??i.width)),height:Math.max(1,Math.floor((d==null?void 0:d.height)??i.height))}}else return{width:e.width??i.width,height:e.height??i.height}},a=new Ow({container:e.container,calculateSizeCallback:o});this._mainView=a;const s=new dE(a,n);this._activeSession=new aE(`doc-${this._nextSessionId++}`,s),this._sessions=[this._activeSession],Mb(this._activeSession.id),this._fontLoader=new iOe,it.instance.setFontLoader(this._fontLoader.fontLoader);const l=this.resolveFontsBaseUrl();this._fontLoader.baseUrl=l,it.instance.baseUrl=l,bn.getInstance().setFontUrl(l),this.installFontFileLoadTimeout(),$r().workingDatabase=n.database,this._commandManager=new Ga,this.registerCommands(),this._pluginManager=new QLe(this.context,this._commandManager),this._dataSourceManager=new SOe,this._dataSourceManager.register(new uOe),this._dataSourceManager.register(new MOe);const c=e.busyIndicatorHost??a.container;if(this._busyIndicatorHost=c,this._openFileProgress=new yOe(c),this._openFileProgress.setSceneBusyGate(()=>this.openProgressView.isProcessingEntities),this._openFileProgress.setOnHidden(()=>this.onOpenProgressHidden()),this._busyIndicator=new tOe(c),KPe({showMessage:(u,h,d)=>this.editor.showMessage(u,h,d),showBusyIndicator:u=>this.showBusyIndicator(u),hideBusyIndicator:()=>this.hideBusyIndicator(),withBusyIndicator:(u,h)=>this.withBusyIndicator(u,h)}),this.events.documentToBeOpened.addEventListener(()=>{this._openFileProgress.reset()}),this.bindOpenProgress(n),this.events.documentCreated.dispatch({doc:n,mode:n.openMode}),e.preloadDefaultFonts&&this.loadDefaultFonts(),this._webworkerFileUrls=e.webworkerFileUrls,this.registerWorkers(e.webworkerFileUrls),e.checkWorkersOnInit&&this.areWorkersReady(),this.loadPlugins(e.plugins).catch(u=>{Ht.error("[AcApDocManager] Error loading plugins:",u)}),fOe({enabled:e.builtinOpenFileDialog!==!1,getOpenDocumentDefaults:()=>this.resolveOpenDocumentDefaults()}),e.notificationCenter!==!1){const u=typeof e.notificationCenter=="object"?e.notificationCenter:{};n3e(this,{host:u.host,showDefaultUi:u.showDefaultUi!==!1,placement:u.placement,enableBridge:!0})}}static createInstance(e={}){return W._instance==null&&(W._instance=new W(e)),this._instance}static checkWebworkerReadiness(e){return QN(e)}static get instance(){if(!W._instance)throw new Error("AcApDocManager instance is not created yet!");return W._instance}static tryGetInstance(){return W._instance}async destroy(){var e,t;this._mainView.abortConversion(),(e=this._splitView)==null||e.abortConversion(),await this._pluginManager.unloadAllPlugins();for(const n of[...this._sessions])n.context.dispose(),n.doc.destroy(),n.viewState&&this.curView.disposeSessionState(n.viewState);this._sessions=[],(t=this._splitView)==null||t.dispose(),this._splitView=void 0,this._mainView.dispose(),mOe(),r3e(),bn.resetInstance(),xOe(),W._instance=void 0}get workersReady(){return this._workersReady}areWorkersReady(){return this._workersReady===!0?Promise.resolve(!0):(this._workersReadyCheckPromise||(this._workersReadyCheckPromise=QN(this._webworkerFileUrls).then(e=>(this._workersReady=e,this._workersReadyCheckPromise=void 0,this.events.workersReady.dispatch({ready:e}),e)).catch(()=>(this._workersReady=!1,this._workersReadyCheckPromise=void 0,this.events.workersReady.dispatch({ready:!1}),!1))),this._workersReadyCheckPromise)}get context(){return this._activeSession.context}get documents(){return this._sessions.map(e=>e.doc)}get documentCount(){return this._sessions.length}get activeSessionId(){return this._activeSession.id}document(e){var t;return(t=this._sessions[e])==null?void 0:t.doc}sessionFor(e){return this._sessions.find(t=>t.doc===e)}get curDocument(){return this.context.doc}get mdiActiveDocument(){return this._activeSession.doc}async activateDocument(e){const t=this.sessionFor(e);if(!t)return!1;if(t===this._activeSession)return!0;const n=t.context.view,i=this._activeSession.context.view;return this._openingSession&&n===i?!1:(await this._commandManager.cancelActive(),this.events.documentToBeActivated.dispatch({doc:e,mode:e.openMode}),n===i?(this.parkActiveSession(),this._activeSession=t,t.context.resume(),t.viewState&&(this.curView.restoreSessionState(t.viewState),t.viewState=void 0)):(this._activeSession!==this._openingSession&&this._activeSession.context.suspend(),this._activeSession=t,t.context.resume()),Mb(t.id),$r().workingDatabase=e.database,this._pluginManager.setContext(t.context),this.curView.bindDrawDatabase(e.database),this.setActiveLayout(),this.curView.syncDisplaySysVars(e.database),this.events.documentActivated.dispatch({doc:e,mode:e.openMode}),this._openingSession||this.syncProgressOverlayHost(),!0)}get mainView(){return this._mainView}get splitView(){return this._splitView}ensureSplitView(e){return this._splitView?this._splitView.container!==e&&e.appendChild(this._splitView.container):this._splitView=new Ow({container:e,calculateSizeCallback:()=>({width:Math.max(1,e.clientWidth),height:Math.max(1,e.clientHeight)})}),this._splitView}attachSatelliteView(e,t){return this.ensureSplitView(e),!0}detachSatelliteView(){}get satelliteDocument(){var e;if(this._splitView)return(e=this._sessions.find(t=>t.context.view===this._splitView))==null?void 0:e.doc}async closeDocument(e){const t=e??this.curDocument,n=this.sessionFor(t);if(!n)return!1;await this._commandManager.cancelActive(),this.events.documentToBeDestroyed.dispatch({doc:t,mode:t.openMode});const i=n===this._activeSession,o=this._sessions.indexOf(n);if(this._sessions.length===1)return this.resetActiveSessionToUntitled(n),this.events.documentDestroyed.dispatch({doc:t,mode:t.openMode}),this.events.documentCreated.dispatch({doc:this.curDocument,mode:this.curDocument.openMode}),this.events.documentActivated.dispatch({doc:this.curDocument,mode:this.curDocument.openMode}),!0;i&&this.parkActiveSession(),n.context.dispose(),t.destroy(),this.clearSessionOverlays(n),rB(n.id);const a=n.context.view;if(n.viewState?(a.disposeSessionState(n.viewState),n.viewState=void 0):a.clear(),this._sessions.splice(o,1),this.events.documentDestroyed.dispatch({doc:t,mode:t.openMode}),i){const s=this._sessions[Math.min(o,this._sessions.length-1)];await this.activateDocument(s.doc)}return!0}get curView(){return this.context.view}get editor(){return this.context.view.editor}get commandManager(){return this._commandManager}get pluginManager(){return this._pluginManager}get dataSourceManager(){return this._dataSourceManager}get drawStyleSessionAccessory(){return EAe(this._mainView)}get baseUrl(){return this._baseUrl}get disableExport(){return this._disableExport}resolveColors(){const e=this.curDocument.database,t=e.tables.layerTable.getAt(e.clayer),n=this.resolveColorToRgb(t==null?void 0:t.color);let i=e.cecolor;return i!=null&&i.isByLayer&&(i=t==null?void 0:t.color),{entityColor:this.resolveColorToRgb(i),layerColor:n}}resolveColorToRgb(e){return!e||e.isByLayer||e.isByBlock||e.isByACI&&e.colorIndex===7?this.resolveAci7ForBackground():e.RGB??this.resolveAci7ForBackground()}resolveAci7ForBackground(){return this.curView.backgroundColor===16777215?0:16777215}get avaiableFonts(){return this._fontLoader.avaiableFonts}async getAvaiableFonts(){try{return await this._fontLoader.getAvaiableFonts()}catch{return Vt.emit("failed-to-get-avaiable-fonts",{url:this._fontLoader.baseUrl}),[]}}async loadFonts(e){await this._fontLoader.load(e)}async loadDefaultFonts(e){e==null?await this._fontLoader.load([...it.instance.getFontsToLoad()]):await this._fontLoader.load(e)}ensurePresetFontsForOpen(){if(this._presetFontsForOpenPromise)return this._presetFontsForOpenPromise;const e=[...it.instance.getFontsToLoad()];if(this._lastPresetFontsForOpen=e,e.length===0)return this._presetFontsForOpenPromise=Promise.resolve(),this._presetFontsForOpenPromise;const t=bn.getInstance(),n=t.getRenderMode()==="worker"?"worker":"main",i=3e4,o=n==="worker"?t.loadFonts(e,{scope:"all"}).then(()=>{}):it.instance.requestFonts(e).then(()=>{});return this._presetFontsForOpenPromise=new Promise(a=>{const s=setTimeout(()=>{a()},i);o.then(()=>{clearTimeout(s),a()},()=>{clearTimeout(s),a()})}),this._presetFontsForOpenPromise}async awaitPresetFontsReady(){await this.ensurePresetFontsForOpen()}get lastPresetFontsForOpen(){return this._lastPresetFontsForOpen}async openUrl(e,t){t=this.setOptions(t);const n=await this.ensureOpenSession();this.beginOpenProgress(),this.onBeforeOpenDocument(t,!n);try{await this._openFileProgress.beginOpen(this.context.doc.database);const i=await this.context.doc.openUri(e,t);return this.onAfterOpenDocument(i,t),!i&&n&&await this.closeFailedOpenSession(),i}catch(i){throw this._openFileProfiler.cancel(),n&&await this.closeFailedOpenSession(),i}}async openDocument(e,t,n,i){n=this.setOptions(n);const o=await this.ensureOpenSession(i);this.beginOpenProgress(),this.onBeforeOpenDocument(n,!o);try{await this._openFileProgress.beginOpen(this.context.doc.database);const a=await this.context.doc.openDocument(e,t,n);return this.onAfterOpenDocument(a,n),!a&&o&&await this.closeFailedOpenSession(),a}catch(a){throw this._openFileProfiler.cancel(),o&&await this.closeFailedOpenSession(),a}}async loadOverlay(e,t,n={}){var i;const{targetView:o,...a}=n,s=new Uf,l=(i=e.split(".").pop())==null?void 0:i.toLocaleLowerCase();return await ZH(s,async()=>{await s.read(t,{readOnly:!0,...a},l==="dwg"?go.DWG:go.DXF)}),this.registerOverlayDatabase(s,{targetView:o})}async registerOverlayDatabase(e,t){const n=(t==null?void 0:t.targetView)??this.curView,i=await n.addOverlayEntities(e),o=`overlay-${this._nextOverlayId++}`;return(this._sessions.find(a=>a.context.view===n)??this._activeSession).overlays.set(o,{db:e,layout:i}),n.isDirty=!0,o}removeOverlay(e){for(const t of this._sessions){const n=t.overlays.get(e);if(n)return this.sessionCadScene(t).internalScene.remove(n.layout.internalObject),n.layout.clear(),t.overlays.delete(e),t.viewState||(t.context.view.isDirty=!0),!0}return!1}setOverlayVisible(e,t){for(const n of this._sessions){const i=n.overlays.get(e);if(i)return i.layout.visible=t,n.context.view.isDirty=!0,!0}return!1}clearOverlays(e){const t=e?this._sessions.filter(n=>n.context.view===e):this._sessions;for(const n of t)for(const i of[...n.overlays.keys()])this.removeOverlay(i)}getOverlayIds(e){if(!e)return Array.from(this._activeSession.overlays.keys());const t=this._sessions.find(n=>n.context.view===e);return t?Array.from(t.overlays.keys()):[]}get overlayIds(){return this.getOverlayIds()}setCompareDisplay(e,t){(t??this.curView).setCompareDisplay(e)}isReadingModeEnabled(e){return(e??this.curView).readingModeEnabled}setReadingMode(e,t){(t??this.curView).setReadingMode(e)}toggleReadingMode(e){(e??this.curView).toggleReadingMode()}setOverlayCompareDisplay(e,t,n){for(const i of this._sessions){const o=i.overlays.get(e);if(o)return(n??i.context.view??this.curView).setCompareDisplay(t,o.layout),!0}return!1}getOverlayLayout(e){for(const t of this._sessions){const n=t.overlays.get(e);if(n)return n.layout}}async newDocument(e){const t=`${this.baseUrl.endsWith("/")?this.baseUrl:`${this.baseUrl}/`}${s3e}`,n=this.setOptions({...e,mode:st.Write}),i=await this.ensureOpenSession();this.beginOpenProgress(),this.onBeforeOpenDocument(n,!i),await this._openFileProgress.beginOpen(this.context.doc.database);const o=await this.context.doc.openUri(t,n);return o&&this.context.doc.resetNewDocumentIdentity(),this.onAfterOpenDocument(o,n),!o&&i&&await this.closeFailedOpenSession(),o}setOpenDocumentDefaults(e){this._openDocumentDefaults=e,pOe({enabled:!0,getOpenDocumentDefaults:()=>this.resolveOpenDocumentDefaults()})}resolveOpenDocumentDefaults(){const e=this._openDocumentDefaults;return e==null?{minimumChunkSize:1e3}:typeof e=="function"?e():e}regen(){this.curView.clear(),this.context.doc.database.regen()}installFontFileLoadTimeout(){const e=it.instance.loader;if(!e||e.__cadFontLoadTimeout)return;const t=e.loadAsync.bind(e),n=3e4;e.loadAsync=i=>new Promise((o,a)=>{const s=setTimeout(()=>{a(new Error(`Font load timed out after ${n}ms`))},n);t(i).then(l=>{clearTimeout(s),o(l)},l=>{clearTimeout(s),a(l)})}),e.__cadFontLoadTimeout=!0}resolveFontsBaseUrl(){return`${this._baseUrl.endsWith("/")?this._baseUrl:`${this._baseUrl}/`}fonts/`}lookupLocalCmd(e){return this._commandManager.lookupLocalCmd(e,this.curDocument.openMode)}lookupGlobalCmd(e){return this._commandManager.lookupGlobalCmd(e,this.curDocument.openMode)}searchCommandsByPrefix(e){return this._commandManager.searchCommandsByPrefix(e,this.curDocument.openMode)}registerCommands(){const e=this._commandManager,t=(n,i,o)=>{const a=l3e[n.toUpperCase()]??[];e.addCommand(Ga.SYSTEMT_COMMAND_GROUP_NAME,n,i,o,this.resolveCommandAliases(n,a))};t("about","about",new zLe),t("arc","arc",new aCe),t("cachefont","cachefont",new Tw),t("circle","circle",new lCe),t("close","close",new HLe),this._disableExport||(t("bmpout","bmpout",new TAe),t("cdxf","cdxf",new LAe),t("jpgout","jpgout",new OAe),t("pngout","pngout",new DAe)),t("entout","entout",new FAe),t("ellipse","ellipse",new vCe),t("erase","erase",new ILe),t("hideobjects","hideobjects",new LLe),t("dimlinear","dimlinear",new uCe),KIe(t,{view:this._mainView,commandManager:this._commandManager}),t("-hatch","-hatch",new bCe),t("imageattach","imageattach",new kCe),t("-insert","-insert",new ICe),t("xattach","xattach",new KTe),t("-layer","-layer",new nCe),t("laycur","laycur",new VAe),t("laydel","laydel",new UAe),t("layfrz","layfrz",new GAe),t("layiso","layiso",new $Ae),t("laylck","laylck",new XAe),t("layon","layon",new YAe),t("layoff","layoff",new KAe),t("laythw","laythw",new JAe),t("layuniso","layuniso",new QAe),t("layulk","layulk",new eCe),t("layerp","layerp",new ZAe),t("layerclose","layerclose",new tCe),t("line","line",new tf),t("mline","mline",new OCe),t("mtext","mtext",new jCe),t("copy","copy",new TLe),t("move","move",new OLe),t("offset","offset",new Cw),t("rotate","rotate",new FLe),t("log","log",new ULe),t("open","open",new VLe),t("pan","pan",new JLe),t("point","point",new UCe),t("polygon","polygon",new XCe),t("pline","pline",new KCe),t("qnew","qnew",new GLe),t("ray","ray",new JCe),t("rectang","rectang",new sTe),t("regen","regen",new WLe),t("revcloud","revcloud",new TTe),CLe(t,{view:this._mainView,commandManager:this._commandManager}),t("select","select",new $Le),t("sketch","sketch",new FTe),t("spline","spline",new NTe),t("switchbg","switchbg",new YLe),t("readingmode","readingmode",new qLe),t("unisolateobjects","unisolateobjects",new BLe),t("xline","xline",new ZTe),t("undo","undo",new KLe),t("redo","redo",new ZLe),t("zoom","zoom",new cg),Lt.instance().getAllDescriptors().forEach(n=>{e.addCommand(Ga.SYSTEMT_COMMAND_GROUP_NAME,n.name,n.name,new XLe,this.resolveCommandAliases(n.name,[]))})}normalizeCommandAliasConfig(e){const t=new Map;return e&&Object.entries(e).forEach(([n,i])=>{const o=n.trim().toUpperCase();if(!o)return;const a=Array.isArray(i)?i:[i],s=new Set;a.forEach(l=>{const c=l.trim().toUpperCase();c&&c!==o&&s.add(c)}),t.set(o,[...s])}),t}resolveCommandAliases(e,t){const n=e.trim().toUpperCase(),i=this._commandAliasOverrides.get(n);if(i)return[...i];const o=new Set;return t.forEach(a=>{const s=a.trim().toUpperCase();s&&s!==n&&o.add(s)}),[...o]}sendStringToExecute(e){this.executeCommandString(e).catch(t=>{const n=t instanceof Error?t.message:String(t);this.editor.showMessage(n,"error"),Ht.error(`[AcApDocManager] Command failed: ${e}`,t)})}async executeCommandString(e){const t=this.splitCommandScript(e);if(!t.length)throw new Error("Command string is empty");const[n,...i]=t;this.editor.clearScriptInputs(),this.editor.enqueueScriptInputs(i),await this.executeNamedCommand(n,{preserveScriptInputs:!1})}async runScript(e){const t=JN(e);for(this.editor.clearScriptInputs(),this.editor.enqueueScriptInputs(t);this.editor.hasScriptInputs();){const n=this.consumeNextScriptCommandName();if(n==null)break;if(eOe(n)){this.editor.clearScriptInputs();break}await this.executeNamedCommand(n,{preserveScriptInputs:!0})}}async executeNamedCommand(e,t){const n=this.context.doc.openMode;let i=this._commandManager.lookupGlobalCmd(e)??this._commandManager.lookupLocalCmd(e,n);if(i||await this._pluginManager.loadByTrigger(e)&&(i=this._commandManager.lookupGlobalCmd(e)??this._commandManager.lookupLocalCmd(e,n)),!i)throw new Error(`Command '${e}' not found`);if(n<i.mode)throw new Error(`Command '${e}' requires mode '${st[i.mode]}' but document is in mode '${st[n]}'!`);await this._commandManager.cancelActive(),await this._commandManager.runActive(i,this.curView,async()=>{try{await i.trigger(this.context)}finally{t.preserveScriptInputs||this.editor.clearScriptInputs()}})}consumeNextScriptCommandName(){for(;this.editor.hasScriptInputs();){const e=this.editor.consumeScriptInput();if(e==null)return;const t=e.trim();if(t)return t}}splitCommandScript(e){const t=JN(e);if(!t.length)return[];let n=0;for(;n<t.length&&!t[n].trim();)n++;return n>=t.length?[]:[t[n].trim(),...t.slice(n+1)]}setActiveLayout(e,t){const n=e??this.curView,i=t??this.curDocument.database;n.activeLayoutBtrId=i.currentSpaceId,n.modelSpaceBtrId=i.tables.blockTable.modelSpace.objectId}onBeforeOpenDocument(e,t=!0){this.events.documentToBeOpened.dispatch({doc:this.context.doc,mode:this.getDocumentEventMode(e)}),t&&(uh.instance.clearAll(),this.clearOverlays(),hB(),gN(),cg.clearOriginalViews(),this.openProgressView.clear()),this.openProgressView.bindDrawDatabase(this.context.doc.database),this.openProgressView.progressiveRendering=(e==null?void 0:e.progressiveRendering)??!1,this._openFileProgress.setSeeThroughOverlay((e==null?void 0:e.progressiveRendering)??!1),this.openProgressView.convertInvisibleLayers=(e==null?void 0:e.convertInvisibleLayers)===!0,this.openProgressView.cooperativeYield=(e==null?void 0:e.cooperativeYield)!==!1;const n=this.openProgressView.cadScene;n&&(n.skipSpatialIndex=(e==null?void 0:e.skipSpatialIndex)===!0),this.ensurePresetFontsForOpen(),this._openFileProfiler.begin(this.context.doc.database)}onAfterOpenDocument(e,t){const n=!e&&this.hasRecoverablePartialContent();if(e||n){const i=this._openingSession??this._activeSession,o=i.context.view;i.doc.destroy();const a=i.doc,s=a.database;o3e(s),this.setActiveLayout(o,s),o.syncDisplaySysVars(s),this.events.documentActivated.dispatch({doc:a,mode:this.getDocumentEventMode(t)});const l=s.tables.blockTable.modelSpace.objectId,c=s.currentSpaceId!==l,u=$r().layoutManager.getActiveLayout(s),h=u==null?void 0:u.limits,d=this.resolveOpenViewMode(t);o.setOpenViewMode(d);const f=(t==null?void 0:t.progressiveRendering)??!1;let p=!1;const m=()=>{f&&o.beginProgressiveOpenFit(),o.zoomToFitDrawing(),o.requestOpenLineworkFrame()};if(c&&d===aa.Saved){const g=u==null?void 0:u.extents,y=Tk({limits:h,viewportsBox:mke(s,s.currentSpaceId),layoutExtents:g&&!g.isEmpty()?{min:{x:g.min.x,y:g.min.y},max:{x:g.max.x,y:g.max.y}}:void 0});y?(o.zoomTo(y.box),p=!0):m()}else if(!c&&d===aa.Saved){const g=o.width/Math.max(o.height,1),y=s.tables.viewportTable.getActiveVportBox(g);y?(o.zoomTo(y),p=!0):m()}else m();o.markLayoutAsInitialized(s.currentSpaceId),p&&cg.rememberOriginalView(o,s.currentSpaceId),t!=null&&t.convertAllLayouts&&o.ensureEntitiesConvertedForExport({includeInvisibleLayers:t.convertInvisibleLayers!==!1,includeLayouts:!0}).catch(g=>{Ht.error("[AcApDocManager] convertAllLayouts export convert failed",g)}),this._openFileProfiler.markReadCompleteAndScheduleReport(o)}else this._openFileProfiler.cancel(),this.openProgressView.endProgressiveOpenFit(),this.regen()}hasRecoverablePartialContent(){const e=(this._openingSession??this._activeSession).doc.database,t=e.tables.blockTable.modelSpace;return t?t.newIterator().count>0:!e.extents.isEmpty()}setOptions(e){return e==null?e={drawNoPlotLayers:!1,progressiveRendering:!1}:(this.stripObsoleteFontOpenOptions(e),this.stripDeprecatedWaitForTextGeometry(e),e.drawNoPlotLayers==null&&(e.drawNoPlotLayers=!1),e.progressiveRendering==null&&(e.progressiveRendering=!1)),e}stripDeprecatedWaitForTextGeometry(e){e.waitForTextGeometry!=null&&(delete e.waitForTextGeometry,console.warn("[AcApDocManager] Ignoring deprecated open option waitForTextGeometry; both stages of progressive rendering are controlled by progressiveRendering."))}stripObsoleteFontOpenOptions(e){const t=e,n=t.fontLoader!=null,i=t.failOnFontLoadError!=null;!n&&!i||(delete t.fontLoader,delete t.failOnFontLoadError,console.warn("[AcApDocManager] Ignoring obsolete open options "+[n?"fontLoader":null,i?"failOnFontLoadError":null].filter(Boolean).join(", ")+"; fonts load on demand via FontManager.lazyFontLoading."))}getDocumentEventMode(e){return(e==null?void 0:e.mode)??st.Read}resolveOpenViewMode(e){return(e==null?void 0:e.openViewMode)!=null?e.openViewMode:this.getDocumentEventMode(e)===st.Write?aa.Saved:aa.Extents}showBusyIndicator(e){this._busyIndicator.show(e)}setBusyIndicatorHost(e){this._busyIndicatorHost=e,this.syncProgressOverlayHost()}get openProgressView(){var e;return((e=this._openingSession)==null?void 0:e.context.view)??this.curView}beginOpenProgress(){this._openingSession=this._activeSession,this.syncProgressOverlayHost()}onOpenProgressHidden(){const e=this._openingSession;this._openingSession=void 0,e&&this._sessions.includes(e)&&e!==this._activeSession&&e.context.suspend(),this.syncProgressOverlayHost()}syncProgressOverlayHost(e=this.openProgressView){const t=this._splitView?e.container:this._busyIndicatorHost;this._openFileProgress.setHost(t),this._busyIndicator.setHost(t)}hideBusyIndicator(){this._busyIndicator.hide()}setBusyIndicatorMessage(e){this._busyIndicator.setMessage(e)}async withBusyIndicator(e,t){return this._busyIndicator.withBusyIndicator(e,t)}registerWorkers(e){const t=bn.getInstance();t.initialize((e==null?void 0:e.mtextRender)??pG.mtextRender),t.setDefaultFonts([...it.instance.defaultFonts])}async loadPlugins(e){if(e){if(e.fromConfig&&e.fromConfig.length>0)try{const t=await this._pluginManager.loadPluginsFromConfig(e.fromConfig,{continueOnError:!0});t.loaded.length>0&&Ht.info(`[AcApDocManager] Loaded ${t.loaded.length} plugin(s) from config:`,t.loaded),t.failed.length>0&&Ht.warn(`[AcApDocManager] Failed to load ${t.failed.length} plugin(s):`,t.failed.map(n=>`${n.name}: ${n.error.message}`))}catch(t){Ht.error("[AcApDocManager] Error loading plugins from config:",t)}if(e.fromFolder)try{const t=await this._pluginManager.loadPluginsFromFolder(e.fromFolder.folderPath,{pluginList:e.fromFolder.pluginList,continueOnError:e.fromFolder.continueOnError??!0});t.loaded.length>0&&Ht.info(`[AcApDocManager] Loaded ${t.loaded.length} plugin(s) from folder:`,t.loaded),t.failed.length>0&&Ht.warn(`[AcApDocManager] Failed to load ${t.failed.length} plugin(s) from folder:`,t.failed.map(n=>`${n.name}: ${n.error.message}`))}catch(t){Ht.error("[AcApDocManager] Error loading plugins from folder:",t)}}}bindOpenProgress(e){e.database.events.openProgress.addEventListener(t=>{if(this._openFileProgress.handle({database:e.database,percentage:t.percentage,stage:t.stage,subStage:t.subStage,subStageStatus:t.subStageStatus,data:t.data}),t.subStage==="STYLE"&&t.subStageStatus==="END"){const o=this._sessions.find(s=>s.doc===e),a=(o==null?void 0:o.context.view)??this.curView;a&&a.startTextStyleFontPreload(e.database)}if(t.subStage!=="HEADER")return;const n=this._sessions.find(o=>o.doc===e),i=(n==null?void 0:n.context.view)??this.curView;i.ltscale=e.database.ltscale,i.celtscale=e.database.celtscale,i.renderer.showLineWeight=e.database.lwdisplay})}parkActiveSession(){this._activeSession.context.suspend(),this._activeSession.viewState=this.curView.captureSessionState()}async ensureOpenSession(e){const t=e??this.curView;if(t===this.curView&&this.curDocument.isReusableUntitled)return!1;const n=this._sessions.find(s=>s.context.view===t);if(n!=null&&n.doc.isReusableUntitled)return n!==this._activeSession&&await this.activateDocument(n.doc),!1;await this._commandManager.cancelActive(),this._activeSession.context.suspend(),t===this.curView&&(this._activeSession.viewState=this.curView.beginNewSession());const i=new lE,o=new dE(t,i),a=new aE(`doc-${this._nextSessionId++}`,o);return this._sessions.push(a),this._activeSession=a,Mb(a.id),$r().workingDatabase=i.database,this._pluginManager.setContext(o),this.bindOpenProgress(i),this.events.documentCreated.dispatch({doc:i,mode:i.openMode}),!0}async closeFailedOpenSession(){this._sessions.length<=1||await this.closeDocument(this.curDocument)}resetActiveSessionToUntitled(e){const t=e.doc,n=e.id;uh.instance.clearAll(),this.clearOverlays(),hB(),gN(),this.curView.clear(),e.context.dispose(),t.destroy(),rB(n);const i=new lE,o=new dE(this.curView,i),a=new aE(`doc-${this._nextSessionId++}`,o);this._sessions=[a],this._activeSession=a,Mb(a.id),$r().workingDatabase=i.database,this._pluginManager.setContext(o),this.bindOpenProgress(i),this.curView.bindDrawDatabase(i.database)}clearSessionOverlays(e){const t=this.sessionCadScene(e);for(const n of e.overlays.values())t.internalScene.remove(n.layout.internalObject),n.layout.clear();e.overlays.clear()}sessionCadScene(e){var t;return((t=e.viewState)==null?void 0:t.scene)??e.context.view.cadScene}}const u3e=Object.freeze(Object.defineProperty({__proto__:null,AcApDocManager:W},Symbol.toStringTag,{value:"Module"}));class Nl{static isFontLoaded(e){return it.instance.isFontLoaded(e)}static getFontType(e){return it.instance.getFontType(e)}static getReplacementFontName(e){return it.instance.findAndReplaceFont(e)}static getShxCodePoints(e){var t;const n=it.instance.getFontByName(e,!1);if(!n||n.type!=="shx")return[];const i=n.data;return Object.keys(((t=i.content)==null?void 0:t.data)??{}).map(o=>Number(o)).filter(o=>Number.isFinite(o)).sort((o,a)=>o-a)}static getLoadedShxFontData(e){const t=it.instance.getFontByName(e,!1);if(!(!t||t.type!=="shx"))return t.data}static createShxParserFont(e){return new NC(e)}static findFontInfoByName(e){var t;const n=((t=W.instance)==null?void 0:t.avaiableFonts)??[],i=e.trim().toLowerCase();if(i)return n.find(o=>o.name.some(a=>a.trim().toLowerCase()===i))}static getCatalogFontType(e){var t;return(t=Nl.findFontInfoByName(e))==null?void 0:t.type}static async ensureDrawingFontLoaded(e){const t=W.instance;t&&(Nl.isFontLoaded(e)||await t.loadFonts([e]))}static async cacheFont(e,t,n,i){return it.instance.cacheFont(e,t,n,i)}static async getCachedMeshFontProgram(e){const t=[e],n=Nl.findFontInfoByName(e);n!=null&&n.file&&t.push(n.file);for(const a of(n==null?void 0:n.name)??[])t.push(a);const i=Nl.getReplacementFontName(e);if(i&&i!==e){t.push(i);const a=Nl.findFontInfoByName(i);a!=null&&a.file&&t.push(a.file);for(const s of(a==null?void 0:a.name)??[])t.push(s)}const o=new Set;for(const a of t){const s=a.trim().toLowerCase();if(!s||o.has(s))continue;o.add(s);const l=await it.instance.getCachedMeshFontProgram(a);if(l&&l.byteLength>0)return new Uint8Array(l)}}static async persistMeshFontProgram(e,t,n){await it.instance.persistMeshFontProgram(e,t,n)}}function h3e(r){const e=[];try{const t=r.tables.textStyleTable;if(e.push(...t.fonts??[]),t.newIterator)for(const n of t.newIterator()){const i=n.textStyle;i!=null&&i.font&&e.push(i.font),i!=null&&i.bigFont&&e.push(i.bigFont),i!=null&&i.extendedFont&&e.push(i.extendedFont)}}catch{return[]}return O0(e)}function d3e(r,e,t){const n=O0([...r]);n.length===0&&t!=null&&t.firstDefaultFont&&n.push(t.firstDefaultFont);const i=new Set(n.map($d)),o=new Set(e.map($d)),a=O0(e.filter(l=>!i.has($d(l))));let s=O0(n.filter(l=>o.has($d(l))));if(s.length===0&&t!=null&&t.firstDefaultFont){const l=$d(t.firstDefaultFont);l&&i.has(l)&&(s=[t.firstDefaultFont])}return s.length>3&&(s=s.slice(0,3)),{critical:n,workerWarm:s,background:a}}function O0(r){const e=new Set,t=[];for(const n of r){if(!n)continue;const i=$d(n);!i||e.has(i)||(e.add(i),t.push(n))}return t}function $d(r){if(r==null)return"";let e=String(r).trim();if(!e)return"";const t=e.lastIndexOf(".");return t>0&&(t===e.length-4||t===e.length-5)&&(e=e.substring(0,t)),e.toLowerCase()}const vG=13,f3e=14,p3e=1,m3e=.5,g3e=.5;let Dd;function y3e(){if(Dd!==void 0)return Dd;if(typeof document>"u")return Dd=null,null;try{Dd=document.createElement("canvas").getContext("2d")}catch{Dd=null}return Dd}function bG(r){return f3e/vG}function xG(r){return p3e/vG}function wG(r,e){return r>0?2*(bG()+xG())*r:0}function v3e(r,e,t){const n=wG(e);if(!(e>0))return n;const i=y3e();if(!i)return r.length*e*.6+n;const o="500",a="sans-serif";return i.font=`${o} ${e}px ${a}`,i.measureText(r).width+n}function b3e(r,e,t,n){if(!(e>0)||!(t>0))return e;const i=m3e,o=t*i,a=v3e(r,e);if(a<=o)return e;if(!(o>0))return 1;const s=Math.max(0,a-wG(e))/e,l=2*(bG()+xG()),c=s+l;return c>0?Math.max(1,o/c):e}function os(r,e,t,n){return e.textHeightMode==="custom"?e.fontSize:b3e(r,e.fontSize,t)}function Oh(r,e,t){const n=r(e),i=r(t);return Math.hypot(i.x-n.x,i.y-n.y)}function fI(r,e,t){return!(e>0)||!(t>0)||t>=e?r:Math.max(1,r*(t/e))}function _G(r,e,t,n){return Math.min(Oh(r,e,t),Oh(r,e,n))*g3e}function pI(r,e,t,n){if(!(t>0)||!(n>0))return 0;const i=r(e),o=r({x:e.x+t,y:e.y});return Math.hypot(o.x-i.x,o.y-i.y)/t*n}function x3e(r,e,t){const n=t.x-e.x,i=t.y-e.y,o=n*n+i*i;if(!(o>0))return Math.hypot(r.x-e.x,r.y-e.y);let a=((r.x-e.x)*n+(r.y-e.y)*i)/o;return a=Math.max(0,Math.min(1,a)),Math.hypot(r.x-(e.x+a*n),r.y-(e.y+a*i))}function SG(r,e){const t=e.length;if(t<3)return 0;let n=1/0;for(let l=0;l<t;l++){const c=e[l],u=e[(l+1)%t];n=Math.min(n,Oh(r,c,u))}let i=0,o=0;for(const l of e)i+=l.x,o+=l.y;i/=t,o/=t;const a=r({x:i,y:o});let s=1/0;for(let l=0;l<t;l++){const c=r(e[l]),u=r(e[(l+1)%t]);s=Math.min(s,x3e(a,c,u))}return Math.min(n,2*s)}const w3e=r=>new _t(r.min,r.max),_3e=r=>new Bt(r.min,r.max),S3e=r=>new Re(r.min,r.max),P3e=r=>new Bt(r.min,r.max),E3e=r=>new RC(r.min,r.max),M3e=r=>new Bt(r.min,r.max),k3e=r=>{const e=new Re;return e.min.set(r.min.x,r.min.y,0),e.max.set(r.max.x,r.max.y,0),e},l4={threeBo2dToGeBox2d:P3e,geBox2dToThreeBox2d:E3e,threeBox3dToGeBox3d:w3e,geBox3dToThreeBox3d:S3e,goBox3dToGeBox2d:_3e,threeBox3dToGeBox2d:M3e,geBox2dToThreeBox3d:k3e};function PG(r,e){if(!e||r.length<2)return r;let t=-1,n=-1;for(let a=0;a<r.length&&(r[a].ownerId===e?t<0&&(t=a):n<0&&(n=a),!(t>=0&&n>=0));a++);if(t<0||n<0||t<n)return r;const i=[],o=[];for(let a=0;a<r.length;a++){const s=r[a];s.ownerId===e?i.push(s):o.push(s)}return i.concat(o)}function A3e(r,e){return{pending:PG(r,e),cursor:0,activeOwnerId:e}}function C3e(r,e,t){if(e.length===0&&t===r.activeOwnerId)return r;const n=r.cursor===0?r.pending:r.pending.slice(r.cursor);if(t!==r.activeOwnerId)return{pending:PG(e.length>0?e.concat(n):n,t),cursor:0,activeOwnerId:t};let i=!1;const o=[],a=[];for(let s=0;s<e.length;s++)t&&e[s].ownerId===t?(i=!0,o.push(e[s])):a.push(e[s]);if(i)return{pending:o.concat(n,a),cursor:0,activeOwnerId:t};for(let s=0;s<a.length;s++)r.pending.push(a[s]);return r}function T3e(r){const{pending:e,cursor:t,activeOwnerId:n}=r;if(!n)return!1;for(let i=t;i<e.length;i++)if(e[i].ownerId===n)return!0;return!1}function I3e(r){const{tookMs:e,budgetMs:t,maxSlice:n,activeLayoutPending:i}=r,o=Math.max(1,r.slice),a=i?2:4;return e<t/2?Math.min(o*a,n):e>t*2?Math.max(1,o>>1):o}class L3e{constructor(e){this.getLayerInfo=e}shouldConvert(e){if(!e.visibility)return!1;const t=this.getLayerInfo(e.layer);return t?this.isBlockReference(e)?!t.isFrozen:rp.isLayerVisible(t):!0}shouldConvertForExport(e,t=!0){return e.visibility?t?!0:this.shouldConvert(e):!1}layerVisibilityMayHaveChanged(e){return e.isOff!==void 0||e.standardFlags!==void 0}collectMissingEntitiesOnLayer(e,t,n){return this.collectMissingEntities(t,n,i=>i.layer===e&&this.shouldConvert(i))}collectMissingEntitiesForExport(e,t,n=!0){return this.collectMissingEntities(e,t,i=>this.shouldConvertForExport(i,n))}isBlockReference(e){return e instanceof rr}collectMissingEntities(e,t,n){const i=[],o=e.newIterator();for(const a of o)n(a)&&(t(a.objectId)||i.push(a));return i}}var K_=(r=>(r[r.LEFT_BOTTOM=0]="LEFT_BOTTOM",r[r.LEFT_TOP=1]="LEFT_TOP",r[r.RIGHT_TOP=2]="RIGHT_TOP",r[r.RIGHT_BOTTOM=4]="RIGHT_BOTTOM",r))(K_||{});class O3e extends or{constructor(e,t,n=150,i=2){super(),this.camera=e,this.renderer=t,this.gizmoCamera=new uc(-2,2,2,-2,0,4),this.gizmoCamera.position.set(0,0,2),this.gizmoDim=n,this.gizmoPos=i,this.initialize()}initialize(){}update(){this.updateOrientation();const e=this.renderer.autoClear;this.renderer.autoClear=!1,this.renderer.clearDepth();const t=new Mn;this.renderer.getViewport(t);const n=this.calculateViewportPos();this.renderer.setViewport(n.x,n.y,this.gizmoDim,this.gizmoDim),this.renderer.render(this,this.gizmoCamera),this.renderer.setViewport(t.x,t.y,t.z,t.w),this.renderer.autoClear=e}dispose(){}updateOrientation(){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld()}calculatePosInViewport(e,t,n){const i=(e-n.min.x)/this.gizmoDim*2-1,o=-((t-n.min.y)/this.gizmoDim)*2+1;return{x:i,y:o}}calculateViewportPos(){const e=this.renderer.domElement,t=e.offsetWidth,n=e.offsetHeight,i=this.gizmoPos,o=this.gizmoDim;let a=t-o,s=n-o;switch(i){case 0:a=0,s=0;break;case 1:a=0;break;case 4:s=0;break}return{x:a,y:s}}calculateViewportBbox(){const e=this.renderer.domElement,t=e.offsetWidth,n=e.offsetHeight,i=this.gizmoPos,o=this.gizmoDim,a=new RC(new Ae(t-o,0),new Ae(t,o));switch(i){case 0:a.set(new Ae(0,n-o),new Ae(o,n));break;case 1:a.set(new Ae(0,0),new Ae(o,o));break;case 4:a.set(new Ae(t-o,n-o),new Ae(t,n));break}return a}}function D3e(r,e){const t=e.font||"Helvetica",n=e.fontSize||30,i=e.width||200,o=e.height||200,a=e.bgColor?e.bgColor.join(", "):"255, 255, 255, 1.0",s=e.color?e.color.join(", "):"0, 0, 0, 1.0",l=document.createElement("canvas");l.width=i,l.height=o;const c=l.getContext("2d");if(c){c.font=`bold ${n}px ${t}`,c.fillStyle=`rgba(${a})`,c.fillRect(0,0,i,o);const h=c.measureText(r).width;c.fillStyle=`rgba(${s})`,c.fillText(r,i/2-h/2,o/2+n/2-2)}const u=new Kr(l);return u.minFilter=vr,u.needsUpdate=!0,u}function uE(r){const e=D3e(r,{fontSize:100,font:"Arial Narrow, sans-serif",color:[255,255,255,1],bgColor:[0,0,0,0]}),t=new aj({map:e,transparent:!0});return new Zoe(t)}K_.RIGHT_TOP;const R3e={pos:K_.LEFT_BOTTOM,size:100,hasZAxis:!0};class F3e extends O3e{constructor(e,t,n){const i={...R3e,...n};super(e,t,i.size,n.pos),this.hasZAxis=i.hasZAxis;const o=[0,0,0,2,0,0,0,0,0,0,2,0],a=[1,0,0,1,.6,0,0,1,0,.6,1,0];this.hasZAxis&&(o.push(0,0,0,0,0,2),a.push(0,0,1,0,.6,1));const s=new dt;s.setAttribute("position",new xn(o,3)),s.setAttribute("color",new xn(a,3));const l=new ns({vertexColors:!0,toneMapped:!1});this.axes=new kr(s,l),this.axes.position.set(-1,-1,-1),this.add(this.axes),this.xText=uE("X"),this.xText.position.set(1.5,-1,-1),this.add(this.xText),this.yText=uE("Y"),this.yText.position.set(-1,1.5,-1),this.add(this.yText),this.hasZAxis&&(this.zText=uE("Z"),this.zText.position.set(-1,-1,1.5),this.add(this.zText))}setLineColors(e,t){const n=new Qe,i=this.axes.geometry.attributes.color.array;return n.set(e),n.toArray(i,0),n.toArray(i,3),n.set(t),n.toArray(i,6),n.toArray(i,9),this.axes.geometry.attributes.color.needsUpdate=!0,this}setTextColor(e){this.xText.material.color=e,this.yText.material.color=e}dispose(){var e,t;this.axes.geometry.dispose(),this.axes.material.dispose(),this.xText.geometry.dispose(),this.xText.material.dispose(),this.yText.geometry.dispose(),this.yText.material.dispose(),this.hasZAxis&&((e=this.zText)==null||e.geometry.dispose(),(t=this.zText)==null||t.material.dispose())}}class B3e extends g9{constructor(e,t,n,i){super(e,n,i),this._layoutBtrId=t,this._mode=ga.SELECTION,this._axesGizmo=this.createAxesGizmo(),this._viewportViews=new Map,this._overlayViewport=new q_e(e)}get layoutBtrId(){return this._layoutBtrId}get mode(){return this._mode}set mode(e){e==ga.SELECTION?this._cameraControls.mouseButtons={MIDDLE:Yl.PAN}:e==ga.PAN&&(this._cameraControls.mouseButtons={LEFT:Yl.PAN}),this._cameraControls.update(),this._mode=e}get viewportCount(){return this._viewportViews.size}get viewportViews(){return this._viewportViews.values()}get overlayViewport(){return this._overlayViewport}get internalCamera(){return this._camera.internalCamera}get viewportsBoundingBox(){if(this._viewportViews.size===0)return;const e=new Bt;return this._viewportViews.forEach(t=>{const n=t.viewport.box;e.expandByPoint(n.min),e.expandByPoint(n.max)}),e.isEmpty()?void 0:e}addViewport(e){this._viewportViews.set(e.viewport.id,e)}removeViewport(e){this._viewportViews.delete(e)}resize(e,t){this._height=t,this._width=e,this._frustum=t/2,this.updateCameraFrustum(),this._viewportViews.forEach(n=>{n.update()})}render(e){var t;this._renderer.clear();const n=this._renderer.render(e.internalScene,this._camera),i=e.modelSpaceLayout;return i&&this.drawViewports(i.internalObject),this.drawOverlay(e),(t=this._axesGizmo)==null||t.update(),n}createAxesGizmo(){return new F3e(this._camera.internalCamera,this._renderer.internalRenderer,{hasZAxis:!1,pos:K_.LEFT_BOTTOM})}drawViewports(e){if(this._viewportViews.size>0){const t=this._renderer.autoClear;this._renderer.autoClear=!1;const n=new Mn;this._renderer.getViewport(n),this._renderer.clearDepth();const i=e.visible;e.visible=!0,this._viewportViews.forEach(o=>{o.render(e)}),e.visible=i,this._renderer.setViewport(n.x,n.y,n.z,n.w),this._renderer.autoClear=t}}drawOverlay(e){const t=this._overlayViewport;if(!t.visible)return;t.render(e.internalScene,this._height);const n=e.modelSpaceLayout;!n||this._viewportViews.size===0||this.drawOverlayViewports(n.internalObject,t)}drawOverlayViewports(e,t){const n=t.screenRect,i=t.viewBox,o=e.visible;e.visible=!0,this._viewportViews.forEach(a=>{const s=Y_e(a.viewport.box,i,n),l=y9(s,n);if(!l)return;const c=v9(l,i,n),u=new Bt;u.expandByPoint(a.paperPointToModel({x:c.minX,y:c.minY})),u.expandByPoint(a.paperPointToModel({x:c.maxX,y:c.minY})),u.expandByPoint(a.paperPointToModel({x:c.maxX,y:c.maxY})),u.expandByPoint(a.paperPointToModel({x:c.minX,y:c.maxY})),!u.isEmpty()&&a.withFrozenLayersHidden(e,()=>{t.renderNested(e,u,l,l,this._height,a.viewport.viewTwistAngle)})}),e.visible=o}}class hE{constructor(){this._activeLayoutBtrId="",this._layoutViews=new Map}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(e){this._activeLayoutBtrId=e,this._layoutViews.forEach(t=>{t.enabled=t.layoutBtrId==e})}get activeLayoutView(){return this._layoutViews.get(this._activeLayoutBtrId)}has(e){return this._layoutViews.has(e)}getAt(e){return this._layoutViews.get(e)}resize(e,t){this._layoutViews.forEach(n=>{n.resize(e,t)})}add(e){this._layoutViews.set(e.layoutBtrId,e)}render(e){var t;return((t=this.activeLayoutView)==null?void 0:t.render(e))??!1}}function N3e(r,e){return[...r].sort((t,n)=>z3e(t,n,e))}function z3e(r,e,t){const n=c4(r)-c4(e);if(Math.abs(n)>Number.EPSILON)return n;const i=u4(t,r)-u4(t,e);return Math.abs(i)>Number.EPSILON?i:0}function c4(r){return Math.max(r.maxX-r.minX,0)*Math.max(r.maxY-r.minY,0)}function u4(r,e){const t=r.x<e.minX?e.minX-r.x:r.x>e.maxX?r.x-e.maxX:0,n=r.y<e.minY?e.minY-r.y:r.y>e.maxY?r.y-e.maxY:0;return t*t+n*n}const D0=class Vm{constructor(e){this.zoomTo=e,this.active=!1,this.userAdjusted=!1,this.programmaticDepth=0,this.incrementalEnabled=!1,this.initialPendingCount=0,this.convertedCount=0,this.lastZoomAt=0}get isActive(){return this.active}begin(e){if(this.active){this.initialPendingCount=Math.max(this.initialPendingCount,e),this.maybeEnableIncrementalFit();return}this.active=!0,this.userAdjusted=!1,this.lastZoomAt=0,this.initialPendingCount=e,this.convertedCount=0,this.lastFittedBox=void 0,this.incrementalEnabled=!1,this.maybeEnableIncrementalFit()}end(){this.active=!1,this.incrementalEnabled=!1,this.lastFittedBox=void 0,this.convertedCount=0}applyFinalFit(e){if(this.userAdjusted)return;const t=e();t&&this.applyZoom(t)}frameProgrammatically(e){this.userAdjusted||this.applyZoom(e)}onLayoutViewChanged(){!this.active||this.userAdjusted||this.programmaticDepth>0||(this.userAdjusted=!0,this.end())}afterGeometryBatch(e,t){this.active&&(this.convertedCount++,this.maybeEnableIncrementalFit(),this.maybeIncrementalFit(e))}maybeEnableIncrementalFit(){this.incrementalEnabled||(this.initialPendingCount>=Vm.SMALL_ENTITY_THRESHOLD||this.convertedCount>=Vm.SMALL_ENTITY_THRESHOLD)&&(this.incrementalEnabled=!0)}maybeIncrementalFit(e){if(!this.active||!this.incrementalEnabled||this.userAdjusted)return;const t=performance.now();if(t-this.lastZoomAt<Vm.FIT_INTERVAL_MS)return;const n=e();!n||!this.shouldApplyIncrementalFit(n)||(this.lastZoomAt=t,this.applyZoom(n))}shouldApplyIncrementalFit(e){const t=this.lastFittedBox;if(!t)return!0;const n=this.estimateBoxArea(t);return n<=Number.EPSILON?!0:this.estimateBoxArea(e)>=n*Vm.BBOX_GROWTH_RATIO}applyZoom(e,t=1.1){this.programmaticDepth++;try{this.zoomTo(e,t),this.lastFittedBox=this.snapshotFitBox(e)}finally{this.programmaticDepth--}}estimateBoxArea(e){const t=new vn;return e.getSize(t),Math.abs(t.x)*Math.abs(t.y)}snapshotFitBox(e){return new Bt({x:e.min.x,y:e.min.y},{x:e.max.x,y:e.max.y})}};D0.SMALL_ENTITY_THRESHOLD=500,D0.BBOX_GROWTH_RATIO=1.5,D0.FIT_INTERVAL_MS=2500;let j3e=D0;const U3e=1e3;function V3e(r,e,t){return r||e>0?!1:t==null?!0:t>=U3e}const h4={background:fu},Il=class ni extends K2e{constructor(e=h4){const t={...h4,...e},n=t.container??document.createElement("div");t.container=n,n.style.overflow="hidden",n.hasAttribute("tabindex")||(n.tabIndex=-1);const i=new Qhe({antialias:!0,alpha:!0});n.appendChild(i.domElement),i.domElement.style.display="block",i.domElement.style.maxWidth="100%",i.domElement.style.maxHeight="100%";const o=fMe(i.domElement,n);super(i.domElement,n),this._rafId=null,this._loadingLayouts=new Set,this._initializedLayouts=new Set,this._externallyFramedLayouts=new Set,this._openViewMode=aa.Extents,this._convertingLayers=new Set,this._claimedConvertObjectIds=new Set,this._entityConvertGeneration=new Map,this._progressiveRendering=!1,this._convertInvisibleLayers=!1,this._cooperativeYield=!0,this._convertQueue=[],this._viewportRepairOwnerIds=new Set,this._convertDrainPromise=null,this._convertEpoch=0,this._lastProgressivePaintAt=0,this._progressivePaintUrgent=!1,this._progressiveInputPauseUntil=0,this._progressivePaintCount=0,this._progressiveYieldCount=0,this._openLineworkFramePending=!1,this._openLineworkFrameTimer=null,this._pendingGeometryJobs=0,this._deferredGeometryQueue=[],this._deferredGeometryActive=0,this._fontLoadedRedrawTimer=null,this._fontLoadedRedrawEpoch=0,this._entityProcessingIdleAt=0,this._textStyleFontPreloadEpoch=-1,this._textStyleFontPreloadPromise=null,this._viewDomAbort=new AbortController,this._viewDisposed=!1,this._readingMode=new D1e({getCurrentBackgroundColor:()=>this._renderer.currentBackgroundColor,applyViewClearColor:E=>this.applyViewClearColor(E),setCompareDisplay:E=>this.setCompareDisplay(E),markDirty:()=>{this._isDirty=!0}}),this._deferredFontsReady=null,this._convertPhaseMs={finishGeometry:0,finishGeometryAsyncDraw:0,finishGeometryQueueWait:0,handleGroup:0,addEntity:0,awaitFonts:0,glyphEntityCount:0,mtextCount:0,shapeCount:0,sharedGlyphDrawCount:0},this._fontPreloadDiag=null,this.animate=()=>{var E;this._rafId=requestAnimationFrame(this.animate),this.events.renderFrame.dispatch({render:this._renderer,camera:this.internalCamera});const C=this._numOfEntitiesToProcess>0,k=C||this._pendingGeometryJobs>0,T=!this._progressiveRendering&&!this._cooperativeYield&&k;if(!this._isDirty&&!this._htmlDirty&&!k||T||!this._isDirty&&!this._htmlDirty)return;const O=this.shouldCountMidOpenPaint(C,k);if(this._isDirty&&!this._progressivePaintUrgent&&O){const F=this._progressiveRendering?ni.PROGRESSIVE_OPEN_PAINT_INTERVAL_MS:ni.NON_PROGRESSIVE_OPEN_PAINT_INTERVAL_MS;if(performance.now()-this._lastProgressivePaintAt<F)return}let I=!1;this._isDirty&&(O&&(this._progressivePaintCount++,this._lastProgressivePaintAt=performance.now(),this._progressivePaintUrgent=!1),I=this._layoutViewManager.render(this._scene)),this.internalCamera&&(this._isDirty||this._htmlDirty)&&this._css2dRenderer.render(this._scene.internalScene,this.internalCamera),(E=this._stats)==null||E.update(),this._isDirty=I,this._htmlDirty=!1},this._meshGlyphFlushTimer=null,this._disposeCanvasTouchCallout=o;const a=()=>this.noteProgressiveUserInput(),s=()=>{a(),this.focusViewerForShortcuts()},l=()=>{a(),this.focusViewerForShortcuts()};i.domElement.addEventListener("pointerdown",s,{capture:!0}),i.domElement.addEventListener("wheel",l,{capture:!0,passive:!0}),this._disposeProgressiveInputWatch=()=>{i.domElement.removeEventListener("pointerdown",s,{capture:!0}),i.domElement.removeEventListener("wheel",l,{capture:!0})},this._gripManager=new HEe(this),this._keyHandler=new kPe(this),e.calculateSizeCallback&&this.setCalculateSizeCallback(e.calculateSizeCallback),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.setSize(this.width,this.height),this._renderer=new U_e(i),Hxe(()=>this._renderer.allocateDrawOrderZ());const c=Kn.instance.fontMapping;this._renderer.setFontMapping(c),this._onFontNotFound=E=>{Vt.emit("font-not-found",{fontName:E.fontName,count:E.count??0})},this._onFontLoaded=E=>{Vt.emit("missed-data-changed",{}),this.scheduleGlyphRedrawAfterFontLoad(E==null?void 0:E.fontName)},this._renderer.events.fontNotFound.addEventListener(this._onFontNotFound),this._renderer.events.fontLoaded.addEventListener(this._onFontLoaded),this._scene=this.createScene(),this._layerAppearance=new RB(this._scene,this._renderer),this._inheritedLayerMaterialMapper=new CPe(E=>this._layerAppearance.getEffectiveLayerTraits(E),this._renderer),this.backgroundColor=t.background??fu,this._stats=this.createStats(Kn.instance.isShowStats&&(W.tryGetInstance()==null||this.isActiveManagedView()));const u=Lt.instance(),h=ae.MODELBKCOLOR.toLowerCase(),d=ae.PAPERBKCOLOR.toLowerCase();this._onSysVarChanged=E=>{const C=E.name.toLowerCase();if(C===h||C===d){const k=E.database;if(!k)return;const T=this.isModelSpaceLayout(k);if(!(C===h&&T||C===d&&!T))return;this.applyCanvasBackground(FP(k,T))}},u.events.sysVarChanged.addEventListener(this._onSysVarChanged),this._onSettingsModified=E=>{E.key=="isShowStats"&&this.toggleStatsVisibility(this._stats,E.value)},Kn.instance.events.modified.addEventListener(this._onSettingsModified);let f=null,p=null,m=null;const g=()=>!this.editor.isActive&&!Sf.getActiveInputBox()&&!nke()&&!this._gripManager.isDragging,y=()=>this.mode===ga.SELECTION&&g(),v=()=>g()&&co().canIdleTouchBox(this.mode),x=()=>{m==null||m.remove(),m=null},b=()=>{f=null,p=null,x()},w=(E,C)=>{p=this.viewportToCanvas({x:E,y:C}),f=this.screenToWorld(p),x(),m=document.createElement("div"),m.className="ml-jig-preview-rect",this.container.appendChild(m)},_=(E,C,k="replace")=>{if(!f||!m||!p)return;const T=this.viewportToCanvas({x:E,y:C}),O=this.screenToWorld(T),I=this.worldToScreen(f),F=this.worldToScreen(O),N=Math.min(I.x,F.x),Y=Math.min(I.y,F.y),U=Math.abs(I.x-F.x),$=Math.abs(I.y-F.y),J=this.getSelectionMode(p,T),G=this.getSelectionPreviewStyle(J,k);Object.assign(m.style,{left:`${N}px`,top:`${Y}px`,width:`${U}px`,height:`${$}px`,borderStyle:G.borderStyle,background:G.background}),m.style.setProperty("--line-color",G.lineColor)},P=(E,C,k,T)=>{if(!f||!p)return;const O=this.viewportToCanvas({x:E,y:C}),I=this.screenToWorld(O);if(x(),T)if(XSe(this,O.x,O.y,k))k==="replace"&&this.selectionSet.clear();else if(this.entitySelectionEnabled){const F=this.pick(I);F.length>0?(k==="replace"&&this.htmlTransientManager.deselectAll(),this.applySelection([F[0].id],k)):k==="replace"&&this.selectionSet.clear()}else k==="replace"&&this.selectionSet.clear();else{const F=new Bt().expandByPoint(f).expandByPoint(I),N=this.getSelectionMode(p,O);this.entitySelectionEnabled&&this.selectByBoxWithMode(F,N,k),YSe(this,F,N,k)}f=null,p=null},S=this._viewDomAbort.signal;this.canvas.addEventListener("mousedown",E=>{E.button===0&&y()&&(Ya(E)||fo()||w(E.clientX,E.clientY))},{signal:S}),this.canvas.addEventListener("mousemove",E=>{!f||!m||!p||Ya(E)||fo()||_(E.clientX,E.clientY,this.getPointerSelectionAction(E))},{signal:S}),this.canvas.addEventListener("mouseup",E=>{if(this._gripManager.isDragging){b();return}if(!f||!p||Ya(E)||fo())return;const C=this.viewportToCanvas({x:E.clientX,y:E.clientY}),k=this.getPointerSelectionAction(E);P(E.clientX,E.clientY,k,this.isSelectionClick(p,C))},{signal:S}),this._disposeMobileBoxGesture=Mk({element:this.canvas,shouldStart:()=>v(),setNavigationEnabled:E=>{this.setNavigationEnabled(E)},onActivate:(E,C)=>{w(E,C),_(E,C)},onMove:(E,C)=>{_(E,C)},onBoxEnd:(E,C,k)=>{P(E,C,"replace",!k)},onTap:(E,C)=>{p=this.viewportToCanvas({x:E,y:C}),f=this.screenToWorld(p),P(E,C,"replace",!0)},onAbort:()=>{b()}}),this.canvas.addEventListener("dblclick",E=>{E.button===0&&y()&&this.entitySelectionEnabled&&W.instance.curDocument.openMode===st.Write&&this.openPickedEntityEditor(E)},{signal:S}),document.addEventListener("keydown",E=>{this.isActiveManagedView()&&this.isShortcutEventInsideViewer(E)&&this._keyHandler.handleKeyDown(E)},{signal:S}),this._onLayoutSwitched=E=>{var C,k;if(!this.isActiveManagedView())return;const T=E.layout.database,O=(k=(C=W._instance)==null?void 0:C.curDocument)==null?void 0:k.database;if(T&&O&&T!==O)return;const I=E.layout.blockTableRecordId,F=!this._initializedLayouts.has(I);this._initializedLayouts.add(I),this.activeLayoutBtrId=I,this.createLayoutViewIfNeeded(I),this.loadLayoutEntitiesIfNeeded(I),this.refreshCanvasBackgroundForActiveLayout(),this._isDirty=!0,F&&this.applyInitialZoom(I,E.layout)},$r().layoutManager.events.layoutSwitched.addEventListener(this._onLayoutSwitched),this._css2dRenderer=new E0e,this._css2dRenderer.setSize(this.width,this.height),this._css2dRenderer.domElement.style.position="absolute",this._css2dRenderer.domElement.style.top="0px",this._css2dRenderer.domElement.style.left="0px",this._css2dRenderer.domElement.style.pointerEvents="none",this._css2dRenderer.domElement.style.zIndex=String(eEe),this._css2dRenderer.domElement.style.maxWidth="100%",this._css2dRenderer.domElement.style.maxHeight="100%",n.appendChild(this._css2dRenderer.domElement),this._missedImages=new Map,this._layoutViewManager=new hE,this._progressiveOpenFit=new j3e((E,C)=>{this.activeLayoutView.zoomTo(E,C??1.1),this._isDirty=!0}),this._entityDisplay=new L3e(E=>this.resolveLayerInfo(E)),this.initialize(),this.onWindowResize(),this._isDirty=!0,this._htmlDirty=!1,this.startAnimationLoop(),this._numOfEntitiesToProcess=0,this.resetDeferredGeometryQueue()}ensureDeferredFontsReady(){if(!this._deferredFontsReady){const e=performance.now(),t=Promise.all([this.awaitPresetFontsReadySafe(),this.awaitTextStyleFontsReady()]).then(()=>{},()=>{});this._deferredFontsReady=t.then(()=>{this._convertPhaseMs.awaitFonts+=performance.now()-e})}return this._deferredFontsReady}async awaitPresetFontsReadySafe(){const e=W;e._instance&&await e._instance.awaitPresetFontsReady()}takeConvertPhaseTimings(){const e={...this._convertPhaseMs,fontPreload:this._fontPreloadDiag?{...this._fontPreloadDiag}:void 0};return this._convertPhaseMs={finishGeometry:0,finishGeometryAsyncDraw:0,finishGeometryQueueWait:0,handleGroup:0,addEntity:0,awaitFonts:0,glyphEntityCount:0,mtextCount:0,shapeCount:0,sharedGlyphDrawCount:0},this._fontPreloadDiag=null,e}getPointerSelectionAction(e){return q2e(e)}initialize(){this.setCursor(Oy.Crosshair),this._onCommandWillStartHitTest=()=>{this.htmlTransientManager.setHitTestEnabled(!1)},this._onCommandEndedHitTest=()=>{this.htmlTransientManager.setHitTestEnabled(!0)},this.editor.events.commandWillStart.addEventListener(this._onCommandWillStartHitTest),this.editor.events.commandEnded.addEventListener(this._onCommandEndedHitTest)}get mode(){const e=this.activeLayoutView;return e?e.mode:ga.SELECTION}set mode(e){this.activeLayoutView.mode=e}setNavigationEnabled(e){const t=this.activeLayoutView;t&&(t.enabled=e)}setSnapLoupe(e){var t;const n=(t=this.activeLayoutView)==null?void 0:t.overlayViewport;if(n){if(!e){n.visible=!1,this._isDirty=!0;return}n.setScreenRect(e.x,e.y,e.size,e.size),n.setViewBox(e.viewBox),n.visible=!0,this._isDirty=!0}}get renderer(){return this._renderer}get gripManager(){return this._gripManager}get isDirty(){return this._isDirty}get isProcessingEntities(){return this._numOfEntitiesToProcess>0||this._pendingGeometryJobs>0}get isConvertingEntities(){return this._numOfEntitiesToProcess>0}async waitUntilIdle(e=6e4){const t=Date.now()+Math.max(0,e);let n=0;for(;;){if(this.isProcessingEntities)n=0;else if(n++,n>=2)return!0;if(Date.now()>t)return!this.isProcessingEntities;await new Promise(i=>setTimeout(i,16))}}get progressiveRendering(){return this._progressiveRendering}set progressiveRendering(e){this._progressiveRendering=e,this.resetProgressiveOpenStats()}get convertInvisibleLayers(){return this._convertInvisibleLayers}set convertInvisibleLayers(e){this._convertInvisibleLayers=e}get cooperativeYield(){return this._cooperativeYield}set cooperativeYield(e){this._cooperativeYield=e}get progressiveOpenStats(){return{paintCount:this._progressivePaintCount,yieldCount:this._progressiveYieldCount}}resetProgressiveOpenStats(){this._progressivePaintCount=0,this._progressiveYieldCount=0,this._lastProgressivePaintAt=0,this._progressivePaintUrgent=!1,this._progressiveInputPauseUntil=0}isProgressiveGesturePauseActive(){return performance.now()<this._progressiveInputPauseUntil}isProgressiveDiscreteInputPending(){var e;const t=navigator.scheduling;return((e=t==null?void 0:t.isInputPending)==null?void 0:e.call(t))===!0}noteProgressiveUserInput(){!this._progressiveRendering||this._numOfEntitiesToProcess<=0||(this._progressivePaintUrgent=!0,this._isDirty=!0,this._progressiveInputPauseUntil=performance.now()+ni.PROGRESSIVE_INPUT_PAUSE_MS)}async progressiveYieldForInput(e,t){if(this.isProgressiveGesturePauseActive()){for(await t();performance.now()<this._progressiveInputPauseUntil;)await new Promise(n=>setTimeout(n,16));this._progressiveYieldCount++;return}if(this.isProgressiveDiscreteInputPending()){await t(),this._progressiveYieldCount++;return}e&&await e.maybeYield(t)&&this._progressiveYieldCount++}beginProgressiveOpenFit(){this._progressiveOpenFit.begin(this._numOfEntitiesToProcess)}endProgressiveOpenFit(){this._progressiveOpenFit.end()}set isDirty(e){this._isDirty=e}get isHtmlDirty(){return this._htmlDirty}set isHtmlDirty(e){this._htmlDirty=e}get missedData(){return{fonts:this._renderer.missedFonts,images:this._missedImages,xrefs:this.collectUnresolvedXrefs()}}collectUnresolvedXrefs(){var e,t;try{const n=(t=(e=W.instance)==null?void 0:e.curDocument)==null?void 0:t.database;if(!n)return[];const i=n.tables.blockTable;return typeof i.getUnresolvedXrefs!="function"?[]:i.getUnresolvedXrefs().map(o=>({name:o.name,pathName:o.pathName,isOverlay:o.isOverlayReference}))}catch{return[]}}get center(){return this.activeLayoutView.center}set center(e){this.activeLayoutView.center=e}get backgroundColor(){return this._renderer.getClearColor()}set backgroundColor(e){this.applyCanvasBackground(e)}applyCanvasBackground(e){if(this._renderer.currentBackgroundColor=e,this._layerAppearance.refreshTextMaterialsInObjectTree(this._scene.internalScene),this._scene.repaintForegroundMaterials($l(e)),this._scene.repaintBackgroundMaterials(e),this.resyncForegroundLayersForBackground(),this._readingMode.isEnabled){this._readingMode.noteLayoutBackground(e),this.applyViewClearColor(M9);return}this.applyViewClearColor(e)}applyViewClearColor(e){this._renderer.setClearColor(e),this.editor.syncCursorBackground(e),this._isDirty=!0}resyncForegroundLayersForBackground(){var e;const t=this._renderer.context.database;if(t)for(const n of t.tables.layerTable.newIterator())(e=n.color)!=null&&e.isForeground&&this._layerAppearance.syncFromLiveRecord(n)}isModelSpaceLayout(e){return e?_Pe(e):this.activeLayoutBtrId===this.modelSpaceBtrId}bindDrawDatabase(e){this._renderer.context.database=e}syncDisplaySysVars(e){this.bindDrawDatabase(e),this.applyCanvasBackground(FP(e,this.isModelSpaceLayout(e))),this._readingMode.reapplyIfEnabled()}get readingModeEnabled(){return this._readingMode.isEnabled}toggleReadingMode(){this._readingMode.toggle()}setReadingMode(e){this._readingMode.setEnabled(e)}async addOverlayEntities(e){const t=new g7;t.isReference=!0,t.internalObject.userData.isReference=!0,this._scene.internalScene.add(t.internalObject);for(const i of e.tables.layerTable.newIterator())t.addLayer({name:i.name,isOff:i.isOff,isFrozen:i.isFrozen,color:i.color});const n=this._renderer.context.database;this._renderer.context.database=e;try{const i=e.tables.blockTable.modelSpace;for(const o of i.newIterator())if(!(o instanceof Va))try{const a=this.drawEntity(o,!1);if(!a)continue;a.objectId=o.objectId,a.ownerId=o.ownerId,a.layerName=o.layer,a.visible=o.visibility!==!1,a instanceof Rn&&a.isOnTheSameLayer&&(a.userData.insertLayerName=a.layerName),await this.finishEntityGeometry(a,!1),a instanceof Rn&&a.isOnTheSameLayer&&this._inheritedLayerMaterialMapper.remap(a.children,"0",a.layerName),t.addEntity(a),a.dispose()}catch(a){Ht.error(`[AcTrView2d] Failed to convert overlay entity ${o.objectId} (${o.type}):`,a)}}finally{this._renderer.context.database=n}return t}refreshCanvasBackgroundForActiveLayout(){var e,t;const n=(t=(e=W._instance)==null?void 0:e.curDocument)==null?void 0:t.database;if(!n)return;const i=this.activeLayoutBtrId===this.modelSpaceBtrId;this.applyCanvasBackground(FP(n,i))}get modelSpaceBtrId(){return this._scene.modelSpaceBtrId}set modelSpaceBtrId(e){this._scene.modelSpaceBtrId=e}get activeLayoutBtrId(){return this._scene.activeLayoutBtrId}set activeLayoutBtrId(e){const t=this._scene.activeLayoutBtrId;this._layoutViewManager.activeLayoutBtrId=e,this._scene.activeLayoutBtrId=e,this.htmlTransientManager.setActiveLayoutId(e),this._isDirty=!0,t!==e&&LSe()}get activeLayoutView(){return this._layoutViewManager.activeLayoutView}get stats(){return this._scene.stats}get cadScene(){return this._scene}async ensureEntitiesConvertedForExport(e){var t;const n=(e==null?void 0:e.includeInvisibleLayers)!==!1,i=(e==null?void 0:e.includeLayouts)!==!1,o=W.instance.curDocument.database,a=[];await this.drainConvertQueue();const s=(t=o.objects)==null?void 0:t.layout;if(i&&s!=null&&s.newIterator)for(const l of s.newIterator()){const c=l.blockTableRecordId;c&&this._scene.addEmptyLayout(c)}for(const[l]of this._scene.layouts){if(!i&&l!==this._scene.modelSpaceBtrId)continue;const c=o.tables.blockTable.getIdAt(l);c&&a.push(...this._entityDisplay.collectMissingEntitiesForExport(c,u=>this.isEntityConvertScheduled(u),n))}a.length>0&&(this._numOfEntitiesToProcess+=a.length,await this.batchConvert(a,{forExport:!0})),await this.waitUntilIdle(12e4)||Ht.warn("[AcTrView2d] Timed out waiting for deferred geometry before export"),this.flushMeshGlyphWorldBatch()}get internalScene(){return this._scene.internalScene}get htmlTransientManager(){return this._scene.htmlTransientManager}get internalCamera(){var e;return(e=this.activeLayoutView)==null?void 0:e.internalCamera}set ltscale(e){this._renderer.ltscale=e}set celtscale(e){this._renderer.celtscale=e}screenToWorld(e){const t=this.activeLayoutView;return t?t.screenToWorld(e):new re(e)}worldToScreen(e){const t=this.activeLayoutView;return t?t.worldToScreen(e):new re(e)}zoomTo(e,t=1.1){this.activeLayoutView.zoomTo(e,t),this._isDirty=!0}rerenderPoints(e,t=0){const n=this._scene.activeLayout;n&&(n.rerenderPoints(e,t),this._isDirty=!0)}requestOpenLineworkFrame(){this._openLineworkFramePending=!0,this.scheduleOpenLineworkFrame()}cancelOpenLineworkFrame(){this._openLineworkFramePending=!1,this._openLineworkFrameTimer!=null&&(clearTimeout(this._openLineworkFrameTimer),this._openLineworkFrameTimer=null)}scheduleOpenLineworkFrame(){if(this._openLineworkFrameTimer!=null||!this._openLineworkFramePending)return;const e=this.isConvertingEntities?50:0;this._openLineworkFrameTimer=setTimeout(()=>{if(this._openLineworkFrameTimer=null,!!this._openLineworkFramePending){if(this.isConvertingEntities){this.scheduleOpenLineworkFrame();return}this.frameOpenLineworkIfReady()}},e)}zoomToFitDrawing(e=0,t){new UP(()=>!this.isProcessingEntities,()=>{if(t&&this._externallyFramedLayouts.delete(t)){this.endProgressiveOpenFit();return}this._progressiveOpenFit.applyFinalFit(()=>this.getDrawingExtents()),this.endProgressiveOpenFit();const n=t??this.activeLayoutBtrId;n&&cg.rememberOriginalView(this,n)},300,e).start()}zoomToFitLayer(e){const t=this._scene.activeLayout;if(t){const n=t.getLayer(e);if(n&&!n.box.isEmpty()){const i=l4.threeBox3dToGeBox2d(n.box);return this.zoomTo(i),this._isDirty=!0,!0}}return!1}zoomToSmartExtents(e=0){return new Promise((t,n)=>{new UP(()=>!this.isProcessingEntities,()=>{(async()=>{try{const i=await this.resolveSmartFitBox();if(i){this.zoomTo(i),this._isDirty=!0,this.endProgressiveOpenFit(),t();return}this._progressiveOpenFit.applyFinalFit(()=>this.getDrawingExtents()),this.endProgressiveOpenFit(),t()}catch(i){this.endProgressiveOpenFit(),n(i)}})()},300,e).start()})}async resolveSmartFitBox(){const e=this._scene.activeLayout;if(!e)return;const t=e.cachedSmartExtents;if(t)return t;const n=e.smartExtentsGeneration,i=new u7,o=await e.collectSpatialExtentBoxesAsync(i),a=await TPe(o,i);return e.smartExtentsGeneration!==n?e.cachedSmartExtents:(a&&(e.cachedSmartExtents=a),a)}flyTo(e,t){this.activeLayoutView.flyTo(e,t),this._isDirty=!0}async openPickedEntityEditor(e){const t=this.viewportToCanvas({x:e.clientX,y:e.clientY}),n=this.screenToWorld(t),i=this.pick(n,void 0,!0);if(!i.length)return;const o=W.instance.curDocument.database.tables.blockTable.getEntityById(i[0].id);if(!o)return;const a=this.resolveAttributedBlockReference(o);if(a){e.preventDefault(),this.selectionSet.clear(),this.selectionSet.add(a.objectId),W.instance.sendStringToExecute("attedit");return}if(o instanceof oc){e.preventDefault(),await this.editMTextEntity(o);return}o instanceof vh&&(e.preventDefault(),await this.editTextEntity(o))}resolveAttributedBlockReference(e){if(e instanceof rr)return e.attributeIterator().count>0?e:void 0;if(e instanceof bh||e.type==="Attrib"||e.type==="Attribute"){const t=W.instance.curDocument.database.tables.blockTable.getEntityById(e.ownerId);if(t instanceof rr&&t.attributeIterator().count>0)return t}}async editMTextEntity(e){const t=e.database;this.setEntitySceneVisible(e.objectId,!1),this._isDirty=!0;const n=e.resolveAnnotativePresentation,i=typeof n=="function"?n.call(e):null,o=(i==null?void 0:i.position)??e.location,a={x:o.x,y:o.y,z:o.z??0},s=(i==null?void 0:i.direction)??e.direction,l=(i==null?void 0:i.attachmentPoint)??e.attachmentPoint,c=i&&Number.isFinite(i.width)&&i.width>0?i.width:this.resolveMTextEditorWidth(e),u=i&&Number.isFinite(i.height)&&i.height>0?i.height:this.resolveMTextEditorTextHeight(e),h=new Sf;let d=!1;try{const f=await h.open({view:this,location:a,width:c,textHeight:u,initialText:e.contents,initialAttachmentPoint:l,initialDrawingDirection:e.drawingDirection,rotation:e.rotation,directionVector:{x:s.x,y:s.y,z:s.z},textStyleName:e.styleName,initialLineSpaceFactor:e.lineSpacingFactor,toolbarFontFamilies:await this.getMTextToolbarFontFamilies()});if(!f)return;Ch(t,"Edit MText",()=>{const p=t.openEntityForWrite(e);p instanceof oc&&(p.location=f.location,p.contents=f.contents,p.width=f.width,p.height=f.height,p.lineSpacingFactor=f.lineSpacingFactor,p.attachmentPoint=f.attachmentPoint)}),d=!0}finally{this.setEntitySceneVisible(e.objectId,!0),d||this.updateEntity(e),this._isDirty=!0}}async editTextEntity(e){const t=e.database;this.setEntitySceneVisible(e.objectId,!1),this._isDirty=!0;const n=Number(e.height),i=Number.isFinite(n)&&n>0?n:this.pixelsToWorldY(24),o=e.textString??"",a=Math.max(i*Math.max(o.length,1)*.6,i),s=Number(e.rotation),l=new Sf;let c=!1;try{const u=await l.open({view:this,location:e.position,width:a,textHeight:i,initialText:o,initialAttachmentPoint:Tt.BaselineLeft,...Number.isFinite(s)?{rotation:s}:{},toolbarFontFamilies:await this.getMTextToolbarFontFamilies()});if(!u)return;Ch(t,"Edit Text",()=>{const h=t.openEntityForWrite(e);h instanceof vh&&(h.position=new D(u.location),h.textString=u.contents,Number.isFinite(u.height)&&u.height>0&&(h.height=u.height))}),c=!0}finally{this.setEntitySceneVisible(e.objectId,!0),c||this.updateEntity(e),this._isDirty=!0}}resolveMTextEditorWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0?t:0}resolveMTextEditorTextHeight(e){const t=Number(e.height);return Number.isFinite(t)&&t>0?t:this.pixelsToWorldY(24)}pixelsToWorldY(e){const t=this.screenToWorld({x:0,y:0}),n=this.screenToWorld({x:0,y:e});return Math.max(Math.abs(n.y-t.y),1e-4)}async getMTextToolbarFontFamilies(){const e=await W.instance.getAvaiableFonts()??[];return Array.from(new Set(e.flatMap(t=>t.name).map(t=>t.trim()).filter(t=>t.length>0)))}pick(e,t,n){e==null&&(e=this.curPos);const i=[],o=this._scene.activeLayout;if(!o)return i;const a=this.activeLayoutView,s=t??this.selectionBoxSize,l=a.pointToBox(e,s),c=Math.max(l.size.width/2,l.size.height/2),u=a.layoutBtrId!==this._scene.modelSpaceBtrId,h=(l.size.width+l.size.height)/2,d=[],f=new Set;if(u)for(const b of a.viewportViews)b.containsPaperPoint(e)&&!b.isNearPaperBorder(e,h)&&(d.push(b),f.add(b.viewport.id));const p=this._scene.search(l),m=a.resetRaycaster(e,c),g=bn.getInstance(),y=new Set;p.forEach(b=>{if(f.has(b.id))return;const w=g.intersectMeshGlyphObjectId(b.id,m);!vw(b)&&!w||(o.isIntersectWith(b.id,m)||w)&&(i.push(b),y.add(b.id))});const v=g.queryMeshGlyphObjectIdsIntersectingBox({minX:l.min.x,minY:l.min.y,maxX:l.max.x,maxY:l.max.y});for(const b of v){if(y.has(b)||f.has(b)||!g.intersectMeshGlyphObjectId(b,m))continue;const w=g.getMeshGlyphWorldPickBoxes().get(b);i.push({id:b,minX:(w==null?void 0:w.min.x)??l.min.x,minY:(w==null?void 0:w.min.y)??l.min.y,maxX:(w==null?void 0:w.max.x)??l.max.x,maxY:(w==null?void 0:w.max.y)??l.max.y}),y.add(b)}d.length>0&&this.pickThroughViewports(e,l,d,i);const x=N3e(i,e);return n?x.slice(0,1):x}getViewportCoordinateMapper(e){var t;let n;for(const i of((t=this.activeLayoutView)==null?void 0:t.viewportViews)??[])if(i.viewport.id===e){n=i;break}if(n)return{paperToModel:i=>n.paperPointToModel(i),modelToPaper:i=>n.modelPointToPaper(i),containsPaperPoint:i=>n.containsPaperPoint(i)}}pickThroughViewports(e,t,n,i){const o=this._scene.modelSpaceLayout;if(!o)return;const a=(t.size.width+t.size.height)/4;for(const s of n){const l=s.paperPointToModel(e),c=a*s.paperToModelScale;if(c<=0)continue;const u=new Bt().setFromPoints([new re(l.x-c,l.y-c),new re(l.x+c,l.y+c)]),h=s.resetRaycaster(l,c);o.search(u).forEach(d=>{vw(d)&&o.isIntersectWith(d.id,h)&&i.push({...d,viewportId:s.viewport.id})})}}search(e,t){return this._scene.search(e,t)}select(e){const t=[];this.pick(e).forEach(i=>t.push(i.id));const n=this.selectableIds(t,"add");n.length>0&&this.selectionSet.add(n)}selectByBox(e){this.selectByBoxWithMode(e,"crossing","add")}refineCrossingSelectionHits(e,t){var n;const i=(n=W.instance.curDocument)==null?void 0:n.database;if(!i)return t.map(a=>a.id);const o=[];for(const a of t){if(!eke(a)){o.push(a.id);continue}const s=new Bt({x:a.minX,y:a.minY},{x:a.maxX,y:a.maxY});if(e.containsBox(s)){o.push(a.id);continue}const l=i.tables.blockTable.getEntityById(a.id);(!l||Q2e(l,e))&&o.push(a.id)}return o}addLayer(e){this._scene.addLayer(this.toLayerInfo(e)),this._layerAppearance.syncFromLiveRecord(e),this._isDirty=!0}updateLayer(e,t){const{touchedObjectIds:n}=this._scene.updateLayer(this.toLayerInfo(e));if(this._layerAppearance.layerStyleMayHaveChanged(t)&&this._layerAppearance.syncFromLiveRecord(e),this._entityDisplay.layerVisibilityMayHaveChanged(t)){const i=this.toLayerInfo(e);(rp.isLayerVisible(i)||!i.isFrozen)&&this.convertMissingEntitiesOnLayer(e.name)}for(const i of n)this.applySessionHiddenObjectState(i);this._isDirty=!0}addTransientEntity(e){const t=Array.isArray(e)?e:[e],n=this._convertEpoch,i=this._renderer.forceShowLineWeight;this._renderer.forceShowLineWeight=!0;try{for(let o=0;o<t.length;++o){const a=t[o],s=this.drawEntity(a,!0);s&&(s.objectId=a.objectId,s.userData.skipMeshGlyphInstancing=!0,s.asyncDraw().then(()=>{if(n!==this._convertEpoch){s.dispose();return}this._scene.addTransientEntity(s),this._isDirty=!0}).catch(l=>{Ht.error("[AcTrView2d] Transient entity geometry failed:",l),s.dispose()}))}}finally{this._renderer.forceShowLineWeight=i}}removeTransientEntity(e){this._scene.removeTransientEntity(e),this._isDirty=!0}setTransientEntityVisible(e,t){this._scene.setTransientEntityVisible(e,t)&&(this._isDirty=!0)}canCreateEntityPreview(e){return this._scene.canCreatePreview(e)}createEntityPreview(e){const t=this._scene.createPreview(e);return t&&(this._isDirty=!0),t}updateEntityPreview(e,t){this._scene.updatePreview(e,tw.createMatrix4(t))&&(this._isDirty=!0)}removeEntityPreview(e){this._scene.removePreview(e)&&(this._isDirty=!0)}updateTransientPreviewTransforms(e){const t=this._scene.updateTransientPreviewTransforms(e.map(n=>({objectId:n.objectId,matrix:tw.createMatrix4(n.matrix)})));t.webgl&&(this._isDirty=!0),t.html&&(this._htmlDirty=!0)}addEntity(e){var t;const n=Array.isArray(e)?e:[e];for(let i=0;i<n.length;i++){const o=(t=n[i])==null?void 0:t.ownerId;if(!o)continue;let a=this._scene.layouts.get(o);a||(this._scene.addEmptyLayout(o),a=this._scene.layouts.get(o)),a&&!a.isLoaded&&(a.isLoaded=!0)}this._numOfEntitiesToProcess+=n.length,this._convertQueue.push(...n),this.drainConvertQueue()}removeEntity(e){(Array.isArray(e)?e:[e]).forEach(t=>this._scene.removeEntity(t.objectId)),this._isDirty=!0}hasEntity(e){return this._scene.hasEntity(e)}isEntityConvertScheduled(e){const t=String(e??"");return t?this.hasEntity(e)||this._claimedConvertObjectIds.has(t):!1}getEntityVisible(e){return this._scene.getEntityVisible(e)}updateEntityVisibility(e){return this._scene.setEntityVisible(e.objectId,e.visibility)?(this._isDirty=!0,!0):!1}setEntitySceneVisible(e,t){return this._scene.setEntityVisible(e,t)?(this._isDirty=!0,!0):!1}applySessionHiddenObjectState(e){W.instance.curDocument.isObjectHidden(e)&&this._scene.setEntityVisible(e,!1)}updateEntity(e){const t=this.resolveSceneUpdateEntities(Array.isArray(e)?e:[e]);if(t.length===0)return;const n=t.map(i=>i.objectId).filter(i=>this.selectionSet.has(i));for(let i=0;i<t.length;++i){const o=t[i],a=String(o.objectId??"");a&&(this._entityConvertGeneration.set(a,(this._entityConvertGeneration.get(a)??0)+1),this._claimedConvertObjectIds.delete(a),bn.getInstance().removeMeshGlyphInstances(a)),this._scene.hasEntity(o.objectId)&&this._scene.removeEntity(o.objectId)}(async()=>(await this.batchConvert(t),await this.waitUntilDeferredGeometryIdle(),n.length>0&&this.highlight(n),this._gripManager.refresh(),this._isDirty=!0))(),this._isDirty=!0,setTimeout(()=>{this._isDirty=!0},100)}resolveSceneUpdateEntities(e){var t;const n=(t=W.instance.curDocument)==null?void 0:t.database,i=[],o=new Set;for(const a of e){let s=a;if(a instanceof bh){const l=n==null?void 0:n.tables.blockTable.getEntityById(a.ownerId);if(!(l instanceof rr))continue;s=l}o.has(s.objectId)||(o.add(s.objectId),i.push(s))}return i}addLayout(e){this._scene.addEmptyLayout(e.blockTableRecordId),this.createLayoutViewIfNeeded(e.blockTableRecordId),this._isDirty=!0}markLayoutAsInitialized(e){this._initializedLayouts.add(e),this._externallyFramedLayouts.add(e)}setOpenViewMode(e){this._openViewMode=e}isLayoutInitialized(e){return this._initializedLayouts.has(e)}getDrawingExtents(){const e=this._scene.box;if(e&&!e.isEmpty())return l4.threeBox3dToGeBox2d(e)}applyInitialZoom(e,t){new UP(()=>!this.isProcessingEntities,()=>{if(this._externallyFramedLayouts.delete(e))return;const n=this.resolveFirstVisitFrameBox(e,t);n&&this.zoomTo(n),this._isDirty=!0,cg.rememberOriginalView(this,e)},300,0).start()}resolveFirstVisitFrameBox(e,t){var n,i;const o=e===this.modelSpaceBtrId,a=this._openViewMode===aa.Saved;if(a&&o){const d=W.instance.curDocument.database,f=this.width/Math.max(this.height,1),p=d.tables.viewportTable.getActiveVportBox(f);if(p)return p}const s=this._layoutViewManager.getAt(e),l=t.extents,c=l&&!l.isEmpty()?{min:{x:l.min.x,y:l.min.y},max:{x:l.max.x,y:l.max.y}}:void 0,u=this.getDrawingExtents(),h=s==null?void 0:s.viewportsBoundingBox;return a&&!o?(n=Tk({limits:t.limits,viewportsBox:h,layoutExtents:c,entityBox:u}))==null?void 0:n.box:(i=Tk({limits:void 0,viewportsBox:o?void 0:h,layoutExtents:c,entityBox:u}))==null?void 0:i.box}abortConversion(){this._convertEpoch++,this.clearFontLoadedRedrawTimer(),this.clearMeshGlyphFlushTimer(),this._convertQueue.length=0,this._viewportRepairOwnerIds.clear(),this._numOfEntitiesToProcess=0,this._claimedConvertObjectIds.clear(),this._entityConvertGeneration.clear(),this.cancelOpenLineworkFrame(),this.resetDeferredGeometryQueue(),this._entityProcessingIdleAt=0}clear(){this.abortConversion(),this._scene.clear(),bn.getInstance().resetMeshGlyphBatch(),this._renderer.resetDrawOrderZ(),this._isDirty=!0,this._missedImages.clear(),this._initializedLayouts.clear(),this._externallyFramedLayouts.clear(),this._openViewMode=aa.Extents,this._loadingLayouts.clear(),this._renderer.dispose(),Io.instance.clear(),Vt.emit("missed-data-changed",{})}captureSessionState(){return this.clearMeshGlyphFlushTimer(),{scene:this._scene,layoutViewManager:this._layoutViewManager,initializedLayouts:this._initializedLayouts,externallyFramedLayouts:this._externallyFramedLayouts,openViewMode:this._openViewMode,loadingLayouts:this._loadingLayouts,missedImages:this._missedImages,missedFonts:this._renderer.snapshotMissedFonts(),selectionIds:this.selectionSet.ids,meshGlyphBatch:bn.getInstance().detachMeshGlyphBatch()}}restoreSessionState(e){this._convertEpoch++,this.clearFontLoadedRedrawTimer(),this.clearMeshGlyphFlushTimer(),this.cancelOpenLineworkFrame(),this._convertQueue.length=0,this._viewportRepairOwnerIds.clear(),this._numOfEntitiesToProcess=0,this._claimedConvertObjectIds.clear(),this._entityConvertGeneration.clear(),this.resetDeferredGeometryQueue(),this._entityProcessingIdleAt=0,this._scene=e.scene,this._layoutViewManager=e.layoutViewManager,this._initializedLayouts=e.initializedLayouts,this._externallyFramedLayouts=e.externallyFramedLayouts,this._openViewMode=e.openViewMode??aa.Extents,this._loadingLayouts=e.loadingLayouts,this._missedImages=e.missedImages,this._renderer.replaceMissedFonts(e.missedFonts??{}),bn.getInstance().attachMeshGlyphBatch(e.meshGlyphBatch),this.rebindLayerAppearance(),this._layoutViewManager.resize(this.width,this.height),this.selectionSet.clear(),e.selectionIds.length>0&&this.selectionSet.add(e.selectionIds),this._isDirty=!0,Vt.emit("missed-data-changed",{})}beginNewSession(){const e=this.captureSessionState();return this._convertEpoch++,this.clearFontLoadedRedrawTimer(),this.cancelOpenLineworkFrame(),this._convertQueue.length=0,this._viewportRepairOwnerIds.clear(),this._numOfEntitiesToProcess=0,this._claimedConvertObjectIds.clear(),this._entityConvertGeneration.clear(),this.resetDeferredGeometryQueue(),this._entityProcessingIdleAt=0,this._scene=this.createScene(),this._layoutViewManager=new hE,this._initializedLayouts=new Set,this._externallyFramedLayouts=new Set,this._openViewMode=aa.Extents,this._loadingLayouts=new Set,this._missedImages=new Map,this._renderer.clearMissedFonts(),this.rebindLayerAppearance(),this.selectionSet.clear(),this._isDirty=!0,Vt.emit("missed-data-changed",{}),e}disposeSessionState(e){e.meshGlyphBatch.dispose(),e.scene.clear(),e.layoutViewManager=new hE,e.initializedLayouts.clear(),e.externallyFramedLayouts.clear(),e.loadingLayouts.clear(),e.missedImages.clear(),e.missedFonts={},e.selectionIds=[]}rebindLayerAppearance(){this._layerAppearance=new RB(this._scene,this._renderer)}isActiveManagedView(){var e;const t=(e=W._instance)==null?void 0:e.curView;return t!=null&&t===this}focusViewerForShortcuts(){const e=document.activeElement;e instanceof Node&&this.container.contains(e)||e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)||this.container.focus({preventScroll:!0})}isShortcutEventInsideViewer(e){const t=e.target;if(t instanceof Node&&this.container.contains(t))return!0;const n=document.activeElement;return n instanceof Node&&this.container.contains(n)}async drainConvertQueue(){if(this._convertDrainPromise){await this._convertDrainPromise,this._convertQueue.length>0&&await this.drainConvertQueue();return}this._convertDrainPromise=this.runConvertDrain().finally(()=>{this._convertDrainPromise=null}),await this._convertDrainPromise}async runConvertDrain(){const e=this._convertEpoch,t=this._cooperativeYield;let n=t?this.activeLayoutBtrId===this.modelSpaceBtrId?ni.CONVERT_SLICE_MAX:1:Number.POSITIVE_INFINITY,i=performance.now(),o=A3e(this._convertQueue.splice(0,this._convertQueue.length),this.activeLayoutBtrId);for(this.repairViewportViewsFor(o.activeOwnerId);o.cursor<o.pending.length||this._convertQueue.length>0;){if(this._convertEpoch!==e)return;const a=this._convertQueue.splice(0,this._convertQueue.length),s=this.activeLayoutBtrId,l=s!==o.activeOwnerId;if(o=C3e(o,a,s),l&&(this.repairViewportViewsFor(s),t&&(n=1)),this.flushViewportViewRepairs(),o.cursor>=o.pending.length)break;const c=Math.min(o.pending.length,o.cursor+n),u=performance.now();if(await this.batchConvert(o.pending.slice(o.cursor,c)),o.cursor=c,this._convertEpoch!==e)return;if(!t)continue;const h=performance.now()-u,d=o.activeOwnerId===this.modelSpaceBtrId,f=this._progressiveRendering?ni.PROGRESSIVE_OPEN_YIELD_BUDGET_MS:ni.OPEN_CONVERT_YIELD_BUDGET_MS,p=d?f:ni.CONVERT_SLICE_BUDGET_MS;if(n=I3e({slice:n,tookMs:h,budgetMs:p,maxSlice:ni.CONVERT_SLICE_MAX,activeLayoutPending:!d&&T3e(o)}),this._progressiveRendering&&this.isProgressiveGesturePauseActive()){for(await new Promise(m=>setTimeout(m,0));performance.now()<this._progressiveInputPauseUntil;)await new Promise(m=>setTimeout(m,16));if(i=performance.now(),this._convertEpoch!==e)return}else if(this._progressiveRendering&&this.isProgressiveDiscreteInputPending()){if(await new Promise(m=>setTimeout(m,0)),i=performance.now(),this._convertEpoch!==e)return}else if(performance.now()-i>=p&&(await new Promise(m=>setTimeout(m,0)),i=performance.now(),this._convertEpoch!==e))return}this.repairViewportViewsFor(this.activeLayoutBtrId),this.flushViewportViewRepairs()}repairViewportViewsFor(e){var t;if(!e||e===this.modelSpaceBtrId)return;const n=this._layoutViewManager.getAt(e);if(!n||n.viewportCount>0){n&&n.viewportCount>0&&this._viewportRepairOwnerIds.delete(e);return}try{const i=(t=W.instance.curDocument)==null?void 0:t.database,o=i==null?void 0:i.tables.blockTable.getIdAt(e);if(!o)return;const a=n.viewportCount;this.ensureViewportViews(o,n),n.viewportCount>a&&(this._isDirty=!0),this._viewportRepairOwnerIds.delete(e)}catch(i){Ht.error("[AcTrView2d] Error repairing viewport views:",i)}}flushViewportViewRepairs(){if(this._viewportRepairOwnerIds.size===0)return;const e=Array.from(this._viewportRepairOwnerIds);for(let t=0;t<e.length;t++)this.repairViewportViewsFor(e[t])}markProgressiveDirty(e=!1){const t=performance.now();(e||t-this._lastProgressivePaintAt>=ni.PROGRESSIVE_OPEN_PAINT_INTERVAL_MS)&&(this._isDirty=!0)}markInteractiveOpenDirty(){this._progressiveRendering||!this._cooperativeYield||(this._isDirty=!0)}shouldCountMidOpenPaint(e,t){return this._progressiveRendering&&e||!this._progressiveRendering&&this._cooperativeYield&&t}highlight(e){this.entitySelectionEnabled&&(this._isDirty=this._scene.select(e))}unhighlight(e){this._isDirty=this._scene.unselect(e)}setCompareDisplay(e,t){var n,i,o,a;const s=e.baseColor??((n=e.colors)==null?void 0:n.unchanged)??10265519,l={enabled:e.enabled,baseColor:s,colors:{deleted:(i=e.colors)==null?void 0:i.deleted,added:(o=e.colors)==null?void 0:o.added,modified:(a=e.colors)==null?void 0:a.modified},overrides:e.overrides};t?t.setCompareDisplay(l):this._scene.setCompareDisplay(l),this._isDirty=!0}stopAnimationLoop(){this._rafId!=null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}dispose(){var e,t,n;if(this._viewDisposed)return;this._viewDisposed=!0,this.abortConversion(),(e=this._disposeCanvasTouchCallout)==null||e.call(this),this._disposeCanvasTouchCallout=void 0,(t=this._disposeProgressiveInputWatch)==null||t.call(this),this._disposeProgressiveInputWatch=void 0,(n=this._disposeMobileBoxGesture)==null||n.call(this),this._disposeMobileBoxGesture=void 0,this._viewDomAbort.abort(),this._onFontNotFound&&this._renderer.events.fontNotFound.removeEventListener(this._onFontNotFound),this._onFontLoaded&&this._renderer.events.fontLoaded.removeEventListener(this._onFontLoaded),this._onSysVarChanged&&Lt.instance().events.sysVarChanged.removeEventListener(this._onSysVarChanged),this._onSettingsModified&&Kn.instance.events.modified.removeEventListener(this._onSettingsModified),this._onLayoutSwitched&&$r().layoutManager.events.layoutSwitched.removeEventListener(this._onLayoutSwitched),this._onCommandWillStartHitTest&&this.editor.events.commandWillStart.removeEventListener(this._onCommandWillStartHitTest),this._onCommandEndedHitTest&&this.editor.events.commandEnded.removeEventListener(this._onCommandEndedHitTest),this._gripManager.dispose(),this.clearFontLoadedRedrawTimer(),this.cancelOpenLineworkFrame(),this.stopAnimationLoop(),this.selectionSet.clear(),this.htmlTransientManager.dispose(),this._scene.clear(),this._renderer.dispose(),Io.instance.clear();const i=this._renderer.internalRenderer;i.dispose(),i.forceContextLoss(),this.canvas.remove(),this._css2dRenderer.domElement.remove(),this._stats.dom.remove(),super.dispose()}onHover(e){this.entitySelectionEnabled&&(this._isDirty=this._scene.hover([e]))}onUnhover(e){this._isDirty=this._scene.unhover([e])}createScene(){return new qPe}createStats(e){const t=new ag;document.body.appendChild(t.dom);const n=t.dom;return n.style.position="fixed",n.style.inset="unset",n.style.bottom="30px",n.style.right="0px",this.toggleStatsVisibility(t,e),t}onWindowResize(){this.refreshViewSize(),this._renderer.setSize(this.width,this.height),this._css2dRenderer.setSize(this.width,this.height),this._layoutViewManager.resize(this.width,this.height),this._isDirty=!0,this.events.viewResize.dispatch({width:this.width,height:this.height}),this.events.viewChanged.dispatch()}startAnimationLoop(){this._rafId==null&&(this._rafId=requestAnimationFrame(this.animate))}createLayoutViewIfNeeded(e){let t=this._layoutViewManager.getAt(e);return t==null&&(t=new B3e(this._renderer,e,this.width,this.height),t.events.viewChanged.addEventListener(()=>{this._progressiveOpenFit.onLayoutViewChanged(),this._isDirty=!0,this._progressiveRendering&&this._numOfEntitiesToProcess>0&&(this._progressivePaintUrgent=!0),this.events.viewChanged.dispatch(),this.clearHover()}),this._layoutViewManager.add(t)),this.flushViewportViewRepairs(),t}loadLayoutEntitiesIfNeeded(e){try{const t=W.instance.curDocument.database.tables.blockTable.getIdAt(e);if(!t)return;const n=this._scene.layouts.get(e);if(n&&n.isLoaded){this.repairViewportViewsFor(e);return}if(this._loadingLayouts.has(e))return;if(this.repairViewportViewsFor(e),n&&n.entityCount>0){n.isLoaded=!0;return}n||this._scene.addEmptyLayout(e);const i=[],o=t.newIterator();for(const a of o)i.push(a);if(i.length===0){const a=this._scene.layouts.get(e);a&&(a.isLoaded=!0);return}this._loadingLayouts.add(e),this._numOfEntitiesToProcess+=i.length,(async()=>{try{this._progressiveRendering?(this._convertQueue.push(...i),await this.drainConvertQueue()):await this.batchConvert(i);const a=this._scene.layouts.get(e);a&&(a.isLoaded=!0)}finally{this._loadingLayouts.delete(e)}})()}catch(t){Ht.error("[AcTrView2d] Error loading layout entities:",t)}}toggleStatsVisibility(e,t){t?e.dom.style.display="block":e.dom.style.display="none"}toLayerInfo(e){return{name:e.name,isFrozen:e.isFrozen,isOff:e.isOff,color:e.color}}resolveLayerInfo(e){const t=W.instance.curDocument.database.tables.layerTable.getAt(e);return t?this.toLayerInfo(t):void 0}async convertMissingEntitiesOnLayer(e){if(!this._convertingLayers.has(e)){this._convertingLayers.add(e);try{const t=W.instance.curDocument.database.tables.blockTable.getIdAt(this.activeLayoutBtrId);if(!t)return;const n=this._entityDisplay.collectMissingEntitiesOnLayer(e,t,i=>this.hasEntity(i));if(n.length===0)return;this._numOfEntitiesToProcess+=n.length,await this.batchConvert(n)}finally{this._convertingLayers.delete(e)}}}drawEntity(e,t){return e.worldDraw(this._renderer,t)}startTextStyleFontPreload(e){var t,n;const i=this._convertEpoch;if(this._textStyleFontPreloadEpoch===i&&this._textStyleFontPreloadPromise)return;this._textStyleFontPreloadEpoch=i;const o=h3e(e),a=it.instance.getFontsToLoad(),s=[...it.instance.defaultFonts][0],l=d3e(o,a,{firstDefaultFont:s}),c=bn.getInstance().getRenderMode()==="worker"?"worker":"main",u=W,h=(n=(t=u._instance)==null?void 0:t.lastPresetFontsForOpen)!=null&&n.length?[...u._instance.lastPresetFontsForOpen]:[...a];if(this._fontPreloadDiag={critical:[...l.critical],workerWarm:[],background:[],preset:h,workerSkipped:0,parseSite:c},c==="worker"){this._textStyleFontPreloadPromise=Promise.resolve();return}const d=3e4;if(l.critical.length===0){this._textStyleFontPreloadPromise=Promise.resolve();return}const f=it.instance.requestFonts(l.critical);this._textStyleFontPreloadPromise=new Promise(p=>{const m=setTimeout(()=>{p()},d);f.then(()=>{clearTimeout(m),p()},()=>{clearTimeout(m),p()})})}async awaitTextStyleFontsReady(){if(!this._textStyleFontPreloadPromise){const e=this._renderer.context.database;if(e)this.startTextStyleFontPreload(e);else return}await this._textStyleFontPreloadPromise}async finishEntityGeometry(e,t){const n=performance.now();try{const i=e instanceof Rn,o=i&&this.groupHasPendingGlyphGeometry(e);(o||Jl(e)||e instanceof lo&&!e.hasDrawableGeometry())&&await this.ensureDeferredFontsReady();const a=()=>{this._convertPhaseMs.glyphEntityCount++,e instanceof T_?this._convertPhaseMs.mtextCount++:e instanceof np&&this._convertPhaseMs.shapeCount++};if(i){if(!o)return;a();const l=performance.now();await e.asyncDraw(),this._convertPhaseMs.finishGeometryAsyncDraw+=performance.now()-l;return}if(Jl(e)){a();const l=performance.now();await e.asyncDraw(),this._convertPhaseMs.finishGeometryAsyncDraw+=performance.now()-l;return}if(e.hasDrawableGeometry())return;a();const s=performance.now();await e.asyncDraw(),this._convertPhaseMs.finishGeometryAsyncDraw+=performance.now()-s}finally{this._convertPhaseMs.finishGeometry+=performance.now()-n}}needsDeferredFontGeometry(e){return e instanceof lo?!e.hasDrawableGeometry():e instanceof Rn?this.groupHasPendingGlyphGeometry(e):Jl(e)}clearFontLoadedRedrawTimer(){this._fontLoadedRedrawTimer!=null&&(clearTimeout(this._fontLoadedRedrawTimer),this._fontLoadedRedrawTimer=null)}scheduleGlyphRedrawAfterFontLoad(e){this.clearFontLoadedRedrawTimer();const t=this._convertEpoch;this._fontLoadedRedrawTimer=setTimeout(()=>{this._fontLoadedRedrawTimer=null,t===this._convertEpoch&&this.redrawGlyphEntitiesAfterFontLoad(t,e)},50)}async redrawGlyphEntitiesAfterFontLoad(e,t){var n,i;if(e!==this._convertEpoch)return;const o=++this._fontLoadedRedrawEpoch,a=[];for(const c of this._scene.layouts.values())c.layers.forEach(u=>{u.internalObject.traverse(h=>{h instanceof lo&&a.push(h)})});for(const c of a){if(e!==this._convertEpoch||o!==this._fontLoadedRedrawEpoch)return;await c.asyncDraw()}if(a.length>0){e===this._convertEpoch&&(this._isDirty=!0);return}if(t){const c=it.instance.defaultFonts,u=t.toLowerCase();if(c.has(t)||c.has(u)||[...c].some(h=>h.toLowerCase()===u))return}if(e!==this._convertEpoch||o!==this._fontLoadedRedrawEpoch||this._entityProcessingIdleAt<=0)return;const s=performance.now()-this._entityProcessingIdleAt;if(!V3e(this.isProcessingEntities,0,s))return;const l=(i=(n=W.instance)==null?void 0:n.curDocument)==null?void 0:i.database;l&&l.regen()}groupHasPendingGlyphGeometry(e){for(const t of e.getSourceEntities())if(t instanceof lo&&!t.hasDrawableGeometry())return!0;return ni.directChildrenHavePendingGlyphs(e)}static directChildrenHavePendingGlyphs(e){const t=e.children;for(let n=0;n<t.length;n++){const i=t[n];if(i instanceof lo){if(!i.hasDrawableGeometry())return!0;continue}if(i instanceof Rn){for(const o of i.getSourceEntities())if(o instanceof lo&&!o.hasDrawableGeometry())return!0;if(ni.directChildrenHavePendingGlyphs(i))return!0;continue}if(i instanceof Xn&&ni.directChildrenHavePendingGlyphs(i))return!0}return!1}enqueueDeferredGeometry(e,t){t===this._convertEpoch&&(this._pendingGeometryJobs++,this._deferredGeometryQueue.push({run:e,epoch:t,enqueuedAt:performance.now()}),this.pumpDeferredGeometryQueue())}pumpDeferredGeometryQueue(){for(;this._deferredGeometryActive<ni.DEFERRED_GEOMETRY_CONCURRENCY&&this._deferredGeometryQueue.length>0;){const e=this._deferredGeometryQueue.shift();if(e.epoch!==this._convertEpoch){this._pendingGeometryJobs=Math.max(0,this._pendingGeometryJobs-1);continue}this._convertPhaseMs.finishGeometryQueueWait+=performance.now()-e.enqueuedAt,this._deferredGeometryActive++,e.run().then(()=>{e.epoch===this._convertEpoch&&(this._progressiveRendering||this._cooperativeYield)&&(this._isDirty=!0)}).catch(t=>{Ht.error("[AcTrView2d] Deferred entity geometry failed:",t)}).finally(()=>{this._deferredGeometryActive=Math.max(0,this._deferredGeometryActive-1),e.epoch===this._convertEpoch&&(this._pendingGeometryJobs=Math.max(0,this._pendingGeometryJobs-1),this._pendingGeometryJobs===0&&(this._isDirty=!0),this.stampEntityProcessingIdle()),this.pumpDeferredGeometryQueue()})}}resetDeferredGeometryQueue(){this._deferredGeometryQueue.length=0,this._pendingGeometryJobs=0,this._textStyleFontPreloadPromise=null,this._textStyleFontPreloadEpoch=-1,this._deferredFontsReady=null,this._fontPreloadDiag=null}async waitUntilDeferredGeometryIdle(){const e=this._convertEpoch;for(;e===this._convertEpoch&&this._pendingGeometryJobs>0;)await new Promise(t=>setTimeout(t,0))}attachViewportView(e){if(Vd.isDefaultPaperSpaceViewport(e))return;const t=e.ownerId,n=t?this._layoutViewManager.getAt(t):void 0;if(!n){t&&this._viewportRepairOwnerIds.add(t);return}n.addViewport(new Vd(n,this.toGiViewportWithFrozenLayers(e),this._renderer)),this._isDirty=!0}ensureViewportViews(e,t){const n=e.newIterator();for(const i of n){if(!(i instanceof Va)||Vd.isDefaultPaperSpaceViewport(i))continue;const o=new Vd(t,this.toGiViewportWithFrozenLayers(i),this._renderer);t.addViewport(o)}}toGiViewportWithFrozenLayers(e){var t;const n=e.toGiViewport();if(n.frozenLayers&&n.frozenLayers.length>0)return n;const i=e.frozenLayerIds;if(!(i!=null&&i.length))return n;const o=[],a=(t=e.database)==null?void 0:t.tables.layerTable;if(a)for(const s of i){const l=a.getIdAt(s);l&&o.push(l.name)}return n.frozenLayerIds=[...i],n.frozenLayers=o,n}async batchConvert(e,t={}){const n=this._convertEpoch;if(!t.forExport&&!this._textStyleFontPreloadPromise){const l=this._renderer.context.database;l&&this.startTextStyleFontPreload(l)}const i=this._progressiveRendering&&!t.forExport,o=i?ni.PROGRESSIVE_OPEN_YIELD_BUDGET_MS:ni.OPEN_CONVERT_YIELD_BUDGET_MS,a=t.forExport||!this._cooperativeYield?void 0:new ty(o),s=()=>new Promise(l=>setTimeout(l,0));for(let l=0;l<e.length;++l){const c=e[l];try{if(n!==this._convertEpoch||c instanceof Va&&Vd.isDefaultPaperSpaceViewport(c)||!(t.forExport||this._convertInvisibleLayers?this._entityDisplay.shouldConvertForExport(c):this._entityDisplay.shouldConvert(c)))continue;const u=String(c.objectId??"");let h=0;if(u&&(this.hasEntity(u)||this._claimedConvertObjectIds.has(u))){c instanceof Va&&this.attachViewportView(c);continue}u&&(this._claimedConvertObjectIds.add(u),h=this._entityConvertGeneration.get(u)??0);const d=c_e(c,this._renderer);if(d){let p=!1,m=!1;try{u&&(this._entityConvertGeneration.get(u)??0)!==h?m=!0:(p=this._scene.addDirectEntity(d,u_e(c)),p&&(this.applySessionHiddenObjectState(c.objectId),i?(this.markProgressiveDirty(),this._progressiveOpenFit.afterGeometryBatch(()=>this.getDrawingExtents(),l)):this.markInteractiveOpenDirty()))}finally{d.geometry.dispose()}if(m||p)continue}const f=this.drawEntity(c,!1);if(!f&&!(c instanceof Va)){u&&this._claimedConvertObjectIds.delete(u);continue}if(f){f.objectId=c.objectId,f.ownerId=c.ownerId,f.layerName=c.layer,f.visible=c.visibility!==!1,f instanceof Rn&&f.isOnTheSameLayer&&(f.userData.insertLayerName=f.layerName);const p=f instanceof Rn&&!f.isOnTheSameLayer,m=!t.forExport&&this.needsDeferredFontGeometry(f);if(p)m?this.enqueueDeferredGeometry(()=>this.handleGroup(f,i,n,h),n):await this.handleGroup(f,i,n,h);else{const g=!(c instanceof Fh||c instanceof py),y=async()=>{if(await this.finishEntityGeometry(f,i),n!==this._convertEpoch){f.dispose();return}if(u&&(this._entityConvertGeneration.get(u)??0)!==h){f.dispose();return}f instanceof Rn&&(this.syncGroupSpatialBoundsForIndexing(f),f.isOnTheSameLayer&&this._inheritedLayerMaterialMapper.remap(f.children,"0",f.layerName));const v=performance.now();this._scene.addEntity(f,g),this._convertPhaseMs.addEntity+=performance.now()-v,this.applySessionHiddenObjectState(c.objectId),f.dispose(),i?(this.markProgressiveDirty(),this._progressiveOpenFit.afterGeometryBatch(()=>this.getDrawingExtents(),l)):this.markInteractiveOpenDirty()};m?this.enqueueDeferredGeometry(y,n):await y()}}if(n!==this._convertEpoch)continue;if(c instanceof Va)this.attachViewportView(c);else if(c instanceof Rh){const p=c.imageFileName;p&&!c.image?this._missedImages.set(c.objectId,p):c.image&&this._missedImages.delete(c.objectId)}}catch(u){const h=String(c.objectId??"");h&&this._claimedConvertObjectIds.delete(h),Ht.error(`[AcTrView2d] Failed to convert entity ${c.objectId} (${c.type}):`,u)}finally{n===this._convertEpoch&&this.decreaseNumOfEntitiesToProcess()}n===this._convertEpoch&&(i?await this.progressiveYieldForInput(a,s):a&&await a.maybeYield(s)&&this._progressiveYieldCount++)}}syncGroupSpatialBoundsForIndexing(e){const t=e.peekLazyChildBoxes();if(t&&t.boxes.length>0){const o=e.userData;o.lazySpatialChildren=t;return}if(e.refreshWcsChildBoxesFromChildren(),e.wcsChildBoxes.length===0)return;const n=e.wcsChildBoxes.map(o=>({minX:o.minX,minY:o.minY,maxX:o.maxX,maxY:o.maxY,id:o.id}));e.wcsBbox=LB(e);const i=e.userData;i.spatialIndexChildBoxes=n}async handleGroup(e,t,n=this._convertEpoch,i=0){const o=performance.now();try{if(await this.finishEntityGeometry(e,t),n!==this._convertEpoch){e.dispose();return}const a=String(e.objectId??"");if(a&&(this._entityConvertGeneration.get(a)??0)!==i){e.dispose();return}this.syncGroupSpatialBoundsForIndexing(e);const s=e.children,l=new Map;s.forEach(v=>{var x;if(v.visible===!1)return;const b=v.userData.layerName;l.has(b)||l.set(b,[]),(x=l.get(b))==null||x.push(v)}),e.children=[];for(const v of s)v.parent=null;const c=e.renderContext,u=e.objectId,h=e.layerName,d=e.userData.lazySpatialChildren,f=d?[]:e.wcsChildBoxes.map(v=>({minX:v.minX,minY:v.minY,maxX:v.maxX,maxY:v.maxY,id:v.id})),p=d?e.wcsBbox.clone():f.length>0?LB(e):e.wcsBbox.clone();f.length>0&&(e.wcsBbox=p.clone());let m=!1;const g=()=>new Promise(v=>setTimeout(v,0));let y=t?performance.now():0;for(const[v,x]of l){const b=v==="0"?h:v,w=x.some(E=>(E.userData.authoredLayerName??v)==="0")?"0":v;this._inheritedLayerMaterialMapper.remap(x,w,b);const _=new Xn(c);_.matrix.copy(e.matrix),_.matrixAutoUpdate=!1,_.matrixWorldNeedsUpdate=!0,_.objectId=u,_.ownerId=e.ownerId,_.layerName=b,_.userData.insertLayerName=h,_.wcsBbox=p.clone();const P=_.userData;!m&&d?(_.userData.lazySpatialChildren=d,m=!0):!m&&f.length>0&&(P.spatialIndexChildBoxes=f,m=!0);for(let E=0;E<x.length;E++)_.add(x[E]);_.updateMatrixWorld(!0),this._layerAppearance.refreshTextMaterialsInObjectTree(_);const S=performance.now();this._scene.addEntity(_,!0),this._convertPhaseMs.addEntity+=performance.now()-S,this.applySessionHiddenObjectState(u),_.dispose(),t&&n===this._convertEpoch&&performance.now()-y>=ni.PROGRESSIVE_OPEN_YIELD_BUDGET_MS&&(await g(),y=performance.now())}e.dispose(),t?(this.markProgressiveDirty(),this._progressiveOpenFit.afterGeometryBatch(()=>this.getDrawingExtents())):this.markInteractiveOpenDirty()}finally{this._convertPhaseMs.handleGroup+=performance.now()-o}}decreaseNumOfEntitiesToProcess(){this._numOfEntitiesToProcess--,this._numOfEntitiesToProcess<0?(this._numOfEntitiesToProcess=0,Ht.warn("Something wrong! The number of entities to process should not be less than 0.")):this._numOfEntitiesToProcess===0&&(this._isDirty=!0,Vt.emit("missed-data-changed",{})),this.stampEntityProcessingIdle()}frameOpenLineworkIfReady(){if(!this._openLineworkFramePending||this.isConvertingEntities)return;const e=this.getDrawingExtents();if(!e||e.isEmpty()){this._openLineworkFramePending=!1;return}this._openLineworkFramePending=!1,this._progressiveOpenFit.frameProgrammatically(e)}stampEntityProcessingIdle(){this._numOfEntitiesToProcess===0&&this._pendingGeometryJobs===0&&(this._entityProcessingIdleAt=performance.now(),this.scheduleMeshGlyphWorldBatchFlush(),Io.instance.clear())}clearMeshGlyphFlushTimer(){this._meshGlyphFlushTimer!=null&&(clearTimeout(this._meshGlyphFlushTimer),this._meshGlyphFlushTimer=null)}scheduleMeshGlyphWorldBatchFlush(){if(!bn.getInstance().getMeshGlyphInstancing())return;this.clearMeshGlyphFlushTimer();const e=this._convertEpoch;this._meshGlyphFlushTimer=setTimeout(()=>{this._meshGlyphFlushTimer=null,e===this._convertEpoch&&(this._numOfEntitiesToProcess>0||this._pendingGeometryJobs>0||this.flushMeshGlyphWorldBatch())},16)}flushMeshGlyphWorldBatch(){this.clearMeshGlyphFlushTimer();const e=bn.getInstance();if(!e.getMeshGlyphInstancing())return;const{placements:t,buckets:n}=e.flushMeshGlyphInstances(this._scene.internalScene,i=>this.resolveMeshGlyphLayerParent(i));t>0&&console.log(`[cad-simple-viewer-cli] mesh glyph InstancedMesh flush: placements=${t} buckets=${n}`)}resolveMeshGlyphLayerParent(e){var t;const n=(t=this._scene.activeLayout)==null?void 0:t.getLayer(e);if(n)return n.internalObject;for(const i of this._scene.layouts.values()){const o=i.getLayer(e);if(o)return o.internalObject}return null}};Il.OPEN_CONVERT_YIELD_BUDGET_MS=300,Il.PROGRESSIVE_OPEN_YIELD_BUDGET_MS=32,Il.PROGRESSIVE_INPUT_PAUSE_MS=120,Il.PROGRESSIVE_OPEN_PAINT_INTERVAL_MS=2500,Il.NON_PROGRESSIVE_OPEN_PAINT_INTERVAL_MS=4e3,Il.DEFERRED_GEOMETRY_CONCURRENCY=8,Il.CONVERT_SLICE_BUDGET_MS=64,Il.CONVERT_SLICE_MAX=512;let Ow=Il;function H3e(r){if(!r)return!1;const e=Object.keys(r);return e.length>0&&e.every(t=>t==="visibility")}function G3e(r,e,t){const{entity:n,changes:i}=r,o=n.objectId;if(!e(o))return!1;if(H3e(i))return!(i.visibility===!0&&t(o)===void 0);if(i&&Object.keys(i).length>0)return!1;const a=t(o);return a===void 0?!1:a&&!n.visibility}function d4(r){return Array.isArray(r)?r:[r]}class dE{constructor(e,t){this._active=!0,this._disposers=[],this._view=e,this._doc=t;const n=(i,o)=>{i.addEventListener(o),this._disposers.push(()=>i.removeEventListener(o))};n(t.database.events.entityAppended,i=>{if(!this._active)return;const o=d4(i.entity).filter(a=>!this.view.hasEntity(a.objectId));o.length!==0&&this.view.addEntity(o.length===1?o[0]:o)}),n(t.database.events.entityModified,i=>{if(!this._active)return;const o=i,a=this.view;a instanceof Ow&&G3e(o,s=>a.hasEntity(s),s=>a.getEntityVisible(s))&&a.updateEntityVisibility(o.entity)||this.view.updateEntity(o.entity)}),n(t.database.events.entityErased,i=>{if(!this._active)return;const o=d4(i.entity).filter(a=>this.view.hasEntity(a.objectId));o.length!==0&&this.view.removeEntity(o.length===1?o[0]:o)}),n(t.database.events.layerAppended,i=>{this._active&&this._view.addLayer(i.layer)}),n(t.database.events.layerModified,i=>{this._active&&this._view.updateLayer(i.layer,i.changes)}),n(Lt.instance().events.sysVarChanged,i=>{if(!(!this._active||i.database!==this._doc.database)){if(i.name==ae.PDMODE.toLowerCase()||i.name==ae.PDSIZE.toLowerCase())this._view.rerenderPoints(i.database.pdmode,i.database.pdsize);else if(i.name==ae.LWDISPLAY.toLowerCase()){const o=this._view,a=!!i.database.lwdisplay;o.renderer.showLineWeight!==a&&(o.renderer.showLineWeight=a,o.clear(),i.database.regen())}}}),n(t.database.events.dictObjetSet,i=>{this._active&&i.object instanceof ec&&this._view.addLayout(i.object)}),n(e.selectionSet.events.selectionAdded,i=>{this._active&&e.highlight(i.ids)}),n(e.selectionSet.events.selectionRemoved,i=>{this._active&&e.unhighlight(i.ids)})}get view(){return this._view}get doc(){return this._doc}get isActive(){return this._active}suspend(){this._active=!1}resume(){this._active=!0}dispose(){this._active=!1;for(const e of this._disposers)e();this._disposers.length=0}}function EG(r){return typeof r.hasEntity=="function"&&typeof r.setEntitySceneVisible=="function"}function W3e(r,e){const t=r.view;if(!EG(t))return 0;const n=r.doc,i=n.database;let o=0;for(const a of e){if(n.isObjectHidden(a))continue;const s=i.tables.blockTable.getEntityById(a);!(s!=null&&s.visibility)||!t.hasEntity(a)||t.setEntitySceneVisible(a,!1)&&(n.addHiddenObject(a),o++)}return o>0&&t.selectionSet.clear(),o}function $3e(r){const e=r.view;if(!EG(e))return 0;const t=r.doc,n=t.database,i=t.takeHiddenObjects();let o=0;for(const a of i){const s=n.tables.blockTable.getEntityById(a);!s||!e.hasEntity(a)||e.setEntitySceneVisible(a,s.visibility)&&o++}return e.selectionSet.clear(),o}const X3e="SvgPlugin",Y3e=["csvg"];function q3e(r){r.registerLazyPlugin({name:X3e,triggers:[...Y3e],loader:async()=>{const{createSvgPlugin:e}=await Qg(async()=>{const{createSvgPlugin:t}=await import("./cad-svg-plugin-BrF5C6WG.js");return{createSvgPlugin:t}},[],import.meta.url);return e()}})}var nf=function(){return nf=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},nf.apply(this,arguments)},Bu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},f4=(function(){function r(){}return r.prototype.convert=function(e){var t=this.createEntity(e);if(t&&(this.processCommonAttrs(e,t),e.type==="ARCALIGNEDTEXT")){var n=e.rawTextColor;t.applyRawTextColor(n)}return t},r.prototype.createEntity=function(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="ATTDEF"?this.convertAttributeDefinition(e):e.type=="ATTRIB"?this.convertAttribute(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MLINE"?this.convertMLine(e):e.type=="MTEXT"?this.convertMText(e):e.type=="MULTILEADER"||e.type=="MLEADER"?this.convertMLeader(e):e.type=="POINT"?this.convertPoint(e):e.type=="POLYLINE2D"?this.convertPolyline2d(e):e.type=="POLYLINE3D"?this.convertPolyline3d(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="TOLERANCE"?this.convertTolerance(e):e.type=="SHAPE"?this.convertShape(e):e.type=="SOLID"?this.convertSolid(e):e.type=="TRACE"?this.convertTrace(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):e.type=="ACAD_PROXY_ENTITY"?this.convertProxyEntity(e):e.type=="OLE2FRAME"?this.convertOle2Frame(e):e.type=="OLEFRAME"?this.convertOleFrame(e):e.type=="ARCALIGNEDTEXT"?this.convertArcAlignedText(e):null},r.prototype.convertProxyEntity=function(e){var t,n=new KA;if(n.proxyEntityClassId=e.proxyEntityClassId,e.originalDxfName&&(n.originalDxfName=e.originalDxfName),e.applicationEntityClassId!=null&&(n.applicationEntityClassId=e.applicationEntityClassId),e.objectDrawingFormat!=null&&(n.objectDrawingFormat=e.objectDrawingFormat),e.originalDataFormat!=null&&(n.originalDataFormat=e.originalDataFormat),e.graphicsData){var i=rh([e.graphicsData]),o=(t=e.graphicsDataSize)!==null&&t!==void 0?t:i.length;n.setProxyGraphic(i.subarray(0,o))}return n},r.prototype.convertFace=function(e){var t=new TA;return e.corner1&&t.setVertexAt(0,e.corner1),e.corner2&&t.setVertexAt(1,e.corner2),e.corner3&&t.setVertexAt(2,e.corner3),e.corner4&&t.setVertexAt(3,e.corner4),t.setEdgeInvisibilities(e.flag),t},r.prototype.convertArc=function(e){var t,n=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,i=new tc(Ei(e.center,n),e.radius,e.startAngle,e.endAngle,n);return i},r.prototype.convertCirle=function(e){var t,n=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,i=new ba(Ei(e.center,n),e.radius,n);return i},r.prototype.convertEllipse=function(e){var t,n=new X(e.majorAxisEndPoint),i=n.length(),o=new Dh(e.center,(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,n,i,i*e.axisRatio,e.startAngle,e.endAngle);return o},r.prototype.convertLine=function(e){var t=e.startPoint,n=e.endPoint,i=new es(new D(t.x,t.y,t.z),new D(n.x,n.y,n.z));return i},r.prototype.convertSpline=function(e){return Us.fromDwgSpline(e)},r.prototype.convertPoint=function(e){var t=new a_;return t.position=e.position,t},r.prototype.convertShape=function(e){var t,n,i,o,a,s=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,l=new ZA;return l.position=Ei(e.insertionPoint,s),l.size=e.size,l.shapeNumber=e.shapeNumber,e.styleName&&(l.styleName=e.styleName),l.rotation=(n=e.rotation)!==null&&n!==void 0?n:0,l.widthFactor=(i=e.xScale)!==null&&i!==void 0?i:1,l.oblique=(o=e.obliqueAngle)!==null&&o!==void 0?o:0,l.thickness=(a=e.thickness)!==null&&a!==void 0?a:0,l.normal.copy(s),l},r.prototype.convertSolid=function(e){return this.convertTraceLike(new JA,e)},r.prototype.convertTrace=function(e){return this.convertTraceLike(new s_,e)},r.prototype.convertTraceLike=function(e,t){var n,i,o,a=(n=t.extrusionDirection)!==null&&n!==void 0?n:X.Z_AXIS,s=function(c){var u;return Ei({x:c.x,y:c.y,z:(u=c.z)!==null&&u!==void 0?u:0},a)},l=(i=t.corner4)!==null&&i!==void 0?i:t.corner3;return e.setPointAt(0,s(t.corner1)),e.setPointAt(1,s(t.corner2)),e.setPointAt(2,s(t.corner3)),e.setPointAt(3,s(l)),e.thickness=(o=t.thickness)!==null&&o!==void 0?o:0,e.normal.copy(a),e.elevation=e.getPointAt(0).z,e},r.prototype.convertLWPolyline=function(e){var t,n=new sn;n.closed=!!(e.flag&512);var i=(t=e.constantWidth)!==null&&t!==void 0?t:-1;return e.vertices.forEach(function(o,a){var s,l;n.addVertexAt(a,new re(o.x,o.y),o.bulge,(s=o.startWidth)!==null&&s!==void 0?s:i,(l=o.endWidth)!==null&&l!==void 0?l:i)}),n},r.prototype.convertPolyline2d=function(e){var t,n,i,o,a=!!(e.flag&1),s=!!(e.flag&16),l=!!(e.flag&64),c=!!(e.flag&32),u=[],h=[],d=[];if(e.vertices.map(function(y){var v,x;if(!(y.flag&16))if(l&&y.flag&128)if(y.flag&64)u.push({x:y.x,y:y.y,z:y.z}),h.push((v=y.bulge)!==null&&v!==void 0?v:0);else{var b=[];y.polyfaceIndex0!=null&&y.polyfaceIndex0!=0&&b.push(Math.abs(y.polyfaceIndex0)-1),y.polyfaceIndex1!=null&&y.polyfaceIndex1!=0&&b.push(Math.abs(y.polyfaceIndex1)-1),y.polyfaceIndex2!=null&&y.polyfaceIndex2!=0&&b.push(Math.abs(y.polyfaceIndex2)-1),y.polyfaceIndex3!=null&&y.polyfaceIndex3!=0&&b.push(Math.abs(y.polyfaceIndex3)-1),b.length>=3&&d.push(b)}else u.push({x:y.x,y:y.y,z:y.z}),h.push((x=y.bulge)!==null&&x!==void 0?x:0)}),s){var f=(t=e.meshMVertexCount)!==null&&t!==void 0?t:2,p=(n=e.meshNVertexCount)!==null&&n!==void 0?n:2;return new mC(f,p,u,a,c)}else{if(l)return new pC(u,d);var m=po.SimplePoly;e.flag&2?m=po.FitCurvePoly:e.flag&4&&(e.smoothType==6?m=po.CubicSplinePoly:e.smoothType==5&&(m=po.QuadSplinePoly));var g=new my(m,u,(o=(i=u[0])===null||i===void 0?void 0:i.z)!==null&&o!==void 0?o:0,a,e.startWidth,e.endWidth,h);return e.extrusionDirection&&(g.normal=e.extrusionDirection),g}},r.prototype.convertPolyline3d=function(e){var t=!!(e.flag&1),n=[];e.vertices.map(function(o){o.flag&16||n.push({x:o.x,y:o.y,z:o.z})});var i=Ka.SimplePoly;return e.flag&4&&(e.smoothType==6?i=Ka.CubicSplinePoly:e.smoothType==5&&(i=Ka.QuadSplinePoly)),new fC(i,n,t)},r.prototype.convertHatch=function(e){var t,n,i,o,a=new hy;(t=e.definitionLines)===null||t===void 0||t.forEach(function(u){a.definitionLines.push({angle:u.angle,base:u.base,offset:u.offset,dashLengths:u.numberOfDashLengths>0?u.dashLengths:[]})}),a.hatchStyle=e.hatchStyle,a.patternName=e.patternName,e.solidFill==1&&(a.isSolidFill=!0),a.patternType=e.patternType,a.patternAngle=e.patternAngle==null?0:e.patternAngle,a.patternScale=e.patternScale==null?0:e.patternScale;var s=e.boundaryPaths;if(s.forEach(function(u){var h=u.boundaryPathTypeFlag;if(h&2){var d=u,f=new Sn;f.closed=d.isClosed,d.vertices.forEach(function(y,v){f.addVertexAt(v,{x:y.x,y:y.y,bulge:y.bulge})}),a.add(f)}else{var p=u,m=[];p.edges.forEach(function(y){if(y!=null){if(y.type==1){var v=y;m.push(new Pi(v.start,v.end))}else if(y.type==2){var x=y;m.push(new wt(x.center,x.radius,x.startAngle,x.endAngle,!x.isCCW))}else if(y.type==3){var b=y,w=new vn;w.subVectors(b.end,b.center);var _=Math.sqrt(Math.pow(b.end.x,2)+Math.pow(b.end.y,2)),P=_*b.lengthOfMinorAxis,S=b.startAngle,E=b.endAngle,C=Math.atan2(b.end.y,b.end.x);b.isCCW||(S=Math.PI*2-S,E=Math.PI*2-E),m.push(new Is(nf(nf({},b.center),{z:0}),_,P,S,E,!b.isCCW,C))}else if(y.type==4){var k=_i.fromDwgSplineEdge(y);k&&m.push(k)}}});var g=Wl.buildFromEdges(m);g.length===1?a.add(g[0]):m.length>0&&a.add(new Wl(m))}}),e.gradientFlag){var l=e;if(a.hatchObjectType=ih.GradientObject,a.gradientName=l.gradientName,a.gradientAngle=(n=l.gradientRotation)!==null&&n!==void 0?n:0,a.gradientShift=(i=l.gradientDefinition)!==null&&i!==void 0?i:0,a.gradientOneColorMode=l.gradientColorFlag==1,a.shadeTintValue=(o=l.colorTint)!==null&&o!==void 0?o:0,l.gradientColors){var c=l.gradientColors.length;c>1?(a.gradientStartColor=l.gradientColors[0].rgb,a.gradientEndColor=l.gradientColors[1].rgb):c>0&&(a.gradientStartColor=l.gradientColors[0].rgb)}}return e.extrusionDirection&&(a.normal=e.extrusionDirection),a},r.prototype.convertTable=function(e){var t,n=new QA((t=e.name)!==null&&t!==void 0?t:"",e.rowCount,e.columnCount);return n.tableStyleId=e.tableStyleId,n.owningBlockRecordId=e.blockRecordHandle,e.directionVector&&(n.horizontalDirection=new X(e.directionVector)),n.attachmentPoint=e.attachmentPoint,n.position.copy(e.startPoint),n.tableValueFlag=e.tableValue,n.tableOverrideFlag=e.overrideFlag,n.borderColorOverrideFlag=e.borderColorOverrideFlag,n.borderLineweightOverrideFlag=e.borderLineWeightOverrideFlag,n.borderVisibilityOverrideFlag=e.borderVisibilityOverrideFlag,e.columnWidthArr.forEach(function(i,o){return n.setColumnWidth(o,i)}),e.rowHeightArr.forEach(function(i,o){return n.setRowHeight(o,i)}),e.cells.forEach(function(i,o){n.setCell(o,i)}),n},r.prototype.convertText=function(e){var t,n,i,o=new vh;o.textString=e.text,o.styleName=e.styleName,o.height=e.textHeight,o.position.copy(e.startPoint);var a=!e.endPoint||e.endPoint.x===0&&e.endPoint.y===0&&((t=e.endPoint.z)!==null&&t!==void 0?t:0)===0;return e.endPoint&&!a?(o.alignmentPoint.copy(e.endPoint),o.hasAlignmentPoint=!0):(o.alignmentPoint.copy(e.startPoint),o.hasAlignmentPoint=!1),o.rotation=e.rotation,o.oblique=(n=e.obliqueAngle)!==null&&n!==void 0?n:0,o.thickness=e.thickness,o.horizontalMode=e.halign,o.verticalMode=e.valign,o.widthFactor=(i=e.xScale)!==null&&i!==void 0?i:1,o},r.prototype.convertArcAlignedText=function(e){var t=new MA;return t.textString=e.text,t.textSize=e.textSize,t.xScale=e.xScale>0?e.xScale:1,t.characterSpacing=e.characterSpacing,e.styleName&&(t.styleName=e.styleName),t.fontName=e.fontName,t.bigFontName=e.bigFontName,t.offsetFromArc=e.offsetFromArc,t.rightOffset=e.rightOffset,t.leftOffset=e.leftOffset,t.center=new D(e.center.x,e.center.y,e.center.z),t.radius=e.radius,t.startAngle=e.startAngle,t.endAngle=e.endAngle,t.normal=new X(e.extrusionDirection.x,e.extrusionDirection.y,e.extrusionDirection.z||1),t.characterSet=e.characterSet,t.pitchAndFamily=e.pitchAndFamily,t.isShx=e.isShx,t.isBold=e.isBold,t.isItalic=e.isItalic,t.isUnderlined=e.isUnderlined,t.alignment=e.alignment,t.isReverse=e.isReverse,t.wizardFlag=e.wizardFlag,t.textPosition=e.textPosition,t.textDirection=e.textDirection,e.arcHandle&&(t.arcId=e.arcHandle),t},r.prototype.convertTolerance=function(e){var t,n=new HA;return n.location.copy(e.insertionPoint),n.text=e.text,n.dimensionStyle=(t=e.styleName)!==null&&t!==void 0?t:"",e.extrusionDirection&&n.normal.copy(e.extrusionDirection),e.xAxisDirection&&n.direction.copy(e.xAxisDirection),n},r.prototype.convertMText=function(e){var t=new oc;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.textHeight,t.width=e.rectWidth,t.rotation=e.rotation||0,t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new X(e.direction)),t.drawingDirection=e.drawingDirection,e.lineSpacing!=null&&e.lineSpacing>0&&(t.lineSpacingFactor=e.lineSpacing),e.lineSpacingStyle!=null&&(t.lineSpacingStyle=e.lineSpacingStyle),e.extentsWidth!=null&&e.extentsWidth>0&&(t.extentsWidth=e.extentsWidth),t},r.prototype.convertLeader=function(e){var t,n=new $A;return e.vertices.forEach(function(i){n.appendVertex(i)}),n.hasArrowHead=e.isArrowheadEnabled,n.hasHookLine=e.isHooklineExists,n.isHookLineSameDirection=e.isHooklineSameDirection,n.isSplined=e.isSpline,n.dimensionStyle=(t=e.styleName)!==null&&t!==void 0?t:"",n.annoType=e.leaderCreationFlag,e.textHeight!=null&&(n.textHeight=e.textHeight),e.textWidth!=null&&(n.textWidth=e.textWidth),e.byBlockColor!=null&&(n.byBlockColor=e.byBlockColor),e.associatedAnnotation&&(n.associatedAnnotation=e.associatedAnnotation),e.normal&&(n.normal=e.normal),e.horizontalDirection&&(n.horizontalDirection=e.horizontalDirection),e.offsetFromBlock&&(n.offsetFromBlock=e.offsetFromBlock),e.offsetFromAnnotation&&(n.offsetFromAnnotation=e.offsetFromAnnotation),n},r.prototype.convertMLine=function(e){var t,n,i,o=new fy;return o.styleName=e.mlineStyle||"STANDARD",o.scale=e.scale,o.flags=e.flags,o.justification=e.justification,o.startPosition=e.startPoint,o.normal=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,o.styleCount=(n=e.numberOfLines)!==null&&n!==void 0?n:0,o.segments=((i=e.vertices)!==null&&i!==void 0?i:[]).map(function(a){var s;return{position:a.vertex,direction:a.vertexDirection,miterDirection:a.miterDirection,elements:((s=a.lines)!==null&&s!==void 0?s:[]).map(function(l){var c,u;return{parameterCount:l.numberOfSegmentParams,parameters:(c=l.segmentParams)!==null&&c!==void 0?c:[],fillCount:l.numberOfAreaFillParams,fillParameters:(u=l.areaFillParams)!==null&&u!==void 0?u:[]}})}}),o},r.prototype.convertMLeader=function(e){var t,n,i,o,a,s,l,c,u,h,d,f,p,m,g,y,v=new XA,x=e;v.version=e.version,v.leaderStyleId=e.leaderStyleId,e.leaderStyleId&&(v.mleaderStyleId=e.leaderStyleId),v.propertyOverrideFlag=e.propertyOverrideFlag,v.leaderLineType=(t=e.leaderLineType)!==null&&t!==void 0?t:Ui.StraightLeader,e.leaderLineColor!=null&&(v.leaderLineColor=this.convertMLeaderEntityColor(e.leaderLineColor)),v.leaderLineTypeId=e.leaderLineTypeId,v.leaderLineWeight=e.leaderLineWeight,v.landingEnabled=e.landingEnabled,v.doglegEnabled=(n=e.doglegEnabled)!==null&&n!==void 0?n:!1,v.doglegLength=(i=e.doglegLength)!==null&&i!==void 0?i:0,v.arrowheadId=e.arrowheadId,v.arrowheadSize=e.arrowheadSize,v.textStyleId=e.textStyleId,v.textLeftAttachmentType=e.textLeftAttachmentType,v.textRightAttachmentType=e.textRightAttachmentType,v.textAngleType=e.textAngleType,v.textAlignmentType=e.textAlignmentType,e.textColor!=null&&(v.textColor=this.convertMLeaderEntityColor(e.textColor)),v.textFrameEnabled=e.textFrameEnabled,v.landingGap=e.landingGap,v.textAttachment=e.textAttachment,v.textFlowDirection=e.textFlowDirection,this.isValidHandleId(e.blockContentId)&&(v.blockContentId=e.blockContentId),e.blockContentColor!=null&&(v.blockContentColor=this.convertMLeaderEntityColor(e.blockContentColor)),v.blockContentRotation=e.blockContentRotation,v.blockContentConnectionType=e.blockContentConnectionType,v.annotativeScaleEnabled=e.annotativeScaleEnabled,v.arrowheadOverrides=e.arrowheadOverrides?e.arrowheadOverrides.map(function(le){return nf({},le)}):[],v.blockAttributes=e.blockAttributes?e.blockAttributes.map(function(le){return nf({},le)}):[],v.textDirectionNegative=e.textDirectionNegative,v.textAlignInIPE=e.textAlignInIPE,v.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection,v.topTextAttachmentDirection=e.topTextAttachmentDirection,v.contentScale=e.contentScale,v.textLineSpacingStyle=e.textLineSpacingStyle,e.textBackgroundColor!=null&&(v.textBackgroundColor=this.convertMLeaderEntityColor(e.textBackgroundColor)),v.textBackgroundScaleFactor=e.textBackgroundScaleFactor,v.textBackgroundTransparency=e.textBackgroundTransparency,v.textBackgroundColorOn=e.textBackgroundColorOn,v.textFillOn=e.textFillOn,v.textColumnType=e.textColumnType,v.textUseAutoHeight=e.textUseAutoHeight,v.textColumnWidth=e.textColumnWidth,v.textColumnGutterWidth=e.textColumnGutterWidth,v.textColumnFlowReversed=e.textColumnFlowReversed,v.textColumnHeight=e.textColumnHeight,v.textUseWordBreak=e.textUseWordBreak,v.hasMText=e.hasMText,v.hasBlock=e.hasBlock,v.planeNormalReversed=e.planeNormalReversed,e.blockContentScale&&(v.blockContentScale=new X(e.blockContentScale)),e.contentBasePosition&&(v.contentBasePosition=new D().copy(e.contentBasePosition)),e.textAnchor&&(v.textAnchor=new D().copy(e.textAnchor)),e.planeOrigin&&(v.planeOrigin=new D().copy(e.planeOrigin)),e.planeXAxisDirection&&(v.planeXAxisDirection=new X(e.planeXAxisDirection)),e.planeYAxisDirection&&(v.planeYAxisDirection=new X(e.planeYAxisDirection));var b=x.textContent,w=b&&typeof b=="object"?b:void 0,_=typeof b=="string"&&b.length>0||this.readString(w??{},["text","contents"])!=null||this.readString(x,["text","contents","mtext"])!=null,P=(o=e.contentType)!==null&&o!==void 0?o:_?cn.MTextContent:e.blockContent?cn.BlockContent:cn.NoneContent;v.contentType=P;var S=this.readPoint(x,["normal","extrusionDirection"]);S&&(v.normal=S);var E=(a=this.readString(w??{},["styleName","textStyleName","textStyle"]))!==null&&a!==void 0?a:this.readString(x,["textStyleName","textStyle","styleName"]);E&&(v.textStyleName=E);var C=(l=(s=this.readPositiveNumber(w??{},["textHeight","height"]))!==null&&s!==void 0?s:this.readPositiveNumber(x,["textHeight","mtextHeight","textContentHeight"]))!==null&&l!==void 0?l:this.readPositiveNumber(x,["arrowheadSize","contentScale"]);C!=null&&(v.textHeight=C);var k=(c=this.readPositiveNumber(w??{},["textWidth","width"]))!==null&&c!==void 0?c:this.readPositiveNumber(x,["textWidth","mtextWidth","textContentWidth"]);k!=null&&(v.textWidth=k),v.textLineSpacingFactor=(h=(u=this.readNumber(w??{},["lineSpacingFactor","textLineSpacingFactor"]))!==null&&u!==void 0?u:this.readNumber(x,["textLineSpacingFactor"]))!==null&&h!==void 0?h:v.textLineSpacingFactor;var T=(d=this.readNumber(w??{},["lineSpacingStyle","textLineSpacingStyle"]))!==null&&d!==void 0?d:this.readNumber(x,["textLineSpacingStyle"]);T!=null&&(v.textLineSpacingStyle=T);var O=(f=this.readNumber(w??{},["textRotation","rotation"]))!==null&&f!==void 0?f:this.readNumber(x,["textRotation","mtextRotation","textContentRotation"]);O!=null&&(v.textRotation=O);var I=this.readPoint(x,["textDirection","mtextDirection","textDirectionVector"]);I&&(v.textDirection=I);var F=this.readNumber(x,["textAttachmentPoint","attachmentPoint"]);F!=null&&F!==0&&(v.textAttachmentPoint=F);var N=e.textAttachmentDirection;N!=null&&(v.textAttachmentDirection=N);var Y=this.readNumber(x,["textDrawingDirection","drawingDirection"]);Y!=null&&(v.textDrawingDirection=Y);var U=typeof b=="string"?b:(p=this.readString(w??{},["text","contents"]))!==null&&p!==void 0?p:this.readString(x,["text","contents","mtext"]),$=(m=this.readPoint(w??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"]))!==null&&m!==void 0?m:this.readPoint(x,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(U!=null&&$&&(v.mtextContent={text:U,anchorPoint:$}),e.blockContent){var J=e.blockContent,G=e.blockContent.blockContentId;if(this.isValidHandleId(G)){var oe=this.readMLeaderEntityColor(J,["color"]);v.blockContent={blockContentId:G,normal:this.readPoint(J,["normal"]),position:e.blockContent.position,scale:this.readPoint(J,["scale"]),rotation:this.readNumber(J,["rotation"]),color:oe,transformationMatrix:Array.isArray(e.blockContent.transformationMatrix)?e.blockContent.transformationMatrix:[]}}}else this.isValidHandleId(e.blockContentId)&&(v.blockContent={blockContentId:e.blockContentId,scale:e.blockContentScale,rotation:e.blockContentRotation,color:v.blockContentColor,transformationMatrix:[]});return(g=this.readMLeaderLeaders(x))===null||g===void 0||g.forEach(function(le){var Ie;v.addLeader({lastLeaderLinePoint:le.lastLeaderLinePoint,lastLeaderLinePointSet:le.lastLeaderLinePointSet,doglegVector:le.doglegVector,doglegVectorSet:le.doglegVectorSet,doglegLength:(Ie=le.doglegLength)!==null&&Ie!==void 0?Ie:e.doglegLength,breaks:le.breaks,leaderBranchIndex:le.leaderBranchIndex,leaderLines:le.leaderLines})}),v.numberOfLeaders===0&&((y=this.readLeaderLineArray(x))===null||y===void 0||y.forEach(function(le){v.addLeader({doglegLength:e.doglegLength}),v.addLeaderLine(v.numberOfLeaders-1,le)})),v.numberOfLeaders===0&&e.contentBasePosition&&v.addLeader({lastLeaderLinePoint:e.contentBasePosition,lastLeaderLinePointSet:!0,doglegLength:e.doglegLength}),v},r.prototype.convertDimension=function(e){var t,n,i,o,a,s,l,c;if(e.subclassMarker=="AcDbAlignedDimension"){var u=e,h=new _h(u.subDefinitionPoint1,u.subDefinitionPoint2,u.definitionPoint);return u.insertionPoint&&(h.dimBlockPosition={x:u.insertionPoint.x,y:u.insertionPoint.y,z:0}),h.rotation=u.rotationAngle,this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbRotatedDimension"){var u=e,h=new hC(u.subDefinitionPoint1,u.subDefinitionPoint2,u.definitionPoint);return u.insertionPoint&&(h.dimBlockPosition={x:u.insertionPoint.x,y:u.insertionPoint.y,z:0}),h.rotation=u.rotationAngle,this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDb3PointAngularDimension"){var u=e,h=new Cx(u.centerPoint,u.subDefinitionPoint1,u.subDefinitionPoint2,u.definitionPoint);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDb2LineAngularDimension"){var u=e,d=(n=(t=u.definitionPoint)!==null&&t!==void 0?t:u.arcPoint)!==null&&n!==void 0?n:u.subDefinitionPoint2,f=(o=(i=u.centerPoint)!==null&&i!==void 0?i:u.subDefinitionPoint2)!==null&&o!==void 0?o:u.subDefinitionPoint1,p=f??d,m=(s=(a=u.subDefinitionPoint1)!==null&&a!==void 0?a:f)!==null&&s!==void 0?s:d,g=(c=(l=u.subDefinitionPoint2)!==null&&l!==void 0?l:f)!==null&&c!==void 0?c:d;if(!d||!u.name)return null;var h=new Cx(p,m,g,d);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbOrdinateDimension"){var u=e,h=new cC(u.subDefinitionPoint1,u.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbRadialDimension"){var u=e,h=new uC(u.definitionPoint,u.centerPoint,u.leaderLength);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbDiametricDimension"){var u=e,h=new lC(u.definitionPoint,u.centerPoint,u.leaderLength);return this.processDimensionCommonAttrs(e,h),h}return null},r.prototype.processImage=function(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.imageDefId=e.imageDefHandle,t.isClipped=e.clipping>0,t.isShownClipped=(e.flags&4)!==0,t.isImageShown=(e.flags&3)!==0,t.isImageTransparent=(e.flags&8)!==0,e.clippingBoundaryPath.forEach(function(n){t.clipBoundary.push(new re(n))}),t.clipBoundaryType=e.clippingBoundaryType,t.width=Math.sqrt(Math.pow(e.uPixel.x,2)+Math.pow(e.uPixel.y,2)+Math.pow(e.uPixel.z,2))*e.imageSize.x,t.height=Math.sqrt(Math.pow(e.vPixel.x,2)+Math.pow(e.vPixel.y,2)+Math.pow(e.vPixel.z,2))*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)},r.prototype.convertImage=function(e){var t=new Rh;return this.processImage(e,t),t},r.prototype.convertWipeout=function(e){var t=new eC;return this.processImage(e,t),t},r.prototype.convertOleFrame=function(e){var t,n=new o_;if(n.oleVersion=(t=e.flag)!==null&&t!==void 0?t:0,e.binaryData){var i=rh([e.binaryData]);n.loadOleObjectFromDxf(e.dataSize,i)}return n},r.prototype.convertOle2Frame=function(e){var t,n,i,o,a,s=new qA;if(s.oleVersion=(t=e.oleVersion)!==null&&t!==void 0?t:0,s.userType=(n=e.oleClient)!==null&&n!==void 0?n:"",e.leftUpPoint&&s.upperLeftCorner.copy(e.leftUpPoint),e.rightDownPoint&&s.lowerRightCorner.copy(e.rightDownPoint),s.setLockAspect((i=e.lockAspect)!==null&&i!==void 0?i:0),s.oleObjectType=(o=e.oleObjectType)!==null&&o!==void 0?o:io.Embedded,s.tileMode=(a=e.tileModeDescriptor)!==null&&a!==void 0?a:za.ModelSpace,e.binaryData){var l=rh([e.binaryData]);s.loadOleObjectFromDxf(e.dataSize,l)}return s},r.prototype.convertViewport=function(e){var t=new Va;t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,e.targetPoint&&t.viewTarget.copy(e.targetPoint),e.viewTwistAngle!=null&&(t.viewTwistAngle=e.viewTwistAngle);var n=1e-6,i=Math.abs(t.centerPoint.x)<n&&Math.abs(t.centerPoint.y)<n,o=t.viewTarget,a=Math.abs(o.x)<n&&Math.abs(o.y)<n,s=Number.isFinite(t.height)&&Number.isFinite(t.viewHeight)&&Math.abs(t.viewHeight-t.height)<n;return i&&a&&s&&t.centerPoint.copy(t.viewCenter),t},r.prototype.convertRay=function(e){var t=new Fh;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t},r.prototype.convertXline=function(e){var t=new py;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t},r.prototype.convertAttributeCommon=function(e,t){var n,i,o,a,s=e.text;t.textString=s.text,t.styleName=s.styleName,t.height=s.textHeight,t.position.copy(s.startPoint);var l=(n=e.alignmentPoint)!==null&&n!==void 0?n:s.endPoint,c=!l||l.x===0&&l.y===0&&((i=l.z)!==null&&i!==void 0?i:0)===0;l&&!c?(t.alignmentPoint.copy(l),t.hasAlignmentPoint=!0):(t.alignmentPoint.copy(s.startPoint),t.hasAlignmentPoint=!1),t.rotation=s.rotation,t.oblique=(o=s.obliqueAngle)!==null&&o!==void 0?o:0,t.thickness=s.thickness,t.horizontalMode=s.halign,t.verticalMode=s.valign,t.widthFactor=(a=s.xScale)!==null&&a!==void 0?a:1,t.tag=e.tag,t.fieldLength=e.fieldLength,t.isInvisible=(e.flags&Zt.Invisible)!==0,t.isConst=(e.flags&Zt.Const)!==0,t.isVerifiable=(e.flags&Zt.Verifiable)!==0,t.isPreset=(e.flags&Zt.Preset)!==0,t.lockPositionInBlock=e.lockPositionFlag,t.isReallyLocked=e.isReallyLocked,t.isMTextAttribute=(e.mtextFlag&mr.MultiLine)!==0,t.isConstMTextAttribute=(e.mtextFlag&mr.ConstMultiLine)!==0},r.prototype.convertAttribute=function(e){var t=new bh;return this.convertAttributeCommon(e,t),t},r.prototype.convertAttributeDefinition=function(e){var t=new kA;return this.convertAttributeCommon(e,t),t.prompt=e.prompt,t},r.prototype.convertBlockReference=function(e){var t=this,n=new rr(e.name);return e.insertionPoint&&n.position.copy(e.insertionPoint),n.scaleFactors.x=e.xScale,n.scaleFactors.y=e.yScale,n.scaleFactors.z=e.zScale,n.rotation=e.rotation,n.normal.copy(e.extrusionDirection),e.columnCount!=null&&(n.columnCount=e.columnCount),e.rowCount!=null&&(n.rowCount=e.rowCount),e.columnSpacing!=null&&(n.columnSpacing=e.columnSpacing),e.rowSpacing!=null&&(n.rowSpacing=e.rowSpacing),e.handle!=null&&(n.objectId=e.handle),e.attribs&&e.attribs.forEach(function(i){var o=t.convert(i);o instanceof bh&&n.appendAttributes(o)}),n},r.prototype.processDimensionCommonAttrs=function(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement},r.prototype.processCommonAttrs=function(e,t){var n,i;t.layer=e.layer||"0",t.objectId=e.handle,e.ownerBlockRecordSoftId!=null&&(t.ownerId=e.ownerBlockRecordSoftId);var o=sC((i=(n=e.extensionDictionary)!==null&&n!==void 0?n:e.ownerDictionaryHardId)!==null&&i!==void 0?i:e.ownerDictionarySoftId);if(o&&(t.extensionDictionary=o),this.applyExtendedData(e,t),e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null||e.colorIndex!=null||e.colorName){var a=new nt;e.color!=null&&a.setRGBValue(e.color),e.colorIndex!=null&&(e.color==null||e.colorIndex===7)&&(a.colorIndex=e.colorIndex),e.colorName&&(a.colorName=e.colorName),t.color=a}if(e.isVisible!=null&&(t.visibility=e.isVisible),e.transparency!=null){var s=new tr;s.method=e.transparencyType,(s.isByBlock||s.isByBlock)&&(s.alpha=e.transparency),t.transparency=s}},r.prototype.applyExtendedData=function(e,t){var n,i,o,a,s,l=e.xdata;if(l){var c=Array.isArray(l)?l:[l];try{for(var u=Bu(c),h=u.next();!h.done;h=u.next()){var d=h.value;if(d!=null&&d.appName){var f=[{code:na.ExtendedDataRegAppName,value:d.appName}];try{for(var p=(o=void 0,Bu((s=d.value)!==null&&s!==void 0?s:[])),m=p.next();!m.done;m=p.next()){var g=m.value;if(g!=null&&typeof g=="object"&&"code"in g&&"value"in g){var y=Number(g.code),v=g.value;if(y===na.ExtendedDataHandle||y>=1e3&&y<=1071){var x=this.normalizeXDataValue(y,v);x!==void 0&&f.push({code:y,value:x})}}}}catch(b){o={error:b}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}t.setImportedXData(f)}}}catch(b){n={error:b}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}},r.prototype.normalizeXDataValue=function(e,t){if(e>=1010&&e<=1013){if(this.isPointLike(t))return{x:t.x,y:t.y,z:typeof t.z=="number"?t.z:0};if(Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number")return{x:t[0],y:t[1],z:typeof t[2]=="number"?t[2]:0};if(typeof t=="number"&&Number.isFinite(t))return t}if(e===na.ExtendedDataBinaryChunk)return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?t:Array.isArray(t)&&t.every(function(n){return typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=255})?Uint8Array.from(t):void 0;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t instanceof Uint8Array)return t;if(this.isPointLike(t))return{x:t.x,y:t.y,z:typeof t.z=="number"?t.z:0}},r.prototype.convertMLeaderEntityColor=function(e){return Wi(e)},r.prototype.readMLeaderEntityColor=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="number"&&Number.isFinite(l))return Wi(l)}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.isValidHandleId=function(e){return e!=null&&e!==""&&e!=="0"},r.prototype.readNumber=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="number"&&Number.isFinite(l))return l}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.readPositiveNumber=function(e,t){var n=this.readNumber(e,t);return n!=null&&n>0?n:void 0},r.prototype.readString=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="string")return l}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.readBoolean=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="boolean")return l;if(typeof l=="number")return l!==0}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.readPoint=function(e,t){var n,i,o;try{for(var a=Bu(t),s=a.next();!s.done;s=a.next()){var l=s.value,c=e[l];if(this.isPointLike(c))return c;if(Array.isArray(c)&&typeof c[0]=="number"&&typeof c[1]=="number")return{x:c[0],y:c[1],z:(o=c[2])!==null&&o!==void 0?o:0}}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},r.prototype.readLeaderLineArray=function(e){var t=this,n=e.leaderLines;if(Array.isArray(n))return n.map(function(a){if(!(!a||typeof a!="object")){var s=a.vertices;return Array.isArray(s)?s.filter(function(l){return t.isPointLike(l)}):void 0}}).filter(function(a){return!!a&&a.length>0});var i=e.vertices;if(Array.isArray(i)){var o=i.filter(function(a){return t.isPointLike(a)});return o.length>0?[o]:void 0}},r.prototype.readMLeaderLeaders=function(e){var t=this,n=e.leaderSections;if(Array.isArray(n)){var i=[];return n.forEach(function(o){if(!(!o||typeof o!="object")){var a=o,s=a.leaderLines,l=Array.isArray(s)?s.reduce(function(m,g){var y=t.readMLeaderLine(g);return y&&m.push(y),m},[]):void 0,c={},u=t.readPoint(a,["lastLeaderLinePoint"]),h=t.readPoint(a,["doglegVector"]),d=t.readNumber(a,["doglegLength"]),f=t.readMLeaderBreaks(a.breaks),p=t.readNumber(a,["leaderBranchIndex"]);u&&(c.lastLeaderLinePoint=u),a.lastLeaderLinePointSet!=null&&(c.lastLeaderLinePointSet=t.readBoolean(a,["lastLeaderLinePointSet"])),h&&(c.doglegVector=h),a.doglegVectorSet!=null&&(c.doglegVectorSet=t.readBoolean(a,["doglegVectorSet"])),d!=null&&(c.doglegLength=d),f&&(c.breaks=f),p!=null&&(c.leaderBranchIndex=p),l&&(c.leaderLines=l),i.push(c)}}),i}},r.prototype.readMLeaderLine=function(e){var t=this;if(!(!e||typeof e!="object")){var n=e,i=n.vertices,o=Array.isArray(i)?i.filter(function(c){return t.isPointLike(c)}):[],a=this.readMLeaderBreaks(n.breaks),s=Array.isArray(n.breakPointIndexes)?n.breakPointIndexes.filter(function(c){return typeof c=="number"}):void 0,l=this.readNumber(n,["leaderLineIndex"]);return o.length>0||a&&a.length>0?{vertices:o,breakPointIndexes:s,leaderLineIndex:l,breaks:a}:void 0}},r.prototype.readMLeaderBreaks=function(e){var t=this;if(Array.isArray(e)){var n=e.map(function(i){if(!(!i||typeof i!="object")){var o=i,a=t.readPoint(o,["start"]),s=t.readPoint(o,["end"]),l=t.readNumber(o,["index"]);if(!(!a||!s)){var c={start:a,end:s};return l!=null&&(c.index=l),c}}}).filter(function(i){return!!i});return n.length>0?n:void 0}},r.prototype.isPointLike=function(e){return!!e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"},r})(),Nu=(function(){function r(){}return r.prototype.convertMLeaderStyle=function(e){var t,n=new ly;return n.unknown1=e.unknown1,e.contentType!=null&&(n.contentType=e.contentType),e.drawMLeaderOrderType!=null&&(n.drawMLeaderOrderType=e.drawMLeaderOrderType),e.drawLeaderOrderType!=null&&(n.drawLeaderOrderType=e.drawLeaderOrderType),e.maxLeaderSegmentPoints!=null&&(n.maxLeaderSegmentPoints=e.maxLeaderSegmentPoints),e.firstSegmentAngleConstraint!=null&&(n.firstSegmentAngleConstraint=e.firstSegmentAngleConstraint),e.secondSegmentAngleConstraint!=null&&(n.secondSegmentAngleConstraint=e.secondSegmentAngleConstraint),e.leaderLineType!=null&&(n.leaderLineType=e.leaderLineType),e.leaderLineColor!=null&&(n.leaderLineColor=Wi(e.leaderLineColor)),n.leaderLineTypeId=e.leaderLineTypeId,e.leaderLineWeight!=null&&(n.leaderLineWeight=e.leaderLineWeight),e.landingEnabled!=null&&(n.landingEnabled=e.landingEnabled),e.landingGap!=null&&(n.landingGap=e.landingGap),e.doglegEnabled!=null&&(n.doglegEnabled=e.doglegEnabled),e.doglegLength!=null&&(n.doglegLength=e.doglegLength),e.description!=null&&(n.description=e.description),n.arrowheadId=e.arrowheadId,e.arrowheadSize!=null&&(n.arrowheadSize=e.arrowheadSize),e.defaultMTextContents!=null&&(n.defaultMTextContents=e.defaultMTextContents),n.textStyleId=e.textStyleId,e.textLeftAttachmentType!=null&&(n.textLeftAttachmentType=e.textLeftAttachmentType),e.textAngleType!=null&&(n.textAngleType=e.textAngleType),e.textAlignmentType!=null&&(n.textAlignmentType=e.textAlignmentType),e.textRightAttachmentType!=null&&(n.textRightAttachmentType=e.textRightAttachmentType),e.textColor!=null&&(n.textColor=Wi(e.textColor)),e.textHeight!=null&&(n.textHeight=e.textHeight),e.textFrameEnabled!=null&&(n.textFrameEnabled=e.textFrameEnabled),e.textAlignAlwaysLeft!=null&&(n.textAlignAlwaysLeft=e.textAlignAlwaysLeft),e.alignSpace!=null&&(n.alignSpace=e.alignSpace),n.blockContentId=e.blockContentId,e.blockContentColor!=null&&(n.blockContentColor=Wi(e.blockContentColor)),e.blockContentScale&&(n.blockContentScale={x:e.blockContentScale.x,y:e.blockContentScale.y,z:(t=e.blockContentScale.z)!==null&&t!==void 0?t:1}),e.blockContentScaleEnabled!=null&&(n.blockContentScaleEnabled=e.blockContentScaleEnabled),e.blockContentRotation!=null&&(n.blockContentRotation=e.blockContentRotation),e.blockContentRotationEnabled!=null&&(n.blockContentRotationEnabled=e.blockContentRotationEnabled),e.blockContentConnectionType!=null&&(n.blockContentConnectionType=e.blockContentConnectionType),e.scale!=null&&(n.scale=e.scale),e.overwritePropertyValue!=null&&(n.overwritePropertyValue=e.overwritePropertyValue),e.annotative!=null&&(n.annotative=e.annotative),e.breakGapSize!=null&&(n.breakGapSize=e.breakGapSize),e.textAttachmentDirection!=null&&(n.textAttachmentDirection=e.textAttachmentDirection),e.bottomTextAttachmentDirection!=null&&(n.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection),e.topTextAttachmentDirection!=null&&(n.topTextAttachmentDirection=e.topTextAttachmentDirection),n.unknown2=e.unknown2,this.processCommonAttrs(e,n),n},r.prototype.convertLayerFilter=function(e){var t,n=new DA;return!((t=e.layerNames)===null||t===void 0)&&t.length&&(n.layerNames=e.layerNames),this.processCommonAttrs(e,n),n},r.prototype.convertLayerIndex=function(e){var t,n,i,o=new RA;return e.timeStamp!=null&&(o.lastUpdatedAt=e.timeStamp,o.lastUpdatedAtU=e.timeStamp),!((t=e.layerNames)===null||t===void 0)&&t.length&&(o.layerNames=e.layerNames),!((n=e.idBufferIds)===null||n===void 0)&&n.length&&(o.idBufferIds=e.idBufferIds),!((i=e.idBufferEntryCounts)===null||i===void 0)&&i.length&&(o.idBufferEntryCounts=e.idBufferEntryCounts),o.isUptoDate=!0,this.processCommonAttrs(e,o),o},r.prototype.convertScale=function(e){var t,n,i,o=new zf;return e.flag!=null&&(o.classVersion=e.flag),o.scaleName=(t=e.name)!==null&&t!==void 0?t:"",o.paperUnits=(n=e.paperUnits)!==null&&n!==void 0?n:1,o.drawingUnits=(i=e.drawingUnits)!==null&&i!==void 0?i:1,o.isUnitScale=!!e.isUnitScale,this.processCommonAttrs(e,o),o},r.prototype.convertDictionaryVar=function(e){var t,n,i=new Sg;return e.schema!=null&&(i.schema=e.schema),i.value=(n=(t=e.value)!==null&&t!==void 0?t:e.strvalue)!==null&&n!==void 0?n:"",this.processCommonAttrs(e,i),i},r.prototype.convertMTextObjectContextData=function(e){var t,n,i,o,a=new e_;return e.classVersion!=null&&(a.classVersion=e.classVersion),a.isDefault=!!e.isDefault,a.scaleId=(n=(t=e.scaleId)!==null&&t!==void 0?t:e.scaleHandle)!==null&&n!==void 0?n:"",e.attachment!=null&&(a.attachmentPoint=e.attachment),e.xAxisDir&&(a.direction=new X(e.xAxisDir.x,e.xAxisDir.y,(i=e.xAxisDir.z)!==null&&i!==void 0?i:0)),e.insertionPoint&&(a.insertionPoint=new D(e.insertionPoint.x,e.insertionPoint.y,(o=e.insertionPoint.z)!==null&&o!==void 0?o:0)),e.definedWidth!=null&&(a.definedWidth=e.definedWidth),e.definedHeight!=null&&(a.definedHeight=e.definedHeight),e.extentsWidth!=null&&(a.extentsWidth=e.extentsWidth),e.extentsHeight!=null&&(a.extentsHeight=e.extentsHeight),e.columnType!=null&&(a.columnType=e.columnType),this.processCommonAttrs(e,a),a},r.prototype.convertXRecord=function(e){var t,n=new cy;return this.processCommonAttrs(e,n),e.extensionDictionary&&(n.extensionDictionary=e.extensionDictionary),n.data=new nh(((t=e.data)!==null&&t!==void 0?t:[]).map(function(i){return{code:Number(i.code),value:i.value}})),n},r.prototype.processCommonAttrs=function(e,t){t.objectId=e.handle,e.ownerHandle!=null&&(t.ownerId=e.ownerHandle)},r})(),K3e=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Zb=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(u){try{c(n.next(u))}catch(h){a(h)}}function l(u){try{c(n.throw(u))}catch(h){a(h)}}function c(u){u.done?o(u.value):i(u.value).then(s,l)}c((n=n.apply(r,e||[])).next())})},Jb=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Ml=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Z3e="*MODEL_SPACE",J3e=(function(r){K3e(e,r);function e(t){t===void 0&&(t={});var n=r.call(this,t)||this;return n.config.useWorker=!0,n.config.parserWorkerUrl||(n.config.parserWorkerUrl="/assets/libredwg-parser-worker.js"),n}return e.prototype.parse=function(t,n){return Zb(this,void 0,void 0,function(){var i,o,a,s;return Jb(this,function(l){switch(l.label){case 0:return i=this.config,o=this.getParserWorkerTimeout(t,n),i.useWorker&&i.parserWorkerUrl?(a=B8({workerUrl:i.parserWorkerUrl,timeout:o,maxConcurrentWorkers:1}),[4,a.execute(t)]):[3,2];case 1:return s=l.sent(),a.destroy(),oh.throwOnWorkerParseFailure(s),[2,s.data];case 2:throw new Error("dwg converter can run in web worker only!")}})})},e.prototype.processLineTypes=function(t,n){var i=this,o=t.tables.LTYPE.entries;o.forEach(function(a){var s={name:a.name,description:a.description,standardFlag:a.standardFlag,totalPatternLength:a.totalPatternLength,pattern:a.pattern},l=new Xl(s);i.processCommonTableEntryAttrs(a,l),n.tables.linetypeTable.add(l)})},e.prototype.processTextStyles=function(t,n){var i=this,o=t.tables.STYLE.entries;o.forEach(function(a){var s={name:a.name,standardFlag:a.standardFlag,fixedTextHeight:a.fixedTextHeight,widthFactor:a.widthFactor,obliqueAngle:a.obliqueAngle,textGenerationFlag:a.textGenerationFlag,lastHeight:a.lastHeight,font:a.font,bigFont:a.bigFont,extendedFont:a.extendedFont},l=new ay(s);i.processCommonTableEntryAttrs(a,l),n.tables.textStyleTable.add(l)}),n.ensureTextStyleDefaults()},e.prototype.processDimStyles=function(t,n){var i=this,o=t.tables.DIMSTYLE.entries;o.forEach(function(a){var s={name:a.name,ownerId:a.ownerHandle,dimpost:a.DIMPOST||"",dimapost:a.DIMAPOST||"",dimscale:a.DIMSCALE,dimasz:a.DIMASZ,dimexo:a.DIMEXO,dimdli:a.DIMDLI,dimexe:a.DIMEXE,dimrnd:a.DIMRND,dimdle:a.DIMDLE,dimtp:a.DIMTP,dimtm:a.DIMTM,dimtxt:a.DIMTXT,dimcen:a.DIMCEN,dimtsz:a.DIMTSZ,dimaltf:a.DIMALTF,dimlfac:a.DIMLFAC,dimtvp:a.DIMTVP,dimtfac:a.DIMTFAC,dimgap:a.DIMGAP,dimaltrnd:a.DIMALTRND,dimtol:a.DIMTOL==null||a.DIMTOL==0?0:1,dimlim:a.DIMLIM==null||a.DIMLIM==0?0:1,dimtih:a.DIMTIH==null||a.DIMTIH==0?0:1,dimtoh:a.DIMTOH==null||a.DIMTOH==0?0:1,dimse1:a.DIMSE1==null||a.DIMSE1==0?0:1,dimse2:a.DIMSE2==null||a.DIMSE2==0?0:1,dimtad:a.DIMTAD,dimzin:a.DIMZIN,dimazin:a.DIMAZIN,dimalt:a.DIMALT,dimaltd:a.DIMALTD,dimtofl:a.DIMTOFL,dimsah:a.DIMSAH,dimtix:a.DIMTIX,dimsoxd:a.DIMSOXD,dimclrd:a.DIMCLRD,dimclre:a.DIMCLRE,dimclrt:a.DIMCLRT,dimadec:a.DIMADEC||0,dimunit:a.DIMUNIT||2,dimdec:a.DIMDEC,dimtdec:a.DIMTDEC,dimaltu:a.DIMALTU,dimalttd:a.DIMALTTD,dimaunit:a.DIMAUNIT,dimfrac:a.DIMFRAC,dimlunit:a.DIMLUNIT,dimdsep:a.DIMDSEP||".",dimtmove:a.DIMTMOVE||0,dimjust:a.DIMJUST,dimsd1:a.DIMSD1,dimsd2:a.DIMSD2,dimtolj:a.DIMTOLJ,dimtzin:a.DIMTZIN,dimaltz:a.DIMALTZ,dimalttz:a.DIMALTTZ,dimfit:a.DIMFIT||0,dimupt:a.DIMUPT,dimatfit:a.DIMATFIT,dimtxsty:Nn,dimldrblk:"",dimblk:a.DIMBLK||"",dimblk1:a.DIMBLK1||"",dimblk2:a.DIMBLK2||"",dimlwd:a.DIMLWD,dimlwe:a.DIMLWE},l=new ua(s);i.processCommonTableEntryAttrs(a,l),n.tables.dimStyleTable.add(l)})},e.prototype.processLayers=function(t,n){var i=this,o=t.tables.LAYER.entries;o.forEach(function(a){var s=new nt;i.applyLibreLayerColor(s,a);var l=new rc({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.off,color:s,isPlottable:a.plotFlag!=0});i.processCommonTableEntryAttrs(a,l),n.tables.layerTable.add(l)})},e.prototype.applyLibreLayerColor=function(t,n){var i=n.colorIndex,o=n.color;i!=null&&i>=1&&i<=255?t.colorIndex=i:i===0?t.colorIndex=0:o!=null&&Number.isFinite(o)?t.setRGBValue(o&16777215):t.colorIndex=256,n.colorName&&(t.colorName=n.colorName)},e.prototype.processViewports=function(t,n){var i=this,o=t.tables.VPORT.entries;o.forEach(function(a){var s,l,c,u,h,d,f=new sy;a.circleSides&&(f.circleSides=a.circleSides),f.standardFlag=a.standardFlag,f.center.copy((s=a.center)!==null&&s!==void 0?s:ME),f.lowerLeftCorner.copy((l=a.lowerLeftCorner)!==null&&l!==void 0?l:z5),f.upperRightCorner.copy((c=a.upperRightCorner)!==null&&c!==void 0?c:j5),a.snapBasePoint&&f.snapBase.copy(a.snapBasePoint),a.snapRotationAngle&&(f.snapAngle=a.snapRotationAngle),a.snapSpacing&&f.snapIncrements.copy(a.snapSpacing),a.majorGridLines&&(f.gridMajor=a.majorGridLines),a.gridSpacing&&f.gridIncrements.copy(a.gridSpacing),a.backgroundObjectId&&(f.backgroundObjectId=a.backgroundObjectId),f.gsView.center.copy((u=a.center)!==null&&u!==void 0?u:ME),f.gsView.viewDirectionFromTarget.copy((h=a.viewDirectionFromTarget)!==null&&h!==void 0?h:U5),f.gsView.viewTarget.copy((d=a.viewTarget)!==null&&d!==void 0?d:V5),a.lensLength&&(f.gsView.lensLength=a.lensLength),a.frontClippingPlane&&(f.gsView.frontClippingPlane=a.frontClippingPlane),a.backClippingPlane&&(f.gsView.backClippingPlane=a.backClippingPlane),a.viewHeight&&(f.gsView.viewHeight=a.viewHeight);var p=a.aspectRatio;p!=null&&Number.isFinite(p)&&p>0&&(f.gsView.aspectRatio=p),a.viewTwistAngle&&(f.gsView.viewTwistAngle=a.viewTwistAngle),a.frozenLayers&&(f.gsView.frozenLayers=a.frozenLayers),a.styleSheet&&(f.gsView.styleSheet=a.styleSheet),a.renderMode&&(f.gsView.renderMode=a.renderMode),a.viewMode&&(f.gsView.viewMode=a.viewMode),a.ucsIconSetting&&(f.gsView.ucsIconSetting=a.ucsIconSetting),a.ucsOrigin&&f.gsView.ucsOrigin.copy(a.ucsOrigin),a.ucsXAxis&&f.gsView.ucsXAxis.copy(a.ucsXAxis),a.ucsYAxis&&f.gsView.ucsYAxis.copy(a.ucsYAxis),a.orthographicType&&(f.gsView.orthographicType=a.orthographicType),a.shadePlotSetting&&(f.gsView.shadePlotSetting=a.shadePlotSetting),a.shadePlotObjectId&&(f.gsView.shadePlotObjectId=a.shadePlotObjectId),a.visualStyleObjectId&&(f.gsView.visualStyleObjectId=a.visualStyleObjectId),a.isDefaultLightingOn&&(f.gsView.isDefaultLightingOn=a.isDefaultLightingOn),a.defaultLightingType&&(f.gsView.defaultLightingType=a.defaultLightingType),a.brightness&&(f.gsView.brightness=a.brightness),a.contrast&&(f.gsView.contrast=a.contrast),a.ambientColor&&(f.gsView.ambientColor=a.ambientColor),i.processCommonTableEntryAttrs(a,f),n.tables.viewportTable.add(f)})},e.prototype.processBlockTables=function(t,n){var i=this,o=t.tables.BLOCK_RECORD.entries;o.forEach(function(a){var s,l=n.tables.blockTable.getAt(a.name);l||(l=new _n,l.name=a.name,l.ownerId=a.ownerHandle,l.layoutId=a.layout,l.flags=_n.sanitizeImportedFlags((s=a.flags)!==null&&s!==void 0?s:0),l.blockInsertUnits=a.insertionUnits,l.explodability=a.explodability,l.blockScaling=a.scalability,l.objectId=a.handle,n.tables.blockTable.add(l)),a.bmpPreview&&(l.previewIcon=rh([a.bmpPreview])),l.origin.copy(a.basePoint),!l.isModelSapce&&a.entities&&a.entities.length>0&&i.processEntitiesInBlock(a.entities,l)})},e.prototype.processBlocks=function(t,n){},e.prototype.processEntitiesInBlock=function(t,n){return Zb(this,void 0,void 0,function(){var i,o,a,s,l,c;return Jb(this,function(u){for(i=new f4,o=t.length,a=[],s=0;s<o;s++)l=t[s],c=i.convert(l),c&&a.push(c);return n.appendEntity(a),[2]})})},e.prototype.processEntities=function(t,n,i,o,a){return Zb(this,void 0,void 0,function(){var s,l,c,u,h,d=this;return Jb(this,function(f){switch(f.label){case 0:return s=new f4,l=[],t.tables.BLOCK_RECORD.entries.forEach(function(p){d.isModelSpace(p.name)&&(l=p.entities)}),c=l.length,u=new IA(c,100-o.value,i),this.config.convertByEntityType&&(l=this.groupAndFlattenByType(l)),h=n.tables.blockTable.modelSpace,[4,u.processChunk(function(p,m){return Zb(d,void 0,void 0,function(){var g,y,v,x,b;return Jb(this,function(w){switch(w.label){case 0:for(g=[],y=p;y<m;y++)v=l[y],x=s.convert(v),x&&g.push(x);return h.appendEntity(g),a?(b=o.value+m/c*(100-o.value),b>100&&(b=100),[4,a(b,"ENTITY","IN-PROGRESS")]):[3,2];case 1:w.sent(),w.label=2;case 2:return[2]}})})})];case 1:return f.sent(),[2]}})})},e.prototype.processClasses=function(t,n){var i;!((i=t.classes)===null||i===void 0)&&i.length&&(n.classes=t.classes.map(function(o){return{name:o.dxfName,cppClassName:o.cppName,appName:o.appName,proxyFlag:o.capabilitiesFlag,instanceCount:o.instanceCount,wasProxy:o.wasAProxyFlag,isEntity:o.isAnEntityFlag}}))},e.prototype.processHeader=function(t,n){var i,o,a,s,l,c,u,h,d,f,p,m,g=t.thumbnailImage;g!=null&&g.length&&(n.thumbnailImage=g);var y=t.header;y.CECOLOR&&(y.CECOLOR.index>=0&&y.CECOLOR.index<=256?n.cecolor.colorIndex=y.CECOLOR.index:n.cecolor.setRGBValue(y.CECOLOR.rgb)),n.angbase=(i=y.ANGBASE)!==null&&i!==void 0?i:0,n.angdir=(o=y.ANGDIR)!==null&&o!==void 0?o:0,n.aunits=(a=y.AUNITS)!==null&&a!==void 0?a:0,y.AUPREC!=null&&(n.auprec=y.AUPREC),y.LUNITS!=null&&(n.lunits=y.LUNITS),y.LUPREC!=null&&(n.luprec=y.LUPREC),y.UNITMODE!=null&&(n.unitmode=y.UNITMODE),y.MEASUREMENT!=null&&(n.measurement=y.MEASUREMENT),n.celtype=(s=y.CELTYPE)!==null&&s!==void 0?s:Mr,n.celtscale=(l=y.CELTSCALE)!==null&&l!==void 0?l:1,n.ltscale=(c=y.LTSCALE)!==null&&c!==void 0?c:1,n.tilemode=(u=y.TILEMODE)!==null&&u!==void 0?u:1,y.EXTMAX&&(n.extmax=y.EXTMAX),y.EXTMIN&&(n.extmin=y.EXTMIN),n.insunits=(h=y.INSUNITS)!==null&&h!==void 0?h:1,n.pdmode=(d=y.PDMODE)!==null&&d!==void 0?d:0,n.pdsize=(f=y.PDSIZE)!==null&&f!==void 0?f:0,n.textstyle=(p=y.TEXTSTYLE)!==null&&p!==void 0?p:Nn;var v=(m=this.normalizeHeaderStringValue(y.CMLEADERSTYLE))!==null&&m!==void 0?m:Ns;n.cmleaderstyle=v},e.prototype.processCommonTableEntryAttrs=function(t,n){n.name=t.name,n.objectId=t.handle,t.ownerHandle!=null&&(n.ownerId=t.ownerHandle)},e.prototype.processObjects=function(t,n){this.processScales(t,n),this.processDictionaryVars(t,n),this.processMTextObjectContextData(t,n),this.processXRecords(t,n),this.processLayouts(t,n),this.processImageDefs(t,n),this.processLayerFilters(t,n),this.processLayerIndexes(t,n),this.processLayerFilterTree(t,n),this.processMLeaderStyles(t,n),this.processDynBlockMetadata(t,n),this.finishCannoscale(t,n)},e.prototype.processDynBlockMetadata=function(t,n){var i,o,a,s,l=function(y){return y==null||y===""||y===0?"":String(y).trim().toUpperCase()};try{for(var c=Ml(t.tables.BLOCK_RECORD.entries),u=c.next();!u.done;u=c.next()){var h=u.value,d=n.tables.blockTable.getAt(h.name);if(d){var f=h,p=sC((s=(a=f.extensionDictionary)!==null&&a!==void 0?a:f.ownerDictionaryHardId)!==null&&s!==void 0?s:f.ownerDictionarySoftId);p&&(d.extensionDictionary=p)}}}catch(y){i={error:y}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}var m=t.objects.DICTIONARY;if(m!=null&&m.length){var g=m.map(function(y){var v,x=[],b=(v=y.entries)!==null&&v!==void 0?v:{};for(var w in b){var _=b[w];w&&_&&x.push({name:w,handle:l(String(_))})}return{handle:l(y.handle),ownerHandle:l(y.ownerHandle)||void 0,entries:x}});M8(n,{dictionaries:g,representationData:[]})}},e.prototype.processLayerFilterTree=function(t,n){var i=t.objects.DICTIONARY,o=t.objects.XRECORD;if(!(!(i!=null&&i.length)||!(o!=null&&o.length))){var a=function(u){return u?String(u).trim().toUpperCase():""},s=new Map;i.forEach(function(u){var h,d={},f=(h=u.entries)!==null&&h!==void 0?h:{};for(var p in f){var m=f[p];p&&m&&(d[p]=a(String(m)))}s.set(a(u.handle),{handle:a(u.handle),ownerObjectId:a(u.ownerHandle),entries:d})});var l=new Map;o.forEach(function(u){var h;l.set(a(u.handle),{handle:a(u.handle),ownerObjectId:a(u.ownerHandle),extensionDictionaryId:a(u.extensionDictionary),data:((h=u.data)!==null&&h!==void 0?h:[]).map(function(d){return{code:Number(d.code),value:d.value}})})});var c=OA({dictionaries:s,xrecords:l});c.root.getNestedFilters().length>0&&(n.layerFilters=c)}},e.prototype.processLayouts=function(t,n){var i=this,o=n.objects.layout,a=t.objects.LAYOUT;a.forEach(function(s){var l,c,u=new ec;u.layoutName=s.layoutName,u.tabOrder=s.tabOrder;var h=n.tables.blockTable.newIterator();u.objectId=s.handle;try{for(var d=Ml(h),f=d.next();!f.done;f=d.next()){var p=f.value;if(p.layoutId===u.objectId){u.blockTableRecordId=p.objectId;break}}}catch(m){l={error:m}}finally{try{f&&!f.done&&(c=d.return)&&c.call(d)}finally{if(l)throw l.error}}u.blockTableRecordId||s.layoutName==="Model"&&(u.blockTableRecordId=n.tables.blockTable.modelSpace.objectId),u.limits.min.copy(s.minLimit),u.limits.max.copy(s.maxLimit),u.extents.min.copy(s.minExtent),u.extents.max.copy(s.maxExtent),s.viewportId&&u.viewportArray.push(s.viewportId),i.processCommonObjectAttrs(s,u),o.setAt(u.layoutName,u)})},e.prototype.processImageDefs=function(t,n){var i=this,o=n.objects.imageDefinition,a=t.objects.IMAGEDEF;a.forEach(function(s){var l=new t_;l.sourceFileName=s.fileName,i.processCommonObjectAttrs(s,l),o.setAt(l.objectId,l)})},e.prototype.processLayerFilters=function(t,n){var i=t.objects.LAYER_FILTER;if(i!=null&&i.length){var o=n.objects.layerFilter,a=new Nu;i.forEach(function(s){var l=a.convertLayerFilter(s);o.setAt(l.objectId,l)})}},e.prototype.processLayerIndexes=function(t,n){var i=t.objects.LAYER_INDEX;if(i!=null&&i.length){var o=n.objects.layerIndex,a=new Nu;i.forEach(function(s){var l=a.convertLayerIndex(s);o.setAt(l.objectId,l)})}},e.prototype.processMLeaderStyles=function(t,n){var i=t.objects.MLEADERSTYLE;if(i!=null&&i.length){var o=n.objects.mleaderStyle,a=new Nu;i.forEach(function(s){var l=a.convertMLeaderStyle(s);o.setAt(l.objectId,l)})}},e.prototype.processScales=function(t,n){var i,o,a=this.optionalObjectArray(t,"SCALE");if(a!=null&&a.length){var s=n.objects.scale,l=new Nu;try{for(var c=Ml(a),u=c.next();!u.done;u=c.next()){var h=u.value,d=l.convertScale(h),f=d.scaleName||d.objectId;f&&s.setAt(f,d)}}catch(p){i={error:p}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}}},e.prototype.processDictionaryVars=function(t,n){var i,o,a=this.optionalObjectArray(t,"DICTIONARYVAR");if(a!=null&&a.length){var s=n.objects.dictionaryVar,l=new Nu;try{for(var c=Ml(a),u=c.next();!u.done;u=c.next()){var h=u.value,d=l.convertDictionaryVar(h);d.objectId&&s.setAt(d.objectId,d)}}catch(f){i={error:f}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}}},e.prototype.processMTextObjectContextData=function(t,n){var i,o,a,s=(a=this.optionalObjectArray(t,"MTEXTOBJECTCONTEXTDATA"))!==null&&a!==void 0?a:this.optionalObjectArray(t,"ACDB_MTEXTOBJECTCONTEXTDATA_CLASS");if(s!=null&&s.length){var l=n.objects.objectContextData,c=new Nu;try{for(var u=Ml(s),h=u.next();!h.done;h=u.next()){var d=h.value,f=c.convertMTextObjectContextData(d);f.objectId&&l.setAt(f.objectId,f)}}catch(p){i={error:p}}finally{try{h&&!h.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}}},e.prototype.processXRecords=function(t,n){var i,o,a=t.objects.XRECORD;if(a!=null&&a.length){var s=n.objects.xrecord,l=new Nu;try{for(var c=Ml(a),u=c.next();!u.done;u=c.next()){var h=u.value,d=l.convertXRecord(h);d.objectId&&s.setAt(d.objectId,d)}}catch(f){i={error:f}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}}},e.prototype.finishCannoscale=function(t,n){var i,o,a,s,l=function(y){var v=y.getAt("CANNOSCALE");return v instanceof Sg&&v.value?(n.cannoscale=v.value,!0):!1},c=n.objects.dictionary.getAt("AcDbVariableDictionary");if(!(c instanceof hn&&l(c))){var u=function(y){return y==null||y===""||y===0?"":String(y).trim().toUpperCase()};try{for(var h=Ml((a=t.objects.DICTIONARY)!==null&&a!==void 0?a:[]),d=h.next();!d.done;d=h.next()){var f=d.value,p=(s=f.entries)!==null&&s!==void 0?s:{},m=p.AcDbVariableDictionary;if(m){var g=n.getObjectById(u(m));if(g instanceof hn&&l(g)){try{n.objects.dictionary.getAt("AcDbVariableDictionary")||n.objects.dictionary.setAt("AcDbVariableDictionary",g)}catch{}return}}}}catch(y){i={error:y}}finally{try{d&&!d.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}}},e.prototype.optionalObjectArray=function(t,n){var i=t.objects,o=i[n];return Array.isArray(o)?o:void 0},e.prototype.processCommonObjectAttrs=function(t,n){n.objectId=t.handle,t.ownerHandle!=null&&(n.ownerId=t.ownerHandle)},e.prototype.groupAndFlattenByType=function(t){var n,i,o,a,s={},l=[];try{for(var c=Ml(t),u=c.next();!u.done;u=c.next()){var h=u.value;s[h.type]||(s[h.type]=[],l.push(h.type)),s[h.type].push(h)}}catch(v){n={error:v}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}var d=[];try{for(var f=Ml(l),p=f.next();!p.done;p=f.next())for(var m=p.value,g=s[m],y=0;y<g.length;y++)d.push(g[y])}catch(v){o={error:v}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}return d},e.prototype.isModelSpace=function(t){return t&&t.toUpperCase()==Z3e},e.prototype.normalizeHeaderStringValue=function(t){if(typeof t=="string"){var n=t.trim();return n.length>0?n:void 0}},e})(Yw);const Q3e=12e4;async function eDe(r=Q3e){const e=W.instance.curView;if(!(e instanceof Ow))return;await e.waitUntilIdle(r)||console.warn("[cad-simple-viewer-cli] Timed out waiting for scene idle; continuing"),await ou()}let p4=!1;const qk=[],Kk=[];let Zk;const m4=new Map;function tDe(){const r=URL.createObjectURL.bind(URL);URL.createObjectURL=e=>{const t=r(e);return e instanceof Blob&&m4.set(t,e),t},document.addEventListener("click",e=>{const t=e.target;if(!(t instanceof Element))return;const n=t.closest("a");if(!(n instanceof HTMLAnchorElement)||!n.hasAttribute("download"))return;const i=n.getAttribute("href")||n.href,o=n.download||"download.bin";if(!i)return;e.preventDefault(),e.stopImmediatePropagation();const a=(async()=>{let s=m4.get(i);if(!s&&i.startsWith("data:")&&(s=await(await fetch(i)).blob()),!s){const u=await fetch(i);if(!u.ok)throw new Error(`Failed to fetch download "${o}"`);s=await u.blob()}if(!Zk)throw new Error("CLI save endpoint not configured");const l=performance.now(),c=await fetch(`${Zk}${encodeURIComponent(o)}`,{method:"POST",body:s});if(!c.ok)throw new Error(`Failed to save download "${o}" (${c.status})`);console.log(`[cad-simple-viewer-cli] saved ${o}: ${(performance.now()-l).toFixed(0)} ms (${s.size} bytes)`),qk.push({fileName:o})})().catch(s=>{throw console.error("[cad-simple-viewer-cli] Failed to capture download",s),s});Kk.push(a)},!0)}function nDe(r){return r==="write"?st.Write:st.Read}function rDe(r){if(r==="extents")return aa.Extents;if(r==="saved")return aa.Saved}function iDe(r){const e={mode:nDe(r.mode),progressiveRendering:!1,convertInvisibleLayers:!0,convertAllLayouts:!0,skipSpatialIndex:!0,cooperativeYield:!1},t=rDe(r.openViewMode);return t!=null&&(e.openViewMode=t),r.drawNoPlotLayers!=null&&(e.drawNoPlotLayers=r.drawNoPlotLayers),r.circleSides!=null&&(e.circleSides=r.circleSides),e}function oDe(r){if(!r)return;const e=r.trim().toLowerCase();if(e==="en"||e==="zh"||e==="tr"||e==="cs")return e}function aDe(){const r=dI.getLastSnapshot();if(!r)return;const e=[`[cad-simple-viewer-cli] OPENPROF total=${r.totalMs.toFixed(0)}ms read=${r.readMs.toFixed(0)}ms convert=${r.convertMs.toFixed(0)}ms parse=${r.parseMs.toFixed(0)}ms entity=${r.entityMs.toFixed(0)}ms`,`[cad-simple-viewer-cli] OPENPROF cache hits=${r.cache.topLevel.hits} misses=${r.cache.topLevel.misses} clone=${r.cache.topLevel.cloneMs.toFixed(0)}ms build=${r.cache.topLevel.missBuildMs.toFixed(0)}ms compact=${r.cache.topLevel.missCompactMs.toFixed(0)}ms`];if(r.convertPhase){const t=r.convertPhase;e.push(`[cad-simple-viewer-cli] OPENPROF convertPhase finishGeometry=${t.finishGeometryMs.toFixed(0)}ms asyncDraw=${t.finishGeometryAsyncDrawMs.toFixed(0)}ms queueWait=${t.finishGeometryQueueWaitMs.toFixed(0)}ms handleGroup=${t.handleGroupMs.toFixed(0)}ms addEntity=${t.addEntityMs.toFixed(0)}ms awaitFonts=${t.awaitFontsMs.toFixed(0)}ms glyphs=${t.glyphEntityCount} mtext=${t.mtextCount} shape=${t.shapeCount} sharedGlyph=${t.sharedGlyphDrawCount}`)}try{const t=r.mtextProfile??bn.getInstance().getTextRenderProfile()??Dt.snapshot(),n="[cad-simple-viewer-cli]";if(e.push(`${n} mtextProfile.enabled=${String(t==null?void 0:t.enabled)} drawCount=${(t==null?void 0:t.drawCount)??0} placedChars=${(t==null?void 0:t.placedChars)??0} triangulateMs=${((t==null?void 0:t.triangulateMs)??0).toFixed(1)} mergeMeshMs=${((t==null?void 0:t.mergeMeshMs)??0).toFixed(1)} parseLayoutMs=${((t==null?void 0:t.parseLayoutMs)??0).toFixed(1)}`),t)for(const i of Dt.formatReport(t))e.push(`${n} ${i.trimStart()}`)}catch(t){e.push(`[cad-simple-viewer-cli] mtextProfile error: ${t instanceof Error?t.message:String(t)}`)}for(const t of e)console.log(t)}async function sDe(r={}){if(p4)return;tDe();const e=document.getElementById("cad-root"),t=`./workers/${vOe}`;BA.instance.register(go.DWG,new J3e({convertByEntityType:!1,useWorker:!0,parserWorkerUrl:t}));const n=r.useMainThreadDraw!==!1;W.createInstance({container:e,width:1280,height:720,autoResize:!1,...r.baseUrl?{baseUrl:r.baseUrl}:{},useMainThreadDraw:n,webworkerFileUrls:{dwgParser:t,mtextRender:`./workers/${fG}`}}),r.meshFontRenderMode&&bn.getInstance().setMeshFontRenderMode(r.meshFontRenderMode),r.meshGlyphInstancing===!1&&bn.getInstance().setMeshGlyphInstancing(!1),globalThis.__MTEXTPROF__=!0,Dt.setEnabled(!0),Dt.reset(),bn.getInstance().setTextRenderProfilerEnabled(!0);const i=W.instance.pluginManager;BG(i,{viewerRuntimeUrl:"./viewer-runtime.iife.js"}),jG(i),q3e(i),p4=!0}window.runCadScript=async(r,e,t,n={})=>{await sDe(n),qk.length=0,Kk.length=0,Zk=n.saveBaseUrl;const i=oDe(n.locale);i&&M.setCurrentLocale(i);const o=W.instance,a=!!(e&&r),s=iDe(n);try{Lt.instance().setVar(ae.OPENPROF,!0,o.curDocument.database)}catch{}const l=performance.now(),c=Date.now();if(a){const h=performance.now(),d=await fetch(e);if(!d.ok)throw new Error(`Failed to fetch drawing "${r}" (${d.status}).`);const f=await d.arrayBuffer();if(console.log(`[cad-simple-viewer-cli] fetch drawing: ${(performance.now()-h).toFixed(0)} ms (${f.byteLength} bytes)`),!await o.openDocument(r,f,s))throw new Error(`Failed to open "${r}".`)}else if(n.startBlank!==!1&&!await o.newDocument({...s,mode:st.Write}))throw new Error("Failed to create a blank drawing.");await eDe(),console.log(`[cad-simple-viewer-cli] open+idle: ${(performance.now()-l).toFixed(0)} ms`);for(let h=0;h<60;h++){const d=dI.getLastSnapshot();if(d&&d.collectedAt>=c)break;await new Promise(f=>setTimeout(f,16))}aDe();const u=performance.now();return await o.runScript(t),await Promise.all(Kk),await ou(),console.log(`[cad-simple-viewer-cli] script: ${(performance.now()-u).toFixed(0)} ms`),{ok:!0,files:qk.map(h=>({...h}))}};export{xP as $,ty as A,Y3e as B,Lt as C,ae as D,yb as E,PF as F,MF as G,vt as H,Va as I,Vd as J,At as K,Je as L,hl as M,MV as N,UDe as O,kr as P,Qi as Q,VDe as R,Yt as S,Xt as T,on as U,$n as V,sr as W,it as X,Ga as Y,ai as Z,Yi as _,ou as a,Ae as a0,__e as a1,QA as a2,bh as a3,Bh as a4,ba as a5,tc as a6,Dh as a7,Us as a8,sn as a9,Is as aA,or as aB,Br as aC,V as aD,I7 as aE,Ow as aF,gke as aG,T1e as aH,RG as aI,FG as aJ,Ue as aK,P8 as aL,rr as aM,Na as aN,st as aO,Ht as aP,Nl as aQ,Oy as aR,bn as aS,Ji as aT,NG as aU,zG as aV,my as aa,fC as ab,hy as ac,Fh as ad,py as ae,JA as af,s_ as ag,TA as ah,$A as ai,fy as aj,XA as ak,vh as al,oc as am,qA as an,Rh as ao,a_ as ap,qr as aq,eh as ar,j as as,es as at,Le as au,tn as av,lt as aw,wt as ax,Wl as ay,Pi as az,aH as b,Bt as c,mh as d,tr as e,Bo as f,nt as g,Io as h,fp as i,yg as j,vg as k,ic as l,Qa as m,Sn as n,re as o,Kn as p,D as q,Rj as r,oo as s,Jt as t,M as u,W as v,Tt as w,hr as x,NC as y,X3e as z};
|
|
7820
|
+
`,document.head.appendChild(e)}class t3e{constructor(){this._center=new cE,this._defaultStore=this._center,this._showDefaultUi=!0,this._isCustom=!1}install(e,t={}){var n;this._docManager=e,this._host=t.host,this._showDefaultUi=t.showDefaultUi!==!1,this._placement=t.placement,t.enableBridge!==!1?((n=this._bridge)==null||n.uninstall(),this._bridge=new qOe(e,()=>this.center),this._bridge.install()):this._center.setActiveSession(e.activeSessionId),!this._isCustom&&this._showDefaultUi&&this.mountDefaultUi()}get placement(){return this._placement}setPlacement(e){var t;this._placement=e,(t=this._defaultUi)==null||t.setPlacement(e)}get center(){return this._center}get isCustom(){return this._isCustom}setCenter(e){var t,n;if(e==null){this.restoreDefault();return}this._center!==e&&(this.disposeDefaultUi(),this._isCustom?(n=(t=this._center).dispose)==null||n.call(t):this._defaultStore.dispose(),this._center=e,this._isCustom=!0,this._docManager&&this._center.setActiveSession(this._docManager.activeSessionId))}restoreDefault(){var e,t;if(!this._isCustom){this._showDefaultUi&&!this._defaultUi&&this.mountDefaultUi();return}(t=(e=this._center).dispose)==null||t.call(e),this._defaultStore=new cE,this._center=this._defaultStore,this._isCustom=!1,this._docManager&&this._center.setActiveSession(this._docManager.activeSessionId),this._showDefaultUi&&this.mountDefaultUi()}resolveHost(){var e,t;return this._host?this._host:((t=(e=this._docManager)==null?void 0:e.curView)==null?void 0:t.container)||document.body}mountDefaultUi(){this.disposeDefaultUi(),!(typeof document>"u")&&(this._defaultUi=new ZOe(this._center,this.resolveHost(),{placement:this._placement}))}disposeDefaultUi(){var e;(e=this._defaultUi)==null||e.dispose(),this._defaultUi=void 0}dispose(){var e,t,n;(e=this._bridge)==null||e.uninstall(),this._bridge=void 0,this.disposeDefaultUi(),(n=(t=this._center).dispose)==null||n.call(t),this._defaultStore=new cE,this._center=this._defaultStore,this._isCustom=!1,this._docManager=void 0,this._host=void 0,this._showDefaultUi=!0,this._placement=void 0}}const yG=new t3e;function n3e(r,e){yG.install(r,e)}function r3e(){yG.dispose()}function i3e(r){var e;const t=r.tables.blockTable,n=t.getAt(_n.PAPER_SPACE_NAME_PREFIX);if(n)return n.objectId;const i=(e=r.objects)==null?void 0:e.layout;if(!(i!=null&&i.newIterator))return;const o=t.modelSpace.objectId;let a;for(const s of i.newIterator()){const l=s.blockTableRecordId;if(!l||l===o)continue;const c=t.getIdAt(l);if(!(!c||!_n.isPaperSapceName(c.name))){if(s.tabSelected)return l;a||(a=l)}}return a}function o3e(r){const e=r.tables.blockTable.modelSpace.objectId;if(r.tilemode){r.currentSpaceId!==e&&(r.currentSpaceId=e);return}const t=i3e(r);t&&t!==r.currentSpaceId&&(r.currentSpaceId=t)}const a3e="https://cdn.jsdelivr.net/gh/mlightcad/cad-data",s3e="templates/acadiso.dxf",l3e={ARC:["A"],CIRCLE:["C"],ELLIPSE:["EL"],ERASE:["E"],DIMLINEAR:["DLI"],MEASUREDISTANCE:["DI","DIST"],MEASUREAREA:["AA","AREA"],MEASUREANGLE:["ANG"],"-HATCH":["-H"],IMAGEATTACH:["IAT"],"-INSERT":["I"],XATTACH:["XA"],LAYER:["LA"],"-LAYER":["-LA"],LINE:["L"],MLINE:["ML"],MTEXT:["T"],MOVE:["M"],OFFSET:["O"],COPY:["CO"],ROTATE:["RO"],OPEN:["OP"],PAN:["P"],POINT:["PO"],POLYGON:["POL"],PLINE:["PL"],RAY:["RA"],RECTANG:["REC"],REGEN:["RE"],SELECT:["SE"],SPLINE:["SPL"],XLINE:["XL"],ZOOM:["Z"],UNDO:["U"],REDO:["REDO"],READINGMODE:["RM"]},c3e="modern";class W{constructor(e={}){var t;this._sessions=[],this._nextSessionId=1,this._openFileProfiler=new dI,this._workersReady=null,this._nextOverlayId=1,this._presetFontsForOpenPromise=null,this._lastPresetFontsForOpen=[],this.events={documentToBeOpened:new Ft,documentCreated:new Ft,documentActivated:new Ft,documentToBeActivated:new Ft,documentToBeDestroyed:new Ft,documentDestroyed:new Ft,workersReady:new Ft},this._baseUrl=e.baseUrl??a3e,I1e(e.docsBaseUrl??xT),this._commandAliasOverrides=this.normalizeCommandAliasConfig(e.commandAliases),this._openDocumentDefaults=e.openDocumentDefaults,this._disableExport=e.disableExport===!0,e.useMainThreadDraw?bn.getInstance().setRenderMode("main"):bn.getInstance().setRenderMode("worker"),it.instance.setDefaultFonts(c3e),it.instance.lazyFontLoading=!0,it.instance.awaitFontsBeforeDraw=!0,bn.getInstance().setLazyFontLoading(!0),bn.getInstance().setAwaitFontsBeforeDraw(!0);const n=new lE,i=((t=e.container)==null?void 0:t.getBoundingClientRect())??{width:300,height:150},o=()=>{var u;if(e.autoResize){const h=e.container;if(h)return{width:Math.max(1,Math.floor(h.clientWidth)),height:Math.max(1,Math.floor(h.clientHeight))};const d=(u=e.container)==null?void 0:u.getBoundingClientRect();return{width:Math.max(1,Math.floor((d==null?void 0:d.width)??i.width)),height:Math.max(1,Math.floor((d==null?void 0:d.height)??i.height))}}else return{width:e.width??i.width,height:e.height??i.height}},a=new Ow({container:e.container,calculateSizeCallback:o});this._mainView=a;const s=new dE(a,n);this._activeSession=new aE(`doc-${this._nextSessionId++}`,s),this._sessions=[this._activeSession],Mb(this._activeSession.id),this._fontLoader=new iOe,it.instance.setFontLoader(this._fontLoader.fontLoader);const l=this.resolveFontsBaseUrl();this._fontLoader.baseUrl=l,it.instance.baseUrl=l,bn.getInstance().setFontUrl(l),this.installFontFileLoadTimeout(),$r().workingDatabase=n.database,this._commandManager=new Ga,this.registerCommands(),this._pluginManager=new QLe(this.context,this._commandManager),this._dataSourceManager=new SOe,this._dataSourceManager.register(new uOe),this._dataSourceManager.register(new MOe);const c=e.busyIndicatorHost??a.container;if(this._busyIndicatorHost=c,this._openFileProgress=new yOe(c),this._openFileProgress.setSceneBusyGate(()=>this.openProgressView.isProcessingEntities),this._openFileProgress.setOnHidden(()=>this.onOpenProgressHidden()),this._busyIndicator=new tOe(c),KPe({showMessage:(u,h,d)=>this.editor.showMessage(u,h,d),showBusyIndicator:u=>this.showBusyIndicator(u),hideBusyIndicator:()=>this.hideBusyIndicator(),withBusyIndicator:(u,h)=>this.withBusyIndicator(u,h)}),this.events.documentToBeOpened.addEventListener(()=>{this._openFileProgress.reset()}),this.bindOpenProgress(n),this.events.documentCreated.dispatch({doc:n,mode:n.openMode}),e.preloadDefaultFonts&&this.loadDefaultFonts(),this._webworkerFileUrls=e.webworkerFileUrls,this.registerWorkers(e.webworkerFileUrls),e.checkWorkersOnInit&&this.areWorkersReady(),this.loadPlugins(e.plugins).catch(u=>{Ht.error("[AcApDocManager] Error loading plugins:",u)}),fOe({enabled:e.builtinOpenFileDialog!==!1,getOpenDocumentDefaults:()=>this.resolveOpenDocumentDefaults()}),e.notificationCenter!==!1){const u=typeof e.notificationCenter=="object"?e.notificationCenter:{};n3e(this,{host:u.host,showDefaultUi:u.showDefaultUi!==!1,placement:u.placement,enableBridge:!0})}}static createInstance(e={}){return W._instance==null&&(W._instance=new W(e)),this._instance}static checkWebworkerReadiness(e){return QN(e)}static get instance(){if(!W._instance)throw new Error("AcApDocManager instance is not created yet!");return W._instance}static tryGetInstance(){return W._instance}async destroy(){var e,t;this._mainView.abortConversion(),(e=this._splitView)==null||e.abortConversion(),await this._pluginManager.unloadAllPlugins();for(const n of[...this._sessions])n.context.dispose(),n.doc.destroy(),n.viewState&&this.curView.disposeSessionState(n.viewState);this._sessions=[],(t=this._splitView)==null||t.dispose(),this._splitView=void 0,this._mainView.dispose(),mOe(),r3e(),bn.resetInstance(),xOe(),W._instance=void 0}get workersReady(){return this._workersReady}areWorkersReady(){return this._workersReady===!0?Promise.resolve(!0):(this._workersReadyCheckPromise||(this._workersReadyCheckPromise=QN(this._webworkerFileUrls).then(e=>(this._workersReady=e,this._workersReadyCheckPromise=void 0,this.events.workersReady.dispatch({ready:e}),e)).catch(()=>(this._workersReady=!1,this._workersReadyCheckPromise=void 0,this.events.workersReady.dispatch({ready:!1}),!1))),this._workersReadyCheckPromise)}get context(){return this._activeSession.context}get documents(){return this._sessions.map(e=>e.doc)}get documentCount(){return this._sessions.length}get activeSessionId(){return this._activeSession.id}document(e){var t;return(t=this._sessions[e])==null?void 0:t.doc}sessionFor(e){return this._sessions.find(t=>t.doc===e)}get curDocument(){return this.context.doc}get mdiActiveDocument(){return this._activeSession.doc}async activateDocument(e){const t=this.sessionFor(e);if(!t)return!1;if(t===this._activeSession)return!0;const n=t.context.view,i=this._activeSession.context.view;return this._openingSession&&n===i?!1:(await this._commandManager.cancelActive(),this.events.documentToBeActivated.dispatch({doc:e,mode:e.openMode}),n===i?(this.parkActiveSession(),this._activeSession=t,t.context.resume(),t.viewState&&(this.curView.restoreSessionState(t.viewState),t.viewState=void 0)):(this._activeSession!==this._openingSession&&this._activeSession.context.suspend(),this._activeSession=t,t.context.resume()),Mb(t.id),$r().workingDatabase=e.database,this._pluginManager.setContext(t.context),this.curView.bindDrawDatabase(e.database),this.setActiveLayout(),this.curView.syncDisplaySysVars(e.database),this.events.documentActivated.dispatch({doc:e,mode:e.openMode}),this._openingSession||this.syncProgressOverlayHost(),!0)}get mainView(){return this._mainView}get splitView(){return this._splitView}ensureSplitView(e){return this._splitView?this._splitView.container!==e&&e.appendChild(this._splitView.container):this._splitView=new Ow({container:e,calculateSizeCallback:()=>({width:Math.max(1,e.clientWidth),height:Math.max(1,e.clientHeight)})}),this._splitView}attachSatelliteView(e,t){return this.ensureSplitView(e),!0}detachSatelliteView(){}get satelliteDocument(){var e;if(this._splitView)return(e=this._sessions.find(t=>t.context.view===this._splitView))==null?void 0:e.doc}async closeDocument(e){const t=e??this.curDocument,n=this.sessionFor(t);if(!n)return!1;await this._commandManager.cancelActive(),this.events.documentToBeDestroyed.dispatch({doc:t,mode:t.openMode});const i=n===this._activeSession,o=this._sessions.indexOf(n);if(this._sessions.length===1)return this.resetActiveSessionToUntitled(n),this.events.documentDestroyed.dispatch({doc:t,mode:t.openMode}),this.events.documentCreated.dispatch({doc:this.curDocument,mode:this.curDocument.openMode}),this.events.documentActivated.dispatch({doc:this.curDocument,mode:this.curDocument.openMode}),!0;i&&this.parkActiveSession(),n.context.dispose(),t.destroy(),this.clearSessionOverlays(n),rB(n.id);const a=n.context.view;if(n.viewState?(a.disposeSessionState(n.viewState),n.viewState=void 0):a.clear(),this._sessions.splice(o,1),this.events.documentDestroyed.dispatch({doc:t,mode:t.openMode}),i){const s=this._sessions[Math.min(o,this._sessions.length-1)];await this.activateDocument(s.doc)}return!0}get curView(){return this.context.view}get editor(){return this.context.view.editor}get commandManager(){return this._commandManager}get pluginManager(){return this._pluginManager}get dataSourceManager(){return this._dataSourceManager}get drawStyleSessionAccessory(){return EAe(this._mainView)}get baseUrl(){return this._baseUrl}get disableExport(){return this._disableExport}resolveColors(){const e=this.curDocument.database,t=e.tables.layerTable.getAt(e.clayer),n=this.resolveColorToRgb(t==null?void 0:t.color);let i=e.cecolor;return i!=null&&i.isByLayer&&(i=t==null?void 0:t.color),{entityColor:this.resolveColorToRgb(i),layerColor:n}}resolveColorToRgb(e){return!e||e.isByLayer||e.isByBlock||e.isByACI&&e.colorIndex===7?this.resolveAci7ForBackground():e.RGB??this.resolveAci7ForBackground()}resolveAci7ForBackground(){return this.curView.backgroundColor===16777215?0:16777215}get avaiableFonts(){return this._fontLoader.avaiableFonts}async getAvaiableFonts(){try{return await this._fontLoader.getAvaiableFonts()}catch{return Vt.emit("failed-to-get-avaiable-fonts",{url:this._fontLoader.baseUrl}),[]}}async loadFonts(e){await this._fontLoader.load(e)}async loadDefaultFonts(e){e==null?await this._fontLoader.load([...it.instance.getFontsToLoad()]):await this._fontLoader.load(e)}ensurePresetFontsForOpen(){if(this._presetFontsForOpenPromise)return this._presetFontsForOpenPromise;const e=[...it.instance.getFontsToLoad()];if(this._lastPresetFontsForOpen=e,e.length===0)return this._presetFontsForOpenPromise=Promise.resolve(),this._presetFontsForOpenPromise;const t=bn.getInstance(),n=t.getRenderMode()==="worker"?"worker":"main",i=3e4,o=n==="worker"?t.loadFonts(e,{scope:"all"}).then(()=>{}):it.instance.requestFonts(e).then(()=>{});return this._presetFontsForOpenPromise=new Promise(a=>{const s=setTimeout(()=>{a()},i);o.then(()=>{clearTimeout(s),a()},()=>{clearTimeout(s),a()})}),this._presetFontsForOpenPromise}async awaitPresetFontsReady(){await this.ensurePresetFontsForOpen()}get lastPresetFontsForOpen(){return this._lastPresetFontsForOpen}async openUrl(e,t){t=this.setOptions(t);const n=await this.ensureOpenSession();this.beginOpenProgress(),this.onBeforeOpenDocument(t,!n);try{await this._openFileProgress.beginOpen(this.context.doc.database);const i=await this.context.doc.openUri(e,t);return this.onAfterOpenDocument(i,t),!i&&n&&await this.closeFailedOpenSession(),i}catch(i){throw this._openFileProfiler.cancel(),n&&await this.closeFailedOpenSession(),i}}async openDocument(e,t,n,i){n=this.setOptions(n);const o=await this.ensureOpenSession(i);this.beginOpenProgress(),this.onBeforeOpenDocument(n,!o);try{await this._openFileProgress.beginOpen(this.context.doc.database);const a=await this.context.doc.openDocument(e,t,n);return this.onAfterOpenDocument(a,n),!a&&o&&await this.closeFailedOpenSession(),a}catch(a){throw this._openFileProfiler.cancel(),o&&await this.closeFailedOpenSession(),a}}async loadOverlay(e,t,n={}){var i;const{targetView:o,...a}=n,s=new Uf,l=(i=e.split(".").pop())==null?void 0:i.toLocaleLowerCase();return await ZH(s,async()=>{await s.read(t,{readOnly:!0,...a},l==="dwg"?go.DWG:go.DXF)}),this.registerOverlayDatabase(s,{targetView:o})}async registerOverlayDatabase(e,t){const n=(t==null?void 0:t.targetView)??this.curView,i=await n.addOverlayEntities(e),o=`overlay-${this._nextOverlayId++}`;return(this._sessions.find(a=>a.context.view===n)??this._activeSession).overlays.set(o,{db:e,layout:i}),n.isDirty=!0,o}removeOverlay(e){for(const t of this._sessions){const n=t.overlays.get(e);if(n)return this.sessionCadScene(t).internalScene.remove(n.layout.internalObject),n.layout.clear(),t.overlays.delete(e),t.viewState||(t.context.view.isDirty=!0),!0}return!1}setOverlayVisible(e,t){for(const n of this._sessions){const i=n.overlays.get(e);if(i)return i.layout.visible=t,n.context.view.isDirty=!0,!0}return!1}clearOverlays(e){const t=e?this._sessions.filter(n=>n.context.view===e):this._sessions;for(const n of t)for(const i of[...n.overlays.keys()])this.removeOverlay(i)}getOverlayIds(e){if(!e)return Array.from(this._activeSession.overlays.keys());const t=this._sessions.find(n=>n.context.view===e);return t?Array.from(t.overlays.keys()):[]}get overlayIds(){return this.getOverlayIds()}setCompareDisplay(e,t){(t??this.curView).setCompareDisplay(e)}isReadingModeEnabled(e){return(e??this.curView).readingModeEnabled}setReadingMode(e,t){(t??this.curView).setReadingMode(e)}toggleReadingMode(e){(e??this.curView).toggleReadingMode()}setOverlayCompareDisplay(e,t,n){for(const i of this._sessions){const o=i.overlays.get(e);if(o)return(n??i.context.view??this.curView).setCompareDisplay(t,o.layout),!0}return!1}getOverlayLayout(e){for(const t of this._sessions){const n=t.overlays.get(e);if(n)return n.layout}}async newDocument(e){const t=`${this.baseUrl.endsWith("/")?this.baseUrl:`${this.baseUrl}/`}${s3e}`,n=this.setOptions({...e,mode:st.Write}),i=await this.ensureOpenSession();this.beginOpenProgress(),this.onBeforeOpenDocument(n,!i),await this._openFileProgress.beginOpen(this.context.doc.database);const o=await this.context.doc.openUri(t,n);return o&&this.context.doc.resetNewDocumentIdentity(),this.onAfterOpenDocument(o,n),!o&&i&&await this.closeFailedOpenSession(),o}setOpenDocumentDefaults(e){this._openDocumentDefaults=e,pOe({enabled:!0,getOpenDocumentDefaults:()=>this.resolveOpenDocumentDefaults()})}resolveOpenDocumentDefaults(){const e=this._openDocumentDefaults;return e==null?{minimumChunkSize:1e3}:typeof e=="function"?e():e}regen(){this.curView.clear(),this.context.doc.database.regen()}installFontFileLoadTimeout(){const e=it.instance.loader;if(!e||e.__cadFontLoadTimeout)return;const t=e.loadAsync.bind(e),n=3e4;e.loadAsync=i=>new Promise((o,a)=>{const s=setTimeout(()=>{a(new Error(`Font load timed out after ${n}ms`))},n);t(i).then(l=>{clearTimeout(s),o(l)},l=>{clearTimeout(s),a(l)})}),e.__cadFontLoadTimeout=!0}resolveFontsBaseUrl(){return`${this._baseUrl.endsWith("/")?this._baseUrl:`${this._baseUrl}/`}fonts/`}lookupLocalCmd(e){return this._commandManager.lookupLocalCmd(e,this.curDocument.openMode)}lookupGlobalCmd(e){return this._commandManager.lookupGlobalCmd(e,this.curDocument.openMode)}searchCommandsByPrefix(e){return this._commandManager.searchCommandsByPrefix(e,this.curDocument.openMode)}registerCommands(){const e=this._commandManager,t=(n,i,o)=>{const a=l3e[n.toUpperCase()]??[];e.addCommand(Ga.SYSTEMT_COMMAND_GROUP_NAME,n,i,o,this.resolveCommandAliases(n,a))};t("about","about",new zLe),t("arc","arc",new aCe),t("cachefont","cachefont",new Tw),t("circle","circle",new lCe),t("close","close",new HLe),this._disableExport||(t("bmpout","bmpout",new TAe),t("cdxf","cdxf",new LAe),t("jpgout","jpgout",new OAe),t("pngout","pngout",new DAe)),t("entout","entout",new FAe),t("ellipse","ellipse",new vCe),t("erase","erase",new ILe),t("hideobjects","hideobjects",new LLe),t("dimlinear","dimlinear",new uCe),KIe(t,{view:this._mainView,commandManager:this._commandManager}),t("-hatch","-hatch",new bCe),t("imageattach","imageattach",new kCe),t("-insert","-insert",new ICe),t("xattach","xattach",new KTe),t("-layer","-layer",new nCe),t("laycur","laycur",new VAe),t("laydel","laydel",new UAe),t("layfrz","layfrz",new GAe),t("layiso","layiso",new $Ae),t("laylck","laylck",new XAe),t("layon","layon",new YAe),t("layoff","layoff",new KAe),t("laythw","laythw",new JAe),t("layuniso","layuniso",new QAe),t("layulk","layulk",new eCe),t("layerp","layerp",new ZAe),t("layerclose","layerclose",new tCe),t("line","line",new tf),t("mline","mline",new OCe),t("mtext","mtext",new jCe),t("copy","copy",new TLe),t("move","move",new OLe),t("offset","offset",new Cw),t("rotate","rotate",new FLe),t("log","log",new ULe),t("open","open",new VLe),t("pan","pan",new JLe),t("point","point",new UCe),t("polygon","polygon",new XCe),t("pline","pline",new KCe),t("qnew","qnew",new GLe),t("ray","ray",new JCe),t("rectang","rectang",new sTe),t("regen","regen",new WLe),t("revcloud","revcloud",new TTe),CLe(t,{view:this._mainView,commandManager:this._commandManager}),t("select","select",new $Le),t("sketch","sketch",new FTe),t("spline","spline",new NTe),t("switchbg","switchbg",new YLe),t("readingmode","readingmode",new qLe),t("unisolateobjects","unisolateobjects",new BLe),t("xline","xline",new ZTe),t("undo","undo",new KLe),t("redo","redo",new ZLe),t("zoom","zoom",new cg),Lt.instance().getAllDescriptors().forEach(n=>{e.addCommand(Ga.SYSTEMT_COMMAND_GROUP_NAME,n.name,n.name,new XLe,this.resolveCommandAliases(n.name,[]))})}normalizeCommandAliasConfig(e){const t=new Map;return e&&Object.entries(e).forEach(([n,i])=>{const o=n.trim().toUpperCase();if(!o)return;const a=Array.isArray(i)?i:[i],s=new Set;a.forEach(l=>{const c=l.trim().toUpperCase();c&&c!==o&&s.add(c)}),t.set(o,[...s])}),t}resolveCommandAliases(e,t){const n=e.trim().toUpperCase(),i=this._commandAliasOverrides.get(n);if(i)return[...i];const o=new Set;return t.forEach(a=>{const s=a.trim().toUpperCase();s&&s!==n&&o.add(s)}),[...o]}sendStringToExecute(e){this.executeCommandString(e).catch(t=>{const n=t instanceof Error?t.message:String(t);this.editor.showMessage(n,"error"),Ht.error(`[AcApDocManager] Command failed: ${e}`,t)})}async executeCommandString(e){const t=this.splitCommandScript(e);if(!t.length)throw new Error("Command string is empty");const[n,...i]=t;this.editor.clearScriptInputs(),this.editor.enqueueScriptInputs(i),await this.executeNamedCommand(n,{preserveScriptInputs:!1})}async runScript(e){const t=JN(e);for(this.editor.clearScriptInputs(),this.editor.enqueueScriptInputs(t);this.editor.hasScriptInputs();){const n=this.consumeNextScriptCommandName();if(n==null)break;if(eOe(n)){this.editor.clearScriptInputs();break}await this.executeNamedCommand(n,{preserveScriptInputs:!0})}}async executeNamedCommand(e,t){const n=this.context.doc.openMode;let i=this._commandManager.lookupGlobalCmd(e)??this._commandManager.lookupLocalCmd(e,n);if(i||await this._pluginManager.loadByTrigger(e)&&(i=this._commandManager.lookupGlobalCmd(e)??this._commandManager.lookupLocalCmd(e,n)),!i)throw new Error(`Command '${e}' not found`);if(n<i.mode)throw new Error(`Command '${e}' requires mode '${st[i.mode]}' but document is in mode '${st[n]}'!`);await this._commandManager.cancelActive(),await this._commandManager.runActive(i,this.curView,async()=>{try{await i.trigger(this.context)}finally{t.preserveScriptInputs||this.editor.clearScriptInputs()}})}consumeNextScriptCommandName(){for(;this.editor.hasScriptInputs();){const e=this.editor.consumeScriptInput();if(e==null)return;const t=e.trim();if(t)return t}}splitCommandScript(e){const t=JN(e);if(!t.length)return[];let n=0;for(;n<t.length&&!t[n].trim();)n++;return n>=t.length?[]:[t[n].trim(),...t.slice(n+1)]}setActiveLayout(e,t){const n=e??this.curView,i=t??this.curDocument.database;n.activeLayoutBtrId=i.currentSpaceId,n.modelSpaceBtrId=i.tables.blockTable.modelSpace.objectId}onBeforeOpenDocument(e,t=!0){this.events.documentToBeOpened.dispatch({doc:this.context.doc,mode:this.getDocumentEventMode(e)}),t&&(uh.instance.clearAll(),this.clearOverlays(),hB(),gN(),cg.clearOriginalViews(),this.openProgressView.clear()),this.openProgressView.bindDrawDatabase(this.context.doc.database),this.openProgressView.progressiveRendering=(e==null?void 0:e.progressiveRendering)??!1,this._openFileProgress.setSeeThroughOverlay((e==null?void 0:e.progressiveRendering)??!1),this.openProgressView.convertInvisibleLayers=(e==null?void 0:e.convertInvisibleLayers)===!0,this.openProgressView.cooperativeYield=(e==null?void 0:e.cooperativeYield)!==!1;const n=this.openProgressView.cadScene;n&&(n.skipSpatialIndex=(e==null?void 0:e.skipSpatialIndex)===!0),this.ensurePresetFontsForOpen(),this._openFileProfiler.begin(this.context.doc.database)}onAfterOpenDocument(e,t){const n=!e&&this.hasRecoverablePartialContent();if(e||n){const i=this._openingSession??this._activeSession,o=i.context.view;i.doc.destroy();const a=i.doc,s=a.database;o3e(s),this.setActiveLayout(o,s),o.syncDisplaySysVars(s),this.events.documentActivated.dispatch({doc:a,mode:this.getDocumentEventMode(t)});const l=s.tables.blockTable.modelSpace.objectId,c=s.currentSpaceId!==l,u=$r().layoutManager.getActiveLayout(s),h=u==null?void 0:u.limits,d=this.resolveOpenViewMode(t);o.setOpenViewMode(d);const f=(t==null?void 0:t.progressiveRendering)??!1;let p=!1;const m=()=>{f&&o.beginProgressiveOpenFit(),o.zoomToFitDrawing(),o.requestOpenLineworkFrame()};if(c&&d===aa.Saved){const g=u==null?void 0:u.extents,y=Tk({limits:h,viewportsBox:mke(s,s.currentSpaceId),layoutExtents:g&&!g.isEmpty()?{min:{x:g.min.x,y:g.min.y},max:{x:g.max.x,y:g.max.y}}:void 0});y?(o.zoomTo(y.box),p=!0):m()}else if(!c&&d===aa.Saved){const g=o.width/Math.max(o.height,1),y=s.tables.viewportTable.getActiveVportBox(g);y?(o.zoomTo(y),p=!0):m()}else m();o.markLayoutAsInitialized(s.currentSpaceId),p&&cg.rememberOriginalView(o,s.currentSpaceId),t!=null&&t.convertAllLayouts&&o.ensureEntitiesConvertedForExport({includeInvisibleLayers:t.convertInvisibleLayers!==!1,includeLayouts:!0}).catch(g=>{Ht.error("[AcApDocManager] convertAllLayouts export convert failed",g)}),this._openFileProfiler.markReadCompleteAndScheduleReport(o)}else this._openFileProfiler.cancel(),this.openProgressView.endProgressiveOpenFit(),this.regen()}hasRecoverablePartialContent(){const e=(this._openingSession??this._activeSession).doc.database,t=e.tables.blockTable.modelSpace;return t?t.newIterator().count>0:!e.extents.isEmpty()}setOptions(e){return e==null?e={drawNoPlotLayers:!1,progressiveRendering:!1}:(this.stripObsoleteFontOpenOptions(e),this.stripDeprecatedWaitForTextGeometry(e),e.drawNoPlotLayers==null&&(e.drawNoPlotLayers=!1),e.progressiveRendering==null&&(e.progressiveRendering=!1)),e}stripDeprecatedWaitForTextGeometry(e){e.waitForTextGeometry!=null&&(delete e.waitForTextGeometry,console.warn("[AcApDocManager] Ignoring deprecated open option waitForTextGeometry; both stages of progressive rendering are controlled by progressiveRendering."))}stripObsoleteFontOpenOptions(e){const t=e,n=t.fontLoader!=null,i=t.failOnFontLoadError!=null;!n&&!i||(delete t.fontLoader,delete t.failOnFontLoadError,console.warn("[AcApDocManager] Ignoring obsolete open options "+[n?"fontLoader":null,i?"failOnFontLoadError":null].filter(Boolean).join(", ")+"; fonts load on demand via FontManager.lazyFontLoading."))}getDocumentEventMode(e){return(e==null?void 0:e.mode)??st.Read}resolveOpenViewMode(e){return(e==null?void 0:e.openViewMode)!=null?e.openViewMode:this.getDocumentEventMode(e)===st.Write?aa.Saved:aa.Extents}showBusyIndicator(e){this._busyIndicator.show(e)}setBusyIndicatorHost(e){this._busyIndicatorHost=e,this.syncProgressOverlayHost()}get openProgressView(){var e;return((e=this._openingSession)==null?void 0:e.context.view)??this.curView}beginOpenProgress(){this._openingSession=this._activeSession,this.syncProgressOverlayHost()}onOpenProgressHidden(){const e=this._openingSession;this._openingSession=void 0,e&&this._sessions.includes(e)&&e!==this._activeSession&&e.context.suspend(),this.syncProgressOverlayHost()}syncProgressOverlayHost(e=this.openProgressView){const t=this._splitView?e.container:this._busyIndicatorHost;this._openFileProgress.setHost(t),this._busyIndicator.setHost(t)}hideBusyIndicator(){this._busyIndicator.hide()}setBusyIndicatorMessage(e){this._busyIndicator.setMessage(e)}async withBusyIndicator(e,t){return this._busyIndicator.withBusyIndicator(e,t)}registerWorkers(e){const t=bn.getInstance();t.initialize((e==null?void 0:e.mtextRender)??pG.mtextRender),t.setDefaultFonts([...it.instance.defaultFonts])}async loadPlugins(e){if(e){if(e.fromConfig&&e.fromConfig.length>0)try{const t=await this._pluginManager.loadPluginsFromConfig(e.fromConfig,{continueOnError:!0});t.loaded.length>0&&Ht.info(`[AcApDocManager] Loaded ${t.loaded.length} plugin(s) from config:`,t.loaded),t.failed.length>0&&Ht.warn(`[AcApDocManager] Failed to load ${t.failed.length} plugin(s):`,t.failed.map(n=>`${n.name}: ${n.error.message}`))}catch(t){Ht.error("[AcApDocManager] Error loading plugins from config:",t)}if(e.fromFolder)try{const t=await this._pluginManager.loadPluginsFromFolder(e.fromFolder.folderPath,{pluginList:e.fromFolder.pluginList,continueOnError:e.fromFolder.continueOnError??!0});t.loaded.length>0&&Ht.info(`[AcApDocManager] Loaded ${t.loaded.length} plugin(s) from folder:`,t.loaded),t.failed.length>0&&Ht.warn(`[AcApDocManager] Failed to load ${t.failed.length} plugin(s) from folder:`,t.failed.map(n=>`${n.name}: ${n.error.message}`))}catch(t){Ht.error("[AcApDocManager] Error loading plugins from folder:",t)}}}bindOpenProgress(e){e.database.events.openProgress.addEventListener(t=>{if(this._openFileProgress.handle({database:e.database,percentage:t.percentage,stage:t.stage,subStage:t.subStage,subStageStatus:t.subStageStatus,data:t.data}),t.subStage==="STYLE"&&t.subStageStatus==="END"){const o=this._sessions.find(s=>s.doc===e),a=(o==null?void 0:o.context.view)??this.curView;a&&a.startTextStyleFontPreload(e.database)}if(t.subStage!=="HEADER")return;const n=this._sessions.find(o=>o.doc===e),i=(n==null?void 0:n.context.view)??this.curView;i.ltscale=e.database.ltscale,i.celtscale=e.database.celtscale,i.renderer.showLineWeight=e.database.lwdisplay})}parkActiveSession(){this._activeSession.context.suspend(),this._activeSession.viewState=this.curView.captureSessionState()}async ensureOpenSession(e){const t=e??this.curView;if(t===this.curView&&this.curDocument.isReusableUntitled)return!1;const n=this._sessions.find(s=>s.context.view===t);if(n!=null&&n.doc.isReusableUntitled)return n!==this._activeSession&&await this.activateDocument(n.doc),!1;await this._commandManager.cancelActive(),this._activeSession.context.suspend(),t===this.curView&&(this._activeSession.viewState=this.curView.beginNewSession());const i=new lE,o=new dE(t,i),a=new aE(`doc-${this._nextSessionId++}`,o);return this._sessions.push(a),this._activeSession=a,Mb(a.id),$r().workingDatabase=i.database,this._pluginManager.setContext(o),this.bindOpenProgress(i),this.events.documentCreated.dispatch({doc:i,mode:i.openMode}),!0}async closeFailedOpenSession(){this._sessions.length<=1||await this.closeDocument(this.curDocument)}resetActiveSessionToUntitled(e){const t=e.doc,n=e.id;uh.instance.clearAll(),this.clearOverlays(),hB(),gN(),this.curView.clear(),e.context.dispose(),t.destroy(),rB(n);const i=new lE,o=new dE(this.curView,i),a=new aE(`doc-${this._nextSessionId++}`,o);this._sessions=[a],this._activeSession=a,Mb(a.id),$r().workingDatabase=i.database,this._pluginManager.setContext(o),this.bindOpenProgress(i),this.curView.bindDrawDatabase(i.database)}clearSessionOverlays(e){const t=this.sessionCadScene(e);for(const n of e.overlays.values())t.internalScene.remove(n.layout.internalObject),n.layout.clear();e.overlays.clear()}sessionCadScene(e){var t;return((t=e.viewState)==null?void 0:t.scene)??e.context.view.cadScene}}const u3e=Object.freeze(Object.defineProperty({__proto__:null,AcApDocManager:W},Symbol.toStringTag,{value:"Module"}));class Nl{static isFontLoaded(e){return it.instance.isFontLoaded(e)}static getFontType(e){return it.instance.getFontType(e)}static getReplacementFontName(e){return it.instance.findAndReplaceFont(e)}static getShxCodePoints(e){var t;const n=it.instance.getFontByName(e,!1);if(!n||n.type!=="shx")return[];const i=n.data;return Object.keys(((t=i.content)==null?void 0:t.data)??{}).map(o=>Number(o)).filter(o=>Number.isFinite(o)).sort((o,a)=>o-a)}static getLoadedShxFontData(e){const t=it.instance.getFontByName(e,!1);if(!(!t||t.type!=="shx"))return t.data}static createShxParserFont(e){return new NC(e)}static findFontInfoByName(e){var t;const n=((t=W.instance)==null?void 0:t.avaiableFonts)??[],i=e.trim().toLowerCase();if(i)return n.find(o=>o.name.some(a=>a.trim().toLowerCase()===i))}static getCatalogFontType(e){var t;return(t=Nl.findFontInfoByName(e))==null?void 0:t.type}static async ensureDrawingFontLoaded(e){const t=W.instance;t&&(Nl.isFontLoaded(e)||await t.loadFonts([e]))}static async cacheFont(e,t,n,i){return it.instance.cacheFont(e,t,n,i)}static async getCachedMeshFontProgram(e){const t=[e],n=Nl.findFontInfoByName(e);n!=null&&n.file&&t.push(n.file);for(const a of(n==null?void 0:n.name)??[])t.push(a);const i=Nl.getReplacementFontName(e);if(i&&i!==e){t.push(i);const a=Nl.findFontInfoByName(i);a!=null&&a.file&&t.push(a.file);for(const s of(a==null?void 0:a.name)??[])t.push(s)}const o=new Set;for(const a of t){const s=a.trim().toLowerCase();if(!s||o.has(s))continue;o.add(s);const l=await it.instance.getCachedMeshFontProgram(a);if(l&&l.byteLength>0)return new Uint8Array(l)}}static async persistMeshFontProgram(e,t,n){await it.instance.persistMeshFontProgram(e,t,n)}}function h3e(r){const e=[];try{const t=r.tables.textStyleTable;if(e.push(...t.fonts??[]),t.newIterator)for(const n of t.newIterator()){const i=n.textStyle;i!=null&&i.font&&e.push(i.font),i!=null&&i.bigFont&&e.push(i.bigFont),i!=null&&i.extendedFont&&e.push(i.extendedFont)}}catch{return[]}return O0(e)}function d3e(r,e,t){const n=O0([...r]);n.length===0&&t!=null&&t.firstDefaultFont&&n.push(t.firstDefaultFont);const i=new Set(n.map($d)),o=new Set(e.map($d)),a=O0(e.filter(l=>!i.has($d(l))));let s=O0(n.filter(l=>o.has($d(l))));if(s.length===0&&t!=null&&t.firstDefaultFont){const l=$d(t.firstDefaultFont);l&&i.has(l)&&(s=[t.firstDefaultFont])}return s.length>3&&(s=s.slice(0,3)),{critical:n,workerWarm:s,background:a}}function O0(r){const e=new Set,t=[];for(const n of r){if(!n)continue;const i=$d(n);!i||e.has(i)||(e.add(i),t.push(n))}return t}function $d(r){if(r==null)return"";let e=String(r).trim();if(!e)return"";const t=e.lastIndexOf(".");return t>0&&(t===e.length-4||t===e.length-5)&&(e=e.substring(0,t)),e.toLowerCase()}const vG=13,f3e=14,p3e=1,m3e=.5,g3e=.5;let Dd;function y3e(){if(Dd!==void 0)return Dd;if(typeof document>"u")return Dd=null,null;try{Dd=document.createElement("canvas").getContext("2d")}catch{Dd=null}return Dd}function bG(r){return f3e/vG}function xG(r){return p3e/vG}function wG(r,e){return r>0?2*(bG()+xG())*r:0}function v3e(r,e,t){const n=wG(e);if(!(e>0))return n;const i=y3e();if(!i)return r.length*e*.6+n;const o="500",a="sans-serif";return i.font=`${o} ${e}px ${a}`,i.measureText(r).width+n}function b3e(r,e,t,n){if(!(e>0)||!(t>0))return e;const i=m3e,o=t*i,a=v3e(r,e);if(a<=o)return e;if(!(o>0))return 1;const s=Math.max(0,a-wG(e))/e,l=2*(bG()+xG()),c=s+l;return c>0?Math.max(1,o/c):e}function os(r,e,t,n){return e.textHeightMode==="custom"?e.fontSize:b3e(r,e.fontSize,t)}function Oh(r,e,t){const n=r(e),i=r(t);return Math.hypot(i.x-n.x,i.y-n.y)}function fI(r,e,t){return!(e>0)||!(t>0)||t>=e?r:Math.max(1,r*(t/e))}function _G(r,e,t,n){return Math.min(Oh(r,e,t),Oh(r,e,n))*g3e}function pI(r,e,t,n){if(!(t>0)||!(n>0))return 0;const i=r(e),o=r({x:e.x+t,y:e.y});return Math.hypot(o.x-i.x,o.y-i.y)/t*n}function x3e(r,e,t){const n=t.x-e.x,i=t.y-e.y,o=n*n+i*i;if(!(o>0))return Math.hypot(r.x-e.x,r.y-e.y);let a=((r.x-e.x)*n+(r.y-e.y)*i)/o;return a=Math.max(0,Math.min(1,a)),Math.hypot(r.x-(e.x+a*n),r.y-(e.y+a*i))}function SG(r,e){const t=e.length;if(t<3)return 0;let n=1/0;for(let l=0;l<t;l++){const c=e[l],u=e[(l+1)%t];n=Math.min(n,Oh(r,c,u))}let i=0,o=0;for(const l of e)i+=l.x,o+=l.y;i/=t,o/=t;const a=r({x:i,y:o});let s=1/0;for(let l=0;l<t;l++){const c=r(e[l]),u=r(e[(l+1)%t]);s=Math.min(s,x3e(a,c,u))}return Math.min(n,2*s)}const w3e=r=>new _t(r.min,r.max),_3e=r=>new Bt(r.min,r.max),S3e=r=>new Re(r.min,r.max),P3e=r=>new Bt(r.min,r.max),E3e=r=>new RC(r.min,r.max),M3e=r=>new Bt(r.min,r.max),k3e=r=>{const e=new Re;return e.min.set(r.min.x,r.min.y,0),e.max.set(r.max.x,r.max.y,0),e},l4={threeBo2dToGeBox2d:P3e,geBox2dToThreeBox2d:E3e,threeBox3dToGeBox3d:w3e,geBox3dToThreeBox3d:S3e,goBox3dToGeBox2d:_3e,threeBox3dToGeBox2d:M3e,geBox2dToThreeBox3d:k3e};function PG(r,e){if(!e||r.length<2)return r;let t=-1,n=-1;for(let a=0;a<r.length&&(r[a].ownerId===e?t<0&&(t=a):n<0&&(n=a),!(t>=0&&n>=0));a++);if(t<0||n<0||t<n)return r;const i=[],o=[];for(let a=0;a<r.length;a++){const s=r[a];s.ownerId===e?i.push(s):o.push(s)}return i.concat(o)}function A3e(r,e){return{pending:PG(r,e),cursor:0,activeOwnerId:e}}function C3e(r,e,t){if(e.length===0&&t===r.activeOwnerId)return r;const n=r.cursor===0?r.pending:r.pending.slice(r.cursor);if(t!==r.activeOwnerId)return{pending:PG(e.length>0?e.concat(n):n,t),cursor:0,activeOwnerId:t};let i=!1;const o=[],a=[];for(let s=0;s<e.length;s++)t&&e[s].ownerId===t?(i=!0,o.push(e[s])):a.push(e[s]);if(i)return{pending:o.concat(n,a),cursor:0,activeOwnerId:t};for(let s=0;s<a.length;s++)r.pending.push(a[s]);return r}function T3e(r){const{pending:e,cursor:t,activeOwnerId:n}=r;if(!n)return!1;for(let i=t;i<e.length;i++)if(e[i].ownerId===n)return!0;return!1}function I3e(r){const{tookMs:e,budgetMs:t,maxSlice:n,activeLayoutPending:i}=r,o=Math.max(1,r.slice),a=i?2:4;return e<t/2?Math.min(o*a,n):e>t*2?Math.max(1,o>>1):o}class L3e{constructor(e){this.getLayerInfo=e}shouldConvert(e){if(!e.visibility)return!1;const t=this.getLayerInfo(e.layer);return t?this.isBlockReference(e)?!t.isFrozen:rp.isLayerVisible(t):!0}shouldConvertForExport(e,t=!0){return e.visibility?t?!0:this.shouldConvert(e):!1}layerVisibilityMayHaveChanged(e){return e.isOff!==void 0||e.standardFlags!==void 0}collectMissingEntitiesOnLayer(e,t,n){return this.collectMissingEntities(t,n,i=>i.layer===e&&this.shouldConvert(i))}collectMissingEntitiesForExport(e,t,n=!0){return this.collectMissingEntities(e,t,i=>this.shouldConvertForExport(i,n))}isBlockReference(e){return e instanceof rr}collectMissingEntities(e,t,n){const i=[],o=e.newIterator();for(const a of o)n(a)&&(t(a.objectId)||i.push(a));return i}}var K_=(r=>(r[r.LEFT_BOTTOM=0]="LEFT_BOTTOM",r[r.LEFT_TOP=1]="LEFT_TOP",r[r.RIGHT_TOP=2]="RIGHT_TOP",r[r.RIGHT_BOTTOM=4]="RIGHT_BOTTOM",r))(K_||{});class O3e extends or{constructor(e,t,n=150,i=2){super(),this.camera=e,this.renderer=t,this.gizmoCamera=new uc(-2,2,2,-2,0,4),this.gizmoCamera.position.set(0,0,2),this.gizmoDim=n,this.gizmoPos=i,this.initialize()}initialize(){}update(){this.updateOrientation();const e=this.renderer.autoClear;this.renderer.autoClear=!1,this.renderer.clearDepth();const t=new Mn;this.renderer.getViewport(t);const n=this.calculateViewportPos();this.renderer.setViewport(n.x,n.y,this.gizmoDim,this.gizmoDim),this.renderer.render(this,this.gizmoCamera),this.renderer.setViewport(t.x,t.y,t.z,t.w),this.renderer.autoClear=e}dispose(){}updateOrientation(){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld()}calculatePosInViewport(e,t,n){const i=(e-n.min.x)/this.gizmoDim*2-1,o=-((t-n.min.y)/this.gizmoDim)*2+1;return{x:i,y:o}}calculateViewportPos(){const e=this.renderer.domElement,t=e.offsetWidth,n=e.offsetHeight,i=this.gizmoPos,o=this.gizmoDim;let a=t-o,s=n-o;switch(i){case 0:a=0,s=0;break;case 1:a=0;break;case 4:s=0;break}return{x:a,y:s}}calculateViewportBbox(){const e=this.renderer.domElement,t=e.offsetWidth,n=e.offsetHeight,i=this.gizmoPos,o=this.gizmoDim,a=new RC(new Ae(t-o,0),new Ae(t,o));switch(i){case 0:a.set(new Ae(0,n-o),new Ae(o,n));break;case 1:a.set(new Ae(0,0),new Ae(o,o));break;case 4:a.set(new Ae(t-o,n-o),new Ae(t,n));break}return a}}function D3e(r,e){const t=e.font||"Helvetica",n=e.fontSize||30,i=e.width||200,o=e.height||200,a=e.bgColor?e.bgColor.join(", "):"255, 255, 255, 1.0",s=e.color?e.color.join(", "):"0, 0, 0, 1.0",l=document.createElement("canvas");l.width=i,l.height=o;const c=l.getContext("2d");if(c){c.font=`bold ${n}px ${t}`,c.fillStyle=`rgba(${a})`,c.fillRect(0,0,i,o);const h=c.measureText(r).width;c.fillStyle=`rgba(${s})`,c.fillText(r,i/2-h/2,o/2+n/2-2)}const u=new Kr(l);return u.minFilter=vr,u.needsUpdate=!0,u}function uE(r){const e=D3e(r,{fontSize:100,font:"Arial Narrow, sans-serif",color:[255,255,255,1],bgColor:[0,0,0,0]}),t=new aj({map:e,transparent:!0});return new Zoe(t)}K_.RIGHT_TOP;const R3e={pos:K_.LEFT_BOTTOM,size:100,hasZAxis:!0};class F3e extends O3e{constructor(e,t,n){const i={...R3e,...n};super(e,t,i.size,n.pos),this.hasZAxis=i.hasZAxis;const o=[0,0,0,2,0,0,0,0,0,0,2,0],a=[1,0,0,1,.6,0,0,1,0,.6,1,0];this.hasZAxis&&(o.push(0,0,0,0,0,2),a.push(0,0,1,0,.6,1));const s=new dt;s.setAttribute("position",new xn(o,3)),s.setAttribute("color",new xn(a,3));const l=new ns({vertexColors:!0,toneMapped:!1});this.axes=new kr(s,l),this.axes.position.set(-1,-1,-1),this.add(this.axes),this.xText=uE("X"),this.xText.position.set(1.5,-1,-1),this.add(this.xText),this.yText=uE("Y"),this.yText.position.set(-1,1.5,-1),this.add(this.yText),this.hasZAxis&&(this.zText=uE("Z"),this.zText.position.set(-1,-1,1.5),this.add(this.zText))}setLineColors(e,t){const n=new Qe,i=this.axes.geometry.attributes.color.array;return n.set(e),n.toArray(i,0),n.toArray(i,3),n.set(t),n.toArray(i,6),n.toArray(i,9),this.axes.geometry.attributes.color.needsUpdate=!0,this}setTextColor(e){this.xText.material.color=e,this.yText.material.color=e}dispose(){var e,t;this.axes.geometry.dispose(),this.axes.material.dispose(),this.xText.geometry.dispose(),this.xText.material.dispose(),this.yText.geometry.dispose(),this.yText.material.dispose(),this.hasZAxis&&((e=this.zText)==null||e.geometry.dispose(),(t=this.zText)==null||t.material.dispose())}}class B3e extends g9{constructor(e,t,n,i){super(e,n,i),this._layoutBtrId=t,this._mode=ga.SELECTION,this._axesGizmo=this.createAxesGizmo(),this._viewportViews=new Map,this._overlayViewport=new q_e(e)}get layoutBtrId(){return this._layoutBtrId}get mode(){return this._mode}set mode(e){e==ga.SELECTION?this._cameraControls.mouseButtons={MIDDLE:Yl.PAN}:e==ga.PAN&&(this._cameraControls.mouseButtons={LEFT:Yl.PAN}),this._cameraControls.update(),this._mode=e}get viewportCount(){return this._viewportViews.size}get viewportViews(){return this._viewportViews.values()}get overlayViewport(){return this._overlayViewport}get internalCamera(){return this._camera.internalCamera}get viewportsBoundingBox(){if(this._viewportViews.size===0)return;const e=new Bt;return this._viewportViews.forEach(t=>{const n=t.viewport.box;e.expandByPoint(n.min),e.expandByPoint(n.max)}),e.isEmpty()?void 0:e}addViewport(e){this._viewportViews.set(e.viewport.id,e)}removeViewport(e){this._viewportViews.delete(e)}resize(e,t){this._height=t,this._width=e,this._frustum=t/2,this.updateCameraFrustum(),this._viewportViews.forEach(n=>{n.update()})}render(e){var t;this._renderer.clear();const n=this._renderer.render(e.internalScene,this._camera),i=e.modelSpaceLayout;return i&&this.drawViewports(i.internalObject),this.drawOverlay(e),(t=this._axesGizmo)==null||t.update(),n}createAxesGizmo(){return new F3e(this._camera.internalCamera,this._renderer.internalRenderer,{hasZAxis:!1,pos:K_.LEFT_BOTTOM})}drawViewports(e){if(this._viewportViews.size>0){const t=this._renderer.autoClear;this._renderer.autoClear=!1;const n=new Mn;this._renderer.getViewport(n),this._renderer.clearDepth();const i=e.visible;e.visible=!0,this._viewportViews.forEach(o=>{o.render(e)}),e.visible=i,this._renderer.setViewport(n.x,n.y,n.z,n.w),this._renderer.autoClear=t}}drawOverlay(e){const t=this._overlayViewport;if(!t.visible)return;t.render(e.internalScene,this._height);const n=e.modelSpaceLayout;!n||this._viewportViews.size===0||this.drawOverlayViewports(n.internalObject,t)}drawOverlayViewports(e,t){const n=t.screenRect,i=t.viewBox,o=e.visible;e.visible=!0,this._viewportViews.forEach(a=>{const s=Y_e(a.viewport.box,i,n),l=y9(s,n);if(!l)return;const c=v9(l,i,n),u=new Bt;u.expandByPoint(a.paperPointToModel({x:c.minX,y:c.minY})),u.expandByPoint(a.paperPointToModel({x:c.maxX,y:c.minY})),u.expandByPoint(a.paperPointToModel({x:c.maxX,y:c.maxY})),u.expandByPoint(a.paperPointToModel({x:c.minX,y:c.maxY})),!u.isEmpty()&&a.withFrozenLayersHidden(e,()=>{t.renderNested(e,u,l,l,this._height,a.viewport.viewTwistAngle)})}),e.visible=o}}class hE{constructor(){this._activeLayoutBtrId="",this._layoutViews=new Map}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(e){this._activeLayoutBtrId=e,this._layoutViews.forEach(t=>{t.enabled=t.layoutBtrId==e})}get activeLayoutView(){return this._layoutViews.get(this._activeLayoutBtrId)}has(e){return this._layoutViews.has(e)}getAt(e){return this._layoutViews.get(e)}resize(e,t){this._layoutViews.forEach(n=>{n.resize(e,t)})}add(e){this._layoutViews.set(e.layoutBtrId,e)}render(e){var t;return((t=this.activeLayoutView)==null?void 0:t.render(e))??!1}}function N3e(r,e){return[...r].sort((t,n)=>z3e(t,n,e))}function z3e(r,e,t){const n=c4(r)-c4(e);if(Math.abs(n)>Number.EPSILON)return n;const i=u4(t,r)-u4(t,e);return Math.abs(i)>Number.EPSILON?i:0}function c4(r){return Math.max(r.maxX-r.minX,0)*Math.max(r.maxY-r.minY,0)}function u4(r,e){const t=r.x<e.minX?e.minX-r.x:r.x>e.maxX?r.x-e.maxX:0,n=r.y<e.minY?e.minY-r.y:r.y>e.maxY?r.y-e.maxY:0;return t*t+n*n}const D0=class Vm{constructor(e){this.zoomTo=e,this.active=!1,this.userAdjusted=!1,this.programmaticDepth=0,this.incrementalEnabled=!1,this.initialPendingCount=0,this.convertedCount=0,this.lastZoomAt=0}get isActive(){return this.active}begin(e){if(this.active){this.initialPendingCount=Math.max(this.initialPendingCount,e),this.maybeEnableIncrementalFit();return}this.active=!0,this.userAdjusted=!1,this.lastZoomAt=0,this.initialPendingCount=e,this.convertedCount=0,this.lastFittedBox=void 0,this.incrementalEnabled=!1,this.maybeEnableIncrementalFit()}end(){this.active=!1,this.incrementalEnabled=!1,this.lastFittedBox=void 0,this.convertedCount=0}applyFinalFit(e){if(this.userAdjusted)return;const t=e();t&&this.applyZoom(t)}frameProgrammatically(e){this.userAdjusted||this.applyZoom(e)}onLayoutViewChanged(){!this.active||this.userAdjusted||this.programmaticDepth>0||(this.userAdjusted=!0,this.end())}afterGeometryBatch(e,t){this.active&&(this.convertedCount++,this.maybeEnableIncrementalFit(),this.maybeIncrementalFit(e))}maybeEnableIncrementalFit(){this.incrementalEnabled||(this.initialPendingCount>=Vm.SMALL_ENTITY_THRESHOLD||this.convertedCount>=Vm.SMALL_ENTITY_THRESHOLD)&&(this.incrementalEnabled=!0)}maybeIncrementalFit(e){if(!this.active||!this.incrementalEnabled||this.userAdjusted)return;const t=performance.now();if(t-this.lastZoomAt<Vm.FIT_INTERVAL_MS)return;const n=e();!n||!this.shouldApplyIncrementalFit(n)||(this.lastZoomAt=t,this.applyZoom(n))}shouldApplyIncrementalFit(e){const t=this.lastFittedBox;if(!t)return!0;const n=this.estimateBoxArea(t);return n<=Number.EPSILON?!0:this.estimateBoxArea(e)>=n*Vm.BBOX_GROWTH_RATIO}applyZoom(e,t=1.1){this.programmaticDepth++;try{this.zoomTo(e,t),this.lastFittedBox=this.snapshotFitBox(e)}finally{this.programmaticDepth--}}estimateBoxArea(e){const t=new vn;return e.getSize(t),Math.abs(t.x)*Math.abs(t.y)}snapshotFitBox(e){return new Bt({x:e.min.x,y:e.min.y},{x:e.max.x,y:e.max.y})}};D0.SMALL_ENTITY_THRESHOLD=500,D0.BBOX_GROWTH_RATIO=1.5,D0.FIT_INTERVAL_MS=2500;let j3e=D0;const U3e=1e3;function V3e(r,e,t){return r||e>0?!1:t==null?!0:t>=U3e}const h4={background:fu},Il=class ni extends K2e{constructor(e=h4){const t={...h4,...e},n=t.container??document.createElement("div");t.container=n,n.style.overflow="hidden",n.hasAttribute("tabindex")||(n.tabIndex=-1);const i=new Qhe({antialias:!0,alpha:!0});n.appendChild(i.domElement),i.domElement.style.display="block",i.domElement.style.maxWidth="100%",i.domElement.style.maxHeight="100%";const o=fMe(i.domElement,n);super(i.domElement,n),this._rafId=null,this._loadingLayouts=new Set,this._initializedLayouts=new Set,this._externallyFramedLayouts=new Set,this._openViewMode=aa.Extents,this._convertingLayers=new Set,this._claimedConvertObjectIds=new Set,this._entityConvertGeneration=new Map,this._progressiveRendering=!1,this._convertInvisibleLayers=!1,this._cooperativeYield=!0,this._convertQueue=[],this._viewportRepairOwnerIds=new Set,this._convertDrainPromise=null,this._convertEpoch=0,this._lastProgressivePaintAt=0,this._progressivePaintUrgent=!1,this._progressiveInputPauseUntil=0,this._progressivePaintCount=0,this._progressiveYieldCount=0,this._openLineworkFramePending=!1,this._openLineworkFrameTimer=null,this._pendingGeometryJobs=0,this._deferredGeometryQueue=[],this._deferredGeometryActive=0,this._fontLoadedRedrawTimer=null,this._fontLoadedRedrawEpoch=0,this._entityProcessingIdleAt=0,this._textStyleFontPreloadEpoch=-1,this._textStyleFontPreloadPromise=null,this._viewDomAbort=new AbortController,this._viewDisposed=!1,this._readingMode=new D1e({getCurrentBackgroundColor:()=>this._renderer.currentBackgroundColor,applyViewClearColor:E=>this.applyViewClearColor(E),setCompareDisplay:E=>this.setCompareDisplay(E),markDirty:()=>{this._isDirty=!0}}),this._deferredFontsReady=null,this._convertPhaseMs={finishGeometry:0,finishGeometryAsyncDraw:0,finishGeometryQueueWait:0,handleGroup:0,addEntity:0,awaitFonts:0,glyphEntityCount:0,mtextCount:0,shapeCount:0,sharedGlyphDrawCount:0},this._fontPreloadDiag=null,this.animate=()=>{var E;this._rafId=requestAnimationFrame(this.animate),this.events.renderFrame.dispatch({render:this._renderer,camera:this.internalCamera});const C=this._numOfEntitiesToProcess>0,k=C||this._pendingGeometryJobs>0,T=!this._progressiveRendering&&!this._cooperativeYield&&k;if(!this._isDirty&&!this._htmlDirty&&!k||T||!this._isDirty&&!this._htmlDirty)return;const O=this.shouldCountMidOpenPaint(C,k);if(this._isDirty&&!this._progressivePaintUrgent&&O){const F=this._progressiveRendering?ni.PROGRESSIVE_OPEN_PAINT_INTERVAL_MS:ni.NON_PROGRESSIVE_OPEN_PAINT_INTERVAL_MS;if(performance.now()-this._lastProgressivePaintAt<F)return}let I=!1;this._isDirty&&(O&&(this._progressivePaintCount++,this._lastProgressivePaintAt=performance.now(),this._progressivePaintUrgent=!1),I=this._layoutViewManager.render(this._scene)),this.internalCamera&&(this._isDirty||this._htmlDirty)&&this._css2dRenderer.render(this._scene.internalScene,this.internalCamera),(E=this._stats)==null||E.update(),this._isDirty=I,this._htmlDirty=!1},this._meshGlyphFlushTimer=null,this._disposeCanvasTouchCallout=o;const a=()=>this.noteProgressiveUserInput(),s=()=>{a(),this.focusViewerForShortcuts()},l=()=>{a(),this.focusViewerForShortcuts()};i.domElement.addEventListener("pointerdown",s,{capture:!0}),i.domElement.addEventListener("wheel",l,{capture:!0,passive:!0}),this._disposeProgressiveInputWatch=()=>{i.domElement.removeEventListener("pointerdown",s,{capture:!0}),i.domElement.removeEventListener("wheel",l,{capture:!0})},this._gripManager=new HEe(this),this._keyHandler=new kPe(this),e.calculateSizeCallback&&this.setCalculateSizeCallback(e.calculateSizeCallback),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.setSize(this.width,this.height),this._renderer=new U_e(i),Hxe(()=>this._renderer.allocateDrawOrderZ());const c=Kn.instance.fontMapping;this._renderer.setFontMapping(c),this._onFontNotFound=E=>{Vt.emit("font-not-found",{fontName:E.fontName,count:E.count??0})},this._onFontLoaded=E=>{Vt.emit("missed-data-changed",{}),this.scheduleGlyphRedrawAfterFontLoad(E==null?void 0:E.fontName)},this._renderer.events.fontNotFound.addEventListener(this._onFontNotFound),this._renderer.events.fontLoaded.addEventListener(this._onFontLoaded),this._scene=this.createScene(),this._layerAppearance=new RB(this._scene,this._renderer),this._inheritedLayerMaterialMapper=new CPe(E=>this._layerAppearance.getEffectiveLayerTraits(E),this._renderer),this.backgroundColor=t.background??fu,this._stats=this.createStats(Kn.instance.isShowStats&&(W.tryGetInstance()==null||this.isActiveManagedView()));const u=Lt.instance(),h=ae.MODELBKCOLOR.toLowerCase(),d=ae.PAPERBKCOLOR.toLowerCase();this._onSysVarChanged=E=>{const C=E.name.toLowerCase();if(C===h||C===d){const k=E.database;if(!k)return;const T=this.isModelSpaceLayout(k);if(!(C===h&&T||C===d&&!T))return;this.applyCanvasBackground(FP(k,T))}},u.events.sysVarChanged.addEventListener(this._onSysVarChanged),this._onSettingsModified=E=>{E.key=="isShowStats"&&this.toggleStatsVisibility(this._stats,E.value)},Kn.instance.events.modified.addEventListener(this._onSettingsModified);let f=null,p=null,m=null;const g=()=>!this.editor.isActive&&!Sf.getActiveInputBox()&&!nke()&&!this._gripManager.isDragging,y=()=>this.mode===ga.SELECTION&&g(),v=()=>g()&&co().canIdleTouchBox(this.mode),x=()=>{m==null||m.remove(),m=null},b=()=>{f=null,p=null,x()},w=(E,C)=>{p=this.viewportToCanvas({x:E,y:C}),f=this.screenToWorld(p),x(),m=document.createElement("div"),m.className="ml-jig-preview-rect",this.container.appendChild(m)},_=(E,C,k="replace")=>{if(!f||!m||!p)return;const T=this.viewportToCanvas({x:E,y:C}),O=this.screenToWorld(T),I=this.worldToScreen(f),F=this.worldToScreen(O),N=Math.min(I.x,F.x),Y=Math.min(I.y,F.y),U=Math.abs(I.x-F.x),$=Math.abs(I.y-F.y),J=this.getSelectionMode(p,T),G=this.getSelectionPreviewStyle(J,k);Object.assign(m.style,{left:`${N}px`,top:`${Y}px`,width:`${U}px`,height:`${$}px`,borderStyle:G.borderStyle,background:G.background}),m.style.setProperty("--line-color",G.lineColor)},P=(E,C,k,T)=>{if(!f||!p)return;const O=this.viewportToCanvas({x:E,y:C}),I=this.screenToWorld(O);if(x(),T)if(XSe(this,O.x,O.y,k))k==="replace"&&this.selectionSet.clear();else if(this.entitySelectionEnabled){const F=this.pick(I);F.length>0?(k==="replace"&&this.htmlTransientManager.deselectAll(),this.applySelection([F[0].id],k)):k==="replace"&&this.selectionSet.clear()}else k==="replace"&&this.selectionSet.clear();else{const F=new Bt().expandByPoint(f).expandByPoint(I),N=this.getSelectionMode(p,O);this.entitySelectionEnabled&&this.selectByBoxWithMode(F,N,k),YSe(this,F,N,k)}f=null,p=null},S=this._viewDomAbort.signal;this.canvas.addEventListener("mousedown",E=>{E.button===0&&y()&&(Ya(E)||fo()||w(E.clientX,E.clientY))},{signal:S}),this.canvas.addEventListener("mousemove",E=>{!f||!m||!p||Ya(E)||fo()||_(E.clientX,E.clientY,this.getPointerSelectionAction(E))},{signal:S}),this.canvas.addEventListener("mouseup",E=>{if(this._gripManager.isDragging){b();return}if(!f||!p||Ya(E)||fo())return;const C=this.viewportToCanvas({x:E.clientX,y:E.clientY}),k=this.getPointerSelectionAction(E);P(E.clientX,E.clientY,k,this.isSelectionClick(p,C))},{signal:S}),this._disposeMobileBoxGesture=Mk({element:this.canvas,shouldStart:()=>v(),setNavigationEnabled:E=>{this.setNavigationEnabled(E)},onActivate:(E,C)=>{w(E,C),_(E,C)},onMove:(E,C)=>{_(E,C)},onBoxEnd:(E,C,k)=>{P(E,C,"replace",!k)},onTap:(E,C)=>{p=this.viewportToCanvas({x:E,y:C}),f=this.screenToWorld(p),P(E,C,"replace",!0)},onAbort:()=>{b()}}),this.canvas.addEventListener("dblclick",E=>{E.button===0&&y()&&this.entitySelectionEnabled&&W.instance.curDocument.openMode===st.Write&&this.openPickedEntityEditor(E)},{signal:S}),document.addEventListener("keydown",E=>{this.isActiveManagedView()&&this.isShortcutEventInsideViewer(E)&&this._keyHandler.handleKeyDown(E)},{signal:S}),this._onLayoutSwitched=E=>{var C,k;if(!this.isActiveManagedView())return;const T=E.layout.database,O=(k=(C=W._instance)==null?void 0:C.curDocument)==null?void 0:k.database;if(T&&O&&T!==O)return;const I=E.layout.blockTableRecordId,F=!this._initializedLayouts.has(I);this._initializedLayouts.add(I),this.activeLayoutBtrId=I,this.createLayoutViewIfNeeded(I),this.loadLayoutEntitiesIfNeeded(I),this.refreshCanvasBackgroundForActiveLayout(),this._isDirty=!0,F&&this.applyInitialZoom(I,E.layout)},$r().layoutManager.events.layoutSwitched.addEventListener(this._onLayoutSwitched),this._css2dRenderer=new E0e,this._css2dRenderer.setSize(this.width,this.height),this._css2dRenderer.domElement.style.position="absolute",this._css2dRenderer.domElement.style.top="0px",this._css2dRenderer.domElement.style.left="0px",this._css2dRenderer.domElement.style.pointerEvents="none",this._css2dRenderer.domElement.style.zIndex=String(eEe),this._css2dRenderer.domElement.style.maxWidth="100%",this._css2dRenderer.domElement.style.maxHeight="100%",n.appendChild(this._css2dRenderer.domElement),this._missedImages=new Map,this._layoutViewManager=new hE,this._progressiveOpenFit=new j3e((E,C)=>{this.activeLayoutView.zoomTo(E,C??1.1),this._isDirty=!0}),this._entityDisplay=new L3e(E=>this.resolveLayerInfo(E)),this.initialize(),this.onWindowResize(),this._isDirty=!0,this._htmlDirty=!1,this.startAnimationLoop(),this._numOfEntitiesToProcess=0,this.resetDeferredGeometryQueue()}ensureDeferredFontsReady(){if(!this._deferredFontsReady){const e=performance.now(),t=Promise.all([this.awaitPresetFontsReadySafe(),this.awaitTextStyleFontsReady()]).then(()=>{},()=>{});this._deferredFontsReady=t.then(()=>{this._convertPhaseMs.awaitFonts+=performance.now()-e})}return this._deferredFontsReady}async awaitPresetFontsReadySafe(){const e=W;e._instance&&await e._instance.awaitPresetFontsReady()}takeConvertPhaseTimings(){const e={...this._convertPhaseMs,fontPreload:this._fontPreloadDiag?{...this._fontPreloadDiag}:void 0};return this._convertPhaseMs={finishGeometry:0,finishGeometryAsyncDraw:0,finishGeometryQueueWait:0,handleGroup:0,addEntity:0,awaitFonts:0,glyphEntityCount:0,mtextCount:0,shapeCount:0,sharedGlyphDrawCount:0},this._fontPreloadDiag=null,e}getPointerSelectionAction(e){return q2e(e)}initialize(){this.setCursor(Oy.Crosshair),this._onCommandWillStartHitTest=()=>{this.htmlTransientManager.setHitTestEnabled(!1)},this._onCommandEndedHitTest=()=>{this.htmlTransientManager.setHitTestEnabled(!0)},this.editor.events.commandWillStart.addEventListener(this._onCommandWillStartHitTest),this.editor.events.commandEnded.addEventListener(this._onCommandEndedHitTest)}get mode(){const e=this.activeLayoutView;return e?e.mode:ga.SELECTION}set mode(e){this.activeLayoutView.mode=e}setNavigationEnabled(e){const t=this.activeLayoutView;t&&(t.enabled=e)}setSnapLoupe(e){var t;const n=(t=this.activeLayoutView)==null?void 0:t.overlayViewport;if(n){if(!e){n.visible=!1,this._isDirty=!0;return}n.setScreenRect(e.x,e.y,e.size,e.size),n.setViewBox(e.viewBox),n.visible=!0,this._isDirty=!0}}get renderer(){return this._renderer}get gripManager(){return this._gripManager}get isDirty(){return this._isDirty}get isProcessingEntities(){return this._numOfEntitiesToProcess>0||this._pendingGeometryJobs>0}get isConvertingEntities(){return this._numOfEntitiesToProcess>0}async waitUntilIdle(e=6e4){const t=Date.now()+Math.max(0,e);let n=0;for(;;){if(this.isProcessingEntities)n=0;else if(n++,n>=2)return!0;if(Date.now()>t)return!this.isProcessingEntities;await new Promise(i=>setTimeout(i,16))}}get progressiveRendering(){return this._progressiveRendering}set progressiveRendering(e){this._progressiveRendering=e,this.resetProgressiveOpenStats()}get convertInvisibleLayers(){return this._convertInvisibleLayers}set convertInvisibleLayers(e){this._convertInvisibleLayers=e}get cooperativeYield(){return this._cooperativeYield}set cooperativeYield(e){this._cooperativeYield=e}get progressiveOpenStats(){return{paintCount:this._progressivePaintCount,yieldCount:this._progressiveYieldCount}}resetProgressiveOpenStats(){this._progressivePaintCount=0,this._progressiveYieldCount=0,this._lastProgressivePaintAt=0,this._progressivePaintUrgent=!1,this._progressiveInputPauseUntil=0}isProgressiveGesturePauseActive(){return performance.now()<this._progressiveInputPauseUntil}isProgressiveDiscreteInputPending(){var e;const t=navigator.scheduling;return((e=t==null?void 0:t.isInputPending)==null?void 0:e.call(t))===!0}noteProgressiveUserInput(){!this._progressiveRendering||this._numOfEntitiesToProcess<=0||(this._progressivePaintUrgent=!0,this._isDirty=!0,this._progressiveInputPauseUntil=performance.now()+ni.PROGRESSIVE_INPUT_PAUSE_MS)}async progressiveYieldForInput(e,t){if(this.isProgressiveGesturePauseActive()){for(await t();performance.now()<this._progressiveInputPauseUntil;)await new Promise(n=>setTimeout(n,16));this._progressiveYieldCount++;return}if(this.isProgressiveDiscreteInputPending()){await t(),this._progressiveYieldCount++;return}e&&await e.maybeYield(t)&&this._progressiveYieldCount++}beginProgressiveOpenFit(){this._progressiveOpenFit.begin(this._numOfEntitiesToProcess)}endProgressiveOpenFit(){this._progressiveOpenFit.end()}set isDirty(e){this._isDirty=e}get isHtmlDirty(){return this._htmlDirty}set isHtmlDirty(e){this._htmlDirty=e}get missedData(){return{fonts:this._renderer.missedFonts,images:this._missedImages,xrefs:this.collectUnresolvedXrefs()}}collectUnresolvedXrefs(){var e,t;try{const n=(t=(e=W.instance)==null?void 0:e.curDocument)==null?void 0:t.database;if(!n)return[];const i=n.tables.blockTable;return typeof i.getUnresolvedXrefs!="function"?[]:i.getUnresolvedXrefs().map(o=>({name:o.name,pathName:o.pathName,isOverlay:o.isOverlayReference}))}catch{return[]}}get center(){return this.activeLayoutView.center}set center(e){this.activeLayoutView.center=e}get backgroundColor(){return this._renderer.getClearColor()}set backgroundColor(e){this.applyCanvasBackground(e)}applyCanvasBackground(e){if(this._renderer.currentBackgroundColor=e,this._layerAppearance.refreshTextMaterialsInObjectTree(this._scene.internalScene),this._scene.repaintForegroundMaterials($l(e)),this._scene.repaintBackgroundMaterials(e),this.resyncForegroundLayersForBackground(),this._readingMode.isEnabled){this._readingMode.noteLayoutBackground(e),this.applyViewClearColor(M9);return}this.applyViewClearColor(e)}applyViewClearColor(e){this._renderer.setClearColor(e),this.editor.syncCursorBackground(e),this._isDirty=!0}resyncForegroundLayersForBackground(){var e;const t=this._renderer.context.database;if(t)for(const n of t.tables.layerTable.newIterator())(e=n.color)!=null&&e.isForeground&&this._layerAppearance.syncFromLiveRecord(n)}isModelSpaceLayout(e){return e?_Pe(e):this.activeLayoutBtrId===this.modelSpaceBtrId}bindDrawDatabase(e){this._renderer.context.database=e}syncDisplaySysVars(e){this.bindDrawDatabase(e),this.applyCanvasBackground(FP(e,this.isModelSpaceLayout(e))),this._readingMode.reapplyIfEnabled()}get readingModeEnabled(){return this._readingMode.isEnabled}toggleReadingMode(){this._readingMode.toggle()}setReadingMode(e){this._readingMode.setEnabled(e)}async addOverlayEntities(e){const t=new g7;t.isReference=!0,t.internalObject.userData.isReference=!0,this._scene.internalScene.add(t.internalObject);for(const i of e.tables.layerTable.newIterator())t.addLayer({name:i.name,isOff:i.isOff,isFrozen:i.isFrozen,color:i.color});const n=this._renderer.context.database;this._renderer.context.database=e;try{const i=e.tables.blockTable.modelSpace;for(const o of i.newIterator())if(!(o instanceof Va))try{const a=this.drawEntity(o,!1);if(!a)continue;a.objectId=o.objectId,a.ownerId=o.ownerId,a.layerName=o.layer,a.visible=o.visibility!==!1,a instanceof Rn&&a.isOnTheSameLayer&&(a.userData.insertLayerName=a.layerName),await this.finishEntityGeometry(a,!1),a instanceof Rn&&a.isOnTheSameLayer&&this._inheritedLayerMaterialMapper.remap(a.children,"0",a.layerName),t.addEntity(a),a.dispose()}catch(a){Ht.error(`[AcTrView2d] Failed to convert overlay entity ${o.objectId} (${o.type}):`,a)}}finally{this._renderer.context.database=n}return t}refreshCanvasBackgroundForActiveLayout(){var e,t;const n=(t=(e=W._instance)==null?void 0:e.curDocument)==null?void 0:t.database;if(!n)return;const i=this.activeLayoutBtrId===this.modelSpaceBtrId;this.applyCanvasBackground(FP(n,i))}get modelSpaceBtrId(){return this._scene.modelSpaceBtrId}set modelSpaceBtrId(e){this._scene.modelSpaceBtrId=e}get activeLayoutBtrId(){return this._scene.activeLayoutBtrId}set activeLayoutBtrId(e){const t=this._scene.activeLayoutBtrId;this._layoutViewManager.activeLayoutBtrId=e,this._scene.activeLayoutBtrId=e,this.htmlTransientManager.setActiveLayoutId(e),this._isDirty=!0,t!==e&&LSe()}get activeLayoutView(){return this._layoutViewManager.activeLayoutView}get stats(){return this._scene.stats}get cadScene(){return this._scene}async ensureEntitiesConvertedForExport(e){var t;const n=(e==null?void 0:e.includeInvisibleLayers)!==!1,i=(e==null?void 0:e.includeLayouts)!==!1,o=W.instance.curDocument.database,a=[];await this.drainConvertQueue();const s=(t=o.objects)==null?void 0:t.layout;if(i&&s!=null&&s.newIterator)for(const l of s.newIterator()){const c=l.blockTableRecordId;c&&this._scene.addEmptyLayout(c)}for(const[l]of this._scene.layouts){if(!i&&l!==this._scene.modelSpaceBtrId)continue;const c=o.tables.blockTable.getIdAt(l);c&&a.push(...this._entityDisplay.collectMissingEntitiesForExport(c,u=>this.isEntityConvertScheduled(u),n))}a.length>0&&(this._numOfEntitiesToProcess+=a.length,await this.batchConvert(a,{forExport:!0})),await this.waitUntilIdle(12e4)||Ht.warn("[AcTrView2d] Timed out waiting for deferred geometry before export"),this.flushMeshGlyphWorldBatch()}get internalScene(){return this._scene.internalScene}get htmlTransientManager(){return this._scene.htmlTransientManager}get internalCamera(){var e;return(e=this.activeLayoutView)==null?void 0:e.internalCamera}set ltscale(e){this._renderer.ltscale=e}set celtscale(e){this._renderer.celtscale=e}screenToWorld(e){const t=this.activeLayoutView;return t?t.screenToWorld(e):new re(e)}worldToScreen(e){const t=this.activeLayoutView;return t?t.worldToScreen(e):new re(e)}zoomTo(e,t=1.1){this.activeLayoutView.zoomTo(e,t),this._isDirty=!0}rerenderPoints(e,t=0){const n=this._scene.activeLayout;n&&(n.rerenderPoints(e,t),this._isDirty=!0)}requestOpenLineworkFrame(){this._openLineworkFramePending=!0,this.scheduleOpenLineworkFrame()}cancelOpenLineworkFrame(){this._openLineworkFramePending=!1,this._openLineworkFrameTimer!=null&&(clearTimeout(this._openLineworkFrameTimer),this._openLineworkFrameTimer=null)}scheduleOpenLineworkFrame(){if(this._openLineworkFrameTimer!=null||!this._openLineworkFramePending)return;const e=this.isConvertingEntities?50:0;this._openLineworkFrameTimer=setTimeout(()=>{if(this._openLineworkFrameTimer=null,!!this._openLineworkFramePending){if(this.isConvertingEntities){this.scheduleOpenLineworkFrame();return}this.frameOpenLineworkIfReady()}},e)}zoomToFitDrawing(e=0,t){new UP(()=>!this.isProcessingEntities,()=>{if(t&&this._externallyFramedLayouts.delete(t)){this.endProgressiveOpenFit();return}this._progressiveOpenFit.applyFinalFit(()=>this.getDrawingExtents()),this.endProgressiveOpenFit();const n=t??this.activeLayoutBtrId;n&&cg.rememberOriginalView(this,n)},300,e).start()}zoomToFitLayer(e){const t=this._scene.activeLayout;if(t){const n=t.getLayer(e);if(n&&!n.box.isEmpty()){const i=l4.threeBox3dToGeBox2d(n.box);return this.zoomTo(i),this._isDirty=!0,!0}}return!1}zoomToSmartExtents(e=0){return new Promise((t,n)=>{new UP(()=>!this.isProcessingEntities,()=>{(async()=>{try{const i=await this.resolveSmartFitBox();if(i){this.zoomTo(i),this._isDirty=!0,this.endProgressiveOpenFit(),t();return}this._progressiveOpenFit.applyFinalFit(()=>this.getDrawingExtents()),this.endProgressiveOpenFit(),t()}catch(i){this.endProgressiveOpenFit(),n(i)}})()},300,e).start()})}async resolveSmartFitBox(){const e=this._scene.activeLayout;if(!e)return;const t=e.cachedSmartExtents;if(t)return t;const n=e.smartExtentsGeneration,i=new u7,o=await e.collectSpatialExtentBoxesAsync(i),a=await TPe(o,i);return e.smartExtentsGeneration!==n?e.cachedSmartExtents:(a&&(e.cachedSmartExtents=a),a)}flyTo(e,t){this.activeLayoutView.flyTo(e,t),this._isDirty=!0}async openPickedEntityEditor(e){const t=this.viewportToCanvas({x:e.clientX,y:e.clientY}),n=this.screenToWorld(t),i=this.pick(n,void 0,!0);if(!i.length)return;const o=W.instance.curDocument.database.tables.blockTable.getEntityById(i[0].id);if(!o)return;const a=this.resolveAttributedBlockReference(o);if(a){e.preventDefault(),this.selectionSet.clear(),this.selectionSet.add(a.objectId),W.instance.sendStringToExecute("attedit");return}if(o instanceof oc){e.preventDefault(),await this.editMTextEntity(o);return}o instanceof vh&&(e.preventDefault(),await this.editTextEntity(o))}resolveAttributedBlockReference(e){if(e instanceof rr)return e.attributeIterator().count>0?e:void 0;if(e instanceof bh||e.type==="Attrib"||e.type==="Attribute"){const t=W.instance.curDocument.database.tables.blockTable.getEntityById(e.ownerId);if(t instanceof rr&&t.attributeIterator().count>0)return t}}async editMTextEntity(e){const t=e.database;this.setEntitySceneVisible(e.objectId,!1),this._isDirty=!0;const n=e.resolveAnnotativePresentation,i=typeof n=="function"?n.call(e):null,o=(i==null?void 0:i.position)??e.location,a={x:o.x,y:o.y,z:o.z??0},s=(i==null?void 0:i.direction)??e.direction,l=(i==null?void 0:i.attachmentPoint)??e.attachmentPoint,c=i&&Number.isFinite(i.width)&&i.width>0?i.width:this.resolveMTextEditorWidth(e),u=i&&Number.isFinite(i.height)&&i.height>0?i.height:this.resolveMTextEditorTextHeight(e),h=new Sf;let d=!1;try{const f=await h.open({view:this,location:a,width:c,textHeight:u,initialText:e.contents,initialAttachmentPoint:l,initialDrawingDirection:e.drawingDirection,rotation:e.rotation,directionVector:{x:s.x,y:s.y,z:s.z},textStyleName:e.styleName,initialLineSpaceFactor:e.lineSpacingFactor,toolbarFontFamilies:await this.getMTextToolbarFontFamilies()});if(!f)return;Ch(t,"Edit MText",()=>{const p=t.openEntityForWrite(e);p instanceof oc&&(p.location=f.location,p.contents=f.contents,p.width=f.width,p.height=f.height,p.lineSpacingFactor=f.lineSpacingFactor,p.attachmentPoint=f.attachmentPoint)}),d=!0}finally{this.setEntitySceneVisible(e.objectId,!0),d||this.updateEntity(e),this._isDirty=!0}}async editTextEntity(e){const t=e.database;this.setEntitySceneVisible(e.objectId,!1),this._isDirty=!0;const n=Number(e.height),i=Number.isFinite(n)&&n>0?n:this.pixelsToWorldY(24),o=e.textString??"",a=Math.max(i*Math.max(o.length,1)*.6,i),s=Number(e.rotation),l=new Sf;let c=!1;try{const u=await l.open({view:this,location:e.position,width:a,textHeight:i,initialText:o,initialAttachmentPoint:Tt.BaselineLeft,...Number.isFinite(s)?{rotation:s}:{},toolbarFontFamilies:await this.getMTextToolbarFontFamilies()});if(!u)return;Ch(t,"Edit Text",()=>{const h=t.openEntityForWrite(e);h instanceof vh&&(h.position=new D(u.location),h.textString=u.contents,Number.isFinite(u.height)&&u.height>0&&(h.height=u.height))}),c=!0}finally{this.setEntitySceneVisible(e.objectId,!0),c||this.updateEntity(e),this._isDirty=!0}}resolveMTextEditorWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0?t:0}resolveMTextEditorTextHeight(e){const t=Number(e.height);return Number.isFinite(t)&&t>0?t:this.pixelsToWorldY(24)}pixelsToWorldY(e){const t=this.screenToWorld({x:0,y:0}),n=this.screenToWorld({x:0,y:e});return Math.max(Math.abs(n.y-t.y),1e-4)}async getMTextToolbarFontFamilies(){const e=await W.instance.getAvaiableFonts()??[];return Array.from(new Set(e.flatMap(t=>t.name).map(t=>t.trim()).filter(t=>t.length>0)))}pick(e,t,n){e==null&&(e=this.curPos);const i=[],o=this._scene.activeLayout;if(!o)return i;const a=this.activeLayoutView,s=t??this.selectionBoxSize,l=a.pointToBox(e,s),c=Math.max(l.size.width/2,l.size.height/2),u=a.layoutBtrId!==this._scene.modelSpaceBtrId,h=(l.size.width+l.size.height)/2,d=[],f=new Set;if(u)for(const b of a.viewportViews)b.containsPaperPoint(e)&&!b.isNearPaperBorder(e,h)&&(d.push(b),f.add(b.viewport.id));const p=this._scene.search(l),m=a.resetRaycaster(e,c),g=bn.getInstance(),y=new Set;p.forEach(b=>{if(f.has(b.id))return;const w=g.intersectMeshGlyphObjectId(b.id,m);!vw(b)&&!w||(o.isIntersectWith(b.id,m)||w)&&(i.push(b),y.add(b.id))});const v=g.queryMeshGlyphObjectIdsIntersectingBox({minX:l.min.x,minY:l.min.y,maxX:l.max.x,maxY:l.max.y});for(const b of v){if(y.has(b)||f.has(b)||!g.intersectMeshGlyphObjectId(b,m))continue;const w=g.getMeshGlyphWorldPickBoxes().get(b);i.push({id:b,minX:(w==null?void 0:w.min.x)??l.min.x,minY:(w==null?void 0:w.min.y)??l.min.y,maxX:(w==null?void 0:w.max.x)??l.max.x,maxY:(w==null?void 0:w.max.y)??l.max.y}),y.add(b)}d.length>0&&this.pickThroughViewports(e,l,d,i);const x=N3e(i,e);return n?x.slice(0,1):x}getViewportCoordinateMapper(e){var t;let n;for(const i of((t=this.activeLayoutView)==null?void 0:t.viewportViews)??[])if(i.viewport.id===e){n=i;break}if(n)return{paperToModel:i=>n.paperPointToModel(i),modelToPaper:i=>n.modelPointToPaper(i),containsPaperPoint:i=>n.containsPaperPoint(i)}}pickThroughViewports(e,t,n,i){const o=this._scene.modelSpaceLayout;if(!o)return;const a=(t.size.width+t.size.height)/4;for(const s of n){const l=s.paperPointToModel(e),c=a*s.paperToModelScale;if(c<=0)continue;const u=new Bt().setFromPoints([new re(l.x-c,l.y-c),new re(l.x+c,l.y+c)]),h=s.resetRaycaster(l,c);o.search(u).forEach(d=>{vw(d)&&o.isIntersectWith(d.id,h)&&i.push({...d,viewportId:s.viewport.id})})}}search(e,t){return this._scene.search(e,t)}select(e){const t=[];this.pick(e).forEach(i=>t.push(i.id));const n=this.selectableIds(t,"add");n.length>0&&this.selectionSet.add(n)}selectByBox(e){this.selectByBoxWithMode(e,"crossing","add")}refineCrossingSelectionHits(e,t){var n;const i=(n=W.instance.curDocument)==null?void 0:n.database;if(!i)return t.map(a=>a.id);const o=[];for(const a of t){if(!eke(a)){o.push(a.id);continue}const s=new Bt({x:a.minX,y:a.minY},{x:a.maxX,y:a.maxY});if(e.containsBox(s)){o.push(a.id);continue}const l=i.tables.blockTable.getEntityById(a.id);(!l||Q2e(l,e))&&o.push(a.id)}return o}addLayer(e){this._scene.addLayer(this.toLayerInfo(e)),this._layerAppearance.syncFromLiveRecord(e),this._isDirty=!0}updateLayer(e,t){const{touchedObjectIds:n}=this._scene.updateLayer(this.toLayerInfo(e));if(this._layerAppearance.layerStyleMayHaveChanged(t)&&this._layerAppearance.syncFromLiveRecord(e),this._entityDisplay.layerVisibilityMayHaveChanged(t)){const i=this.toLayerInfo(e);(rp.isLayerVisible(i)||!i.isFrozen)&&this.convertMissingEntitiesOnLayer(e.name)}for(const i of n)this.applySessionHiddenObjectState(i);this._isDirty=!0}addTransientEntity(e){const t=Array.isArray(e)?e:[e],n=this._convertEpoch,i=this._renderer.forceShowLineWeight;this._renderer.forceShowLineWeight=!0;try{for(let o=0;o<t.length;++o){const a=t[o],s=this.drawEntity(a,!0);s&&(s.objectId=a.objectId,s.userData.skipMeshGlyphInstancing=!0,s.asyncDraw().then(()=>{if(n!==this._convertEpoch){s.dispose();return}this._scene.addTransientEntity(s),this._isDirty=!0}).catch(l=>{Ht.error("[AcTrView2d] Transient entity geometry failed:",l),s.dispose()}))}}finally{this._renderer.forceShowLineWeight=i}}removeTransientEntity(e){this._scene.removeTransientEntity(e),this._isDirty=!0}setTransientEntityVisible(e,t){this._scene.setTransientEntityVisible(e,t)&&(this._isDirty=!0)}canCreateEntityPreview(e){return this._scene.canCreatePreview(e)}createEntityPreview(e){const t=this._scene.createPreview(e);return t&&(this._isDirty=!0),t}updateEntityPreview(e,t){this._scene.updatePreview(e,tw.createMatrix4(t))&&(this._isDirty=!0)}removeEntityPreview(e){this._scene.removePreview(e)&&(this._isDirty=!0)}updateTransientPreviewTransforms(e){const t=this._scene.updateTransientPreviewTransforms(e.map(n=>({objectId:n.objectId,matrix:tw.createMatrix4(n.matrix)})));t.webgl&&(this._isDirty=!0),t.html&&(this._htmlDirty=!0)}addEntity(e){var t;const n=Array.isArray(e)?e:[e];for(let i=0;i<n.length;i++){const o=(t=n[i])==null?void 0:t.ownerId;if(!o)continue;let a=this._scene.layouts.get(o);a||(this._scene.addEmptyLayout(o),a=this._scene.layouts.get(o)),a&&!a.isLoaded&&(a.isLoaded=!0)}this._numOfEntitiesToProcess+=n.length,this._convertQueue.push(...n),this.drainConvertQueue()}removeEntity(e){(Array.isArray(e)?e:[e]).forEach(t=>this._scene.removeEntity(t.objectId)),this._isDirty=!0}hasEntity(e){return this._scene.hasEntity(e)}isEntityConvertScheduled(e){const t=String(e??"");return t?this.hasEntity(e)||this._claimedConvertObjectIds.has(t):!1}getEntityVisible(e){return this._scene.getEntityVisible(e)}updateEntityVisibility(e){return this._scene.setEntityVisible(e.objectId,e.visibility)?(this._isDirty=!0,!0):!1}setEntitySceneVisible(e,t){return this._scene.setEntityVisible(e,t)?(this._isDirty=!0,!0):!1}applySessionHiddenObjectState(e){W.instance.curDocument.isObjectHidden(e)&&this._scene.setEntityVisible(e,!1)}updateEntity(e){const t=this.resolveSceneUpdateEntities(Array.isArray(e)?e:[e]);if(t.length===0)return;const n=t.map(i=>i.objectId).filter(i=>this.selectionSet.has(i));for(let i=0;i<t.length;++i){const o=t[i],a=String(o.objectId??"");a&&(this._entityConvertGeneration.set(a,(this._entityConvertGeneration.get(a)??0)+1),this._claimedConvertObjectIds.delete(a),bn.getInstance().removeMeshGlyphInstances(a)),this._scene.hasEntity(o.objectId)&&this._scene.removeEntity(o.objectId)}(async()=>(await this.batchConvert(t),await this.waitUntilDeferredGeometryIdle(),n.length>0&&this.highlight(n),this._gripManager.refresh(),this._isDirty=!0))(),this._isDirty=!0,setTimeout(()=>{this._isDirty=!0},100)}resolveSceneUpdateEntities(e){var t;const n=(t=W.instance.curDocument)==null?void 0:t.database,i=[],o=new Set;for(const a of e){let s=a;if(a instanceof bh){const l=n==null?void 0:n.tables.blockTable.getEntityById(a.ownerId);if(!(l instanceof rr))continue;s=l}o.has(s.objectId)||(o.add(s.objectId),i.push(s))}return i}addLayout(e){this._scene.addEmptyLayout(e.blockTableRecordId),this.createLayoutViewIfNeeded(e.blockTableRecordId),this._isDirty=!0}markLayoutAsInitialized(e){this._initializedLayouts.add(e),this._externallyFramedLayouts.add(e)}setOpenViewMode(e){this._openViewMode=e}isLayoutInitialized(e){return this._initializedLayouts.has(e)}getDrawingExtents(){const e=this._scene.box;if(e&&!e.isEmpty())return l4.threeBox3dToGeBox2d(e)}applyInitialZoom(e,t){new UP(()=>!this.isProcessingEntities,()=>{if(this._externallyFramedLayouts.delete(e))return;const n=this.resolveFirstVisitFrameBox(e,t);n&&this.zoomTo(n),this._isDirty=!0,cg.rememberOriginalView(this,e)},300,0).start()}resolveFirstVisitFrameBox(e,t){var n,i;const o=e===this.modelSpaceBtrId,a=this._openViewMode===aa.Saved;if(a&&o){const d=W.instance.curDocument.database,f=this.width/Math.max(this.height,1),p=d.tables.viewportTable.getActiveVportBox(f);if(p)return p}const s=this._layoutViewManager.getAt(e),l=t.extents,c=l&&!l.isEmpty()?{min:{x:l.min.x,y:l.min.y},max:{x:l.max.x,y:l.max.y}}:void 0,u=this.getDrawingExtents(),h=s==null?void 0:s.viewportsBoundingBox;return a&&!o?(n=Tk({limits:t.limits,viewportsBox:h,layoutExtents:c,entityBox:u}))==null?void 0:n.box:(i=Tk({limits:void 0,viewportsBox:o?void 0:h,layoutExtents:c,entityBox:u}))==null?void 0:i.box}abortConversion(){this._convertEpoch++,this.clearFontLoadedRedrawTimer(),this.clearMeshGlyphFlushTimer(),this._convertQueue.length=0,this._viewportRepairOwnerIds.clear(),this._numOfEntitiesToProcess=0,this._claimedConvertObjectIds.clear(),this._entityConvertGeneration.clear(),this.cancelOpenLineworkFrame(),this.resetDeferredGeometryQueue(),this._entityProcessingIdleAt=0}clear(){this.abortConversion(),this._scene.clear(),bn.getInstance().resetMeshGlyphBatch(),this._renderer.resetDrawOrderZ(),this._isDirty=!0,this._missedImages.clear(),this._initializedLayouts.clear(),this._externallyFramedLayouts.clear(),this._openViewMode=aa.Extents,this._loadingLayouts.clear(),this._renderer.dispose(),Io.instance.clear(),Vt.emit("missed-data-changed",{})}captureSessionState(){return this.clearMeshGlyphFlushTimer(),{scene:this._scene,layoutViewManager:this._layoutViewManager,initializedLayouts:this._initializedLayouts,externallyFramedLayouts:this._externallyFramedLayouts,openViewMode:this._openViewMode,loadingLayouts:this._loadingLayouts,missedImages:this._missedImages,missedFonts:this._renderer.snapshotMissedFonts(),selectionIds:this.selectionSet.ids,meshGlyphBatch:bn.getInstance().detachMeshGlyphBatch()}}restoreSessionState(e){this._convertEpoch++,this.clearFontLoadedRedrawTimer(),this.clearMeshGlyphFlushTimer(),this.cancelOpenLineworkFrame(),this._convertQueue.length=0,this._viewportRepairOwnerIds.clear(),this._numOfEntitiesToProcess=0,this._claimedConvertObjectIds.clear(),this._entityConvertGeneration.clear(),this.resetDeferredGeometryQueue(),this._entityProcessingIdleAt=0,this._scene=e.scene,this._layoutViewManager=e.layoutViewManager,this._initializedLayouts=e.initializedLayouts,this._externallyFramedLayouts=e.externallyFramedLayouts,this._openViewMode=e.openViewMode??aa.Extents,this._loadingLayouts=e.loadingLayouts,this._missedImages=e.missedImages,this._renderer.replaceMissedFonts(e.missedFonts??{}),bn.getInstance().attachMeshGlyphBatch(e.meshGlyphBatch),this.rebindLayerAppearance(),this._layoutViewManager.resize(this.width,this.height),this.selectionSet.clear(),e.selectionIds.length>0&&this.selectionSet.add(e.selectionIds),this._isDirty=!0,Vt.emit("missed-data-changed",{})}beginNewSession(){const e=this.captureSessionState();return this._convertEpoch++,this.clearFontLoadedRedrawTimer(),this.cancelOpenLineworkFrame(),this._convertQueue.length=0,this._viewportRepairOwnerIds.clear(),this._numOfEntitiesToProcess=0,this._claimedConvertObjectIds.clear(),this._entityConvertGeneration.clear(),this.resetDeferredGeometryQueue(),this._entityProcessingIdleAt=0,this._scene=this.createScene(),this._layoutViewManager=new hE,this._initializedLayouts=new Set,this._externallyFramedLayouts=new Set,this._openViewMode=aa.Extents,this._loadingLayouts=new Set,this._missedImages=new Map,this._renderer.clearMissedFonts(),this.rebindLayerAppearance(),this.selectionSet.clear(),this._isDirty=!0,Vt.emit("missed-data-changed",{}),e}disposeSessionState(e){e.meshGlyphBatch.dispose(),e.scene.clear(),e.layoutViewManager=new hE,e.initializedLayouts.clear(),e.externallyFramedLayouts.clear(),e.loadingLayouts.clear(),e.missedImages.clear(),e.missedFonts={},e.selectionIds=[]}rebindLayerAppearance(){this._layerAppearance=new RB(this._scene,this._renderer)}isActiveManagedView(){var e;const t=(e=W._instance)==null?void 0:e.curView;return t!=null&&t===this}focusViewerForShortcuts(){const e=document.activeElement;e instanceof Node&&this.container.contains(e)||e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)||this.container.focus({preventScroll:!0})}isShortcutEventInsideViewer(e){const t=e.target;if(t instanceof Node&&this.container.contains(t))return!0;const n=document.activeElement;return n instanceof Node&&this.container.contains(n)}async drainConvertQueue(){if(this._convertDrainPromise){await this._convertDrainPromise,this._convertQueue.length>0&&await this.drainConvertQueue();return}this._convertDrainPromise=this.runConvertDrain().finally(()=>{this._convertDrainPromise=null}),await this._convertDrainPromise}async runConvertDrain(){const e=this._convertEpoch,t=this._cooperativeYield;let n=t?this.activeLayoutBtrId===this.modelSpaceBtrId?ni.CONVERT_SLICE_MAX:1:Number.POSITIVE_INFINITY,i=performance.now(),o=A3e(this._convertQueue.splice(0,this._convertQueue.length),this.activeLayoutBtrId);for(this.repairViewportViewsFor(o.activeOwnerId);o.cursor<o.pending.length||this._convertQueue.length>0;){if(this._convertEpoch!==e)return;const a=this._convertQueue.splice(0,this._convertQueue.length),s=this.activeLayoutBtrId,l=s!==o.activeOwnerId;if(o=C3e(o,a,s),l&&(this.repairViewportViewsFor(s),t&&(n=1)),this.flushViewportViewRepairs(),o.cursor>=o.pending.length)break;const c=Math.min(o.pending.length,o.cursor+n),u=performance.now();if(await this.batchConvert(o.pending.slice(o.cursor,c)),o.cursor=c,this._convertEpoch!==e)return;if(!t)continue;const h=performance.now()-u,d=o.activeOwnerId===this.modelSpaceBtrId,f=this._progressiveRendering?ni.PROGRESSIVE_OPEN_YIELD_BUDGET_MS:ni.OPEN_CONVERT_YIELD_BUDGET_MS,p=d?f:ni.CONVERT_SLICE_BUDGET_MS;if(n=I3e({slice:n,tookMs:h,budgetMs:p,maxSlice:ni.CONVERT_SLICE_MAX,activeLayoutPending:!d&&T3e(o)}),this._progressiveRendering&&this.isProgressiveGesturePauseActive()){for(await new Promise(m=>setTimeout(m,0));performance.now()<this._progressiveInputPauseUntil;)await new Promise(m=>setTimeout(m,16));if(i=performance.now(),this._convertEpoch!==e)return}else if(this._progressiveRendering&&this.isProgressiveDiscreteInputPending()){if(await new Promise(m=>setTimeout(m,0)),i=performance.now(),this._convertEpoch!==e)return}else if(performance.now()-i>=p&&(await new Promise(m=>setTimeout(m,0)),i=performance.now(),this._convertEpoch!==e))return}this.repairViewportViewsFor(this.activeLayoutBtrId),this.flushViewportViewRepairs()}repairViewportViewsFor(e){var t;if(!e||e===this.modelSpaceBtrId)return;const n=this._layoutViewManager.getAt(e);if(!n||n.viewportCount>0){n&&n.viewportCount>0&&this._viewportRepairOwnerIds.delete(e);return}try{const i=(t=W.instance.curDocument)==null?void 0:t.database,o=i==null?void 0:i.tables.blockTable.getIdAt(e);if(!o)return;const a=n.viewportCount;this.ensureViewportViews(o,n),n.viewportCount>a&&(this._isDirty=!0),this._viewportRepairOwnerIds.delete(e)}catch(i){Ht.error("[AcTrView2d] Error repairing viewport views:",i)}}flushViewportViewRepairs(){if(this._viewportRepairOwnerIds.size===0)return;const e=Array.from(this._viewportRepairOwnerIds);for(let t=0;t<e.length;t++)this.repairViewportViewsFor(e[t])}markProgressiveDirty(e=!1){const t=performance.now();(e||t-this._lastProgressivePaintAt>=ni.PROGRESSIVE_OPEN_PAINT_INTERVAL_MS)&&(this._isDirty=!0)}markInteractiveOpenDirty(){this._progressiveRendering||!this._cooperativeYield||(this._isDirty=!0)}shouldCountMidOpenPaint(e,t){return this._progressiveRendering&&e||!this._progressiveRendering&&this._cooperativeYield&&t}highlight(e){this.entitySelectionEnabled&&(this._isDirty=this._scene.select(e))}unhighlight(e){this._isDirty=this._scene.unselect(e)}setCompareDisplay(e,t){var n,i,o,a;const s=e.baseColor??((n=e.colors)==null?void 0:n.unchanged)??10265519,l={enabled:e.enabled,baseColor:s,colors:{deleted:(i=e.colors)==null?void 0:i.deleted,added:(o=e.colors)==null?void 0:o.added,modified:(a=e.colors)==null?void 0:a.modified},overrides:e.overrides};t?t.setCompareDisplay(l):this._scene.setCompareDisplay(l),this._isDirty=!0}stopAnimationLoop(){this._rafId!=null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}dispose(){var e,t,n;if(this._viewDisposed)return;this._viewDisposed=!0,this.abortConversion(),(e=this._disposeCanvasTouchCallout)==null||e.call(this),this._disposeCanvasTouchCallout=void 0,(t=this._disposeProgressiveInputWatch)==null||t.call(this),this._disposeProgressiveInputWatch=void 0,(n=this._disposeMobileBoxGesture)==null||n.call(this),this._disposeMobileBoxGesture=void 0,this._viewDomAbort.abort(),this._onFontNotFound&&this._renderer.events.fontNotFound.removeEventListener(this._onFontNotFound),this._onFontLoaded&&this._renderer.events.fontLoaded.removeEventListener(this._onFontLoaded),this._onSysVarChanged&&Lt.instance().events.sysVarChanged.removeEventListener(this._onSysVarChanged),this._onSettingsModified&&Kn.instance.events.modified.removeEventListener(this._onSettingsModified),this._onLayoutSwitched&&$r().layoutManager.events.layoutSwitched.removeEventListener(this._onLayoutSwitched),this._onCommandWillStartHitTest&&this.editor.events.commandWillStart.removeEventListener(this._onCommandWillStartHitTest),this._onCommandEndedHitTest&&this.editor.events.commandEnded.removeEventListener(this._onCommandEndedHitTest),this._gripManager.dispose(),this.clearFontLoadedRedrawTimer(),this.cancelOpenLineworkFrame(),this.stopAnimationLoop(),this.selectionSet.clear(),this.htmlTransientManager.dispose(),this._scene.clear(),this._renderer.dispose(),Io.instance.clear();const i=this._renderer.internalRenderer;i.dispose(),i.forceContextLoss(),this.canvas.remove(),this._css2dRenderer.domElement.remove(),this._stats.dom.remove(),super.dispose()}onHover(e){this.entitySelectionEnabled&&(this._isDirty=this._scene.hover([e]))}onUnhover(e){this._isDirty=this._scene.unhover([e])}createScene(){return new qPe}createStats(e){const t=new ag;document.body.appendChild(t.dom);const n=t.dom;return n.style.position="fixed",n.style.inset="unset",n.style.bottom="30px",n.style.right="0px",this.toggleStatsVisibility(t,e),t}onWindowResize(){this.refreshViewSize(),this._renderer.setSize(this.width,this.height),this._css2dRenderer.setSize(this.width,this.height),this._layoutViewManager.resize(this.width,this.height),this._isDirty=!0,this.events.viewResize.dispatch({width:this.width,height:this.height}),this.events.viewChanged.dispatch()}startAnimationLoop(){this._rafId==null&&(this._rafId=requestAnimationFrame(this.animate))}createLayoutViewIfNeeded(e){let t=this._layoutViewManager.getAt(e);return t==null&&(t=new B3e(this._renderer,e,this.width,this.height),t.events.viewChanged.addEventListener(()=>{this._progressiveOpenFit.onLayoutViewChanged(),this._isDirty=!0,this._progressiveRendering&&this._numOfEntitiesToProcess>0&&(this._progressivePaintUrgent=!0),this.events.viewChanged.dispatch(),this.clearHover()}),this._layoutViewManager.add(t)),this.flushViewportViewRepairs(),t}loadLayoutEntitiesIfNeeded(e){try{const t=W.instance.curDocument.database.tables.blockTable.getIdAt(e);if(!t)return;const n=this._scene.layouts.get(e);if(n&&n.isLoaded){this.repairViewportViewsFor(e);return}if(this._loadingLayouts.has(e))return;if(this.repairViewportViewsFor(e),n&&n.entityCount>0){n.isLoaded=!0;return}n||this._scene.addEmptyLayout(e);const i=[],o=t.newIterator();for(const a of o)i.push(a);if(i.length===0){const a=this._scene.layouts.get(e);a&&(a.isLoaded=!0);return}this._loadingLayouts.add(e),this._numOfEntitiesToProcess+=i.length,(async()=>{try{this._progressiveRendering?(this._convertQueue.push(...i),await this.drainConvertQueue()):await this.batchConvert(i);const a=this._scene.layouts.get(e);a&&(a.isLoaded=!0)}finally{this._loadingLayouts.delete(e)}})()}catch(t){Ht.error("[AcTrView2d] Error loading layout entities:",t)}}toggleStatsVisibility(e,t){t?e.dom.style.display="block":e.dom.style.display="none"}toLayerInfo(e){return{name:e.name,isFrozen:e.isFrozen,isOff:e.isOff,color:e.color}}resolveLayerInfo(e){const t=W.instance.curDocument.database.tables.layerTable.getAt(e);return t?this.toLayerInfo(t):void 0}async convertMissingEntitiesOnLayer(e){if(!this._convertingLayers.has(e)){this._convertingLayers.add(e);try{const t=W.instance.curDocument.database.tables.blockTable.getIdAt(this.activeLayoutBtrId);if(!t)return;const n=this._entityDisplay.collectMissingEntitiesOnLayer(e,t,i=>this.hasEntity(i));if(n.length===0)return;this._numOfEntitiesToProcess+=n.length,await this.batchConvert(n)}finally{this._convertingLayers.delete(e)}}}drawEntity(e,t){return e.worldDraw(this._renderer,t)}startTextStyleFontPreload(e){var t,n;const i=this._convertEpoch;if(this._textStyleFontPreloadEpoch===i&&this._textStyleFontPreloadPromise)return;this._textStyleFontPreloadEpoch=i;const o=h3e(e),a=it.instance.getFontsToLoad(),s=[...it.instance.defaultFonts][0],l=d3e(o,a,{firstDefaultFont:s}),c=bn.getInstance().getRenderMode()==="worker"?"worker":"main",u=W,h=(n=(t=u._instance)==null?void 0:t.lastPresetFontsForOpen)!=null&&n.length?[...u._instance.lastPresetFontsForOpen]:[...a];if(this._fontPreloadDiag={critical:[...l.critical],workerWarm:[],background:[],preset:h,workerSkipped:0,parseSite:c},c==="worker"){this._textStyleFontPreloadPromise=Promise.resolve();return}const d=3e4;if(l.critical.length===0){this._textStyleFontPreloadPromise=Promise.resolve();return}const f=it.instance.requestFonts(l.critical);this._textStyleFontPreloadPromise=new Promise(p=>{const m=setTimeout(()=>{p()},d);f.then(()=>{clearTimeout(m),p()},()=>{clearTimeout(m),p()})})}async awaitTextStyleFontsReady(){if(!this._textStyleFontPreloadPromise){const e=this._renderer.context.database;if(e)this.startTextStyleFontPreload(e);else return}await this._textStyleFontPreloadPromise}async finishEntityGeometry(e,t){const n=performance.now();try{const i=e instanceof Rn,o=i&&this.groupHasPendingGlyphGeometry(e);(o||Jl(e)||e instanceof lo&&!e.hasDrawableGeometry())&&await this.ensureDeferredFontsReady();const a=()=>{this._convertPhaseMs.glyphEntityCount++,e instanceof T_?this._convertPhaseMs.mtextCount++:e instanceof np&&this._convertPhaseMs.shapeCount++};if(i){if(!o)return;a();const l=performance.now();await e.asyncDraw(),this._convertPhaseMs.finishGeometryAsyncDraw+=performance.now()-l;return}if(Jl(e)){a();const l=performance.now();await e.asyncDraw(),this._convertPhaseMs.finishGeometryAsyncDraw+=performance.now()-l;return}if(e.hasDrawableGeometry())return;a();const s=performance.now();await e.asyncDraw(),this._convertPhaseMs.finishGeometryAsyncDraw+=performance.now()-s}finally{this._convertPhaseMs.finishGeometry+=performance.now()-n}}needsDeferredFontGeometry(e){return e instanceof lo?!e.hasDrawableGeometry():e instanceof Rn?this.groupHasPendingGlyphGeometry(e):Jl(e)}clearFontLoadedRedrawTimer(){this._fontLoadedRedrawTimer!=null&&(clearTimeout(this._fontLoadedRedrawTimer),this._fontLoadedRedrawTimer=null)}scheduleGlyphRedrawAfterFontLoad(e){this.clearFontLoadedRedrawTimer();const t=this._convertEpoch;this._fontLoadedRedrawTimer=setTimeout(()=>{this._fontLoadedRedrawTimer=null,t===this._convertEpoch&&this.redrawGlyphEntitiesAfterFontLoad(t,e)},50)}async redrawGlyphEntitiesAfterFontLoad(e,t){var n,i;if(e!==this._convertEpoch)return;const o=++this._fontLoadedRedrawEpoch,a=[];for(const c of this._scene.layouts.values())c.layers.forEach(u=>{u.internalObject.traverse(h=>{h instanceof lo&&a.push(h)})});for(const c of a){if(e!==this._convertEpoch||o!==this._fontLoadedRedrawEpoch)return;await c.asyncDraw()}if(a.length>0){e===this._convertEpoch&&(this._isDirty=!0);return}if(t){const c=it.instance.defaultFonts,u=t.toLowerCase();if(c.has(t)||c.has(u)||[...c].some(h=>h.toLowerCase()===u))return}if(e!==this._convertEpoch||o!==this._fontLoadedRedrawEpoch||this._entityProcessingIdleAt<=0)return;const s=performance.now()-this._entityProcessingIdleAt;if(!V3e(this.isProcessingEntities,0,s))return;const l=(i=(n=W.instance)==null?void 0:n.curDocument)==null?void 0:i.database;l&&l.regen()}groupHasPendingGlyphGeometry(e){for(const t of e.getSourceEntities())if(t instanceof lo&&!t.hasDrawableGeometry())return!0;return ni.directChildrenHavePendingGlyphs(e)}static directChildrenHavePendingGlyphs(e){const t=e.children;for(let n=0;n<t.length;n++){const i=t[n];if(i instanceof lo){if(!i.hasDrawableGeometry())return!0;continue}if(i instanceof Rn){for(const o of i.getSourceEntities())if(o instanceof lo&&!o.hasDrawableGeometry())return!0;if(ni.directChildrenHavePendingGlyphs(i))return!0;continue}if(i instanceof Xn&&ni.directChildrenHavePendingGlyphs(i))return!0}return!1}enqueueDeferredGeometry(e,t){t===this._convertEpoch&&(this._pendingGeometryJobs++,this._deferredGeometryQueue.push({run:e,epoch:t,enqueuedAt:performance.now()}),this.pumpDeferredGeometryQueue())}pumpDeferredGeometryQueue(){for(;this._deferredGeometryActive<ni.DEFERRED_GEOMETRY_CONCURRENCY&&this._deferredGeometryQueue.length>0;){const e=this._deferredGeometryQueue.shift();if(e.epoch!==this._convertEpoch){this._pendingGeometryJobs=Math.max(0,this._pendingGeometryJobs-1);continue}this._convertPhaseMs.finishGeometryQueueWait+=performance.now()-e.enqueuedAt,this._deferredGeometryActive++,e.run().then(()=>{e.epoch===this._convertEpoch&&(this._progressiveRendering||this._cooperativeYield)&&(this._isDirty=!0)}).catch(t=>{Ht.error("[AcTrView2d] Deferred entity geometry failed:",t)}).finally(()=>{this._deferredGeometryActive=Math.max(0,this._deferredGeometryActive-1),e.epoch===this._convertEpoch&&(this._pendingGeometryJobs=Math.max(0,this._pendingGeometryJobs-1),this._pendingGeometryJobs===0&&(this._isDirty=!0),this.stampEntityProcessingIdle()),this.pumpDeferredGeometryQueue()})}}resetDeferredGeometryQueue(){this._deferredGeometryQueue.length=0,this._pendingGeometryJobs=0,this._textStyleFontPreloadPromise=null,this._textStyleFontPreloadEpoch=-1,this._deferredFontsReady=null,this._fontPreloadDiag=null}async waitUntilDeferredGeometryIdle(){const e=this._convertEpoch;for(;e===this._convertEpoch&&this._pendingGeometryJobs>0;)await new Promise(t=>setTimeout(t,0))}attachViewportView(e){if(Vd.isDefaultPaperSpaceViewport(e))return;const t=e.ownerId,n=t?this._layoutViewManager.getAt(t):void 0;if(!n){t&&this._viewportRepairOwnerIds.add(t);return}n.addViewport(new Vd(n,this.toGiViewportWithFrozenLayers(e),this._renderer)),this._isDirty=!0}ensureViewportViews(e,t){const n=e.newIterator();for(const i of n){if(!(i instanceof Va)||Vd.isDefaultPaperSpaceViewport(i))continue;const o=new Vd(t,this.toGiViewportWithFrozenLayers(i),this._renderer);t.addViewport(o)}}toGiViewportWithFrozenLayers(e){var t;const n=e.toGiViewport();if(n.frozenLayers&&n.frozenLayers.length>0)return n;const i=e.frozenLayerIds;if(!(i!=null&&i.length))return n;const o=[],a=(t=e.database)==null?void 0:t.tables.layerTable;if(a)for(const s of i){const l=a.getIdAt(s);l&&o.push(l.name)}return n.frozenLayerIds=[...i],n.frozenLayers=o,n}async batchConvert(e,t={}){const n=this._convertEpoch;if(!t.forExport&&!this._textStyleFontPreloadPromise){const l=this._renderer.context.database;l&&this.startTextStyleFontPreload(l)}const i=this._progressiveRendering&&!t.forExport,o=i?ni.PROGRESSIVE_OPEN_YIELD_BUDGET_MS:ni.OPEN_CONVERT_YIELD_BUDGET_MS,a=t.forExport||!this._cooperativeYield?void 0:new ty(o),s=()=>new Promise(l=>setTimeout(l,0));for(let l=0;l<e.length;++l){const c=e[l];try{if(n!==this._convertEpoch||c instanceof Va&&Vd.isDefaultPaperSpaceViewport(c)||!(t.forExport||this._convertInvisibleLayers?this._entityDisplay.shouldConvertForExport(c):this._entityDisplay.shouldConvert(c)))continue;const u=String(c.objectId??"");let h=0;if(u&&(this.hasEntity(u)||this._claimedConvertObjectIds.has(u))){c instanceof Va&&this.attachViewportView(c);continue}u&&(this._claimedConvertObjectIds.add(u),h=this._entityConvertGeneration.get(u)??0);const d=c_e(c,this._renderer);if(d){let p=!1,m=!1;try{u&&(this._entityConvertGeneration.get(u)??0)!==h?m=!0:(p=this._scene.addDirectEntity(d,u_e(c)),p&&(this.applySessionHiddenObjectState(c.objectId),i?(this.markProgressiveDirty(),this._progressiveOpenFit.afterGeometryBatch(()=>this.getDrawingExtents(),l)):this.markInteractiveOpenDirty()))}finally{d.geometry.dispose()}if(m||p)continue}const f=this.drawEntity(c,!1);if(!f&&!(c instanceof Va)){u&&this._claimedConvertObjectIds.delete(u);continue}if(f){f.objectId=c.objectId,f.ownerId=c.ownerId,f.layerName=c.layer,f.visible=c.visibility!==!1,f instanceof Rn&&f.isOnTheSameLayer&&(f.userData.insertLayerName=f.layerName);const p=f instanceof Rn&&!f.isOnTheSameLayer,m=!t.forExport&&this.needsDeferredFontGeometry(f);if(p)m?this.enqueueDeferredGeometry(()=>this.handleGroup(f,i,n,h),n):await this.handleGroup(f,i,n,h);else{const g=!(c instanceof Fh||c instanceof py),y=async()=>{if(await this.finishEntityGeometry(f,i),n!==this._convertEpoch){f.dispose();return}if(u&&(this._entityConvertGeneration.get(u)??0)!==h){f.dispose();return}f instanceof Rn&&(this.syncGroupSpatialBoundsForIndexing(f),f.isOnTheSameLayer&&this._inheritedLayerMaterialMapper.remap(f.children,"0",f.layerName));const v=performance.now();this._scene.addEntity(f,g),this._convertPhaseMs.addEntity+=performance.now()-v,this.applySessionHiddenObjectState(c.objectId),f.dispose(),i?(this.markProgressiveDirty(),this._progressiveOpenFit.afterGeometryBatch(()=>this.getDrawingExtents(),l)):this.markInteractiveOpenDirty()};m?this.enqueueDeferredGeometry(y,n):await y()}}if(n!==this._convertEpoch)continue;if(c instanceof Va)this.attachViewportView(c);else if(c instanceof Rh){const p=c.imageFileName;p&&!c.image?this._missedImages.set(c.objectId,p):c.image&&this._missedImages.delete(c.objectId)}}catch(u){const h=String(c.objectId??"");h&&this._claimedConvertObjectIds.delete(h),Ht.error(`[AcTrView2d] Failed to convert entity ${c.objectId} (${c.type}):`,u)}finally{n===this._convertEpoch&&this.decreaseNumOfEntitiesToProcess()}n===this._convertEpoch&&(i?await this.progressiveYieldForInput(a,s):a&&await a.maybeYield(s)&&this._progressiveYieldCount++)}}syncGroupSpatialBoundsForIndexing(e){const t=e.peekLazyChildBoxes();if(t&&t.boxes.length>0){const o=e.userData;o.lazySpatialChildren=t;return}if(e.refreshWcsChildBoxesFromChildren(),e.wcsChildBoxes.length===0)return;const n=e.wcsChildBoxes.map(o=>({minX:o.minX,minY:o.minY,maxX:o.maxX,maxY:o.maxY,id:o.id}));e.wcsBbox=LB(e);const i=e.userData;i.spatialIndexChildBoxes=n}async handleGroup(e,t,n=this._convertEpoch,i=0){const o=performance.now();try{if(await this.finishEntityGeometry(e,t),n!==this._convertEpoch){e.dispose();return}const a=String(e.objectId??"");if(a&&(this._entityConvertGeneration.get(a)??0)!==i){e.dispose();return}this.syncGroupSpatialBoundsForIndexing(e);const s=e.children,l=new Map;s.forEach(v=>{var x;if(v.visible===!1)return;const b=v.userData.layerName;l.has(b)||l.set(b,[]),(x=l.get(b))==null||x.push(v)}),e.children=[];for(const v of s)v.parent=null;const c=e.renderContext,u=e.objectId,h=e.layerName,d=e.userData.lazySpatialChildren,f=d?[]:e.wcsChildBoxes.map(v=>({minX:v.minX,minY:v.minY,maxX:v.maxX,maxY:v.maxY,id:v.id})),p=d?e.wcsBbox.clone():f.length>0?LB(e):e.wcsBbox.clone();f.length>0&&(e.wcsBbox=p.clone());let m=!1;const g=()=>new Promise(v=>setTimeout(v,0));let y=t?performance.now():0;for(const[v,x]of l){const b=v==="0"?h:v,w=x.some(E=>(E.userData.authoredLayerName??v)==="0")?"0":v;this._inheritedLayerMaterialMapper.remap(x,w,b);const _=new Xn(c);_.matrix.copy(e.matrix),_.matrixAutoUpdate=!1,_.matrixWorldNeedsUpdate=!0,_.objectId=u,_.ownerId=e.ownerId,_.layerName=b,_.userData.insertLayerName=h,_.wcsBbox=p.clone();const P=_.userData;!m&&d?(_.userData.lazySpatialChildren=d,m=!0):!m&&f.length>0&&(P.spatialIndexChildBoxes=f,m=!0);for(let E=0;E<x.length;E++)_.add(x[E]);_.updateMatrixWorld(!0),this._layerAppearance.refreshTextMaterialsInObjectTree(_);const S=performance.now();this._scene.addEntity(_,!0),this._convertPhaseMs.addEntity+=performance.now()-S,this.applySessionHiddenObjectState(u),_.dispose(),t&&n===this._convertEpoch&&performance.now()-y>=ni.PROGRESSIVE_OPEN_YIELD_BUDGET_MS&&(await g(),y=performance.now())}e.dispose(),t?(this.markProgressiveDirty(),this._progressiveOpenFit.afterGeometryBatch(()=>this.getDrawingExtents())):this.markInteractiveOpenDirty()}finally{this._convertPhaseMs.handleGroup+=performance.now()-o}}decreaseNumOfEntitiesToProcess(){this._numOfEntitiesToProcess--,this._numOfEntitiesToProcess<0?(this._numOfEntitiesToProcess=0,Ht.warn("Something wrong! The number of entities to process should not be less than 0.")):this._numOfEntitiesToProcess===0&&(this._isDirty=!0,Vt.emit("missed-data-changed",{})),this.stampEntityProcessingIdle()}frameOpenLineworkIfReady(){if(!this._openLineworkFramePending||this.isConvertingEntities)return;const e=this.getDrawingExtents();if(!e||e.isEmpty()){this._openLineworkFramePending=!1;return}this._openLineworkFramePending=!1,this._progressiveOpenFit.frameProgrammatically(e)}stampEntityProcessingIdle(){this._numOfEntitiesToProcess===0&&this._pendingGeometryJobs===0&&(this._entityProcessingIdleAt=performance.now(),this.scheduleMeshGlyphWorldBatchFlush(),Io.instance.clear())}clearMeshGlyphFlushTimer(){this._meshGlyphFlushTimer!=null&&(clearTimeout(this._meshGlyphFlushTimer),this._meshGlyphFlushTimer=null)}scheduleMeshGlyphWorldBatchFlush(){if(!bn.getInstance().getMeshGlyphInstancing())return;this.clearMeshGlyphFlushTimer();const e=this._convertEpoch;this._meshGlyphFlushTimer=setTimeout(()=>{this._meshGlyphFlushTimer=null,e===this._convertEpoch&&(this._numOfEntitiesToProcess>0||this._pendingGeometryJobs>0||this.flushMeshGlyphWorldBatch())},16)}flushMeshGlyphWorldBatch(){this.clearMeshGlyphFlushTimer();const e=bn.getInstance();if(!e.getMeshGlyphInstancing())return;const{placements:t,buckets:n}=e.flushMeshGlyphInstances(this._scene.internalScene,i=>this.resolveMeshGlyphLayerParent(i));t>0&&console.log(`[cad-simple-viewer-cli] mesh glyph InstancedMesh flush: placements=${t} buckets=${n}`)}resolveMeshGlyphLayerParent(e){var t;const n=(t=this._scene.activeLayout)==null?void 0:t.getLayer(e);if(n)return n.internalObject;for(const i of this._scene.layouts.values()){const o=i.getLayer(e);if(o)return o.internalObject}return null}};Il.OPEN_CONVERT_YIELD_BUDGET_MS=300,Il.PROGRESSIVE_OPEN_YIELD_BUDGET_MS=32,Il.PROGRESSIVE_INPUT_PAUSE_MS=120,Il.PROGRESSIVE_OPEN_PAINT_INTERVAL_MS=2500,Il.NON_PROGRESSIVE_OPEN_PAINT_INTERVAL_MS=4e3,Il.DEFERRED_GEOMETRY_CONCURRENCY=8,Il.CONVERT_SLICE_BUDGET_MS=64,Il.CONVERT_SLICE_MAX=512;let Ow=Il;function H3e(r){if(!r)return!1;const e=Object.keys(r);return e.length>0&&e.every(t=>t==="visibility")}function G3e(r,e,t){const{entity:n,changes:i}=r,o=n.objectId;if(!e(o))return!1;if(H3e(i))return!(i.visibility===!0&&t(o)===void 0);if(i&&Object.keys(i).length>0)return!1;const a=t(o);return a===void 0?!1:a&&!n.visibility}function d4(r){return Array.isArray(r)?r:[r]}class dE{constructor(e,t){this._active=!0,this._disposers=[],this._view=e,this._doc=t;const n=(i,o)=>{i.addEventListener(o),this._disposers.push(()=>i.removeEventListener(o))};n(t.database.events.entityAppended,i=>{if(!this._active)return;const o=d4(i.entity).filter(a=>!this.view.hasEntity(a.objectId));o.length!==0&&this.view.addEntity(o.length===1?o[0]:o)}),n(t.database.events.entityModified,i=>{if(!this._active)return;const o=i,a=this.view;a instanceof Ow&&G3e(o,s=>a.hasEntity(s),s=>a.getEntityVisible(s))&&a.updateEntityVisibility(o.entity)||this.view.updateEntity(o.entity)}),n(t.database.events.entityErased,i=>{if(!this._active)return;const o=d4(i.entity).filter(a=>this.view.hasEntity(a.objectId));o.length!==0&&this.view.removeEntity(o.length===1?o[0]:o)}),n(t.database.events.layerAppended,i=>{this._active&&this._view.addLayer(i.layer)}),n(t.database.events.layerModified,i=>{this._active&&this._view.updateLayer(i.layer,i.changes)}),n(Lt.instance().events.sysVarChanged,i=>{if(!(!this._active||i.database!==this._doc.database)){if(i.name==ae.PDMODE.toLowerCase()||i.name==ae.PDSIZE.toLowerCase())this._view.rerenderPoints(i.database.pdmode,i.database.pdsize);else if(i.name==ae.LWDISPLAY.toLowerCase()){const o=this._view,a=!!i.database.lwdisplay;o.renderer.showLineWeight!==a&&(o.renderer.showLineWeight=a,o.clear(),i.database.regen())}}}),n(t.database.events.dictObjetSet,i=>{this._active&&i.object instanceof ec&&this._view.addLayout(i.object)}),n(e.selectionSet.events.selectionAdded,i=>{this._active&&e.highlight(i.ids)}),n(e.selectionSet.events.selectionRemoved,i=>{this._active&&e.unhighlight(i.ids)})}get view(){return this._view}get doc(){return this._doc}get isActive(){return this._active}suspend(){this._active=!1}resume(){this._active=!0}dispose(){this._active=!1;for(const e of this._disposers)e();this._disposers.length=0}}function EG(r){return typeof r.hasEntity=="function"&&typeof r.setEntitySceneVisible=="function"}function W3e(r,e){const t=r.view;if(!EG(t))return 0;const n=r.doc,i=n.database;let o=0;for(const a of e){if(n.isObjectHidden(a))continue;const s=i.tables.blockTable.getEntityById(a);!(s!=null&&s.visibility)||!t.hasEntity(a)||t.setEntitySceneVisible(a,!1)&&(n.addHiddenObject(a),o++)}return o>0&&t.selectionSet.clear(),o}function $3e(r){const e=r.view;if(!EG(e))return 0;const t=r.doc,n=t.database,i=t.takeHiddenObjects();let o=0;for(const a of i){const s=n.tables.blockTable.getEntityById(a);!s||!e.hasEntity(a)||e.setEntitySceneVisible(a,s.visibility)&&o++}return e.selectionSet.clear(),o}const X3e="SvgPlugin",Y3e=["csvg"];function q3e(r){r.registerLazyPlugin({name:X3e,triggers:[...Y3e],loader:async()=>{const{createSvgPlugin:e}=await Qg(async()=>{const{createSvgPlugin:t}=await import("./cad-svg-plugin-CXH4E96n.js");return{createSvgPlugin:t}},[],import.meta.url);return e()}})}var nf=function(){return nf=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},nf.apply(this,arguments)},Bu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},f4=(function(){function r(){}return r.prototype.convert=function(e){var t=this.createEntity(e);if(t&&(this.processCommonAttrs(e,t),e.type==="ARCALIGNEDTEXT")){var n=e.rawTextColor;t.applyRawTextColor(n)}return t},r.prototype.createEntity=function(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="ATTDEF"?this.convertAttributeDefinition(e):e.type=="ATTRIB"?this.convertAttribute(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MLINE"?this.convertMLine(e):e.type=="MTEXT"?this.convertMText(e):e.type=="MULTILEADER"||e.type=="MLEADER"?this.convertMLeader(e):e.type=="POINT"?this.convertPoint(e):e.type=="POLYLINE2D"?this.convertPolyline2d(e):e.type=="POLYLINE3D"?this.convertPolyline3d(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="TOLERANCE"?this.convertTolerance(e):e.type=="SHAPE"?this.convertShape(e):e.type=="SOLID"?this.convertSolid(e):e.type=="TRACE"?this.convertTrace(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):e.type=="ACAD_PROXY_ENTITY"?this.convertProxyEntity(e):e.type=="OLE2FRAME"?this.convertOle2Frame(e):e.type=="OLEFRAME"?this.convertOleFrame(e):e.type=="ARCALIGNEDTEXT"?this.convertArcAlignedText(e):null},r.prototype.convertProxyEntity=function(e){var t,n=new KA;if(n.proxyEntityClassId=e.proxyEntityClassId,e.originalDxfName&&(n.originalDxfName=e.originalDxfName),e.applicationEntityClassId!=null&&(n.applicationEntityClassId=e.applicationEntityClassId),e.objectDrawingFormat!=null&&(n.objectDrawingFormat=e.objectDrawingFormat),e.originalDataFormat!=null&&(n.originalDataFormat=e.originalDataFormat),e.graphicsData){var i=rh([e.graphicsData]),o=(t=e.graphicsDataSize)!==null&&t!==void 0?t:i.length;n.setProxyGraphic(i.subarray(0,o))}return n},r.prototype.convertFace=function(e){var t=new TA;return e.corner1&&t.setVertexAt(0,e.corner1),e.corner2&&t.setVertexAt(1,e.corner2),e.corner3&&t.setVertexAt(2,e.corner3),e.corner4&&t.setVertexAt(3,e.corner4),t.setEdgeInvisibilities(e.flag),t},r.prototype.convertArc=function(e){var t,n=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,i=new tc(Ei(e.center,n),e.radius,e.startAngle,e.endAngle,n);return i},r.prototype.convertCirle=function(e){var t,n=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,i=new ba(Ei(e.center,n),e.radius,n);return i},r.prototype.convertEllipse=function(e){var t,n=new X(e.majorAxisEndPoint),i=n.length(),o=new Dh(e.center,(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,n,i,i*e.axisRatio,e.startAngle,e.endAngle);return o},r.prototype.convertLine=function(e){var t=e.startPoint,n=e.endPoint,i=new es(new D(t.x,t.y,t.z),new D(n.x,n.y,n.z));return i},r.prototype.convertSpline=function(e){return Us.fromDwgSpline(e)},r.prototype.convertPoint=function(e){var t=new a_;return t.position=e.position,t},r.prototype.convertShape=function(e){var t,n,i,o,a,s=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,l=new ZA;return l.position=Ei(e.insertionPoint,s),l.size=e.size,l.shapeNumber=e.shapeNumber,e.styleName&&(l.styleName=e.styleName),l.rotation=(n=e.rotation)!==null&&n!==void 0?n:0,l.widthFactor=(i=e.xScale)!==null&&i!==void 0?i:1,l.oblique=(o=e.obliqueAngle)!==null&&o!==void 0?o:0,l.thickness=(a=e.thickness)!==null&&a!==void 0?a:0,l.normal.copy(s),l},r.prototype.convertSolid=function(e){return this.convertTraceLike(new JA,e)},r.prototype.convertTrace=function(e){return this.convertTraceLike(new s_,e)},r.prototype.convertTraceLike=function(e,t){var n,i,o,a=(n=t.extrusionDirection)!==null&&n!==void 0?n:X.Z_AXIS,s=function(c){var u;return Ei({x:c.x,y:c.y,z:(u=c.z)!==null&&u!==void 0?u:0},a)},l=(i=t.corner4)!==null&&i!==void 0?i:t.corner3;return e.setPointAt(0,s(t.corner1)),e.setPointAt(1,s(t.corner2)),e.setPointAt(2,s(t.corner3)),e.setPointAt(3,s(l)),e.thickness=(o=t.thickness)!==null&&o!==void 0?o:0,e.normal.copy(a),e.elevation=e.getPointAt(0).z,e},r.prototype.convertLWPolyline=function(e){var t,n=new sn;n.closed=!!(e.flag&512);var i=(t=e.constantWidth)!==null&&t!==void 0?t:-1;return e.vertices.forEach(function(o,a){var s,l;n.addVertexAt(a,new re(o.x,o.y),o.bulge,(s=o.startWidth)!==null&&s!==void 0?s:i,(l=o.endWidth)!==null&&l!==void 0?l:i)}),n},r.prototype.convertPolyline2d=function(e){var t,n,i,o,a=!!(e.flag&1),s=!!(e.flag&16),l=!!(e.flag&64),c=!!(e.flag&32),u=[],h=[],d=[];if(e.vertices.map(function(y){var v,x;if(!(y.flag&16))if(l&&y.flag&128)if(y.flag&64)u.push({x:y.x,y:y.y,z:y.z}),h.push((v=y.bulge)!==null&&v!==void 0?v:0);else{var b=[];y.polyfaceIndex0!=null&&y.polyfaceIndex0!=0&&b.push(Math.abs(y.polyfaceIndex0)-1),y.polyfaceIndex1!=null&&y.polyfaceIndex1!=0&&b.push(Math.abs(y.polyfaceIndex1)-1),y.polyfaceIndex2!=null&&y.polyfaceIndex2!=0&&b.push(Math.abs(y.polyfaceIndex2)-1),y.polyfaceIndex3!=null&&y.polyfaceIndex3!=0&&b.push(Math.abs(y.polyfaceIndex3)-1),b.length>=3&&d.push(b)}else u.push({x:y.x,y:y.y,z:y.z}),h.push((x=y.bulge)!==null&&x!==void 0?x:0)}),s){var f=(t=e.meshMVertexCount)!==null&&t!==void 0?t:2,p=(n=e.meshNVertexCount)!==null&&n!==void 0?n:2;return new mC(f,p,u,a,c)}else{if(l)return new pC(u,d);var m=po.SimplePoly;e.flag&2?m=po.FitCurvePoly:e.flag&4&&(e.smoothType==6?m=po.CubicSplinePoly:e.smoothType==5&&(m=po.QuadSplinePoly));var g=new my(m,u,(o=(i=u[0])===null||i===void 0?void 0:i.z)!==null&&o!==void 0?o:0,a,e.startWidth,e.endWidth,h);return e.extrusionDirection&&(g.normal=e.extrusionDirection),g}},r.prototype.convertPolyline3d=function(e){var t=!!(e.flag&1),n=[];e.vertices.map(function(o){o.flag&16||n.push({x:o.x,y:o.y,z:o.z})});var i=Ka.SimplePoly;return e.flag&4&&(e.smoothType==6?i=Ka.CubicSplinePoly:e.smoothType==5&&(i=Ka.QuadSplinePoly)),new fC(i,n,t)},r.prototype.convertHatch=function(e){var t,n,i,o,a=new hy;(t=e.definitionLines)===null||t===void 0||t.forEach(function(u){a.definitionLines.push({angle:u.angle,base:u.base,offset:u.offset,dashLengths:u.numberOfDashLengths>0?u.dashLengths:[]})}),a.hatchStyle=e.hatchStyle,a.patternName=e.patternName,e.solidFill==1&&(a.isSolidFill=!0),a.patternType=e.patternType,a.patternAngle=e.patternAngle==null?0:e.patternAngle,a.patternScale=e.patternScale==null?0:e.patternScale;var s=e.boundaryPaths;if(s.forEach(function(u){var h=u.boundaryPathTypeFlag;if(h&2){var d=u,f=new Sn;f.closed=d.isClosed,d.vertices.forEach(function(y,v){f.addVertexAt(v,{x:y.x,y:y.y,bulge:y.bulge})}),a.add(f)}else{var p=u,m=[];p.edges.forEach(function(y){if(y!=null){if(y.type==1){var v=y;m.push(new Pi(v.start,v.end))}else if(y.type==2){var x=y;m.push(new wt(x.center,x.radius,x.startAngle,x.endAngle,!x.isCCW))}else if(y.type==3){var b=y,w=new vn;w.subVectors(b.end,b.center);var _=Math.sqrt(Math.pow(b.end.x,2)+Math.pow(b.end.y,2)),P=_*b.lengthOfMinorAxis,S=b.startAngle,E=b.endAngle,C=Math.atan2(b.end.y,b.end.x);b.isCCW||(S=Math.PI*2-S,E=Math.PI*2-E),m.push(new Is(nf(nf({},b.center),{z:0}),_,P,S,E,!b.isCCW,C))}else if(y.type==4){var k=_i.fromDwgSplineEdge(y);k&&m.push(k)}}});var g=Wl.buildFromEdges(m);g.length===1?a.add(g[0]):m.length>0&&a.add(new Wl(m))}}),e.gradientFlag){var l=e;if(a.hatchObjectType=ih.GradientObject,a.gradientName=l.gradientName,a.gradientAngle=(n=l.gradientRotation)!==null&&n!==void 0?n:0,a.gradientShift=(i=l.gradientDefinition)!==null&&i!==void 0?i:0,a.gradientOneColorMode=l.gradientColorFlag==1,a.shadeTintValue=(o=l.colorTint)!==null&&o!==void 0?o:0,l.gradientColors){var c=l.gradientColors.length;c>1?(a.gradientStartColor=l.gradientColors[0].rgb,a.gradientEndColor=l.gradientColors[1].rgb):c>0&&(a.gradientStartColor=l.gradientColors[0].rgb)}}return e.extrusionDirection&&(a.normal=e.extrusionDirection),a},r.prototype.convertTable=function(e){var t,n=new QA((t=e.name)!==null&&t!==void 0?t:"",e.rowCount,e.columnCount);return n.tableStyleId=e.tableStyleId,n.owningBlockRecordId=e.blockRecordHandle,e.directionVector&&(n.horizontalDirection=new X(e.directionVector)),n.attachmentPoint=e.attachmentPoint,n.position.copy(e.startPoint),n.tableValueFlag=e.tableValue,n.tableOverrideFlag=e.overrideFlag,n.borderColorOverrideFlag=e.borderColorOverrideFlag,n.borderLineweightOverrideFlag=e.borderLineWeightOverrideFlag,n.borderVisibilityOverrideFlag=e.borderVisibilityOverrideFlag,e.columnWidthArr.forEach(function(i,o){return n.setColumnWidth(o,i)}),e.rowHeightArr.forEach(function(i,o){return n.setRowHeight(o,i)}),e.cells.forEach(function(i,o){n.setCell(o,i)}),n},r.prototype.convertText=function(e){var t,n,i,o=new vh;o.textString=e.text,o.styleName=e.styleName,o.height=e.textHeight,o.position.copy(e.startPoint);var a=!e.endPoint||e.endPoint.x===0&&e.endPoint.y===0&&((t=e.endPoint.z)!==null&&t!==void 0?t:0)===0;return e.endPoint&&!a?(o.alignmentPoint.copy(e.endPoint),o.hasAlignmentPoint=!0):(o.alignmentPoint.copy(e.startPoint),o.hasAlignmentPoint=!1),o.rotation=e.rotation,o.oblique=(n=e.obliqueAngle)!==null&&n!==void 0?n:0,o.thickness=e.thickness,o.horizontalMode=e.halign,o.verticalMode=e.valign,o.widthFactor=(i=e.xScale)!==null&&i!==void 0?i:1,o},r.prototype.convertArcAlignedText=function(e){var t=new MA;return t.textString=e.text,t.textSize=e.textSize,t.xScale=e.xScale>0?e.xScale:1,t.characterSpacing=e.characterSpacing,e.styleName&&(t.styleName=e.styleName),t.fontName=e.fontName,t.bigFontName=e.bigFontName,t.offsetFromArc=e.offsetFromArc,t.rightOffset=e.rightOffset,t.leftOffset=e.leftOffset,t.center=new D(e.center.x,e.center.y,e.center.z),t.radius=e.radius,t.startAngle=e.startAngle,t.endAngle=e.endAngle,t.normal=new X(e.extrusionDirection.x,e.extrusionDirection.y,e.extrusionDirection.z||1),t.characterSet=e.characterSet,t.pitchAndFamily=e.pitchAndFamily,t.isShx=e.isShx,t.isBold=e.isBold,t.isItalic=e.isItalic,t.isUnderlined=e.isUnderlined,t.alignment=e.alignment,t.isReverse=e.isReverse,t.wizardFlag=e.wizardFlag,t.textPosition=e.textPosition,t.textDirection=e.textDirection,e.arcHandle&&(t.arcId=e.arcHandle),t},r.prototype.convertTolerance=function(e){var t,n=new HA;return n.location.copy(e.insertionPoint),n.text=e.text,n.dimensionStyle=(t=e.styleName)!==null&&t!==void 0?t:"",e.extrusionDirection&&n.normal.copy(e.extrusionDirection),e.xAxisDirection&&n.direction.copy(e.xAxisDirection),n},r.prototype.convertMText=function(e){var t=new oc;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.textHeight,t.width=e.rectWidth,t.rotation=e.rotation||0,t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new X(e.direction)),t.drawingDirection=e.drawingDirection,e.lineSpacing!=null&&e.lineSpacing>0&&(t.lineSpacingFactor=e.lineSpacing),e.lineSpacingStyle!=null&&(t.lineSpacingStyle=e.lineSpacingStyle),e.extentsWidth!=null&&e.extentsWidth>0&&(t.extentsWidth=e.extentsWidth),t},r.prototype.convertLeader=function(e){var t,n=new $A;return e.vertices.forEach(function(i){n.appendVertex(i)}),n.hasArrowHead=e.isArrowheadEnabled,n.hasHookLine=e.isHooklineExists,n.isHookLineSameDirection=e.isHooklineSameDirection,n.isSplined=e.isSpline,n.dimensionStyle=(t=e.styleName)!==null&&t!==void 0?t:"",n.annoType=e.leaderCreationFlag,e.textHeight!=null&&(n.textHeight=e.textHeight),e.textWidth!=null&&(n.textWidth=e.textWidth),e.byBlockColor!=null&&(n.byBlockColor=e.byBlockColor),e.associatedAnnotation&&(n.associatedAnnotation=e.associatedAnnotation),e.normal&&(n.normal=e.normal),e.horizontalDirection&&(n.horizontalDirection=e.horizontalDirection),e.offsetFromBlock&&(n.offsetFromBlock=e.offsetFromBlock),e.offsetFromAnnotation&&(n.offsetFromAnnotation=e.offsetFromAnnotation),n},r.prototype.convertMLine=function(e){var t,n,i,o=new fy;return o.styleName=e.mlineStyle||"STANDARD",o.scale=e.scale,o.flags=e.flags,o.justification=e.justification,o.startPosition=e.startPoint,o.normal=(t=e.extrusionDirection)!==null&&t!==void 0?t:X.Z_AXIS,o.styleCount=(n=e.numberOfLines)!==null&&n!==void 0?n:0,o.segments=((i=e.vertices)!==null&&i!==void 0?i:[]).map(function(a){var s;return{position:a.vertex,direction:a.vertexDirection,miterDirection:a.miterDirection,elements:((s=a.lines)!==null&&s!==void 0?s:[]).map(function(l){var c,u;return{parameterCount:l.numberOfSegmentParams,parameters:(c=l.segmentParams)!==null&&c!==void 0?c:[],fillCount:l.numberOfAreaFillParams,fillParameters:(u=l.areaFillParams)!==null&&u!==void 0?u:[]}})}}),o},r.prototype.convertMLeader=function(e){var t,n,i,o,a,s,l,c,u,h,d,f,p,m,g,y,v=new XA,x=e;v.version=e.version,v.leaderStyleId=e.leaderStyleId,e.leaderStyleId&&(v.mleaderStyleId=e.leaderStyleId),v.propertyOverrideFlag=e.propertyOverrideFlag,v.leaderLineType=(t=e.leaderLineType)!==null&&t!==void 0?t:Ui.StraightLeader,e.leaderLineColor!=null&&(v.leaderLineColor=this.convertMLeaderEntityColor(e.leaderLineColor)),v.leaderLineTypeId=e.leaderLineTypeId,v.leaderLineWeight=e.leaderLineWeight,v.landingEnabled=e.landingEnabled,v.doglegEnabled=(n=e.doglegEnabled)!==null&&n!==void 0?n:!1,v.doglegLength=(i=e.doglegLength)!==null&&i!==void 0?i:0,v.arrowheadId=e.arrowheadId,v.arrowheadSize=e.arrowheadSize,v.textStyleId=e.textStyleId,v.textLeftAttachmentType=e.textLeftAttachmentType,v.textRightAttachmentType=e.textRightAttachmentType,v.textAngleType=e.textAngleType,v.textAlignmentType=e.textAlignmentType,e.textColor!=null&&(v.textColor=this.convertMLeaderEntityColor(e.textColor)),v.textFrameEnabled=e.textFrameEnabled,v.landingGap=e.landingGap,v.textAttachment=e.textAttachment,v.textFlowDirection=e.textFlowDirection,this.isValidHandleId(e.blockContentId)&&(v.blockContentId=e.blockContentId),e.blockContentColor!=null&&(v.blockContentColor=this.convertMLeaderEntityColor(e.blockContentColor)),v.blockContentRotation=e.blockContentRotation,v.blockContentConnectionType=e.blockContentConnectionType,v.annotativeScaleEnabled=e.annotativeScaleEnabled,v.arrowheadOverrides=e.arrowheadOverrides?e.arrowheadOverrides.map(function(le){return nf({},le)}):[],v.blockAttributes=e.blockAttributes?e.blockAttributes.map(function(le){return nf({},le)}):[],v.textDirectionNegative=e.textDirectionNegative,v.textAlignInIPE=e.textAlignInIPE,v.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection,v.topTextAttachmentDirection=e.topTextAttachmentDirection,v.contentScale=e.contentScale,v.textLineSpacingStyle=e.textLineSpacingStyle,e.textBackgroundColor!=null&&(v.textBackgroundColor=this.convertMLeaderEntityColor(e.textBackgroundColor)),v.textBackgroundScaleFactor=e.textBackgroundScaleFactor,v.textBackgroundTransparency=e.textBackgroundTransparency,v.textBackgroundColorOn=e.textBackgroundColorOn,v.textFillOn=e.textFillOn,v.textColumnType=e.textColumnType,v.textUseAutoHeight=e.textUseAutoHeight,v.textColumnWidth=e.textColumnWidth,v.textColumnGutterWidth=e.textColumnGutterWidth,v.textColumnFlowReversed=e.textColumnFlowReversed,v.textColumnHeight=e.textColumnHeight,v.textUseWordBreak=e.textUseWordBreak,v.hasMText=e.hasMText,v.hasBlock=e.hasBlock,v.planeNormalReversed=e.planeNormalReversed,e.blockContentScale&&(v.blockContentScale=new X(e.blockContentScale)),e.contentBasePosition&&(v.contentBasePosition=new D().copy(e.contentBasePosition)),e.textAnchor&&(v.textAnchor=new D().copy(e.textAnchor)),e.planeOrigin&&(v.planeOrigin=new D().copy(e.planeOrigin)),e.planeXAxisDirection&&(v.planeXAxisDirection=new X(e.planeXAxisDirection)),e.planeYAxisDirection&&(v.planeYAxisDirection=new X(e.planeYAxisDirection));var b=x.textContent,w=b&&typeof b=="object"?b:void 0,_=typeof b=="string"&&b.length>0||this.readString(w??{},["text","contents"])!=null||this.readString(x,["text","contents","mtext"])!=null,P=(o=e.contentType)!==null&&o!==void 0?o:_?cn.MTextContent:e.blockContent?cn.BlockContent:cn.NoneContent;v.contentType=P;var S=this.readPoint(x,["normal","extrusionDirection"]);S&&(v.normal=S);var E=(a=this.readString(w??{},["styleName","textStyleName","textStyle"]))!==null&&a!==void 0?a:this.readString(x,["textStyleName","textStyle","styleName"]);E&&(v.textStyleName=E);var C=(l=(s=this.readPositiveNumber(w??{},["textHeight","height"]))!==null&&s!==void 0?s:this.readPositiveNumber(x,["textHeight","mtextHeight","textContentHeight"]))!==null&&l!==void 0?l:this.readPositiveNumber(x,["arrowheadSize","contentScale"]);C!=null&&(v.textHeight=C);var k=(c=this.readPositiveNumber(w??{},["textWidth","width"]))!==null&&c!==void 0?c:this.readPositiveNumber(x,["textWidth","mtextWidth","textContentWidth"]);k!=null&&(v.textWidth=k),v.textLineSpacingFactor=(h=(u=this.readNumber(w??{},["lineSpacingFactor","textLineSpacingFactor"]))!==null&&u!==void 0?u:this.readNumber(x,["textLineSpacingFactor"]))!==null&&h!==void 0?h:v.textLineSpacingFactor;var T=(d=this.readNumber(w??{},["lineSpacingStyle","textLineSpacingStyle"]))!==null&&d!==void 0?d:this.readNumber(x,["textLineSpacingStyle"]);T!=null&&(v.textLineSpacingStyle=T);var O=(f=this.readNumber(w??{},["textRotation","rotation"]))!==null&&f!==void 0?f:this.readNumber(x,["textRotation","mtextRotation","textContentRotation"]);O!=null&&(v.textRotation=O);var I=this.readPoint(x,["textDirection","mtextDirection","textDirectionVector"]);I&&(v.textDirection=I);var F=this.readNumber(x,["textAttachmentPoint","attachmentPoint"]);F!=null&&F!==0&&(v.textAttachmentPoint=F);var N=e.textAttachmentDirection;N!=null&&(v.textAttachmentDirection=N);var Y=this.readNumber(x,["textDrawingDirection","drawingDirection"]);Y!=null&&(v.textDrawingDirection=Y);var U=typeof b=="string"?b:(p=this.readString(w??{},["text","contents"]))!==null&&p!==void 0?p:this.readString(x,["text","contents","mtext"]),$=(m=this.readPoint(w??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"]))!==null&&m!==void 0?m:this.readPoint(x,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(U!=null&&$&&(v.mtextContent={text:U,anchorPoint:$}),e.blockContent){var J=e.blockContent,G=e.blockContent.blockContentId;if(this.isValidHandleId(G)){var oe=this.readMLeaderEntityColor(J,["color"]);v.blockContent={blockContentId:G,normal:this.readPoint(J,["normal"]),position:e.blockContent.position,scale:this.readPoint(J,["scale"]),rotation:this.readNumber(J,["rotation"]),color:oe,transformationMatrix:Array.isArray(e.blockContent.transformationMatrix)?e.blockContent.transformationMatrix:[]}}}else this.isValidHandleId(e.blockContentId)&&(v.blockContent={blockContentId:e.blockContentId,scale:e.blockContentScale,rotation:e.blockContentRotation,color:v.blockContentColor,transformationMatrix:[]});return(g=this.readMLeaderLeaders(x))===null||g===void 0||g.forEach(function(le){var Ie;v.addLeader({lastLeaderLinePoint:le.lastLeaderLinePoint,lastLeaderLinePointSet:le.lastLeaderLinePointSet,doglegVector:le.doglegVector,doglegVectorSet:le.doglegVectorSet,doglegLength:(Ie=le.doglegLength)!==null&&Ie!==void 0?Ie:e.doglegLength,breaks:le.breaks,leaderBranchIndex:le.leaderBranchIndex,leaderLines:le.leaderLines})}),v.numberOfLeaders===0&&((y=this.readLeaderLineArray(x))===null||y===void 0||y.forEach(function(le){v.addLeader({doglegLength:e.doglegLength}),v.addLeaderLine(v.numberOfLeaders-1,le)})),v.numberOfLeaders===0&&e.contentBasePosition&&v.addLeader({lastLeaderLinePoint:e.contentBasePosition,lastLeaderLinePointSet:!0,doglegLength:e.doglegLength}),v},r.prototype.convertDimension=function(e){var t,n,i,o,a,s,l,c;if(e.subclassMarker=="AcDbAlignedDimension"){var u=e,h=new _h(u.subDefinitionPoint1,u.subDefinitionPoint2,u.definitionPoint);return u.insertionPoint&&(h.dimBlockPosition={x:u.insertionPoint.x,y:u.insertionPoint.y,z:0}),h.rotation=u.rotationAngle,this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbRotatedDimension"){var u=e,h=new hC(u.subDefinitionPoint1,u.subDefinitionPoint2,u.definitionPoint);return u.insertionPoint&&(h.dimBlockPosition={x:u.insertionPoint.x,y:u.insertionPoint.y,z:0}),h.rotation=u.rotationAngle,this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDb3PointAngularDimension"){var u=e,h=new Cx(u.centerPoint,u.subDefinitionPoint1,u.subDefinitionPoint2,u.definitionPoint);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDb2LineAngularDimension"){var u=e,d=(n=(t=u.definitionPoint)!==null&&t!==void 0?t:u.arcPoint)!==null&&n!==void 0?n:u.subDefinitionPoint2,f=(o=(i=u.centerPoint)!==null&&i!==void 0?i:u.subDefinitionPoint2)!==null&&o!==void 0?o:u.subDefinitionPoint1,p=f??d,m=(s=(a=u.subDefinitionPoint1)!==null&&a!==void 0?a:f)!==null&&s!==void 0?s:d,g=(c=(l=u.subDefinitionPoint2)!==null&&l!==void 0?l:f)!==null&&c!==void 0?c:d;if(!d||!u.name)return null;var h=new Cx(p,m,g,d);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbOrdinateDimension"){var u=e,h=new cC(u.subDefinitionPoint1,u.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbRadialDimension"){var u=e,h=new uC(u.definitionPoint,u.centerPoint,u.leaderLength);return this.processDimensionCommonAttrs(e,h),h}else if(e.subclassMarker=="AcDbDiametricDimension"){var u=e,h=new lC(u.definitionPoint,u.centerPoint,u.leaderLength);return this.processDimensionCommonAttrs(e,h),h}return null},r.prototype.processImage=function(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.imageDefId=e.imageDefHandle,t.isClipped=e.clipping>0,t.isShownClipped=(e.flags&4)!==0,t.isImageShown=(e.flags&3)!==0,t.isImageTransparent=(e.flags&8)!==0,e.clippingBoundaryPath.forEach(function(n){t.clipBoundary.push(new re(n))}),t.clipBoundaryType=e.clippingBoundaryType,t.width=Math.sqrt(Math.pow(e.uPixel.x,2)+Math.pow(e.uPixel.y,2)+Math.pow(e.uPixel.z,2))*e.imageSize.x,t.height=Math.sqrt(Math.pow(e.vPixel.x,2)+Math.pow(e.vPixel.y,2)+Math.pow(e.vPixel.z,2))*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)},r.prototype.convertImage=function(e){var t=new Rh;return this.processImage(e,t),t},r.prototype.convertWipeout=function(e){var t=new eC;return this.processImage(e,t),t},r.prototype.convertOleFrame=function(e){var t,n=new o_;if(n.oleVersion=(t=e.flag)!==null&&t!==void 0?t:0,e.binaryData){var i=rh([e.binaryData]);n.loadOleObjectFromDxf(e.dataSize,i)}return n},r.prototype.convertOle2Frame=function(e){var t,n,i,o,a,s=new qA;if(s.oleVersion=(t=e.oleVersion)!==null&&t!==void 0?t:0,s.userType=(n=e.oleClient)!==null&&n!==void 0?n:"",e.leftUpPoint&&s.upperLeftCorner.copy(e.leftUpPoint),e.rightDownPoint&&s.lowerRightCorner.copy(e.rightDownPoint),s.setLockAspect((i=e.lockAspect)!==null&&i!==void 0?i:0),s.oleObjectType=(o=e.oleObjectType)!==null&&o!==void 0?o:io.Embedded,s.tileMode=(a=e.tileModeDescriptor)!==null&&a!==void 0?a:za.ModelSpace,e.binaryData){var l=rh([e.binaryData]);s.loadOleObjectFromDxf(e.dataSize,l)}return s},r.prototype.convertViewport=function(e){var t=new Va;t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,e.targetPoint&&t.viewTarget.copy(e.targetPoint),e.viewTwistAngle!=null&&(t.viewTwistAngle=e.viewTwistAngle);var n=1e-6,i=Math.abs(t.centerPoint.x)<n&&Math.abs(t.centerPoint.y)<n,o=t.viewTarget,a=Math.abs(o.x)<n&&Math.abs(o.y)<n,s=Number.isFinite(t.height)&&Number.isFinite(t.viewHeight)&&Math.abs(t.viewHeight-t.height)<n;return i&&a&&s&&t.centerPoint.copy(t.viewCenter),t},r.prototype.convertRay=function(e){var t=new Fh;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t},r.prototype.convertXline=function(e){var t=new py;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t},r.prototype.convertAttributeCommon=function(e,t){var n,i,o,a,s=e.text;t.textString=s.text,t.styleName=s.styleName,t.height=s.textHeight,t.position.copy(s.startPoint);var l=(n=e.alignmentPoint)!==null&&n!==void 0?n:s.endPoint,c=!l||l.x===0&&l.y===0&&((i=l.z)!==null&&i!==void 0?i:0)===0;l&&!c?(t.alignmentPoint.copy(l),t.hasAlignmentPoint=!0):(t.alignmentPoint.copy(s.startPoint),t.hasAlignmentPoint=!1),t.rotation=s.rotation,t.oblique=(o=s.obliqueAngle)!==null&&o!==void 0?o:0,t.thickness=s.thickness,t.horizontalMode=s.halign,t.verticalMode=s.valign,t.widthFactor=(a=s.xScale)!==null&&a!==void 0?a:1,t.tag=e.tag,t.fieldLength=e.fieldLength,t.isInvisible=(e.flags&Zt.Invisible)!==0,t.isConst=(e.flags&Zt.Const)!==0,t.isVerifiable=(e.flags&Zt.Verifiable)!==0,t.isPreset=(e.flags&Zt.Preset)!==0,t.lockPositionInBlock=e.lockPositionFlag,t.isReallyLocked=e.isReallyLocked,t.isMTextAttribute=(e.mtextFlag&mr.MultiLine)!==0,t.isConstMTextAttribute=(e.mtextFlag&mr.ConstMultiLine)!==0},r.prototype.convertAttribute=function(e){var t=new bh;return this.convertAttributeCommon(e,t),t},r.prototype.convertAttributeDefinition=function(e){var t=new kA;return this.convertAttributeCommon(e,t),t.prompt=e.prompt,t},r.prototype.convertBlockReference=function(e){var t=this,n=new rr(e.name);return e.insertionPoint&&n.position.copy(e.insertionPoint),n.scaleFactors.x=e.xScale,n.scaleFactors.y=e.yScale,n.scaleFactors.z=e.zScale,n.rotation=e.rotation,n.normal.copy(e.extrusionDirection),e.columnCount!=null&&(n.columnCount=e.columnCount),e.rowCount!=null&&(n.rowCount=e.rowCount),e.columnSpacing!=null&&(n.columnSpacing=e.columnSpacing),e.rowSpacing!=null&&(n.rowSpacing=e.rowSpacing),e.handle!=null&&(n.objectId=e.handle),e.attribs&&e.attribs.forEach(function(i){var o=t.convert(i);o instanceof bh&&n.appendAttributes(o)}),n},r.prototype.processDimensionCommonAttrs=function(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement},r.prototype.processCommonAttrs=function(e,t){var n,i;t.layer=e.layer||"0",t.objectId=e.handle,e.ownerBlockRecordSoftId!=null&&(t.ownerId=e.ownerBlockRecordSoftId);var o=sC((i=(n=e.extensionDictionary)!==null&&n!==void 0?n:e.ownerDictionaryHardId)!==null&&i!==void 0?i:e.ownerDictionarySoftId);if(o&&(t.extensionDictionary=o),this.applyExtendedData(e,t),e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null||e.colorIndex!=null||e.colorName){var a=new nt;e.color!=null&&a.setRGBValue(e.color),e.colorIndex!=null&&(e.color==null||e.colorIndex===7)&&(a.colorIndex=e.colorIndex),e.colorName&&(a.colorName=e.colorName),t.color=a}if(e.isVisible!=null&&(t.visibility=e.isVisible),e.transparency!=null){var s=new tr;s.method=e.transparencyType,(s.isByBlock||s.isByBlock)&&(s.alpha=e.transparency),t.transparency=s}},r.prototype.applyExtendedData=function(e,t){var n,i,o,a,s,l=e.xdata;if(l){var c=Array.isArray(l)?l:[l];try{for(var u=Bu(c),h=u.next();!h.done;h=u.next()){var d=h.value;if(d!=null&&d.appName){var f=[{code:na.ExtendedDataRegAppName,value:d.appName}];try{for(var p=(o=void 0,Bu((s=d.value)!==null&&s!==void 0?s:[])),m=p.next();!m.done;m=p.next()){var g=m.value;if(g!=null&&typeof g=="object"&&"code"in g&&"value"in g){var y=Number(g.code),v=g.value;if(y===na.ExtendedDataHandle||y>=1e3&&y<=1071){var x=this.normalizeXDataValue(y,v);x!==void 0&&f.push({code:y,value:x})}}}}catch(b){o={error:b}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}t.setImportedXData(f)}}}catch(b){n={error:b}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}},r.prototype.normalizeXDataValue=function(e,t){if(e>=1010&&e<=1013){if(this.isPointLike(t))return{x:t.x,y:t.y,z:typeof t.z=="number"?t.z:0};if(Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number")return{x:t[0],y:t[1],z:typeof t[2]=="number"?t[2]:0};if(typeof t=="number"&&Number.isFinite(t))return t}if(e===na.ExtendedDataBinaryChunk)return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?t:Array.isArray(t)&&t.every(function(n){return typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=255})?Uint8Array.from(t):void 0;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t instanceof Uint8Array)return t;if(this.isPointLike(t))return{x:t.x,y:t.y,z:typeof t.z=="number"?t.z:0}},r.prototype.convertMLeaderEntityColor=function(e){return Wi(e)},r.prototype.readMLeaderEntityColor=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="number"&&Number.isFinite(l))return Wi(l)}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.isValidHandleId=function(e){return e!=null&&e!==""&&e!=="0"},r.prototype.readNumber=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="number"&&Number.isFinite(l))return l}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.readPositiveNumber=function(e,t){var n=this.readNumber(e,t);return n!=null&&n>0?n:void 0},r.prototype.readString=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="string")return l}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.readBoolean=function(e,t){var n,i;try{for(var o=Bu(t),a=o.next();!a.done;a=o.next()){var s=a.value,l=e[s];if(typeof l=="boolean")return l;if(typeof l=="number")return l!==0}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},r.prototype.readPoint=function(e,t){var n,i,o;try{for(var a=Bu(t),s=a.next();!s.done;s=a.next()){var l=s.value,c=e[l];if(this.isPointLike(c))return c;if(Array.isArray(c)&&typeof c[0]=="number"&&typeof c[1]=="number")return{x:c[0],y:c[1],z:(o=c[2])!==null&&o!==void 0?o:0}}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},r.prototype.readLeaderLineArray=function(e){var t=this,n=e.leaderLines;if(Array.isArray(n))return n.map(function(a){if(!(!a||typeof a!="object")){var s=a.vertices;return Array.isArray(s)?s.filter(function(l){return t.isPointLike(l)}):void 0}}).filter(function(a){return!!a&&a.length>0});var i=e.vertices;if(Array.isArray(i)){var o=i.filter(function(a){return t.isPointLike(a)});return o.length>0?[o]:void 0}},r.prototype.readMLeaderLeaders=function(e){var t=this,n=e.leaderSections;if(Array.isArray(n)){var i=[];return n.forEach(function(o){if(!(!o||typeof o!="object")){var a=o,s=a.leaderLines,l=Array.isArray(s)?s.reduce(function(m,g){var y=t.readMLeaderLine(g);return y&&m.push(y),m},[]):void 0,c={},u=t.readPoint(a,["lastLeaderLinePoint"]),h=t.readPoint(a,["doglegVector"]),d=t.readNumber(a,["doglegLength"]),f=t.readMLeaderBreaks(a.breaks),p=t.readNumber(a,["leaderBranchIndex"]);u&&(c.lastLeaderLinePoint=u),a.lastLeaderLinePointSet!=null&&(c.lastLeaderLinePointSet=t.readBoolean(a,["lastLeaderLinePointSet"])),h&&(c.doglegVector=h),a.doglegVectorSet!=null&&(c.doglegVectorSet=t.readBoolean(a,["doglegVectorSet"])),d!=null&&(c.doglegLength=d),f&&(c.breaks=f),p!=null&&(c.leaderBranchIndex=p),l&&(c.leaderLines=l),i.push(c)}}),i}},r.prototype.readMLeaderLine=function(e){var t=this;if(!(!e||typeof e!="object")){var n=e,i=n.vertices,o=Array.isArray(i)?i.filter(function(c){return t.isPointLike(c)}):[],a=this.readMLeaderBreaks(n.breaks),s=Array.isArray(n.breakPointIndexes)?n.breakPointIndexes.filter(function(c){return typeof c=="number"}):void 0,l=this.readNumber(n,["leaderLineIndex"]);return o.length>0||a&&a.length>0?{vertices:o,breakPointIndexes:s,leaderLineIndex:l,breaks:a}:void 0}},r.prototype.readMLeaderBreaks=function(e){var t=this;if(Array.isArray(e)){var n=e.map(function(i){if(!(!i||typeof i!="object")){var o=i,a=t.readPoint(o,["start"]),s=t.readPoint(o,["end"]),l=t.readNumber(o,["index"]);if(!(!a||!s)){var c={start:a,end:s};return l!=null&&(c.index=l),c}}}).filter(function(i){return!!i});return n.length>0?n:void 0}},r.prototype.isPointLike=function(e){return!!e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"},r})(),Nu=(function(){function r(){}return r.prototype.convertMLeaderStyle=function(e){var t,n=new ly;return n.unknown1=e.unknown1,e.contentType!=null&&(n.contentType=e.contentType),e.drawMLeaderOrderType!=null&&(n.drawMLeaderOrderType=e.drawMLeaderOrderType),e.drawLeaderOrderType!=null&&(n.drawLeaderOrderType=e.drawLeaderOrderType),e.maxLeaderSegmentPoints!=null&&(n.maxLeaderSegmentPoints=e.maxLeaderSegmentPoints),e.firstSegmentAngleConstraint!=null&&(n.firstSegmentAngleConstraint=e.firstSegmentAngleConstraint),e.secondSegmentAngleConstraint!=null&&(n.secondSegmentAngleConstraint=e.secondSegmentAngleConstraint),e.leaderLineType!=null&&(n.leaderLineType=e.leaderLineType),e.leaderLineColor!=null&&(n.leaderLineColor=Wi(e.leaderLineColor)),n.leaderLineTypeId=e.leaderLineTypeId,e.leaderLineWeight!=null&&(n.leaderLineWeight=e.leaderLineWeight),e.landingEnabled!=null&&(n.landingEnabled=e.landingEnabled),e.landingGap!=null&&(n.landingGap=e.landingGap),e.doglegEnabled!=null&&(n.doglegEnabled=e.doglegEnabled),e.doglegLength!=null&&(n.doglegLength=e.doglegLength),e.description!=null&&(n.description=e.description),n.arrowheadId=e.arrowheadId,e.arrowheadSize!=null&&(n.arrowheadSize=e.arrowheadSize),e.defaultMTextContents!=null&&(n.defaultMTextContents=e.defaultMTextContents),n.textStyleId=e.textStyleId,e.textLeftAttachmentType!=null&&(n.textLeftAttachmentType=e.textLeftAttachmentType),e.textAngleType!=null&&(n.textAngleType=e.textAngleType),e.textAlignmentType!=null&&(n.textAlignmentType=e.textAlignmentType),e.textRightAttachmentType!=null&&(n.textRightAttachmentType=e.textRightAttachmentType),e.textColor!=null&&(n.textColor=Wi(e.textColor)),e.textHeight!=null&&(n.textHeight=e.textHeight),e.textFrameEnabled!=null&&(n.textFrameEnabled=e.textFrameEnabled),e.textAlignAlwaysLeft!=null&&(n.textAlignAlwaysLeft=e.textAlignAlwaysLeft),e.alignSpace!=null&&(n.alignSpace=e.alignSpace),n.blockContentId=e.blockContentId,e.blockContentColor!=null&&(n.blockContentColor=Wi(e.blockContentColor)),e.blockContentScale&&(n.blockContentScale={x:e.blockContentScale.x,y:e.blockContentScale.y,z:(t=e.blockContentScale.z)!==null&&t!==void 0?t:1}),e.blockContentScaleEnabled!=null&&(n.blockContentScaleEnabled=e.blockContentScaleEnabled),e.blockContentRotation!=null&&(n.blockContentRotation=e.blockContentRotation),e.blockContentRotationEnabled!=null&&(n.blockContentRotationEnabled=e.blockContentRotationEnabled),e.blockContentConnectionType!=null&&(n.blockContentConnectionType=e.blockContentConnectionType),e.scale!=null&&(n.scale=e.scale),e.overwritePropertyValue!=null&&(n.overwritePropertyValue=e.overwritePropertyValue),e.annotative!=null&&(n.annotative=e.annotative),e.breakGapSize!=null&&(n.breakGapSize=e.breakGapSize),e.textAttachmentDirection!=null&&(n.textAttachmentDirection=e.textAttachmentDirection),e.bottomTextAttachmentDirection!=null&&(n.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection),e.topTextAttachmentDirection!=null&&(n.topTextAttachmentDirection=e.topTextAttachmentDirection),n.unknown2=e.unknown2,this.processCommonAttrs(e,n),n},r.prototype.convertLayerFilter=function(e){var t,n=new DA;return!((t=e.layerNames)===null||t===void 0)&&t.length&&(n.layerNames=e.layerNames),this.processCommonAttrs(e,n),n},r.prototype.convertLayerIndex=function(e){var t,n,i,o=new RA;return e.timeStamp!=null&&(o.lastUpdatedAt=e.timeStamp,o.lastUpdatedAtU=e.timeStamp),!((t=e.layerNames)===null||t===void 0)&&t.length&&(o.layerNames=e.layerNames),!((n=e.idBufferIds)===null||n===void 0)&&n.length&&(o.idBufferIds=e.idBufferIds),!((i=e.idBufferEntryCounts)===null||i===void 0)&&i.length&&(o.idBufferEntryCounts=e.idBufferEntryCounts),o.isUptoDate=!0,this.processCommonAttrs(e,o),o},r.prototype.convertScale=function(e){var t,n,i,o=new zf;return e.flag!=null&&(o.classVersion=e.flag),o.scaleName=(t=e.name)!==null&&t!==void 0?t:"",o.paperUnits=(n=e.paperUnits)!==null&&n!==void 0?n:1,o.drawingUnits=(i=e.drawingUnits)!==null&&i!==void 0?i:1,o.isUnitScale=!!e.isUnitScale,this.processCommonAttrs(e,o),o},r.prototype.convertDictionaryVar=function(e){var t,n,i=new Sg;return e.schema!=null&&(i.schema=e.schema),i.value=(n=(t=e.value)!==null&&t!==void 0?t:e.strvalue)!==null&&n!==void 0?n:"",this.processCommonAttrs(e,i),i},r.prototype.convertMTextObjectContextData=function(e){var t,n,i,o,a=new e_;return e.classVersion!=null&&(a.classVersion=e.classVersion),a.isDefault=!!e.isDefault,a.scaleId=(n=(t=e.scaleId)!==null&&t!==void 0?t:e.scaleHandle)!==null&&n!==void 0?n:"",e.attachment!=null&&(a.attachmentPoint=e.attachment),e.xAxisDir&&(a.direction=new X(e.xAxisDir.x,e.xAxisDir.y,(i=e.xAxisDir.z)!==null&&i!==void 0?i:0)),e.insertionPoint&&(a.insertionPoint=new D(e.insertionPoint.x,e.insertionPoint.y,(o=e.insertionPoint.z)!==null&&o!==void 0?o:0)),e.definedWidth!=null&&(a.definedWidth=e.definedWidth),e.definedHeight!=null&&(a.definedHeight=e.definedHeight),e.extentsWidth!=null&&(a.extentsWidth=e.extentsWidth),e.extentsHeight!=null&&(a.extentsHeight=e.extentsHeight),e.columnType!=null&&(a.columnType=e.columnType),this.processCommonAttrs(e,a),a},r.prototype.convertXRecord=function(e){var t,n=new cy;return this.processCommonAttrs(e,n),e.extensionDictionary&&(n.extensionDictionary=e.extensionDictionary),n.data=new nh(((t=e.data)!==null&&t!==void 0?t:[]).map(function(i){return{code:Number(i.code),value:i.value}})),n},r.prototype.processCommonAttrs=function(e,t){t.objectId=e.handle,e.ownerHandle!=null&&(t.ownerId=e.ownerHandle)},r})(),K3e=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Zb=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function s(u){try{c(n.next(u))}catch(h){a(h)}}function l(u){try{c(n.throw(u))}catch(h){a(h)}}function c(u){u.done?o(u.value):i(u.value).then(s,l)}c((n=n.apply(r,e||[])).next())})},Jb=function(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(c){return function(u){return l([c,u])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(r,t)}catch(u){c=[6,u],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Ml=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Z3e="*MODEL_SPACE",J3e=(function(r){K3e(e,r);function e(t){t===void 0&&(t={});var n=r.call(this,t)||this;return n.config.useWorker=!0,n.config.parserWorkerUrl||(n.config.parserWorkerUrl="/assets/libredwg-parser-worker.js"),n}return e.prototype.parse=function(t,n){return Zb(this,void 0,void 0,function(){var i,o,a,s;return Jb(this,function(l){switch(l.label){case 0:return i=this.config,o=this.getParserWorkerTimeout(t,n),i.useWorker&&i.parserWorkerUrl?(a=B8({workerUrl:i.parserWorkerUrl,timeout:o,maxConcurrentWorkers:1}),[4,a.execute(t)]):[3,2];case 1:return s=l.sent(),a.destroy(),oh.throwOnWorkerParseFailure(s),[2,s.data];case 2:throw new Error("dwg converter can run in web worker only!")}})})},e.prototype.processLineTypes=function(t,n){var i=this,o=t.tables.LTYPE.entries;o.forEach(function(a){var s={name:a.name,description:a.description,standardFlag:a.standardFlag,totalPatternLength:a.totalPatternLength,pattern:a.pattern},l=new Xl(s);i.processCommonTableEntryAttrs(a,l),n.tables.linetypeTable.add(l)})},e.prototype.processTextStyles=function(t,n){var i=this,o=t.tables.STYLE.entries;o.forEach(function(a){var s={name:a.name,standardFlag:a.standardFlag,fixedTextHeight:a.fixedTextHeight,widthFactor:a.widthFactor,obliqueAngle:a.obliqueAngle,textGenerationFlag:a.textGenerationFlag,lastHeight:a.lastHeight,font:a.font,bigFont:a.bigFont,extendedFont:a.extendedFont},l=new ay(s);i.processCommonTableEntryAttrs(a,l),n.tables.textStyleTable.add(l)}),n.ensureTextStyleDefaults()},e.prototype.processDimStyles=function(t,n){var i=this,o=t.tables.DIMSTYLE.entries;o.forEach(function(a){var s={name:a.name,ownerId:a.ownerHandle,dimpost:a.DIMPOST||"",dimapost:a.DIMAPOST||"",dimscale:a.DIMSCALE,dimasz:a.DIMASZ,dimexo:a.DIMEXO,dimdli:a.DIMDLI,dimexe:a.DIMEXE,dimrnd:a.DIMRND,dimdle:a.DIMDLE,dimtp:a.DIMTP,dimtm:a.DIMTM,dimtxt:a.DIMTXT,dimcen:a.DIMCEN,dimtsz:a.DIMTSZ,dimaltf:a.DIMALTF,dimlfac:a.DIMLFAC,dimtvp:a.DIMTVP,dimtfac:a.DIMTFAC,dimgap:a.DIMGAP,dimaltrnd:a.DIMALTRND,dimtol:a.DIMTOL==null||a.DIMTOL==0?0:1,dimlim:a.DIMLIM==null||a.DIMLIM==0?0:1,dimtih:a.DIMTIH==null||a.DIMTIH==0?0:1,dimtoh:a.DIMTOH==null||a.DIMTOH==0?0:1,dimse1:a.DIMSE1==null||a.DIMSE1==0?0:1,dimse2:a.DIMSE2==null||a.DIMSE2==0?0:1,dimtad:a.DIMTAD,dimzin:a.DIMZIN,dimazin:a.DIMAZIN,dimalt:a.DIMALT,dimaltd:a.DIMALTD,dimtofl:a.DIMTOFL,dimsah:a.DIMSAH,dimtix:a.DIMTIX,dimsoxd:a.DIMSOXD,dimclrd:a.DIMCLRD,dimclre:a.DIMCLRE,dimclrt:a.DIMCLRT,dimadec:a.DIMADEC||0,dimunit:a.DIMUNIT||2,dimdec:a.DIMDEC,dimtdec:a.DIMTDEC,dimaltu:a.DIMALTU,dimalttd:a.DIMALTTD,dimaunit:a.DIMAUNIT,dimfrac:a.DIMFRAC,dimlunit:a.DIMLUNIT,dimdsep:a.DIMDSEP||".",dimtmove:a.DIMTMOVE||0,dimjust:a.DIMJUST,dimsd1:a.DIMSD1,dimsd2:a.DIMSD2,dimtolj:a.DIMTOLJ,dimtzin:a.DIMTZIN,dimaltz:a.DIMALTZ,dimalttz:a.DIMALTTZ,dimfit:a.DIMFIT||0,dimupt:a.DIMUPT,dimatfit:a.DIMATFIT,dimtxsty:Nn,dimldrblk:"",dimblk:a.DIMBLK||"",dimblk1:a.DIMBLK1||"",dimblk2:a.DIMBLK2||"",dimlwd:a.DIMLWD,dimlwe:a.DIMLWE},l=new ua(s);i.processCommonTableEntryAttrs(a,l),n.tables.dimStyleTable.add(l)})},e.prototype.processLayers=function(t,n){var i=this,o=t.tables.LAYER.entries;o.forEach(function(a){var s=new nt;i.applyLibreLayerColor(s,a);var l=new rc({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.off,color:s,isPlottable:a.plotFlag!=0});i.processCommonTableEntryAttrs(a,l),n.tables.layerTable.add(l)})},e.prototype.applyLibreLayerColor=function(t,n){var i=n.colorIndex,o=n.color;i!=null&&i>=1&&i<=255?t.colorIndex=i:i===0?t.colorIndex=0:o!=null&&Number.isFinite(o)?t.setRGBValue(o&16777215):t.colorIndex=256,n.colorName&&(t.colorName=n.colorName)},e.prototype.processViewports=function(t,n){var i=this,o=t.tables.VPORT.entries;o.forEach(function(a){var s,l,c,u,h,d,f=new sy;a.circleSides&&(f.circleSides=a.circleSides),f.standardFlag=a.standardFlag,f.center.copy((s=a.center)!==null&&s!==void 0?s:ME),f.lowerLeftCorner.copy((l=a.lowerLeftCorner)!==null&&l!==void 0?l:z5),f.upperRightCorner.copy((c=a.upperRightCorner)!==null&&c!==void 0?c:j5),a.snapBasePoint&&f.snapBase.copy(a.snapBasePoint),a.snapRotationAngle&&(f.snapAngle=a.snapRotationAngle),a.snapSpacing&&f.snapIncrements.copy(a.snapSpacing),a.majorGridLines&&(f.gridMajor=a.majorGridLines),a.gridSpacing&&f.gridIncrements.copy(a.gridSpacing),a.backgroundObjectId&&(f.backgroundObjectId=a.backgroundObjectId),f.gsView.center.copy((u=a.center)!==null&&u!==void 0?u:ME),f.gsView.viewDirectionFromTarget.copy((h=a.viewDirectionFromTarget)!==null&&h!==void 0?h:U5),f.gsView.viewTarget.copy((d=a.viewTarget)!==null&&d!==void 0?d:V5),a.lensLength&&(f.gsView.lensLength=a.lensLength),a.frontClippingPlane&&(f.gsView.frontClippingPlane=a.frontClippingPlane),a.backClippingPlane&&(f.gsView.backClippingPlane=a.backClippingPlane),a.viewHeight&&(f.gsView.viewHeight=a.viewHeight);var p=a.aspectRatio;p!=null&&Number.isFinite(p)&&p>0&&(f.gsView.aspectRatio=p),a.viewTwistAngle&&(f.gsView.viewTwistAngle=a.viewTwistAngle),a.frozenLayers&&(f.gsView.frozenLayers=a.frozenLayers),a.styleSheet&&(f.gsView.styleSheet=a.styleSheet),a.renderMode&&(f.gsView.renderMode=a.renderMode),a.viewMode&&(f.gsView.viewMode=a.viewMode),a.ucsIconSetting&&(f.gsView.ucsIconSetting=a.ucsIconSetting),a.ucsOrigin&&f.gsView.ucsOrigin.copy(a.ucsOrigin),a.ucsXAxis&&f.gsView.ucsXAxis.copy(a.ucsXAxis),a.ucsYAxis&&f.gsView.ucsYAxis.copy(a.ucsYAxis),a.orthographicType&&(f.gsView.orthographicType=a.orthographicType),a.shadePlotSetting&&(f.gsView.shadePlotSetting=a.shadePlotSetting),a.shadePlotObjectId&&(f.gsView.shadePlotObjectId=a.shadePlotObjectId),a.visualStyleObjectId&&(f.gsView.visualStyleObjectId=a.visualStyleObjectId),a.isDefaultLightingOn&&(f.gsView.isDefaultLightingOn=a.isDefaultLightingOn),a.defaultLightingType&&(f.gsView.defaultLightingType=a.defaultLightingType),a.brightness&&(f.gsView.brightness=a.brightness),a.contrast&&(f.gsView.contrast=a.contrast),a.ambientColor&&(f.gsView.ambientColor=a.ambientColor),i.processCommonTableEntryAttrs(a,f),n.tables.viewportTable.add(f)})},e.prototype.processBlockTables=function(t,n){var i=this,o=t.tables.BLOCK_RECORD.entries;o.forEach(function(a){var s,l=n.tables.blockTable.getAt(a.name);l||(l=new _n,l.name=a.name,l.ownerId=a.ownerHandle,l.layoutId=a.layout,l.flags=_n.sanitizeImportedFlags((s=a.flags)!==null&&s!==void 0?s:0),l.blockInsertUnits=a.insertionUnits,l.explodability=a.explodability,l.blockScaling=a.scalability,l.objectId=a.handle,n.tables.blockTable.add(l)),a.bmpPreview&&(l.previewIcon=rh([a.bmpPreview])),l.origin.copy(a.basePoint),!l.isModelSapce&&a.entities&&a.entities.length>0&&i.processEntitiesInBlock(a.entities,l)})},e.prototype.processBlocks=function(t,n){},e.prototype.processEntitiesInBlock=function(t,n){return Zb(this,void 0,void 0,function(){var i,o,a,s,l,c;return Jb(this,function(u){for(i=new f4,o=t.length,a=[],s=0;s<o;s++)l=t[s],c=i.convert(l),c&&a.push(c);return n.appendEntity(a),[2]})})},e.prototype.processEntities=function(t,n,i,o,a){return Zb(this,void 0,void 0,function(){var s,l,c,u,h,d=this;return Jb(this,function(f){switch(f.label){case 0:return s=new f4,l=[],t.tables.BLOCK_RECORD.entries.forEach(function(p){d.isModelSpace(p.name)&&(l=p.entities)}),c=l.length,u=new IA(c,100-o.value,i),this.config.convertByEntityType&&(l=this.groupAndFlattenByType(l)),h=n.tables.blockTable.modelSpace,[4,u.processChunk(function(p,m){return Zb(d,void 0,void 0,function(){var g,y,v,x,b;return Jb(this,function(w){switch(w.label){case 0:for(g=[],y=p;y<m;y++)v=l[y],x=s.convert(v),x&&g.push(x);return h.appendEntity(g),a?(b=o.value+m/c*(100-o.value),b>100&&(b=100),[4,a(b,"ENTITY","IN-PROGRESS")]):[3,2];case 1:w.sent(),w.label=2;case 2:return[2]}})})})];case 1:return f.sent(),[2]}})})},e.prototype.processClasses=function(t,n){var i;!((i=t.classes)===null||i===void 0)&&i.length&&(n.classes=t.classes.map(function(o){return{name:o.dxfName,cppClassName:o.cppName,appName:o.appName,proxyFlag:o.capabilitiesFlag,instanceCount:o.instanceCount,wasProxy:o.wasAProxyFlag,isEntity:o.isAnEntityFlag}}))},e.prototype.processHeader=function(t,n){var i,o,a,s,l,c,u,h,d,f,p,m,g=t.thumbnailImage;g!=null&&g.length&&(n.thumbnailImage=g);var y=t.header;y.CECOLOR&&(y.CECOLOR.index>=0&&y.CECOLOR.index<=256?n.cecolor.colorIndex=y.CECOLOR.index:n.cecolor.setRGBValue(y.CECOLOR.rgb)),n.angbase=(i=y.ANGBASE)!==null&&i!==void 0?i:0,n.angdir=(o=y.ANGDIR)!==null&&o!==void 0?o:0,n.aunits=(a=y.AUNITS)!==null&&a!==void 0?a:0,y.AUPREC!=null&&(n.auprec=y.AUPREC),y.LUNITS!=null&&(n.lunits=y.LUNITS),y.LUPREC!=null&&(n.luprec=y.LUPREC),y.UNITMODE!=null&&(n.unitmode=y.UNITMODE),y.MEASUREMENT!=null&&(n.measurement=y.MEASUREMENT),n.celtype=(s=y.CELTYPE)!==null&&s!==void 0?s:Mr,n.celtscale=(l=y.CELTSCALE)!==null&&l!==void 0?l:1,n.ltscale=(c=y.LTSCALE)!==null&&c!==void 0?c:1,n.tilemode=(u=y.TILEMODE)!==null&&u!==void 0?u:1,y.EXTMAX&&(n.extmax=y.EXTMAX),y.EXTMIN&&(n.extmin=y.EXTMIN),n.insunits=(h=y.INSUNITS)!==null&&h!==void 0?h:1,n.pdmode=(d=y.PDMODE)!==null&&d!==void 0?d:0,n.pdsize=(f=y.PDSIZE)!==null&&f!==void 0?f:0,n.textstyle=(p=y.TEXTSTYLE)!==null&&p!==void 0?p:Nn;var v=(m=this.normalizeHeaderStringValue(y.CMLEADERSTYLE))!==null&&m!==void 0?m:Ns;n.cmleaderstyle=v},e.prototype.processCommonTableEntryAttrs=function(t,n){n.name=t.name,n.objectId=t.handle,t.ownerHandle!=null&&(n.ownerId=t.ownerHandle)},e.prototype.processObjects=function(t,n){this.processScales(t,n),this.processDictionaryVars(t,n),this.processMTextObjectContextData(t,n),this.processXRecords(t,n),this.processLayouts(t,n),this.processImageDefs(t,n),this.processLayerFilters(t,n),this.processLayerIndexes(t,n),this.processLayerFilterTree(t,n),this.processMLeaderStyles(t,n),this.processDynBlockMetadata(t,n),this.finishCannoscale(t,n)},e.prototype.processDynBlockMetadata=function(t,n){var i,o,a,s,l=function(y){return y==null||y===""||y===0?"":String(y).trim().toUpperCase()};try{for(var c=Ml(t.tables.BLOCK_RECORD.entries),u=c.next();!u.done;u=c.next()){var h=u.value,d=n.tables.blockTable.getAt(h.name);if(d){var f=h,p=sC((s=(a=f.extensionDictionary)!==null&&a!==void 0?a:f.ownerDictionaryHardId)!==null&&s!==void 0?s:f.ownerDictionarySoftId);p&&(d.extensionDictionary=p)}}}catch(y){i={error:y}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}var m=t.objects.DICTIONARY;if(m!=null&&m.length){var g=m.map(function(y){var v,x=[],b=(v=y.entries)!==null&&v!==void 0?v:{};for(var w in b){var _=b[w];w&&_&&x.push({name:w,handle:l(String(_))})}return{handle:l(y.handle),ownerHandle:l(y.ownerHandle)||void 0,entries:x}});M8(n,{dictionaries:g,representationData:[]})}},e.prototype.processLayerFilterTree=function(t,n){var i=t.objects.DICTIONARY,o=t.objects.XRECORD;if(!(!(i!=null&&i.length)||!(o!=null&&o.length))){var a=function(u){return u?String(u).trim().toUpperCase():""},s=new Map;i.forEach(function(u){var h,d={},f=(h=u.entries)!==null&&h!==void 0?h:{};for(var p in f){var m=f[p];p&&m&&(d[p]=a(String(m)))}s.set(a(u.handle),{handle:a(u.handle),ownerObjectId:a(u.ownerHandle),entries:d})});var l=new Map;o.forEach(function(u){var h;l.set(a(u.handle),{handle:a(u.handle),ownerObjectId:a(u.ownerHandle),extensionDictionaryId:a(u.extensionDictionary),data:((h=u.data)!==null&&h!==void 0?h:[]).map(function(d){return{code:Number(d.code),value:d.value}})})});var c=OA({dictionaries:s,xrecords:l});c.root.getNestedFilters().length>0&&(n.layerFilters=c)}},e.prototype.processLayouts=function(t,n){var i=this,o=n.objects.layout,a=t.objects.LAYOUT;a.forEach(function(s){var l,c,u=new ec;u.layoutName=s.layoutName,u.tabOrder=s.tabOrder;var h=n.tables.blockTable.newIterator();u.objectId=s.handle;try{for(var d=Ml(h),f=d.next();!f.done;f=d.next()){var p=f.value;if(p.layoutId===u.objectId){u.blockTableRecordId=p.objectId;break}}}catch(m){l={error:m}}finally{try{f&&!f.done&&(c=d.return)&&c.call(d)}finally{if(l)throw l.error}}u.blockTableRecordId||s.layoutName==="Model"&&(u.blockTableRecordId=n.tables.blockTable.modelSpace.objectId),u.limits.min.copy(s.minLimit),u.limits.max.copy(s.maxLimit),u.extents.min.copy(s.minExtent),u.extents.max.copy(s.maxExtent),s.viewportId&&u.viewportArray.push(s.viewportId),i.processCommonObjectAttrs(s,u),o.setAt(u.layoutName,u)})},e.prototype.processImageDefs=function(t,n){var i=this,o=n.objects.imageDefinition,a=t.objects.IMAGEDEF;a.forEach(function(s){var l=new t_;l.sourceFileName=s.fileName,i.processCommonObjectAttrs(s,l),o.setAt(l.objectId,l)})},e.prototype.processLayerFilters=function(t,n){var i=t.objects.LAYER_FILTER;if(i!=null&&i.length){var o=n.objects.layerFilter,a=new Nu;i.forEach(function(s){var l=a.convertLayerFilter(s);o.setAt(l.objectId,l)})}},e.prototype.processLayerIndexes=function(t,n){var i=t.objects.LAYER_INDEX;if(i!=null&&i.length){var o=n.objects.layerIndex,a=new Nu;i.forEach(function(s){var l=a.convertLayerIndex(s);o.setAt(l.objectId,l)})}},e.prototype.processMLeaderStyles=function(t,n){var i=t.objects.MLEADERSTYLE;if(i!=null&&i.length){var o=n.objects.mleaderStyle,a=new Nu;i.forEach(function(s){var l=a.convertMLeaderStyle(s);o.setAt(l.objectId,l)})}},e.prototype.processScales=function(t,n){var i,o,a=this.optionalObjectArray(t,"SCALE");if(a!=null&&a.length){var s=n.objects.scale,l=new Nu;try{for(var c=Ml(a),u=c.next();!u.done;u=c.next()){var h=u.value,d=l.convertScale(h),f=d.scaleName||d.objectId;f&&s.setAt(f,d)}}catch(p){i={error:p}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}}},e.prototype.processDictionaryVars=function(t,n){var i,o,a=this.optionalObjectArray(t,"DICTIONARYVAR");if(a!=null&&a.length){var s=n.objects.dictionaryVar,l=new Nu;try{for(var c=Ml(a),u=c.next();!u.done;u=c.next()){var h=u.value,d=l.convertDictionaryVar(h);d.objectId&&s.setAt(d.objectId,d)}}catch(f){i={error:f}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}}},e.prototype.processMTextObjectContextData=function(t,n){var i,o,a,s=(a=this.optionalObjectArray(t,"MTEXTOBJECTCONTEXTDATA"))!==null&&a!==void 0?a:this.optionalObjectArray(t,"ACDB_MTEXTOBJECTCONTEXTDATA_CLASS");if(s!=null&&s.length){var l=n.objects.objectContextData,c=new Nu;try{for(var u=Ml(s),h=u.next();!h.done;h=u.next()){var d=h.value,f=c.convertMTextObjectContextData(d);f.objectId&&l.setAt(f.objectId,f)}}catch(p){i={error:p}}finally{try{h&&!h.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}}},e.prototype.processXRecords=function(t,n){var i,o,a=t.objects.XRECORD;if(a!=null&&a.length){var s=n.objects.xrecord,l=new Nu;try{for(var c=Ml(a),u=c.next();!u.done;u=c.next()){var h=u.value,d=l.convertXRecord(h);d.objectId&&s.setAt(d.objectId,d)}}catch(f){i={error:f}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}}},e.prototype.finishCannoscale=function(t,n){var i,o,a,s,l=function(y){var v=y.getAt("CANNOSCALE");return v instanceof Sg&&v.value?(n.cannoscale=v.value,!0):!1},c=n.objects.dictionary.getAt("AcDbVariableDictionary");if(!(c instanceof hn&&l(c))){var u=function(y){return y==null||y===""||y===0?"":String(y).trim().toUpperCase()};try{for(var h=Ml((a=t.objects.DICTIONARY)!==null&&a!==void 0?a:[]),d=h.next();!d.done;d=h.next()){var f=d.value,p=(s=f.entries)!==null&&s!==void 0?s:{},m=p.AcDbVariableDictionary;if(m){var g=n.getObjectById(u(m));if(g instanceof hn&&l(g)){try{n.objects.dictionary.getAt("AcDbVariableDictionary")||n.objects.dictionary.setAt("AcDbVariableDictionary",g)}catch{}return}}}}catch(y){i={error:y}}finally{try{d&&!d.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}}},e.prototype.optionalObjectArray=function(t,n){var i=t.objects,o=i[n];return Array.isArray(o)?o:void 0},e.prototype.processCommonObjectAttrs=function(t,n){n.objectId=t.handle,t.ownerHandle!=null&&(n.ownerId=t.ownerHandle)},e.prototype.groupAndFlattenByType=function(t){var n,i,o,a,s={},l=[];try{for(var c=Ml(t),u=c.next();!u.done;u=c.next()){var h=u.value;s[h.type]||(s[h.type]=[],l.push(h.type)),s[h.type].push(h)}}catch(v){n={error:v}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}var d=[];try{for(var f=Ml(l),p=f.next();!p.done;p=f.next())for(var m=p.value,g=s[m],y=0;y<g.length;y++)d.push(g[y])}catch(v){o={error:v}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}return d},e.prototype.isModelSpace=function(t){return t&&t.toUpperCase()==Z3e},e.prototype.normalizeHeaderStringValue=function(t){if(typeof t=="string"){var n=t.trim();return n.length>0?n:void 0}},e})(Yw);const Q3e=12e4;async function eDe(r=Q3e){const e=W.instance.curView;if(!(e instanceof Ow))return;await e.waitUntilIdle(r)||console.warn("[cad-simple-viewer-cli] Timed out waiting for scene idle; continuing"),await ou()}let p4=!1;const qk=[],Kk=[];let Zk;const m4=new Map;function tDe(){const r=URL.createObjectURL.bind(URL);URL.createObjectURL=e=>{const t=r(e);return e instanceof Blob&&m4.set(t,e),t},document.addEventListener("click",e=>{const t=e.target;if(!(t instanceof Element))return;const n=t.closest("a");if(!(n instanceof HTMLAnchorElement)||!n.hasAttribute("download"))return;const i=n.getAttribute("href")||n.href,o=n.download||"download.bin";if(!i)return;e.preventDefault(),e.stopImmediatePropagation();const a=(async()=>{let s=m4.get(i);if(!s&&i.startsWith("data:")&&(s=await(await fetch(i)).blob()),!s){const u=await fetch(i);if(!u.ok)throw new Error(`Failed to fetch download "${o}"`);s=await u.blob()}if(!Zk)throw new Error("CLI save endpoint not configured");const l=performance.now(),c=await fetch(`${Zk}${encodeURIComponent(o)}`,{method:"POST",body:s});if(!c.ok)throw new Error(`Failed to save download "${o}" (${c.status})`);console.log(`[cad-simple-viewer-cli] saved ${o}: ${(performance.now()-l).toFixed(0)} ms (${s.size} bytes)`),qk.push({fileName:o})})().catch(s=>{throw console.error("[cad-simple-viewer-cli] Failed to capture download",s),s});Kk.push(a)},!0)}function nDe(r){return r==="write"?st.Write:st.Read}function rDe(r){if(r==="extents")return aa.Extents;if(r==="saved")return aa.Saved}function iDe(r){const e={mode:nDe(r.mode),progressiveRendering:!1,convertInvisibleLayers:!0,convertAllLayouts:!0,skipSpatialIndex:!0,cooperativeYield:!1},t=rDe(r.openViewMode);return t!=null&&(e.openViewMode=t),r.drawNoPlotLayers!=null&&(e.drawNoPlotLayers=r.drawNoPlotLayers),r.circleSides!=null&&(e.circleSides=r.circleSides),e}function oDe(r){if(!r)return;const e=r.trim().toLowerCase();if(e==="en"||e==="zh"||e==="tr"||e==="cs")return e}function aDe(){const r=dI.getLastSnapshot();if(!r)return;const e=[`[cad-simple-viewer-cli] OPENPROF total=${r.totalMs.toFixed(0)}ms read=${r.readMs.toFixed(0)}ms convert=${r.convertMs.toFixed(0)}ms parse=${r.parseMs.toFixed(0)}ms entity=${r.entityMs.toFixed(0)}ms`,`[cad-simple-viewer-cli] OPENPROF cache hits=${r.cache.topLevel.hits} misses=${r.cache.topLevel.misses} clone=${r.cache.topLevel.cloneMs.toFixed(0)}ms build=${r.cache.topLevel.missBuildMs.toFixed(0)}ms compact=${r.cache.topLevel.missCompactMs.toFixed(0)}ms`];if(r.convertPhase){const t=r.convertPhase;e.push(`[cad-simple-viewer-cli] OPENPROF convertPhase finishGeometry=${t.finishGeometryMs.toFixed(0)}ms asyncDraw=${t.finishGeometryAsyncDrawMs.toFixed(0)}ms queueWait=${t.finishGeometryQueueWaitMs.toFixed(0)}ms handleGroup=${t.handleGroupMs.toFixed(0)}ms addEntity=${t.addEntityMs.toFixed(0)}ms awaitFonts=${t.awaitFontsMs.toFixed(0)}ms glyphs=${t.glyphEntityCount} mtext=${t.mtextCount} shape=${t.shapeCount} sharedGlyph=${t.sharedGlyphDrawCount}`)}try{const t=r.mtextProfile??bn.getInstance().getTextRenderProfile()??Dt.snapshot(),n="[cad-simple-viewer-cli]";if(e.push(`${n} mtextProfile.enabled=${String(t==null?void 0:t.enabled)} drawCount=${(t==null?void 0:t.drawCount)??0} placedChars=${(t==null?void 0:t.placedChars)??0} triangulateMs=${((t==null?void 0:t.triangulateMs)??0).toFixed(1)} mergeMeshMs=${((t==null?void 0:t.mergeMeshMs)??0).toFixed(1)} parseLayoutMs=${((t==null?void 0:t.parseLayoutMs)??0).toFixed(1)}`),t)for(const i of Dt.formatReport(t))e.push(`${n} ${i.trimStart()}`)}catch(t){e.push(`[cad-simple-viewer-cli] mtextProfile error: ${t instanceof Error?t.message:String(t)}`)}for(const t of e)console.log(t)}async function sDe(r={}){if(p4)return;tDe();const e=document.getElementById("cad-root"),t=`./workers/${vOe}`;BA.instance.register(go.DWG,new J3e({convertByEntityType:!1,useWorker:!0,parserWorkerUrl:t}));const n=r.useMainThreadDraw!==!1;W.createInstance({container:e,width:1280,height:720,autoResize:!1,...r.baseUrl?{baseUrl:r.baseUrl}:{},useMainThreadDraw:n,webworkerFileUrls:{dwgParser:t,mtextRender:`./workers/${fG}`}}),r.meshFontRenderMode&&bn.getInstance().setMeshFontRenderMode(r.meshFontRenderMode),r.meshGlyphInstancing===!1&&bn.getInstance().setMeshGlyphInstancing(!1),globalThis.__MTEXTPROF__=!0,Dt.setEnabled(!0),Dt.reset(),bn.getInstance().setTextRenderProfilerEnabled(!0);const i=W.instance.pluginManager;BG(i,{viewerRuntimeUrl:"./viewer-runtime.iife.js"}),jG(i),q3e(i),p4=!0}window.runCadScript=async(r,e,t,n={})=>{await sDe(n),qk.length=0,Kk.length=0,Zk=n.saveBaseUrl;const i=oDe(n.locale);i&&M.setCurrentLocale(i);const o=W.instance,a=!!(e&&r),s=iDe(n);try{Lt.instance().setVar(ae.OPENPROF,!0,o.curDocument.database)}catch{}const l=performance.now(),c=Date.now();if(a){const h=performance.now(),d=await fetch(e);if(!d.ok)throw new Error(`Failed to fetch drawing "${r}" (${d.status}).`);const f=await d.arrayBuffer();if(console.log(`[cad-simple-viewer-cli] fetch drawing: ${(performance.now()-h).toFixed(0)} ms (${f.byteLength} bytes)`),!await o.openDocument(r,f,s))throw new Error(`Failed to open "${r}".`)}else if(n.startBlank!==!1&&!await o.newDocument({...s,mode:st.Write}))throw new Error("Failed to create a blank drawing.");await eDe(),console.log(`[cad-simple-viewer-cli] open+idle: ${(performance.now()-l).toFixed(0)} ms`);for(let h=0;h<60;h++){const d=dI.getLastSnapshot();if(d&&d.collectedAt>=c)break;await new Promise(f=>setTimeout(f,16))}aDe();const u=performance.now();return await o.runScript(t),await Promise.all(Kk),await ou(),console.log(`[cad-simple-viewer-cli] script: ${(performance.now()-u).toFixed(0)} ms`),{ok:!0,files:qk.map(h=>({...h}))}};export{xP as $,ty as A,Y3e as B,Lt as C,ae as D,yb as E,PF as F,MF as G,vt as H,Va as I,Vd as J,At as K,Je as L,hl as M,MV as N,UDe as O,kr as P,Qi as Q,VDe as R,Yt as S,Xt as T,on as U,$n as V,sr as W,it as X,Ga as Y,ai as Z,Yi as _,ou as a,Ae as a0,__e as a1,QA as a2,bh as a3,Bh as a4,ba as a5,tc as a6,Dh as a7,Us as a8,sn as a9,Is as aA,or as aB,Br as aC,V as aD,I7 as aE,Ow as aF,gke as aG,T1e as aH,RG as aI,FG as aJ,Ue as aK,P8 as aL,rr as aM,Na as aN,st as aO,Ht as aP,Nl as aQ,Oy as aR,bn as aS,Ji as aT,NG as aU,zG as aV,my as aa,fC as ab,hy as ac,Fh as ad,py as ae,JA as af,s_ as ag,TA as ah,$A as ai,fy as aj,XA as ak,vh as al,oc as am,qA as an,Rh as ao,a_ as ap,qr as aq,eh as ar,j as as,es as at,Le as au,tn as av,lt as aw,wt as ax,Wl as ay,Pi as az,aH as b,Bt as c,mh as d,tr as e,Bo as f,nt as g,Io as h,fp as i,yg as j,vg as k,ic as l,Qa as m,Sn as n,re as o,Kn as p,D as q,Rj as r,oo as s,Jt as t,M as u,W as v,Tt as w,hr as x,NC as y,X3e as z};
|