@mlightcad/data-model 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- (function(g,ce){typeof exports=="object"&&typeof module<"u"?ce(exports):typeof define=="function"&&define.amd?define(["exports"],ce):(g=typeof globalThis<"u"?globalThis:g||self,ce(g["data-model"]={}))})(this,function(g){"use strict";function ce(n,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in n)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const Re={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},fs=[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];function de(n,t,e){return Math.max(t,Math.min(e,n))}const mn=class la{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(de(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=de(t,0,256),this._color=fs[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const e=Re[t.toLowerCase()];e!==void 0?(this._colorName=t,this._color=e,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+t)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,e,s){const r=Math.round(de(t,0,255)),i=Math.round(de(e,0,255)),a=Math.round(de(s,0,255));return this.color=(r<<16)+(i<<8)+a,this}setColorName(t){const e=Re[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new la;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[e,s]of Object.entries(Re))if(s===t)return e;return null}getColorIndexByValue(t){const e=fs.length-1;for(let s=1;s<e;++s)if(fs[s]===t)return s;return null}};mn.NAMES=Re;let zt=mn;const et={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class ga{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let r=0,i=s.length;r<i;r++)s[r].call(this,t)}}}let st=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};var pa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ya(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var gn={exports:{}};(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(pa,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],i={},a=null;function o(_,x){var f=_[x];if(typeof f.bind=="function")return f.bind(_);try{return Function.prototype.bind.call(f,_)}catch{return function(){return Function.prototype.apply.apply(f,[_,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function h(_){return _==="debug"&&(_="log"),typeof console===e?!1:_==="trace"&&s?c:console[_]!==void 0?o(console,_):console.log!==void 0?o(console,"log"):t}function d(){for(var _=this.getLevel(),x=0;x<r.length;x++){var f=r[x];this[f]=x<_?t:this.methodFactory(f,_,this.name)}if(this.log=this.debug,typeof console===e&&_<this.levels.SILENT)return"No console available for logging"}function u(_){return function(){typeof console!==e&&(d.call(this),this[_].apply(this,arguments))}}function m(_,x,f){return h(_)||u.apply(this,arguments)}function p(_,x){var f=this,M,T,S,P="loglevel";typeof _=="string"?P+=":"+_:typeof _=="symbol"&&(P=void 0);function z(N){var V=(r[N]||"silent").toUpperCase();if(!(typeof window===e||!P)){try{window.localStorage[P]=V;return}catch{}try{window.document.cookie=encodeURIComponent(P)+"="+V+";"}catch{}}}function I(){var N;if(!(typeof window===e||!P)){try{N=window.localStorage[P]}catch{}if(typeof N===e)try{var V=window.document.cookie,Jt=encodeURIComponent(P),te=V.indexOf(Jt+"=");te!==-1&&(N=/^([^;]+)/.exec(V.slice(te+Jt.length+1))[1])}catch{}return f.levels[N]===void 0&&(N=void 0),N}}function W(){if(!(typeof window===e||!P)){try{window.localStorage.removeItem(P)}catch{}try{window.document.cookie=encodeURIComponent(P)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function lt(N){var V=N;if(typeof V=="string"&&f.levels[V.toUpperCase()]!==void 0&&(V=f.levels[V.toUpperCase()]),typeof V=="number"&&V>=0&&V<=f.levels.SILENT)return V;throw new TypeError("log.setLevel() called with invalid level: "+N)}f.name=_,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=x||m,f.getLevel=function(){return S??T??M},f.setLevel=function(N,V){return S=lt(N),V!==!1&&z(S),d.call(f)},f.setDefaultLevel=function(N){T=lt(N),I()||f.setLevel(N,!1)},f.resetLevel=function(){S=null,W(),d.call(f)},f.enableAll=function(N){f.setLevel(f.levels.TRACE,N)},f.disableAll=function(N){f.setLevel(f.levels.SILENT,N)},f.rebuild=function(){if(a!==f&&(M=lt(a.getLevel())),d.call(f),a===f)for(var N in i)i[N].rebuild()},M=lt(a?a.getLevel():"WARN");var vt=I();vt!=null&&(S=lt(vt)),d.call(f)}a=new p,a.getLogger=function(_){if(typeof _!="symbol"&&typeof _!="string"||_==="")throw new TypeError("You must supply a name when creating a logger.");var x=i[_];return x||(x=i[_]=new p(_,a.methodFactory)),x};var y=typeof window!==e?window.log:void 0;return a.noConflict=function(){return typeof window!==e&&window.log===a&&(window.log=y),a},a.getLoggers=function(){return i},a.default=a,a})})(gn);var pn=gn.exports;const _a=ya(pn),fa=ce({__proto__:null,default:_a},[pn]),xa=!0,ue=fa;ue.setLevel("debug");const ba=n=>{try{ue.setLevel(n)}catch(t){ue.setLevel("error"),ue.error(t)}};function me(n){return n===null||typeof n!="object"?n:Array.isArray(n)?[...n]:{...n}}function ee(n,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&n[s]===void 0&&(n[s]=e[s]);return n}function yn(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function _n(n){return n==null?!0:Array.isArray(n)||typeof n=="string"?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function se(n,t){if(n===t)return!0;if(n==null||t==null)return n===t;if(typeof n!=typeof t)return!1;if(typeof n!="object")return n===t;if(Array.isArray(n)!==Array.isArray(t))return!1;if(Array.isArray(n)){if(n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(!se(n[r],t[r]))return!1;return!0}const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(const r of e)if(!Object.prototype.hasOwnProperty.call(t,r)||!se(n[r],t[r]))return!1;return!0}let fn=class ha{constructor(t,e){this.events={attrChanged:new st,modelChanged:new st},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&ee(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let r;typeof t=="object"?(r=t,s=e):(r={},r[t]=e),s||(s={});const i=s.unset,a=s.silent,o=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=me(this.attributes),this.changed={});const h=this.attributes,d=this.changed,u=this._previousAttributes;for(const m in r)e=r[m],se(h[m],e)||o.push(m),se(u[m],e)?delete d[m]:d[m]=e,i?delete h[m]:h[m]=e;if(!a){o.length&&(this._pending=s);for(let m=0;m<o.length;m++)this.events.attrChanged.dispatch({object:this,attrName:o[m],attrValue:h[o[m]],options:s})}if(c)return this;if(!a)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!_n(this.changed):yn(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?me(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const r in t){const i=t[r];se(e[r],i)||(s[r]=i)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return me(this._previousAttributes)}clone(){const t=me(this.attributes);return new ha(t)}},xs=class De{constructor(){this.entries=new Map}static getInstance(){return De.instance||(De.instance=new De),De.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class wa{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,r=Math.max(0,e),i=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(t)/Math.log(s)),o=t/Math.pow(s,a);return`${parseFloat(o.toFixed(r))} ${i[a]}`}}class xn{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class bn{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let r=0;r<e;r++){const i=this.tasks[r];try{s=await new Promise((a,o)=>{setTimeout(async()=>{try{const c=await i.run(s);this.onProgress((r+1)/e,i),a(c)}catch(c){o(c)}},0)})}catch(a){this.onError(a,r,i);return}}this.onComplete(s)}}let wn=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const r=this.handlers[e],i=this.handlers[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return i}return null}};const An=new wn;let Aa=class{constructor(t){this.manager=t!==void 0?t:An,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,r)=>{this.load(t,s,e,r)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};class Pn{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(t):setTimeout(t,0)}async processChunk(t){let e=0;const s=async()=>{const r=e,i=Math.min(e+this._chunkSize,this._count);await t(r,i),e=i,e<this._count&&this.scheduleTask(s)};await s()}}var Y,ge,j,U,pe,ht,Z,_t,ct,Ft,ye,_e,Bt,Vt,fe,xe,be,nt,ft,R,jt,we,E,Q,Ae,J,xt,Pe,bt,dt,Ie,Gt,rt,wt,bs,ws,At,Ee,Te,Pt,Se,As,Ps,Ht,q,It,X,it,Is,Es,Ts,Ss,Ms,vs;(Y={})[Y.None=0]="None",Y[Y.Anonymous=1]="Anonymous",Y[Y.NonConstant=2]="NonConstant",Y[Y.Xref=4]="Xref",Y[Y.XrefOverlay=8]="XrefOverlay",Y[Y.ExternallyDependent=16]="ExternallyDependent",Y[Y.ResolvedOrDependent=32]="ResolvedOrDependent",Y[Y.ReferencedXref=64]="ReferencedXref",(ge={})[ge.BYBLOCK=0]="BYBLOCK",ge[ge.BYLAYER=256]="BYLAYER",(j={})[j.Rotated=0]="Rotated",j[j.Aligned=1]="Aligned",j[j.Angular=2]="Angular",j[j.Diameter=3]="Diameter",j[j.Radius=4]="Radius",j[j.Angular3Point=5]="Angular3Point",j[j.Ordinate=6]="Ordinate",j[j.ReferenceIsExclusive=32]="ReferenceIsExclusive",j[j.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",j[j.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(U={})[U.TopLeft=1]="TopLeft",U[U.TopCenter=2]="TopCenter",U[U.TopRight=3]="TopRight",U[U.MiddleLeft=4]="MiddleLeft",U[U.MiddleCenter=5]="MiddleCenter",U[U.MiddleRight=6]="MiddleRight",U[U.BottomLeft=7]="BottomLeft",U[U.BottomCenter=8]="BottomCenter",U[U.BottomRight=9]="BottomRight",(pe={})[pe.AtLeast=1]="AtLeast",pe[pe.Exact=2]="Exact";var In=((ht={})[ht.Center=0]="Center",ht[ht.Above=1]="Above",ht[ht.Outside=2]="Outside",ht[ht.JIS=3]="JIS",ht[ht.Below=4]="Below",ht),ne=((Z={})[Z.Feet=0]="Feet",Z[Z.None=1]="None",Z[Z.Inch=2]="Inch",Z[Z.FeetAndInch=3]="FeetAndInch",Z[Z.Leading=4]="Leading",Z[Z.Trailing=8]="Trailing",Z[Z.LeadingAndTrailing=12]="LeadingAndTrailing",Z),Pa=((_t={})[_t.None=0]="None",_t[_t.Leading=1]="Leading",_t[_t.Trailing=2]="Trailing",_t[_t.LeadingAndTrailing=3]="LeadingAndTrailing",_t),Ia=((ct={})[ct.Center=0]="Center",ct[ct.Left=1]="Left",ct[ct.Right=2]="Right",ct[ct.OverFirst=3]="OverFirst",ct[ct.OverSecond=4]="OverSecond",ct),Ea=((Ft={})[Ft.Bottom=0]="Bottom",Ft[Ft.Center=1]="Center",Ft[Ft.Top=2]="Top",Ft);(ye={})[ye.PatternFill=0]="PatternFill",ye[ye.SolidFill=1]="SolidFill",(_e={})[_e.NonAssociative=0]="NonAssociative",_e[_e.Associative=1]="Associative",(Bt={})[Bt.Normal=0]="Normal",Bt[Bt.Outer=1]="Outer",Bt[Bt.Ignore=2]="Ignore",(Vt={})[Vt.UserDefined=0]="UserDefined",Vt[Vt.Predefined=1]="Predefined",Vt[Vt.Custom=2]="Custom",(fe={})[fe.NotAnnotated=0]="NotAnnotated",fe[fe.Annotated=1]="Annotated",(xe={})[xe.Solid=0]="Solid",xe[xe.Gradient=1]="Gradient",(be={})[be.TwoColor=0]="TwoColor",be[be.OneColor=1]="OneColor";var Ta=((nt={})[nt.Default=0]="Default",nt[nt.External=1]="External",nt[nt.Polyline=2]="Polyline",nt[nt.Derived=4]="Derived",nt[nt.Textbox=8]="Textbox",nt[nt.Outermost=16]="Outermost",nt),ze=((ft={})[ft.Line=1]="Line",ft[ft.Circular=2]="Circular",ft[ft.Elliptic=3]="Elliptic",ft[ft.Spline=4]="Spline",ft),Sa=((R={})[R.Off=0]="Off",R[R.Solid=1]="Solid",R[R.Dashed=2]="Dashed",R[R.Dotted=3]="Dotted",R[R.ShotDash=4]="ShotDash",R[R.MediumDash=5]="MediumDash",R[R.LongDash=6]="LongDash",R[R.DoubleShortDash=7]="DoubleShortDash",R[R.DoubleMediumDash=8]="DoubleMediumDash",R[R.DoubleLongDash=9]="DoubleLongDash",R[R.DoubleMediumLongDash=10]="DoubleMediumLongDash",R[R.SparseDot=11]="SparseDot",R);Sa.Off,(jt={})[jt.Standard=-3]="Standard",jt[jt.ByLayer=-2]="ByLayer",jt[jt.ByBlock=-1]="ByBlock",(we={})[we.English=0]="English",we[we.Metric=1]="Metric",(E={})[E.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",E[E.FRONT_CLIPPING=2]="FRONT_CLIPPING",E[E.BACK_CLIPPING=4]="BACK_CLIPPING",E[E.UCS_FOLLOW=8]="UCS_FOLLOW",E[E.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",E[E.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",E[E.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",E[E.FAST_ZOOM=128]="FAST_ZOOM",E[E.SNAP_MODE=256]="SNAP_MODE",E[E.GRID_MODE=512]="GRID_MODE",E[E.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",E[E.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",E[E.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",E[E.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",E[E.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",E[E.UNUSED=32768]="UNUSED",E[E.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",E[E.VIEWPORT_OFF=131072]="VIEWPORT_OFF",E[E.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",E[E.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",E[E.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",E[E.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(Q={})[Q.OPTIMIZED_2D=0]="OPTIMIZED_2D",Q[Q.WIREFRAME=1]="WIREFRAME",Q[Q.HIDDEN_LINE=2]="HIDDEN_LINE",Q[Q.FLAT_SHADED=3]="FLAT_SHADED",Q[Q.GOURAUD_SHADED=4]="GOURAUD_SHADED",Q[Q.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",Q[Q.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(Ae={})[Ae.UCS_UNCHANGED=0]="UCS_UNCHANGED",Ae[Ae.HAS_OWN_UCS=1]="HAS_OWN_UCS",(J={})[J.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",J[J.TOP=1]="TOP",J[J.BOTTOM=2]="BOTTOM",J[J.FRONT=3]="FRONT",J[J.BACK=4]="BACK",J[J.LEFT=5]="LEFT",J[J.RIGHT=6]="RIGHT",(xt={})[xt.AS_DISPLAYED=0]="AS_DISPLAYED",xt[xt.WIREFRAME=1]="WIREFRAME",xt[xt.HIDDEN=2]="HIDDEN",xt[xt.RENDERED=3]="RENDERED",(Pe={})[Pe.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Pe[Pe.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";function k(n,t,e){return n.code===t&&(e==null||n.value===e)}function D(n){let t={};n.rewind();let e=n.next(),s=e.code;if(t.x=e.value,(e=n.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=n.next()).code!==s+20?n.rewind():t.z=e.value,t}let Ls=Symbol();function v(n,t){return(e,s,r)=>{let i=n.reduce((c,h)=>{h.pushContext&&c.push({});let d=c[c.length-1];for(let u of typeof h.code=="number"?[h.code]:h.code){let m=d[u]??(d[u]=[]);h.isMultiple&&m.length&&console.warn(`Snippet ${m.at(-1).name} for code(${u}) is shadowed by ${h.name}`),m.push(h)}return c},[{}]),a=!1,o=i.length-1;for(;!k(e,0,"EOF");){let c=function(y,_,x){return y.find((f,M)=>{var T;return M>=x&&((T=f[_])==null?void 0:T.length)})}(i,e.code,o),h=c==null?void 0:c[e.code].at(-1);if(!c||!h){s.rewind();break}h.isMultiple||c[e.code].pop();let{name:d,parser:u,isMultiple:m}=h,p=u==null?void 0:u(e,s,r);if(p===Ls){s.rewind();break}if(d){let[y,_]=function(x,f){let M=f.split("."),T=x;for(let S=0;S<M.length-1;++S){let P=M[S];Object.hasOwn(T,P)||(T[P]={}),T=T[P]}return[T,M.at(-1)]}(r,d);m?(Object.hasOwn(y,_)||(y[_]=[]),y[_].push(p)):y[_]=p}h.pushContext&&(o-=1),a=!0,e=s.next()}return t&&Object.setPrototypeOf(r,t),a}}function l({value:n}){return n}function A(n,t){return D(t)}function F({value:n}){return!!n}var En=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function Tn(n,t){var r;if(!k(n,1001))throw Error("XData must starts with code 1001");let e={appName:n.value,value:[]};n=t.next();let s=[e.value];for(;!k(n,0,"EOF")&&n.code>=1e3;){let i=s.at(-1);switch(n.code){case 1002:n.value==="{"?s.push([]):(s.pop(),(r=s.at(-1))==null||r.push(i));break;case 1e3:case 1004:case 1040:case 1070:case 1071:i.push({type:Et(n.code),value:n.value});break;case 1003:i.push({name:"layer",type:Et(n.code),value:n.value});break;case 1005:i.push({name:"handle",type:Et(n.code),value:n.value});break;case 1010:i.push({type:Et(n.code),value:D(t)});break;case 1011:i.push({name:"worldSpacePosition",type:Et(n.code),value:D(t)});break;case 1012:i.push({name:"worldSpaceDisplacement",type:Et(n.code),value:D(t)});break;case 1013:i.push({name:"worldSpaceDirection",type:Et(n.code),value:D(t)});break;case 1041:i.push({name:"distance",type:Et(n.code),value:n.value});break;case 1042:i.push({name:"scale",type:Et(n.code),value:n.value})}n=t.next()}return t.rewind(),e}function Et(n){switch(n){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function ks(n,t,e){if(k(t,102))return Fe(t,e),!0;switch(t.code){case 0:n.type=t.value;break;case 5:n.handle=t.value;break;case 330:n.ownerDictionarySoftId?n.ownerBlockRecordSoftId=t.value:n.ownerDictionarySoftId=t.value;break;case 360:n.ownerdictionaryHardId=t.value;break;case 67:n.isInPaperSpace=!!t.value;break;case 8:n.layer=t.value;break;case 6:n.lineType=t.value;break;case 347:n.materialObjectHardId=t.value;break;case 62:n.colorIndex=t.value,n.color=En[Math.abs(t.value)];break;case 370:n.lineweight=t.value;break;case 48:n.lineTypeScale=t.value;break;case 60:n.isVisible=!!t.value;break;case 92:n.proxyByte=t.value;break;case 310:n.proxyEntity=t.value;break;case 100:break;case 420:n.color=t.value;break;case 430:n.transparency=t.value;break;case 390:n.plotStyleHardId=t.value;break;case 284:n.shadowMode=t.value;break;case 1001:n.xdata=Tn(t,e);break;default:return!1}return!0}let Ma=0;function Sn(n){if(!n)throw TypeError("entity cannot be undefined or null");n.handle||(n.handle=Ma++)}(bt={})[bt.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",bt[bt.CAST=1]="CAST",bt[bt.RECEIVE=2]="RECEIVE",bt[bt.IGNORE=3]="IGNORE";let G=[{code:1001,name:"xdata",parser:Tn},{code:284,name:"shadowMode",parser:l},{code:390,name:"plotStyleHardId",parser:l},{code:440,name:"transparency",parser:l},{code:430,name:"colorName",parser:l},{code:420,name:"color",parser:l},{code:310,name:"proxyEntity",isMultiple:!0,parser:l},{code:92,name:"proxyByte",parser:l},{code:60,name:"isVisible",parser:F},{code:48,name:"lineTypeScale",parser:l},{code:370,name:"lineweight",parser:l},{code:62,name:"colorIndex",parser(n,t,e){let s=n.value;return e.color=En[Math.abs(s)],s}},{code:347,name:"materialObjectHardId",parser:l},{code:6,name:"lineType",parser:l},{code:8,name:"layer",parser:l},{code:410,name:"layoutTabName",parser:l},{code:67,name:"isInPaperSpace",parser:F},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:l},{code:102,parser:Fe},{code:102,parser:Fe},{code:102,parser:Fe},{code:5,name:"handle",parser:l}];function Fe(n,t){for(n=t.next();!k(n,102)&&!k(n,0,"EOF");)n=t.next()}function Mn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let va={extrusionDirection:{x:0,y:0,z:1}},La=[{code:210,name:"extrusionDirection",parser:A},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:100,name:"subclassMarker",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:A},{code:39,name:"thickness",parser:l},{code:100},...G];class vn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Mn(this,"parser",v(La,va))}}Mn(vn,"ForEntityName","ARC"),(dt={})[dt.NONE=0]="NONE",dt[dt.INVISIBLE=1]="INVISIBLE",dt[dt.CONSTANT=2]="CONSTANT",dt[dt.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",dt[dt.PRESET=8]="PRESET",(Ie={})[Ie.MULTILINE=2]="MULTILINE",Ie[Ie.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Gt={})[Gt.NONE=0]="NONE",Gt[Gt.MIRRORED_X=2]="MIRRORED_X",Gt[Gt.MIRRORED_Y=4]="MIRRORED_Y";var ka=((rt={})[rt.LEFT=0]="LEFT",rt[rt.CENTER=1]="CENTER",rt[rt.RIGHT=2]="RIGHT",rt[rt.ALIGNED=3]="ALIGNED",rt[rt.MIDDLE=4]="MIDDLE",rt[rt.FIT=5]="FIT",rt),Ca=((wt={})[wt.BASELINE=0]="BASELINE",wt[wt.BOTTOM=1]="BOTTOM",wt[wt.MIDDLE=2]="MIDDLE",wt[wt.TOP=3]="TOP",wt);function Ln(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let kn={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:ka.LEFT,valign:Ca.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Cn=[{code:73,name:"valign",parser:l},{code:100},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"endPoint",parser:A},{code:72,name:"valign",parser:l},{code:72,name:"halign",parser:l},{code:71,name:"generationFlag",parser:l},{code:7,name:"styleName",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"xScale",parser:l},{code:50,name:"rotation",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class On{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ln(this,"parser",v(Cn,kn))}}function Nn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ln(On,"ForEntityName","TEXT");let Oa={...kn},Na=[{code:2},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:A},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:F},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedRecord",parser:F},{code:100},{code:280,name:"isLocked",parser:F},{code:74,name:"valign",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:3,name:"prompt",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},...Cn.slice(2)];class Dn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Nn(this,"parser",v(Na,Oa))}}function Rn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Nn(Dn,"ForEntityName","ATTDEF");let Da={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Ra=[{code:210,name:"extrusionDirection",parser:A},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:A},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class zn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Rn(this,"parser",v(Ra,Da))}}Rn(zn,"ForEntityName","CIRCLE");let Be=class{parseEntity(t,e){let s={};for(;!k(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(r,i,a){switch(i.code){case 100:r.subclassMarker=i.value;break;case 280:r.version=i.value;break;case 2:r.name=i.value;break;case 10:r.definitionPoint=D(a);break;case 11:r.textPoint=D(a);break;case 12:r.insertionPoint=D(a);break;case 13:r.subDefinitionPoint1=D(a);break;case 14:r.subDefinitionPoint2=D(a);break;case 15:r.centerPoint=D(a);break;case 16:r.arcPoint=D(a);break;case 70:r.dimensionType=i.value;break;case 71:r.attachmentPoint=i.value;break;case 72:r.textLineSpacingStyle=i.value;break;case 40:r.leaderLength=i.value;break;case 41:r.textLineSpacingFactor=i.value;break;case 42:r.measurement=i.value;break;case 1:r.text=i.value;break;case 50:r.rotationAngle=i.value;break;case 52:r.obliqueAngle=i.value;break;case 53:r.textRotation=i.value;break;case 51:r.ocsRotation=i.value;break;case 210:r.extrusionDirection=D(a);break;case 3:r.styleName=i.value;break;default:ks(r,i,a)}})(s,e,t),e=t.next()}return s}};function Fn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ws="DIMENSION",(bs="ForEntityName")in Be?Object.defineProperty(Be,bs,{value:ws,enumerable:!0,configurable:!0,writable:!0}):Be[bs]=ws;let za={extrusionDirection:{x:0,y:0,z:1}},Fa=[{code:42,name:"endAngle",parser:l},{code:41,name:"startAngle",parser:l},{code:40,name:"axisRatio",parser:l},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"majorAxisEndPoint",parser:A},{code:10,name:"center",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class Bn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Fn(this,"parser",v(Fa,za))}}Fn(Bn,"ForEntityName","ELLIPSE");let Vn=[{code:330,name:"sourceBoundaryObjects",parser:l,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:l}],Ba=[{code:11,name:"end",parser:A},{code:10,name:"start",parser:A}],Va=[{code:73,name:"isCCW",parser:F},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:A}],ja=[{code:73,name:"isCCW",parser:F},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"lengthOfMinorAxis",parser:l},{code:11,name:"end",parser:A},{code:10,name:"center",parser:A}],Ga=[{code:13,name:"endTangent",parser:A},{code:12,name:"startTangent",parser:A},{code:11,name:"fitDatum",isMultiple:!0,parser:A},{code:97,name:"numberOfFitData",parser:l},{code:10,name:"controlPoints",isMultiple:!0,parser(n,t){let e={...D(t),weight:1};return(n=t.next()).code===42?e.weight=n.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:l},{code:96,name:"numberOfControlPoints",parser:l},{code:95,name:"numberOfKnots",parser:l},{code:74,name:"isPeriodic",parser:F},{code:73,name:"splineFlag",parser:l},{code:94,name:"degree",parser:l}],Ha={[ze.Line]:Ba,[ze.Circular]:Va,[ze.Elliptic]:ja,[ze.Spline]:Ga},Ua=[...Vn,{code:72,name:"edges",parser(n,t){let e={type:n.value},s=v(Ha[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(n=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:l}],Wa=[...Vn,{code:10,name:"vertices",parser(n,t){let e={...D(t),bulge:0};return(n=t.next()).code===42?e.bulge=n.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:l},{code:73,name:"isClosed",parser:F},{code:72,name:"hasBulge",parser:F}],Ya=[{code:49,name:"dashLengths",parser:l,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:l},{code:45,name:"offset",parser:jn},{code:43,name:"base",parser:jn},{code:53,name:"angle",parser:l}];function jn(n,t){let e=n.code+1,s={x:n.value,y:1};return(n=t.next()).code===e?s.y=n.value:t.rewind(),s}function Gn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let qa={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Xa=[{code:470},{code:463},{code:462,name:"colorTint",parser:l},{code:461,name:"gradientDefinition",parser:l},{code:460,name:"gradientRotation",parser:l},{code:453,name:"numberOfColors",parser:l},{code:452,name:"gradientColorFlag",parser:l},{code:451},{code:450,name:"gradientFlag",parser:l},{code:10,name:"seedPoints",parser:A,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:A},{code:98,name:"numberOfSeedPoints",parser:l},{code:47,name:"pixelSize",parser:l},{code:53,name:"definitionLines",parser:function(n,t){let e={};return v(Ya)(n,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:l},{code:77,name:"isDouble",parser:F},{code:73,name:"isAnnotated",parser:F},{code:41,name:"patternScale",parser:l},{code:52,name:"patternAngle",parser:l},{code:76,name:"patternType",parser:l},{code:75,name:"hatchStyle",parser:l},{code:92,name:"boundaryPaths",parser:function(n,t){let e={boundaryPathTypeFlag:n.value},s=e.boundaryPathTypeFlag&Ta.Polyline;return n=t.next(),s?v(Wa)(n,t,e):v(Ua)(n,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:l},{code:71,name:"associativity",parser:l},{code:63,name:"patternFillColor",parser:l},{code:70,name:"solidFill",parser:l},{code:2,name:"patternName",parser:l},{code:210,name:"extrusionDirection",parser:A},{code:10,name:"elevationPoint",parser:A},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...G];class Hn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gn(this,"parser",v(Xa,qa))}}Gn(Hn,"ForEntityName","HATCH"),(At={})[At.ShowImage=1]="ShowImage",At[At.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",At[At.UseClippingBoundary=4]="UseClippingBoundary",At[At.TransparencyIsOn=8]="TransparencyIsOn",(Ee={})[Ee.Rectangular=1]="Rectangular",Ee[Ee.Polygonal=2]="Polygonal",(Te={})[Te.Outside=0]="Outside",Te[Te.Inside=1]="Inside";function Un(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let $a={clippingBoundaryPath:[]},Ka=[{code:90,name:"version",parser:l},{code:10,name:"position",parser:A},{code:11,name:"uPixel",parser:A},{code:12,name:"vPixel",parser:A},{code:13,name:"imageSize",parser:A},{code:340,name:"imageDefHandle",parser:l},{code:70,name:"flags",parser:l},{code:280,name:"clipping",parser:l},{code:281,name:"brightness",parser:l},{code:282,name:"contrast",parser:l},{code:283,name:"fade",parser:l},{code:360,name:"imageDefReactorHandle",parser:l},{code:71,name:"clippingBoundaryType",parser:l},{code:91,name:"countBoundaryPoints",parser:l},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:A},{code:290,name:"clipMode",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Cs{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Un(this,"parser",v(Ka,$a))}}function Wn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Un(Cs,"ForEntityName","IMAGE");let Za={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Qa=[{code:210,name:"extrusionDirection",parser:A},{code:45,name:"rowSpacing",parser:l},{code:44,name:"columnSpacing",parser:l},{code:71,name:"rowCount",parser:l},{code:70,name:"columnCount",parser:l},{code:50,name:"rotation",parser:l},{code:43,name:"zScale",parser:l},{code:42,name:"yScale",parser:l},{code:41,name:"xScale",parser:l},{code:10,name:"insertionPoint",parser:A},{code:2,name:"name",parser:l},{code:66,name:"isVariableAttributes",parser:F},{code:100,name:"subclassMarker",parser:l},...G];class Yn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wn(this,"parser",v(Qa,Za))}}function qn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Wn(Yn,"ForEntityName","INSERT");let Ja={isArrowheadEnabled:!0},to=[{code:213,name:"offsetFromAnnotation",parser:A},{code:212,name:"offsetFromBlock",parser:A},{code:211,name:"horizontalDirection",parser:A},{code:210,name:"normal",parser:A},{code:340,name:"associatedAnnotation",parser:l},{code:77,name:"byBlockColor",parser:l},{code:10,name:"vertices",parser:A,isMultiple:!0},{code:76,name:"numberOfVertices",parser:l},{code:41,name:"textWidth",parser:l},{code:40,name:"textHeight",parser:l},{code:75,name:"isHooklineExists",parser:F},{code:74,name:"isHooklineSameDirection",parser:F},{code:73,name:"leaderCreationFlag",parser:l},{code:72,name:"isSpline",parser:F},{code:71,name:"isArrowheadEnabled",parser:F},{code:3,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Xn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){qn(this,"parser",v(to,Ja))}}qn(Xn,"ForEntityName","LEADER"),(Pt={})[Pt.TextAnnotation=0]="TextAnnotation",Pt[Pt.ToleranceAnnotation=1]="ToleranceAnnotation",Pt[Pt.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Pt[Pt.NoAnnotation=3]="NoAnnotation";function $n(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let eo={thickness:0,extrusionDirection:{x:0,y:0,z:1}},so=[{code:210,name:"extrusionDirection",parser:A},{code:11,name:"endPoint",parser:A},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Kn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){$n(this,"parser",v(so,eo))}}$n(Kn,"ForEntityName","LINE"),(Se={})[Se.IS_CLOSED=1]="IS_CLOSED",Se[Se.PLINE_GEN=128]="PLINE_GEN";let no={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},ro={bulge:0},io=[{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:91,name:"id",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l}],ao=[{code:210,name:"extrusionDirection",parser:A},{code:10,name:"vertices",isMultiple:!0,parser(n,t){let e={};return v(io,ro)(n,t,e),e}},{code:39,name:"thickness",parser:l},{code:38,name:"elevation",parser:l},{code:43,name:"constantWidth",parser:l},{code:70,name:"flag",parser:l},{code:90,name:"numberOfVertices",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Ve{parseEntity(t,e){let s={};return v(ao,no)(e,t,s),s}}Ps="LWPOLYLINE",(As="ForEntityName")in Ve?Object.defineProperty(Ve,As,{value:Ps,enumerable:!0,configurable:!0,writable:!0}):Ve[As]=Ps,(Ht={})[Ht.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ht[Ht.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ht[Ht.BY_STYLE=5]="BY_STYLE";function oo(n,t){let e={};for(let s of n){let r=t(s);r!=null&&(e[r]??(e[r]=[]),e[r].push(s))}return e}function*je(n,t=1/0,e=1){for(let s=n;s!==t;s+=e)yield s}function Lt(n){return{x:n.x??0,y:n.y??0,z:n.z??0}}function Zn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let lo={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Ge=[{code:46,name:"annotationHeight",parser:l},{code:101,parser(n,t){(function(e){e.rewind();let s=e.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=e.next();while(s.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:l},{code:49,name:"columnGutter",parser:l},{code:48,name:"columnWidth",parser:l},{code:79,name:"columnAutoHeight",parser:l},{code:78,name:"columnFlowReversed",parser:l},{code:76,name:"columnCount",parser:l},{code:75,name:"columnType",parser:l},{code:441,name:"backgroundFillTransparency",parser:l},{code:63,name:"backgroundFillColor",parser:l},{code:45,name:"fillBoxScale",parser:l},{code:[...je(430,440)],name:"backgroundColor",parser:l},{code:[...je(420,430)],name:"backgroundColor",parser:l},{code:90,name:"backgroundFill",parser:l},{code:44,name:"lineSpacing",parser:l},{code:73,name:"lineSpacingStyle",parser:l},{code:50,name:"rotation",parser:l},{code:43},{code:42},{code:11,name:"direction",parser:A},{code:210,name:"extrusionDirection",parser:A},{code:7,name:"styleName",parser:l},{code:3,name:"text",isMultiple:!0,parser:l},{code:1,name:"text",isMultiple:!0,parser:l},{code:72,name:"drawingDirection",parser:l},{code:71,name:"attachmentPoint",parser:l},{code:41,name:"width",parser:l},{code:40,name:"height",parser:l},{code:10,name:"insertionPoint",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class Qn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zn(this,"parser",v(Ge,lo))}}function Jn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Zn(Qn,"ForEntityName","MTEXT");let ho={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},co=[{code:50,name:"angle",parser:l},{code:210,name:"extrusionDirection",parser:A},{code:39,name:"thickness",parser:l},{code:10,name:"position",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class tr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Jn(this,"parser",v(co,ho))}}Jn(tr,"ForEntityName","POINT"),(q={})[q.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",q[q.CURVE_FIT=2]="CURVE_FIT",q[q.SPLINE_FIT=4]="SPLINE_FIT",q[q.POLYLINE_3D=8]="POLYLINE_3D",q[q.POLYGON_3D=16]="POLYGON_3D",q[q.CLOSED_POLYGON=32]="CLOSED_POLYGON",q[q.POLYFACE=64]="POLYFACE",q[q.CONTINUOUS=128]="CONTINUOUS",(It={})[It.NONE=0]="NONE",It[It.QUADRATIC=5]="QUADRATIC",It[It.CUBIC=6]="CUBIC",It[It.BEZIER=8]="BEZIER",(X={})[X.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",X[X.TANGENT_DEFINED=2]="TANGENT_DEFINED",X[X.NOT_USED=4]="NOT_USED",X[X.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",X[X.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",X[X.FOR_POLYLINE=32]="FOR_POLYLINE",X[X.FOR_POLYGON=64]="FOR_POLYGON",X[X.POLYFACE=128]="POLYFACE";function er(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let uo={startWidth:0,endWidth:0,bulge:0},mo=[{code:91,name:"id",parser:l},{code:[...je(71,75)],name:"faces",isMultiple:!0,parser:l},{code:50,name:"tangentDirection",parser:l},{code:70,name:"flag",parser:l},{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:30,name:"z",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l},{code:100,name:"subclassMarker",parser:l},{code:100},...G],sr=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){er(this,"parser",v(mo,uo))}};function nr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}er(sr,"ForEntityName","VERTEX");let go={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},po=[{code:0,name:"vertices",isMultiple:!0,parser:(n,t)=>k(n,0,"VERTEX")?(n=t.next(),new sr().parseEntity(t,n)):Ls},{code:210,name:"extrusionDirection",parser:A},{code:75,name:"smoothType",parser:l},{code:74,name:"surfaceNDensity",parser:l},{code:73,name:"surfaceMDensity",parser:l},{code:72,name:"meshNVertexCount",parser:l},{code:71,name:"meshMVertexCount",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:70,name:"flag",parser:l},{code:39,name:"thickness",parser:l},{code:30,name:"elevation",parser:l},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:l},...G];class rr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nr(this,"parser",v(po,go))}}function ir(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}nr(rr,"ForEntityName","POLYLINE");let yo={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},_o=[{code:10,name:"firstPoint",parser:A},{code:11,name:"unitDirection",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class ar{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ir(this,"parser",v(_o,yo))}}function or(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ir(ar,"ForEntityName","RAY");let fo={vertices:[],backLineVertices:[]},xo=[{code:360,name:"geometrySettingHardId",parser:l},{code:12,name:"backLineVertices",isMultiple:!0,parser:A},{code:93,name:"numberOfBackLineVertices",parser:l},{code:11,name:"vertices",isMultiple:!0,parser:A},{code:92,name:"verticesCount",parser:l},{code:[63,411],name:"indicatorColor",parser:l},{code:70,name:"indicatorTransparency",parser:l},{code:41,name:"bottomHeight",parser:l},{code:40,name:"topHeight",parser:l},{code:10,name:"verticalDirection",parser:A},{code:1,name:"name",parser:l},{code:91,name:"flag",parser:l},{code:90,name:"state",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class lr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){or(this,"parser",v(xo,fo))}}function hr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}or(lr,"ForEntityName","SECTION");let bo={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},wo=[{code:210,name:"extrusionDirection",parser:A},{code:39,name:"thickness",parser:l},{code:[...je(10,14)],name:"points",isMultiple:!0,parser:A},{code:100,name:"subclassMarker",parser:l},...G];class cr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){hr(this,"parser",v(wo,bo))}}hr(cr,"ForEntityName","SOLID"),(it={})[it.NONE=0]="NONE",it[it.CLOSED=1]="CLOSED",it[it.PERIODIC=2]="PERIODIC",it[it.RATIONAL=4]="RATIONAL",it[it.PLANAR=8]="PLANAR",it[it.LINEAR=16]="LINEAR";function dr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Ao={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Po=[{code:11,name:"fitPoints",isMultiple:!0,parser:A},{code:10,name:"controlPoints",isMultiple:!0,parser:A},{code:41,name:"weights",isMultiple:!0,parser:l},{code:40,name:"knots",isMultiple:!0,parser:l},{code:13,name:"endTangent",parser:A},{code:12,name:"startTangent",parser:A},{code:44,name:"fitTolerance",parser:l},{code:43,name:"controlTolerance",parser:l},{code:42,name:"knotTolerance",parser:l},{code:74,name:"numberOfFitPoints",parser:l},{code:73,name:"numberOfControlPoints",parser:l},{code:72,name:"numberOfKnots",parser:l},{code:71,name:"degree",parser:l},{code:70,name:"flag",parser:l},{code:210,name:"normal",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class ur{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dr(this,"parser",v(Po,Ao))}}dr(ur,"ForEntityName","SPLINE");class He{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=Lt(D(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Lt(D(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerDictionaryId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(r,i){let a=!1,o=!1,c={};for(;!r.isEOF()&&i.code!==0&&!o;)switch(i.code){case 171:if(a){o=!0;continue}c.cellType=i.value,a=!0,i=r.next();break;case 172:c.flagValue=i.value,i=r.next();break;case 173:c.mergedValue=i.value,i=r.next();break;case 174:c.autoFit=i.value,i=r.next();break;case 175:c.borderWidth=i.value,i=r.next();break;case 176:c.borderHeight=i.value,i=r.next();break;case 91:c.overrideFlag=i.value,i=r.next();break;case 178:c.virtualEdgeFlag=i.value,i=r.next();break;case 145:c.rotation=i.value,i=r.next();break;case 345:c.fieldObjetId=i.value,i=r.next();break;case 340:c.blockTableRecordId=i.value,i=r.next();break;case 146:c.blockScale=i.value,i=r.next();break;case 177:c.blockAttrNum=i.value,i=r.next();break;case 7:c.textStyle=i.value,i=r.next();break;case 140:c.textHeight=i.value,i=r.next();break;case 170:c.attachmentPoint=i.value,i=r.next();break;case 92:c.extendedCellFlags=i.value,i=r.next();break;case 285:c.rightBorderVisibility=!!(i.value??!0),i=r.next();break;case 286:c.bottomBorderVisibility=!!(i.value??!0),i=r.next();break;case 288:c.leftBorderVisibility=!!(i.value??!0),i=r.next();break;case 289:c.topBorderVisibility=!!(i.value??!0),i=r.next();break;case 301:(function(h,d,u){for(;u.code!==304;)switch(u.code){case 301:case 93:case 90:case 94:u=d.next();break;case 1:h.text=u.value,u=d.next();break;case 300:h.attrText=u.value,u=d.next();break;case 302:h.text=u.value?u.value:h.text,u=d.next();break;default:console.log(`Ignore code: ${u.code}, value: ${u.value}`),u=d.next()}})(c,r,i),i=r.next();break;default:return c}return a=!1,o=!1,c}(t,e)),e=t.lastReadGroup;break;default:ks(s,e,t),e=t.next()}}return s}}Es="ACAD_TABLE",(Is="ForEntityName")in He?Object.defineProperty(He,Is,{value:Es,enumerable:!0,configurable:!0,writable:!0}):He[Is]=Es;class Ue{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(r,i,a){if(a==="EOF")return!1;switch(a.code){case 0:default:return!1;case 100:r.subclassMarker=a.value;break;case 10:r.viewportCenter=Lt(D(i));break;case 40:r.width=a.value;break;case 41:r.height=a.value;break;case 68:r.status=a.value;break;case 69:r.viewportId=a.value;break;case 12:r.displayCenter=D(i);break;case 13:r.snapBase=D(i);break;case 14:r.snapSpacing=D(i);break;case 15:r.gridSpacing=D(i);break;case 16:r.viewDirection=Lt(D(i));break;case 17:r.targetPoint=Lt(D(i));break;case 42:r.perspectiveLensLength=a.value;break;case 43:r.frontClipZ=a.value;break;case 44:r.backClipZ=a.value;break;case 45:r.viewHeight=a.value;break;case 50:r.snapAngle=a.value;break;case 51:r.viewTwistAngle=a.value;break;case 72:r.circleZoomPercent=a.value;break;case 331:r.frozenLayerIds??(r.frozenLayerIds=[]),r.frozenLayerIds.push(a.value);break;case 90:r.statusBitFlags=a.value;break;case 330:r.ownerBlockRecordSoftId=a.value;break;case 340:r.clippingBoundaryId=a.value;break;case 1:r.sheetName=a.value;break;case 281:r.renderMode=a.value;break;case 71:r.ucsPerViewport=a.value;break;case 110:r.ucsOrigin=Lt(D(i));break;case 111:r.ucsXAxis=Lt(D(i));break;case 112:r.ucsYAxis=Lt(D(i));break;case 345:r.ucsId=a.value;break;case 346:r.ucsBaseId=a.value;break;case 79:r.orthographicType=a.value;break;case 146:r.elevation=a.value;break;case 170:r.shadePlotMode=a.value;break;case 61:r.majorGridFrequency=a.value;break;case 332:r.backgroundId=a.value;break;case 333:r.shadePlotId=a.value;break;case 348:r.visualStyleId=a.value;break;case 292:r.isDefaultLighting=!!a.value;break;case 282:r.defaultLightingType=a.value;break;case 141:r.brightness=a.value;break;case 142:r.contrast=a.value;break;case 63:case 421:case 431:r.ambientLightColor=a.value;break;case 361:r.sunId=a.value;break;case 335:case 343:case 344:case 91:r.softPointer=a.value}return!0}(s,t,e)&&ks(s,e,t),e=t.next()}return s}}Ss="VIEWPORT",(Ts="ForEntityName")in Ue?Object.defineProperty(Ue,Ts,{value:Ss,enumerable:!0,configurable:!0,writable:!0}):Ue[Ts]=Ss;class We extends Cs{parseEntity(t,e){return super.parseEntity(t,e)}}function mr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}vs="WIPEOUT",(Ms="ForEntityName")in We?Object.defineProperty(We,Ms,{value:vs,enumerable:!0,configurable:!0,writable:!0}):We[Ms]=vs;let Io={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},Eo=[{code:10,name:"firstPoint",parser:A},{code:11,name:"unitDirection",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class gr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){mr(this,"parser",v(Eo,Io))}}function pr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}mr(gr,"ForEntityName","XLINE");let To={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},So=[...Ge.slice(Ge.findIndex(({name:n})=>n==="columnType"),Ge.findIndex(({name:n})=>n==="subclassMarker")+1),{code:100},{code:0,parser(n){if(!k(n,0,"MTEXT"))return Ls}},{code:2,name:"definitionTag",parser:l},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:A},{code:340,name:"secondaryAttributesHardId",parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:F},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedEntriesKeep",parser:F},{code:100},{code:280,name:"lockPositionFlag",parser:F},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"alignmentPoint",parser:A},{code:74,name:"verticalJustification",parser:l},{code:72,name:"horizontalJustification",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:7,name:"textStyle",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"scale",parser:l},{code:50,name:"rotation",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:l},{code:100},...G];class yr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){pr(this,"parser",v(So,To))}}pr(yr,"ForEntityName","ATTRIB");let Mo=Object.fromEntries([vn,Dn,yr,zn,Be,Bn,Cs,Yn,Xn,Kn,Ve,Qn,tr,rr,ar,lr,cr,ur,He,On,Hn,Ue,We,gr].map(n=>[n.ForEntityName,new n]));function _r(n,t){let e=[];for(;!k(n,0,"EOF");){if(n.code===0){if(n.value==="ENDBLK"||n.value==="ENDSEC"){t.rewind();break}let s=Mo[n.value];if(s){let r=n.value;n=t.next();let i=s.parseEntity(t,n);i.type=r,Sn(i),e.push(i)}else console.warn(`Unsupported ENTITY type: ${n.value}`)}n=t.next()}return e}function vo(n,t){let e={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");){if(k(n,0,"BLOCK")){let s=Lo(n=t.next(),t);Sn(s),s.name&&(e[s.name]=s)}n=t.next()}return e}function Lo(n,t){let e={};for(;!k(n,0,"EOF");){if(k(n,0,"ENDBLK")){for(n=t.next();!k(n,0,"EOF");){if(k(n,100,"AcDbBlockEnd"))return e;n=t.next()}break}switch(n.code){case 1:e.xrefPath=n.value;break;case 2:e.name=n.value;break;case 3:e.name2=n.value;break;case 5:e.handle=n.value;break;case 8:e.layer=n.value;break;case 10:e.position=D(t);break;case 67:e.paperSpace=!!n.value&&n.value==1;break;case 70:n.value!==0&&(e.type=n.value);break;case 100:break;case 330:e.ownerHandle=n.value;break;case 0:e.entities=_r(n,t)}n=t.next()}return e}function ko(n,t){let e=null,s={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");)n.code===9?e=n.value:n.code===10?s[e]=D(t):s[e]=n.value,n=t.next();return s}let Co=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:l},{code:90,name:"version",parser:l},{code:1,name:"fileName",parser:l},{code:10,name:"size",parser:A},{code:11,name:"sizeOfOnePixel",parser:A},{code:280,name:"isLoaded",parser:l},{code:281,name:"resolutionUnits",parser:l},{code:100,name:"subclassMarker",parser:l}],fr=[{code:333,name:"shadePlotId",parser:l},{code:149,name:"imageOriginY",parser:l},{code:148,name:"imageOriginX",parser:l},{code:147,name:"scaleFactor",parser:l},{code:78,name:"shadePlotCustomDPI",parser:l},{code:77,name:"shadePlotResolution",parser:l},{code:76,name:"shadePlotMode",parser:l},{code:75,name:"standardScaleType",parser:l},{code:7,name:"currentStyleSheet",parser:l},{code:74,name:"plotType",parser:l},{code:73,name:"plotRotation",parser:l},{code:72,name:"paperUnit",parser:l},{code:70,name:"layoutFlag",parser:l},{code:143,name:"printScaleDenominator",parser:l},{code:142,name:"printScaleNominator",parser:l},{code:141,name:"windowAreaYMax",parser:l},{code:140,name:"windowAreaYMin",parser:l},{code:49,name:"windowAreaXMax",parser:l},{code:48,name:"windowAreaXMin",parser:l},{code:47,name:"plotOriginY",parser:l},{code:46,name:"plotOriginX",parser:l},{code:45,name:"paperHeight",parser:l},{code:44,name:"paperWidth",parser:l},{code:43,name:"marginTop",parser:l},{code:42,name:"marginRight",parser:l},{code:41,name:"marginBottom",parser:l},{code:40,name:"marginLeft",parser:l},{code:6,name:"plotViewName",parser:l},{code:4,name:"paperSize",parser:l},{code:2,name:"configName",parser:l},{code:1,name:"pageSetupName",parser:l},{code:100,name:"subclassMarker",parser:l}],Oo=[{code:333,name:"shadePlotId",parser:l},{code:346,name:"orthographicUcsId",parser:l},{code:345,name:"namedUcsId",parser:l},{code:331,name:"viewportId",parser:l},{code:330,name:"paperSpaceTableId",parser:l},{code:76,name:"orthographicType",parser:l},{code:17,name:"ucsYAxis",parser:A},{code:16,name:"ucsXAxis",parser:A},{code:13,name:"ucsOrigin",parser:A},{code:146,name:"elevation",parser:l},{code:15,name:"maxExtent",parser:A},{code:14,name:"minExtent",parser:A},{code:12,name:"insertionBase",parser:A},{code:11,name:"maxLimit",parser:A},{code:10,name:"minLimit",parser:A},{code:71,name:"tabOrder",parser:l},{code:70,name:"controlFlag",parser:l},{code:1,name:"layoutName",parser:l},{code:100,name:"subclassMarker",parser:l},...fr],No=[{code:330,name:"ownerObjectId",parser:l},{code:102},{code:360,name:"ownerDictionaryIdHard",parser:l},{code:102},{code:102},{code:330,name:"ownerDictionaryIdSoft",parser:l},{code:102},{code:102},{code:102},{code:5,name:"handle",parser:l}];function xr(n){return n.subclassMarker==="AcDbDictionary"}let Do={LAYOUT:Oo,PLOTSETTINGS:fr,DICTIONARY:[{code:3,name:"entries",parser:(n,t)=>{let e={name:n.value};return(n=t.next()).code===350?e.objectId=n.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:l},{code:280,name:"isHardOwned",parser:F},{code:100,name:"subclassMarker",parser:l}],IMAGEDEF:Co};function Ro(n,t){let e=[];for(;n.code!==0||!["EOF","ENDSEC"].includes(n.value);){let s=n.value,r=Do[s];if(n.code===0&&(r!=null&&r.length)){let i=v([...No,...r]),a={name:s};i(n=t.next(),t,a)?(e.push(a),n=t.peek()):n=t.next()}else n=t.next()}return{byName:oo(e,({name:s})=>s),byTree:function(s){let r=Object.fromEntries(s.map(i=>[i.handle,i]));for(let i of s)(!xr(i)||i.ownerDictionaryIdSoft!=="0")&&(i.ownerDictionaryIdSoft&&(i.ownerDictionarySoft=r[i.ownerDictionaryIdSoft]),i.ownerDictionaryIdHard&&(i.ownerDictionaryHard=r[i.ownerDictionaryIdHard]),i.ownerObjectId&&(i.ownerObject=r[i.ownerObjectId])),function(a,o){xr(a)&&a.entries&&(a.entries=Object.fromEntries(a.entries.map(({name:c,objectId:h})=>[c,o[h]])))}(i,r);return s[0]}(e)}}let re=[{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102,parser(n,t){for(;!k(n,0,"EOF")&&!k(n,102,"}");)n=t.next()}},{code:5,name:"handle",parser:l}],zo=v([{code:310,name:"bmpPreview",parser:l},{code:281,name:"scalability",parser:l},{code:280,name:"explodability",parser:l},{code:70,name:"insertionUnits",parser:l},{code:340,name:"layoutObjects",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),Fo=v([...[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:In.Above,defaultValueImperial:In.Center},{name:"DIMZIN",code:78,defaultValue:ne.Trailing,defaultValueImperial:ne.Feet},{name:"DIMAZIN",code:79,defaultValue:Pa.None},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:2,defaultValueImperial:4},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:",",defaultValueImperial:"."},{name:"DIMJUST",code:280,defaultValue:Ia.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Ea.Center},{name:"DIMTZIN",code:284,defaultValue:ne.Trailing,defaultValueImperial:ne.Feet},{name:"DIMALTZ",code:285,defaultValue:ne.Trailing},{name:"DIMALTTZ",code:286,defaultValue:ne.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}].map(n=>({...n,parser:l})),{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},{code:105,name:"handle",parser:l},...re.filter(n=>n.code!==5)]),Bo=v([{code:347,name:"materialObjectId",parser:l},{code:390,name:"plotStyleNameObjectId",parser:l},{code:370,name:"lineweight",parser:l},{code:290,name:"isPlotting",parser:F},{code:6,name:"lineType",parser:l},{code:62,name:"colorIndex",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),Vo=v([{code:9,name:"text",parser:l},{code:45,name:"offsetY",parser:l},{code:44,name:"offsetX",parser:l},{code:50,name:"rotation",parser:l},{code:46,name:"scale",parser:l},{code:340,name:"styleObjectId",parser:l},{code:75,name:"shapeNumber",parser:l},{code:74,name:"elementTypeFlag",parser:l},{code:49,name:"elementLength",parser:l}],{elementTypeFlag:0,elementLength:0}),jo={BLOCK_RECORD:zo,DIMSTYLE:Fo,LAYER:Bo,LTYPE:v([{code:49,name:"pattern",parser(n,t){let e={};return Vo(n,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:l},{code:73,name:"numberOfLineTypes",parser:l},{code:72,parser:l},{code:3,name:"description",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),STYLE:v([{code:1e3,name:"extendedFont",parser:l},{code:1001},{code:4,name:"bigFont",parser:l},{code:3,name:"font",parser:l},{code:42,name:"lastHeight",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:50,name:"obliqueAngle",parser:l},{code:41,name:"widthFactor",parser:l},{code:40,name:"fixedTextHeight",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),VPORT:v([{code:[63,421,431],name:"ambientColor",parser:l},{code:142,name:"contrast",parser:l},{code:141,name:"brightness",parser:l},{code:282,name:"defaultLightingType",parser:l},{code:292,name:"isDefaultLightingOn",parser:F},{code:348,name:"visualStyleObjectId",parser:l},{code:333,name:"shadePlotObjectId",parser:l},{code:332,name:"backgroundObjectId",parser:l},{code:61,name:"majorGridLines",parser:l},{code:170,name:"shadePlotSetting",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:112,name:"ucsYAxis",parser:A},{code:111,name:"ucsXAxis",parser:A},{code:110,name:"ucsOrigin",parser:A},{code:74,name:"ucsIconSetting",parser:l},{code:71,name:"viewMode",parser:l},{code:281,name:"renderMode",parser:l},{code:1,name:"styleSheet",parser:l},{code:[331,441],name:"frozenLayers",parser:l,isMultiple:!0},{code:72,name:"circleSides",parser:l},{code:51,name:"viewTwistAngle",parser:l},{code:50,name:"snapRotationAngle",parser:l},{code:45,name:"viewHeight",parser:l},{code:44,name:"backClippingPlane",parser:l},{code:43,name:"frontClippingPlane",parser:l},{code:42,name:"lensLength",parser:l},{code:17,name:"viewTarget",parser:A},{code:16,name:"viewDirectionFromTarget",parser:A},{code:15,name:"gridSpacing",parser:A},{code:14,name:"snapSpacing",parser:A},{code:13,name:"snapBasePoint",parser:A},{code:12,name:"center",parser:A},{code:11,name:"upperRightCorner",parser:A},{code:10,name:"lowerLeftCorner",parser:A},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re])},Go=v([{code:70,name:"maxNumberOfEntries",parser:l},{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:l},{code:2,name:"name",parser:l}]);function Ho(n,t){var s;let e={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");){if(k(n,0,"TABLE")){n=t.next();let r={entries:[]};Go(n,t,r),e[r.name]=r}if(k(n,0)&&!k(n,0,"ENDTAB")){let r=n.value;n=t.next();let i=jo[r];if(!i){console.warn(`parseTable: Invalid table name '${r}'`),n=t.next();continue}let a={};i(n,t,a),(s=e[r])==null||s.entries.push(a)}n=t.next()}return e}function Ye(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}class br{next(){if(!this.hasNext())return this._eof?console.warn("Cannot call 'next' after EOF group has been read"):console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=wr(t,this._data[this._pointer++]),s={code:t,value:e};return k(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=wr(t.code,this._data[this._pointer+1]),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t){Ye(this,"_pointer",void 0),Ye(this,"_data",void 0),Ye(this,"_eof",void 0),Ye(this,"lastReadGroup",{code:0,value:0}),this._pointer=0,this._data=t,this._eof=!1}}function wr(n,t){return n<=9?t:n>=10&&n<=59?parseFloat(t.trim()):n>=60&&n<=99?parseInt(t.trim()):n>=100&&n<=109?t:n>=110&&n<=149?parseFloat(t.trim()):n>=160&&n<=179?parseInt(t.trim()):n>=210&&n<=239?parseFloat(t.trim()):n>=270&&n<=289?parseInt(t.trim()):n>=290&&n<=299?function(e){if(e==="0")return!1;if(e==="1")return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}(t.trim()):n>=300&&n<=369?t:n>=370&&n<=389?parseInt(t.trim()):n>=390&&n<=399?t:n>=400&&n<=409?parseInt(t.trim()):n>=410&&n<=419?t:n>=420&&n<=429?parseInt(t.trim()):n>=430&&n<=439?t:n>=440&&n<=459?parseInt(t.trim()):n>=460&&n<=469?parseFloat(t.trim()):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?t:n>=1010&&n<=1059?parseFloat(t.trim()):n>=1060&&n<=1071?parseInt(t.trim()):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:t}),t)}function Os(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Uo=class{constructor(){Os(this,"encoding","utf-8"),Os(this,"encodingFailureFatal",!1)}};class Wo extends EventTarget{parseSync(t){let e=new br(t.split(/\r\n|\r|\n/g));if(!e.hasNext())throw Error("Empty file");return this.parseAll(e)}parseStream(t){let e="",s=this;return new Promise((r,i)=>{t.on("data",a=>{e+=a}),t.on("end",()=>{try{let a=e.split(/\r\n|\r|\n/g),o=new br(a);if(!o.hasNext())throw Error("Empty file");r(s.parseAll(o))}catch(a){i(a)}}),t.on("error",a=>{i(a)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let r=s.body.getReader(),i="";for(;;){let{done:a,value:o}=await r.read();if(a){i+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}i+=this._decoder.decode(o,{stream:!0})}return this.parseSync(i)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!k(s,0,"EOF");)k(s,0,"SECTION")&&(k(s=t.next(),2,"HEADER")?(s=t.next(),e.header=ko(s,t)):k(s,2,"BLOCKS")?(s=t.next(),e.blocks=vo(s,t)):k(s,2,"ENTITIES")?(s=t.next(),e.entities=_r(s,t)):k(s,2,"TABLES")?(s=t.next(),e.tables=Ho(s,t)):k(s,2,"OBJECTS")&&(s=t.next(),e.objects=Ro(s,t))),s=t.next();return e}constructor(t=new Uo){super(),Os(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}var Ns=(n=>(n[n.DecimalDegrees=0]="DecimalDegrees",n[n.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",n[n.Gradians=2]="Gradians",n[n.Radians=3]="Radians",n[n.SurveyorsUnits=4]="SurveyorsUnits",n))(Ns||{});class kt{static get instance(){return this._instance||(this._instance=new kt),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,r=!0,i,a){const o=[];if(e!=null){const c=this.createKey(e.name,s);let h;if(this.has(c))h=this.get(c);else{const d=e.newIterator();for(const u of d)if(u.color.isByBlock&&s){Ar.copy(u.color),u.color.color=s;const m=u.draw(t);m&&o.push(m),u.color.copy(Ar)}else{const m=u.draw(t);m&&o.push(m)}h=t.group(o),h&&r&&this.set(c,h)}return h&&i&&(h.applyMatrix(i),a&&(a.x!=0||a.y!=0||a.z!=1)&&(i.setFromExtrusionDirection(a),h.applyMatrix(i))),h}else return t.group(o)}}const Ar=new zt,qe="Continuous",Xe="ByLayer",Pr="ByBlock";var Ut=(n=>(n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(Ut||{}),Ds=(n=>(n[n.Undefined=0]="Undefined",n[n.Inches=1]="Inches",n[n.Feet=2]="Feet",n[n.Miles=3]="Miles",n[n.Millimeters=4]="Millimeters",n[n.Centimeters=5]="Centimeters",n[n.Meters=6]="Meters",n[n.Kilometers=7]="Kilometers",n[n.Microinches=8]="Microinches",n[n.Mils=9]="Mils",n[n.Yards=10]="Yards",n[n.Angstroms=11]="Angstroms",n[n.Nanometers=12]="Nanometers",n[n.Microns=13]="Microns",n[n.Decimeters=14]="Decimeters",n[n.Dekameters=15]="Dekameters",n[n.Hectometers=16]="Hectometers",n[n.Gigameters=17]="Gigameters",n[n.Astronomical=18]="Astronomical",n[n.LightYears=19]="LightYears",n[n.Parsecs=20]="Parsecs",n[n.USSurveyFeet=21]="USSurveyFeet",n[n.USSurveyInch=22]="USSurveyInch",n[n.USSurveyYard=23]="USSurveyYard",n[n.USSurveyMile=24]="USSurveyMile",n[n.Max=24]="Max",n))(Ds||{});function Yo(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function qo(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}var Ir=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(Ir||{});class $e{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const Er="Load Database";class tt extends xn{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=xs.getInstance().getEntry(Er),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const r=await this.data.task(t);if(this.progress){const i=r.data;await this.progress(this.data.progress.value,this.data.stage,"END",i),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)}return e&&(e.data[this.name]=Date.now()-s),r}}class Tr{async read(t,e,s,r){const i={name:Er,data:{total:0},format(){let h="";return Object.keys(this.data).forEach(d=>{d!=="total"&&(h+=`- ${d}: ${this.data[d]} ms
2
- `)}),h+=`- total: ${this.data.total} ms`,h}};xs.getInstance().collect(i),this.progress=r;const a={value:0},o=new bn;o.setCompleteCallback(()=>this.onFinished()),o.setErrorCallback(()=>this.onFinished()),o.addTask(new tt({stage:"START",step:1,progress:a,task:async h=>h},r)),o.addTask(new tt({stage:"PARSE",step:5,progress:a,task:async h=>({model:await this.parse(h)})},r)),o.addTask(new tt({stage:"FONT",step:5,progress:a,task:async h=>{const d=this.getFonts(h.model);return{model:h.model,data:d}}},r)),o.addTask(new tt({stage:"LTYPE",step:1,progress:a,task:async h=>(this.processLineTypes(h.model,e),h)},r)),o.addTask(new tt({stage:"STYLE",step:1,progress:a,task:async h=>(this.processTextStyles(h.model,e),h)},r)),o.addTask(new tt({stage:"DIMSTYLE",step:1,progress:a,task:async h=>(this.processDimStyles(h.model,e),h)},r)),o.addTask(new tt({stage:"LAYER",step:1,progress:a,task:async h=>(this.processLayers(h.model,e),h)},r)),o.addTask(new tt({stage:"VPORT",step:1,progress:a,task:async h=>(this.processViewports(h.model,e),h)},r)),o.addTask(new tt({stage:"HEADER",step:1,progress:a,task:async h=>(this.processHeader(h.model,e),h)},r)),o.addTask(new tt({stage:"BLOCK_RECORD",step:5,progress:a,task:async h=>(this.processBlockTables(h.model,e),h)},r)),o.addTask(new tt({stage:"OBJECT",step:5,progress:a,task:async h=>(this.processObjects(h.model,e),h)},r)),o.addTask(new tt({stage:"BLOCK",step:5,progress:a,task:async h=>(await this.processBlocks(h.model,e),h)},r)),o.addTask(new tt({stage:"ENTITY",step:100,progress:a,task:async h=>(await this.processEntities(h.model,e,s,a,r),h)},r)),o.addTask(new tt({stage:"END",step:0,progress:a,task:async h=>h},r));const c=Date.now();await o.run(t),i.data.total=Date.now()-c}onFinished(){this.progress&&(this.progress(100,"END","END"),kt.instance.clear())}parse(t){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,r,i){throw new Error("Not impelemented yet!")}}const $=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Sr=1234567;const Rs=Math.PI/180,zs=180/Math.PI;function Mr(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return($[n&255]+$[n>>8&255]+$[n>>16&255]+$[n>>24&255]+"-"+$[t&255]+$[t>>8&255]+"-"+$[t>>16&15|64]+$[t>>24&255]+"-"+$[e&63|128]+$[e>>8&255]+"-"+$[e>>16&255]+$[e>>24&255]+$[s&255]+$[s>>8&255]+$[s>>16&255]+$[s>>24&255]).toLowerCase()}function Tt(n,t,e){return Math.max(t,Math.min(e,n))}function Fs(n,t){return(n%t+t)%t}function vr(n,t,e,s,r){return s+(n-t)*(r-s)/(e-t)}function Lr(n,t,e){return n!==t?(e-n)/(t-n):0}function Bs(n,t,e){return(1-e)*n+e*t}function kr(n,t,e,s){return Bs(n,t,1-Math.exp(-e*s))}function Cr(n,t=1){return t-Math.abs(Fs(n,t*2)-t)}function Or(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function Nr(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function Dr(n,t){return n+Math.floor(Math.random()*(t-n+1))}function Rr(n,t){return n+Math.random()*(t-n)}function zr(n){return n*(.5-Math.random())}function Fr(n){n!==void 0&&(Sr=n);let t=Sr+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Br(n){return n*Rs}function Vr(n){return n*zs}function jr(n){return(n&n-1)===0&&n!==0}function Gr(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Hr(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Me(n){const t=Math.PI*2;return(n%t+t)%t}function Ur(n,t,e){return n>t&&n<e||n>e&&n<t}function Wr(n,t,e,s=!1){return n=Me(n),t=Me(t),e=Me(e),s?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function Vs(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function Yr(n,t=1e-7){const e=Vs(n);return Math.max(Math.pow(10,e)*t,t)}const C={DEG2RAD:Rs,RAD2DEG:zs,generateUUID:Mr,clamp:Tt,euclideanModulo:Fs,mapLinear:vr,inverseLerp:Lr,lerp:Bs,damp:kr,pingpong:Cr,smoothstep:Or,smootherstep:Nr,randInt:Dr,randFloat:Rr,randFloatSpread:zr,seededRandom:Fr,degToRad:Br,radToDeg:Vr,isPowerOfTwo:jr,ceilPowerOfTwo:Gr,floorPowerOfTwo:Hr,normalizeAngle:Me,isBetween:Ur,isBetweenAngle:Wr,intPartLength:Vs,relativeEps:Yr},js=class ca{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:r,y:i}=t;this.x=r,this.y=i;return}if(s===2){this.x=t,this.y=e;return}throw et.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new ca(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6],this.y=r[1]*e+r[4]*s+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*s-a*r+t.x,this.y=i*r+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(C.relativeEps(this.x,t),C.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};js.EMPTY=Object.freeze(new js(0,0));let B=js;const Gs=class da{constructor(t,e,s,r,i,a,o,c,h){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&r!=null&&i!=null&&a!=null&&o!=null&&c!=null&&h!=null&&this.set(t,e,s,r,i,a,o,c,h)}set(t,e,s,r,i,a,o,c,h){const d=this.elements;return d[0]=t,d[1]=r,d[2]=o,d[3]=e,d[4]=i,d[5]=c,d[6]=s,d[7]=a,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,i=this.elements,a=s[0],o=s[3],c=s[6],h=s[1],d=s[4],u=s[7],m=s[2],p=s[5],y=s[8],_=r[0],x=r[3],f=r[6],M=r[1],T=r[4],S=r[7],P=r[2],z=r[5],I=r[8];return i[0]=a*_+o*M+c*P,i[3]=a*x+o*T+c*z,i[6]=a*f+o*S+c*I,i[1]=h*_+d*M+u*P,i[4]=h*x+d*T+u*z,i[7]=h*f+d*S+u*I,i[2]=m*_+p*M+y*P,i[5]=m*x+p*T+y*z,i[8]=m*f+p*S+y*I,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],h=t[7],d=t[8];return e*a*d-e*o*h-s*i*d+s*o*c+r*i*h-r*a*c}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],h=t[7],d=t[8],u=d*a-o*h,m=o*c-d*i,p=h*i-a*c,y=e*u+s*m+r*p;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return t[0]=u*_,t[1]=(r*h-d*s)*_,t[2]=(o*s-r*a)*_,t[3]=m*_,t[4]=(d*e-r*c)*_,t[5]=(r*i-o*e)*_,t[6]=p*_,t[7]=(s*c-h*e)*_,t[8]=(a*e-s*i)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,r,i,a,o){const c=Math.cos(i),h=Math.sin(i);return this.set(s*c,s*h,-s*(c*a+h*o)+a+t,-r*h,r*c,-r*(-h*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Hs.makeScale(t,e)),this}rotate(t){return this.premultiply(Hs.makeRotation(-t)),this}translate(t,e){return this.premultiply(Hs.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof B?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let r=0;r<9;r++)if(e[r]!==s[r])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new da().fromArray(this.elements)}};Gs.IDENTITY=Object.freeze(new Gs);let Ke=Gs;const Hs=new Ke,Wt=1e-6,H=2*Math.PI,Xo={x:0,y:0},Us={x:0,y:0,z:0};class Ws{constructor(){this.equalPointTol=Wt,this.equalVectorTol=Wt}equalPoint2d(t,e){return new B(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new w(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=Wt){return t<e&&t>-e}static equal(t,e,s=Wt){return Math.abs(t-e)<s}static great(t,e,s=Wt){return t-e>s}static less(t,e,s=Wt){return t-e<s}}const Ys=new Ws;function qs(n,t,e=!1){const s=n.x,r=n.y;let i=!1;const a=t.length;for(let o=0,c=a-1;o<a;c=o++){const h=t[o].x,d=t[o].y,u=t[c].x,m=t[c].y;let p=d>r!=m>r;e&&(p=d>=r!=m>=r),p&&s<(u-h)*(r-d)/(m-d)+h&&(i=!i)}return i}function qr(n,t){if(n.length===0||t.length===0)return!1;const e=new K().setFromPoints(n),s=new K().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let r=0;r<n.length;){if(qs(n[r],t,!0))return!0;r<n.length-1&&Ys.equalPoint2d(n[r+1],n[r])&&++r,++r}return!1}const Xr={isPointInPolygon:qs,isPolygonIntersect:qr};function $r(n,t){const e=[],s=t-1,r=n;for(let i=0;i<=r;i++)e.push(0);for(let i=1;i<=s-r;i++)e.push(i);for(let i=0;i<=r;i++)e.push(s-r+1);return e}function Kr(n,t){const e=t.length-1,s=n,r=[0];let i=0;for(let o=1;o<=e;o++){const c=t[o][0]-t[o-1][0],h=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(c*c+h*h+d*d);i+=u,r.push(i)}const a=[];for(let o=0;o<=s;o++)a.push(0);for(let o=1;o<=e-s;o++){const c=r[o]/i;a.push(c*(e-s+1))}for(let o=0;o<=s;o++)a.push(e-s+1);return a}function Zr(n,t){const e=t.length-1,s=n,r=[0];let i=0;for(let o=1;o<=e;o++){const c=t[o][0]-t[o-1][0],h=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(c*c+h*h+d*d),m=Math.sqrt(u);i+=m,r.push(i)}const a=[];for(let o=0;o<=s;o++)a.push(0);for(let o=1;o<=e-s;o++){const c=r[o]/i;a.push(c*(e-s+1))}for(let o=0;o<=s;o++)a.push(e-s+1);return a}function Ze(n,t,e,s){if(t===0)return e>=s[n]&&e<s[n+1]?1:0;const r=s[n+t]-s[n],i=s[n+t+1]-s[n+1],a=r>1e-10?(e-s[n])/r:0,o=i>1e-10?(s[n+t+1]-e)/i:0;return a*Ze(n,t-1,e,s)+o*Ze(n+1,t-1,e,s)}function ve(n,t,e,s,r){const i=s.length-1,a=t;if(n=Math.max(e[a],Math.min(e[i+1],n)),Math.abs(n-e[i+1])<1e-8)return[...s[i]];if(Math.abs(n-e[a])<1e-8)return[...s[0]];const o=[0,0,0];let c=0;for(let h=0;h<=i;h++){const d=Ze(h,a,n,e),u=r[h]*d;o[0]+=s[h][0]*u,o[1]+=s[h][1]*u,o[2]+=s[h][2]*u,c+=u}if(c<1e-10){const h=e[e.length-a-1];if(Math.abs(n-h)<1e-8)return[...s[i]];if(Math.abs(n-e[a])<1e-8)return[...s[0]]}return c>1e-10&&(o[0]/=c,o[1]/=c,o[2]/=c),o}function Qr(n,t,e,s){const r=n,i=t[r],a=t[t.length-r-1];let o=0;const c=1e3,h=(a-i)/c;let d=ve(i,n,t,e,s);for(let _=1;_<=c;_++){const x=i+_*h,f=ve(x,n,t,e,s),M=f[0]-d[0],T=f[1]-d[1],S=f[2]-d[2];o+=Math.sqrt(M*M+T*T+S*S),d=f}const u=ve(a,n,t,e,s),m=u[0]-d[0],p=u[1]-d[1],y=u[2]-d[2];return o+=Math.sqrt(m*m+p*p+y*y),o}function $o(n){return n.map(t=>[...t])}class Ct{constructor(t=0,e=0,s=0,r=1){this._x=t,this._y=e,this._z=s,this._w=r}static slerpFlat(t,e,s,r,i,a,o){let c=s[r+0],h=s[r+1],d=s[r+2],u=s[r+3];const m=i[a+0],p=i[a+1],y=i[a+2],_=i[a+3];if(o===0){t[e+0]=c,t[e+1]=h,t[e+2]=d,t[e+3]=u;return}if(o===1){t[e+0]=m,t[e+1]=p,t[e+2]=y,t[e+3]=_;return}if(u!==_||c!==m||h!==p||d!==y){let x=1-o;const f=c*m+h*p+d*y+u*_,M=f>=0?1:-1,T=1-f*f;if(T>Number.EPSILON){const P=Math.sqrt(T),z=Math.atan2(P,f*M);x=Math.sin(x*z)/P,o=Math.sin(o*z)/P}const S=o*M;if(c=c*x+m*S,h=h*x+p*S,d=d*x+y*S,u=u*x+_*S,x===1-o){const P=1/Math.sqrt(c*c+h*h+d*d+u*u);c*=P,h*=P,d*=P,u*=P}}t[e]=c,t[e+1]=h,t[e+2]=d,t[e+3]=u}static multiplyQuaternionsFlat(t,e,s,r,i,a){const o=s[r],c=s[r+1],h=s[r+2],d=s[r+3],u=i[a],m=i[a+1],p=i[a+2],y=i[a+3];return t[e]=o*y+d*u+c*p-h*m,t[e+1]=c*y+d*m+h*u-o*p,t[e+2]=h*y+d*p+o*m-c*u,t[e+3]=d*y-o*u-c*m-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,r){return this._x=t,this._y=e,this._z=s,this._w=r,this._onChangeCallback(),this}clone(){return new Ct(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t.x,r=t.y,i=t.z,a=t.order,o=Math.cos,c=Math.sin,h=o(s/2),d=o(r/2),u=o(i/2),m=c(s/2),p=c(r/2),y=c(i/2);switch(a){case"XYZ":this._x=m*d*u+h*p*y,this._y=h*p*u-m*d*y,this._z=h*d*y+m*p*u,this._w=h*d*u-m*p*y;break;case"YXZ":this._x=m*d*u+h*p*y,this._y=h*p*u-m*d*y,this._z=h*d*y-m*p*u,this._w=h*d*u+m*p*y;break;case"ZXY":this._x=m*d*u-h*p*y,this._y=h*p*u+m*d*y,this._z=h*d*y+m*p*u,this._w=h*d*u-m*p*y;break;case"ZYX":this._x=m*d*u-h*p*y,this._y=h*p*u+m*d*y,this._z=h*d*y-m*p*u,this._w=h*d*u+m*p*y;break;case"YZX":this._x=m*d*u+h*p*y,this._y=h*p*u+m*d*y,this._z=h*d*y-m*p*u,this._w=h*d*u-m*p*y;break;case"XZY":this._x=m*d*u-h*p*y,this._y=h*p*u-m*d*y,this._z=h*d*y+m*p*u,this._w=h*d*u+m*p*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,r=Math.sin(s);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],r=e[4],i=e[8],a=e[1],o=e[5],c=e[9],h=e[2],d=e[6],u=e[10],m=s+o+u;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(i-h)*p,this._z=(a-r)*p}else if(s>o&&s>u){const p=2*Math.sqrt(1+s-o-u);this._w=(d-c)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(i+h)/p}else if(o>u){const p=2*Math.sqrt(1+o-s-u);this._w=(i-h)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+u-s-o);this._w=(a-r)/p,this._x=(i+h)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Tt(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const r=Math.min(1,e/s);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,r=t._y,i=t._z,a=t._w,o=e._x,c=e._y,h=e._z,d=e._w;return this._x=s*d+a*o+r*h-i*c,this._y=r*d+a*c+i*o-s*h,this._z=i*d+a*h+s*c-r*o,this._w=a*d-s*o-r*c-i*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,r=this._y,i=this._z,a=this._w;let o=a*t._w+s*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=s,this._y=r,this._z=i,this;const c=1-o*o;if(c<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*s+e*this._x,this._y=p*r+e*this._y,this._z=p*i+e*this._z,this.normalize(),this}const h=Math.sqrt(c),d=Math.atan2(h,o),u=Math.sin((1-e)*d)/h,m=Math.sin(e*d)/h;return this._w=a*u+this._w*m,this._x=s*u+this._x*m,this._y=r*u+this._y*m,this._z=i*u+this._z*m,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),r=Math.sqrt(1-s),i=Math.sqrt(s);return this.set(r*Math.sin(t),r*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const at=class ua{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const r=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0);if(r!==0){if(r===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(r===1){const{x:i,y:a,z:o}=t;this.x=i,this.y=a,this.z=o||0;return}if(r===3){this.x=t,this.y=e,this.z=s;return}throw et.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new ua(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Jr.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Jr.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6]*r,this.y=i[1]*e+i[4]*s+i[7]*r,this.z=i[2]*e+i[5]*s+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix3d(t){const e=this.x,s=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*s+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*s+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*s+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*s+i[10]*r+i[14])*a,this}applyQuaternion(t){const e=this.x,s=this.y,r=this.z,i=t.x,a=t.y,o=t.z,c=t.w,h=2*(a*r-o*s),d=2*(o*e-i*r),u=2*(i*s-a*e);return this.x=e+c*h+a*u-o*d,this.y=s+c*d+o*h-i*u,this.z=r+c*u+i*d-a*h,this}transformDirection(t){const e=this.x,s=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*s+i[8]*r,this.y=i[1]*e+i[5]*s+i[9]*r,this.z=i[2]*e+i[6]*s+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),s=this.length(),r=t.length();return Math.abs(e)===s*r}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,r=t.y,i=t.z,a=e.x,o=e.y,c=e.z;return this.x=r*c-i*o,this.y=i*a-s*c,this.z=s*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Xs.copy(this).projectOnVector(t),this.sub(Xs)}reflect(t){return this.sub(Xs.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,r=this.z-t.z;return e*e+s*s+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};at.X_AXIS=Object.freeze(new at(1,0,0)),at.NEGATIVE_X_AXIS=Object.freeze(new at(-1,0,0)),at.Y_AXIS=Object.freeze(new at(0,1,0)),at.NEGATIVE_Y_AXIS=Object.freeze(new at(0,-1,0)),at.Z_AXIS=Object.freeze(new at(0,0,1)),at.NEGATIVE_Z_AXIS=Object.freeze(new at(0,0,-1));let w=at;const Xs=new w,Jr=new Ct,$s=class ma{constructor(t,e,s,r,i,a,o,c,h,d,u,m,p,y,_,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&r!=null&&i!=null&&a!=null&&o!=null&&c!=null&&h!=null&&d!=null&&u!=null&&m!=null&&p!=null&&y!=null&&_!=null&&x!=null&&this.set(t,e,s,r,i,a,o,c,h,d,u,m,p,y,_,x)}set(t,e,s,r,i,a,o,c,h,d,u,m,p,y,_,x){const f=this.elements;return f[0]=t,f[4]=e,f[8]=s,f[12]=r,f[1]=i,f[5]=a,f[9]=o,f[13]=c,f[2]=h,f[6]=d,f[10]=u,f[14]=m,f[3]=p,f[7]=y,f[11]=_,f[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ma().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(Ys.equalPoint3d(t,w.Z_AXIS))this.identity();else{const e=new w(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(w.Y_AXIS,t).normalize():e.crossVectors(w.Z_AXIS,t).normalize();const s=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,s.x,s.y,s.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,r=1/ie.setFromMatrixColumn(t,0).length(),i=1/ie.setFromMatrixColumn(t,1).length(),a=1/ie.setFromMatrixColumn(t,2).length();return e[0]=s[0]*r,e[1]=s[1]*r,e[2]=s[2]*r,e[3]=0,e[4]=s[4]*i,e[5]=s[5]*i,e[6]=s[6]*i,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ko,t,Zo)}lookAt(t,e,s){const r=this.elements;return ot.subVectors(t,e),ot.lengthSq()===0&&(ot.z=1),ot.normalize(),Ot.crossVectors(s,ot),Ot.lengthSq()===0&&(Math.abs(s.z)===1?ot.x+=1e-4:ot.z+=1e-4,ot.normalize(),Ot.crossVectors(s,ot)),Ot.normalize(),Qe.crossVectors(ot,Ot),r[0]=Ot.x,r[4]=Qe.x,r[8]=ot.x,r[1]=Ot.y,r[5]=Qe.y,r[9]=ot.y,r[2]=Ot.z,r[6]=Qe.z,r[10]=ot.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,i=this.elements,a=s[0],o=s[4],c=s[8],h=s[12],d=s[1],u=s[5],m=s[9],p=s[13],y=s[2],_=s[6],x=s[10],f=s[14],M=s[3],T=s[7],S=s[11],P=s[15],z=r[0],I=r[4],W=r[8],lt=r[12],vt=r[1],N=r[5],V=r[9],Jt=r[13],te=r[2],ds=r[6],us=r[10],ms=r[14],gs=r[3],ps=r[7],ys=r[11],_s=r[15];return i[0]=a*z+o*vt+c*te+h*gs,i[4]=a*I+o*N+c*ds+h*ps,i[8]=a*W+o*V+c*us+h*ys,i[12]=a*lt+o*Jt+c*ms+h*_s,i[1]=d*z+u*vt+m*te+p*gs,i[5]=d*I+u*N+m*ds+p*ps,i[9]=d*W+u*V+m*us+p*ys,i[13]=d*lt+u*Jt+m*ms+p*_s,i[2]=y*z+_*vt+x*te+f*gs,i[6]=y*I+_*N+x*ds+f*ps,i[10]=y*W+_*V+x*us+f*ys,i[14]=y*lt+_*Jt+x*ms+f*_s,i[3]=M*z+T*vt+S*te+P*gs,i[7]=M*I+T*N+S*ds+P*ps,i[11]=M*W+T*V+S*us+P*ys,i[15]=M*lt+T*Jt+S*ms+P*_s,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],r=t[8],i=t[12],a=t[1],o=t[5],c=t[9],h=t[13],d=t[2],u=t[6],m=t[10],p=t[14],y=t[3],_=t[7],x=t[11],f=t[15];return y*(+i*c*u-r*h*u-i*o*m+s*h*m+r*o*p-s*c*p)+_*(+e*c*p-e*h*m+i*a*m-r*a*p+r*h*d-i*c*d)+x*(+e*h*u-e*o*p-i*a*u+s*a*p+i*o*d-s*h*d)+f*(-r*o*d-e*c*u+e*o*m+r*a*u-s*a*m+s*c*d)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const r=this.elements;return t instanceof w?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],h=t[7],d=t[8],u=t[9],m=t[10],p=t[11],y=t[12],_=t[13],x=t[14],f=t[15],M=u*x*h-_*m*h+_*c*p-o*x*p-u*c*f+o*m*f,T=y*m*h-d*x*h-y*c*p+a*x*p+d*c*f-a*m*f,S=d*_*h-y*u*h+y*o*p-a*_*p-d*o*f+a*u*f,P=y*u*c-d*_*c-y*o*m+a*_*m+d*o*x-a*u*x,z=e*M+s*T+r*S+i*P;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/z;return t[0]=M*I,t[1]=(_*m*i-u*x*i-_*r*p+s*x*p+u*r*f-s*m*f)*I,t[2]=(o*x*i-_*c*i+_*r*h-s*x*h-o*r*f+s*c*f)*I,t[3]=(u*c*i-o*m*i-u*r*h+s*m*h+o*r*p-s*c*p)*I,t[4]=T*I,t[5]=(d*x*i-y*m*i+y*r*p-e*x*p-d*r*f+e*m*f)*I,t[6]=(y*c*i-a*x*i-y*r*h+e*x*h+a*r*f-e*c*f)*I,t[7]=(a*m*i-d*c*i+d*r*h-e*m*h-a*r*p+e*c*p)*I,t[8]=S*I,t[9]=(y*u*i-d*_*i-y*s*p+e*_*p+d*s*f-e*u*f)*I,t[10]=(a*_*i-y*o*i+y*s*h-e*_*h-a*s*f+e*o*f)*I,t[11]=(d*o*i-a*u*i-d*s*h+e*u*h+a*s*p-e*o*p)*I,t[12]=P*I,t[13]=(d*_*r-y*u*r+y*s*m-e*_*m-d*s*x+e*u*x)*I,t[14]=(y*o*r-a*_*r-y*s*c+e*_*c+a*s*x-e*o*x)*I,t[15]=(a*u*r-d*o*r+d*s*c-e*u*c-a*s*m+e*o*m)*I,this}scale(t){const e=this.elements,s=t.x,r=t.y,i=t.z;return e[0]*=s,e[4]*=r,e[8]*=i,e[1]*=s,e[5]*=r,e[9]*=i,e[2]*=s,e[6]*=r,e[10]*=i,e[3]*=s,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,r))}makeTranslation(t,e,s){return t instanceof w?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),r=Math.sin(e),i=1-s,a=t.x,o=t.y,c=t.z,h=i*a,d=i*o;return this.set(h*a+s,h*o-r*c,h*c+r*o,0,h*o+r*c,d*o+s,d*c-r*a,0,h*c-r*o,d*c+r*a,i*c*c+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,r,i,a){return this.set(1,s,i,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,s){const r=this.elements,i=e.x,a=e.y,o=e.z,c=e.w,h=i+i,d=a+a,u=o+o,m=i*h,p=i*d,y=i*u,_=a*d,x=a*u,f=o*u,M=c*h,T=c*d,S=c*u,P=s.x,z=s.y,I=s.z;return r[0]=(1-(_+f))*P,r[1]=(p+S)*P,r[2]=(y-T)*P,r[3]=0,r[4]=(p-S)*z,r[5]=(1-(m+f))*z,r[6]=(x+M)*z,r[7]=0,r[8]=(y+T)*I,r[9]=(x-M)*I,r[10]=(1-(m+_))*I,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,s){const r=this.elements;let i=ie.set(r[0],r[1],r[2]).length();const a=ie.set(r[4],r[5],r[6]).length(),o=ie.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],ut.copy(this);const c=1/i,h=1/a,d=1/o;return ut.elements[0]*=c,ut.elements[1]*=c,ut.elements[2]*=c,ut.elements[4]*=h,ut.elements[5]*=h,ut.elements[6]*=h,ut.elements[8]*=d,ut.elements[9]*=d,ut.elements[10]*=d,e.setFromRotationMatrix(ut),s.x=i,s.y=a,s.z=o,this}equals(t){const e=this.elements,s=t.elements;for(let r=0;r<16;r++)if(e[r]!==s[r])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};$s.IDENTITY=Object.freeze(new $s);let Yt=$s;const ie=new w,ut=new Yt,Ko=new w(0,0,0),Zo=new w(1,1,1),Ot=new w,Qe=new w,ot=new w;class O{constructor(t=void 0,e=void 0){this.min=t==null?new w(1/0,1/0,1/0):new w(t.x,t.y,t.z),this.max=e==null?new w(-1/0,-1/0,-1/0):new w(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Ks.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Ks.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new O().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ks).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(St[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(t),St[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(t),St[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(t),St[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(t),St[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(t),St[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(t),St[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(t),St[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(t),this.setFromPoints(St),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const St=[new w,new w,new w,new w,new w,new w,new w,new w],Ks=new w,ti=new B;class K{constructor(t=void 0,e=void 0){this.min=t==null?new B(1/0,1/0):new B(t.x,t.y),this.max=e==null?new B(-1/0,-1/0):new B(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=ti.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new K().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new B(0,0):new B(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new B(0,0):new B(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ti).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ei=new w,Qo=new w,Jo=new Ke;class Le{constructor(t=new w(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,r){return this.normal.set(t,e,s),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const r=ei.subVectors(s,e).cross(Qo.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||Jo.getNormalMatrix(t),r=this.coplanarPoint(ei).applyMatrix3d(t),i=this.normal.applyMatrix3(s).normalize();return this.constant=-r.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new Le().copy(this)}}class L extends B{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,r)=>{s.toArray(e,r*2)}),e}}class b extends w{static pointArrayToNumberArray(t,e=!0){const s=e?3:2,r=new Array(t.length*s);return t.forEach((i,a)=>{i.toArray(r,a*s)}),r}}const si=new Yt,ni=new Ct,ri=class un{constructor(t=0,e=0,s=0,r=un.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,r=this._order){return this._x=t,this._y=e,this._z=s,this._order=r,this._onChangeCallback(),this}clone(){return new un(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const r=t.elements,i=r[0],a=r[4],o=r[8],c=r[1],h=r[5],d=r[9],u=r[2],m=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(Tt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Tt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Tt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(c,i));break;case"ZYX":this._y=Math.asin(-Tt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,i)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(Tt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,h),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Tt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return si.makeRotationFromQuaternion(t),this.setFromRotationMatrix(si,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ni.setFromEuler(this),this.setFromQuaternion(ni,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ri.DEFAULT_ORDER="XYZ";let ii=ri;class ai{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Zs extends ai{translate(t){return this.transform(new Ke().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Je extends Zs{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new K}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const r=this.loops[s].getPoints(t);e.push(r)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),r=this.sortBoundaryBoxesByAreas(s),i=new Map,a=r.length;for(let c=0;c<a;c++)i.set(r[c],{index:r[c],children:[]});const o={index:-1,children:[]};for(let c=0;c<a;c++){const h=r[c],d=e[h],u=s[h];let m=c+1;for(;m<a;m++){const p=r[m],y=e[p];if(s[p].containsBox(u)&&Xr.isPointInPolygon(d[C.randInt(0,d.length-1)],y)){(t=i.get(p))==null||t.children.push(i.get(h));break}}m===a&&o.children.push(i.get(h))}return o}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new K().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((r,i)=>{const a=r.size,o=a.width*a.height;e.push({area:o,index:i})}),e.sort((r,i)=>r.area-i.area);const s=[];return e.forEach(r=>{s.push(r.index)}),s}}class ae extends Zs{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,r=this.getPoint(0),i=0;e.push(0);for(let a=1;a<=t;a++)s=this.getPoint(a/t),i+=s.distanceTo(r),e.push(i),r=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let r=0;const i=s.length;let a;e?a=e:a=t*s[i-1];let o=0,c=i-1,h;for(;o<=c;)if(r=Math.floor(o+(c-o)/2),h=s[r]-a,h<0)o=r+1;else if(h>0)c=r-1;else{c=r;break}if(r=c,s[r]===a)return r/(i-1);const d=s[r],u=s[r+1]-d,m=(a-d)/u;return(r+m)/(i-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const r=this.getPoint(e),i=this.getPoint(s),a=new L;return a.copy(i).sub(r).normalize(),a}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class oe extends ae{constructor(t,e,s,r,i){super();const a=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0)+ +(i!==void 0);if(a==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(a==5){const o=t;this.center=new L(o.x,o.y),this.radius=e,this.startAngle=s,this.endAngle=r,this.clockwise=i}else throw et.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const r=(I,W)=>({x:(I.x+W.x)/2,y:(I.y+W.y)/2}),i=(I,W)=>(W.y-I.y)/(W.x-I.x),a=I=>-1/I,o=r(t,e),c=r(e,s),h=i(t,e),d=i(e,s),u=a(h),m=a(d),p=(I,W,lt,vt)=>{const N=(vt-W)/(I-lt),V=I*N+W;return{x:N,y:V}},y=o.y-u*o.x,_=c.y-m*c.x,x=p(u,y,m,_),f=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),M=(I,W)=>Math.atan2(I.y-W.y,I.x-W.x),T=M(t,x),S=M(e,x),P=M(s,x),z=P>T&&P<S||T>P&&T<S||S>P&&S<T;this.center=x,this.radius=f,this.startAngle=T,this.endAngle=P,this.clockwise=!z}createByStartEndPointsAndBulge(t,e,s){let r,i,a;s<0?(r=Math.atan(-s)*4,i=new B(t),a=new B(e)):(r=Math.atan(s)*4,i=new B(e),a=new B(t));const o=new B().subVectors(a,i),c=o.length(),h=new B().addVectors(i,o.multiplyScalar(.5)),d=Math.abs(c/2/Math.tan(r/2)),u=o.normalize();let m;if(r<Math.PI){const p=new B(u.x*Math.cos(Math.PI/2)-u.y*Math.sin(Math.PI/2),u.y*Math.cos(Math.PI/2)+u.x*Math.sin(Math.PI/2));m=h.add(p.multiplyScalar(-d))}else{const p=new B(u.x*Math.cos(Math.PI/2)-u.y*Math.sin(Math.PI/2),u.y*Math.cos(Math.PI/2)+u.x*Math.sin(Math.PI/2));m=h.add(p.multiplyScalar(d))}s<0?(this.startAngle=Math.atan2(i.y-m.y,i.x-m.x),this.endAngle=Math.atan2(a.y-m.y,a.x-m.x)):(this.startAngle=Math.atan2(a.y-m.y,a.x-m.x),this.endAngle=Math.atan2(i.y-m.y,i.x-m.x)),this.clockwise=s<0,this.center=m,this.radius=a.sub(m).length()}get center(){return this._center}set center(t){this._center=new L(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return this.clockwise?C.normalizeAngle(this.startAngle-this.endAngle):C.normalizeAngle(this.endAngle-this.startAngle)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=C.normalizeAngle((this.startAngle+this.endAngle)/2);return this.getPointAtAngle(t)}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of e)C.isBetweenAngle(i,this.startAngle,this.endAngle,this.clockwise)&&t.push(this.getPointAtAngle(i));const s=t.map(i=>i.x),r=t.map(i=>i.y);return new K(new L(Math.min(...s),Math.min(...r)),new L(Math.max(...s),Math.max(...r)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new oe(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.clockwise)}getPointAtAngle(t){const e=this.center.x+this.radius*Math.cos(t),s=this.center.y+this.radius*Math.sin(t);return new L(e,s)}getPoints(t=100){const e=[];let s=this.deltaAngle,r=this.startAngle;if(this.closed&&(s=H,r=0),this.clockwise)for(let i=0;i<=t;i++){const a=r-s*(i/t),o=this.getPointAtAngle(a);e.push(new L(o.x,o.y))}else for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(new L(o.x,o.y))}return e}}class tl extends ai{translate(t){return this.transform(new Yt().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ke extends tl{}class Nt extends ke{constructor(t,e){super(),this._start=new b(t),this._end=new b(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new w().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new b((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const s=this.delta(qt).normalize();return new b(this._start).addScaledVector(s,t)}else{const s=this.delta(qt).normalize();return new b(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=qt.subVectors(this._start,this._end).normalize();this._start=new b(this._start).addScaledVector(s,t)}else{const s=this.delta(qt).normalize();this._end=new b(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){oi.subVectors(t,this._start),ts.subVectors(this.endPoint,this.startPoint);const s=ts.dot(ts);let r=ts.dot(oi)/s;return e&&(r=C.clamp(r,0,1)),r}closestPointToPoint(t,e,s){const r=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(r).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=qt.subVectors(t,this.startPoint).dot(e);return new b().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,r=qt.subVectors(t,s).dot(e),i=qt.copy(e).multiplyScalar(r);return new b().addVectors(s,i)}calculateBoundingBox(){const t=new b(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new b(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new O(t,e)}transform(t){return this._start.applyMatrix3d(t),this._end.applyMatrix3d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Nt(this._start.clone(),this._end.clone())}}const qt=new w,oi=new w,ts=new w;class Xt extends ke{static computeCenterPoint(t,e,s){const r=new w().addVectors(t,e).multiplyScalar(.5),i=new w().addVectors(t,s).multiplyScalar(.5),a=new w().subVectors(e,t),o=new w().subVectors(s,t),c=new w().crossVectors(a,o).normalize();if(c.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const h=new w().crossVectors(a,c).normalize(),d=new w().crossVectors(o,c).normalize(),u=h.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=d.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=new Nt(r,r.clone().add(u)),y=new Nt(i,i.clone().add(m)),_=new w;return p.closestPointToPoint(y.startPoint,!0,_)?_:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const r=Xt.computeCenterPoint(t,e,s);if(r){const i=r.distanceTo(t),a=new w().subVectors(t,r),o=new w().subVectors(e,r),c=Math.atan2(a.y,a.x),h=Math.atan2(o.y,o.x);return new Xt(r,i,c,h,w.Z_AXIS)}}constructor(t,e,s,r,i,a=w.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=r,this.normal=i,this.refVec=a,(r-s)%H==0?(this.startAngle=0,this.endAngle=H):(this.startAngle=s,this.endAngle=r)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return C.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new w(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new w(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get length(){return Math.abs(this.deltaAngle*this.radius)}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let c=0;c<2*Math.PI;c+=Math.PI/2)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&t.push(c);let e=1/0,s=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(const c of t){const h=this.getPointAtAngle(c);h.x<e&&(e=h.x),h.y<s&&(s=h.y),h.z<r&&(r=h.z),h.x>i&&(i=h.x),h.y>a&&(a=h.y),h.z>o&&(o=h.z)}return new O({x:e,y:s,z:r},{x:i,y:a,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,r=this.startAngle;this.closed&&(s=H,r=0);for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(o)}return e}transform(t){const e=Qs.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=Qs.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(t),e.applyMatrix3d(t),s.applyMatrix3d(t),this.normal.applyMatrix3d(t).normalize(),this.refVec.applyMatrix3d(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Xt(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Qs.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,r={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},i=this.center,a=this.radius;return new b(i.x+a*(s.x*Math.cos(t)+r.x*Math.sin(t)),i.y+a*(s.y*Math.cos(t)+r.y*Math.sin(t)),i.z+a*(s.z*Math.cos(t)+r.z*Math.sin(t)))}get plane(){const t=new w(this.center).distanceTo(Us);return new Le(this.normal,t)}}const Qs=new w;class es extends ae{constructor(t,e,s,r=0,i=H,a=!1,o=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(i-r)%H==0?(this.startAngle=0,this.endAngle=H):(this.startAngle=r,this.endAngle=i),this.clockwise=a,this.rotation=o}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return C.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,r=-1/0;for(let i=0;i<=100;i++){const a=this.getPoint(i/100);t=Math.min(t,a.x),e=Math.min(e,a.y),s=Math.max(s,a.x),r=Math.max(r,a.y)}return new K({x:t,y:e},{x:s,y:r})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const r=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(r?s=0:s=e),this.clockwise===!0&&!r&&(s===e?s=-e:s=s-e);const i=this.startAngle+t*s;let a=this.center.x+this.majorAxisRadius*Math.cos(i),o=this.center.y+this.minorAxisRadius*Math.sin(i);if(this.rotation!==0){const c=Math.cos(this.rotation),h=Math.sin(this.rotation),d=a-this.center.x,u=o-this.center.y;a=d*c-u*h+this.center.x,o=d*h+u*c+this.center.y}return new L(a,o)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new es(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class ss extends ke{constructor(t,e,s,r,i,a=0,o=H){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=r,this.minorAxisRadius=i;const c=Math.abs(o-a);Math.abs(c-H)<1e-10||Math.abs(c-2*H)<1e-10?(this.startAngle=0,this.endAngle=H):(this.startAngle=a,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-H)<1e-10?H:C.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new w(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new w(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new w().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get isCircular(){return Ws.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let s=0,r=this.getPointAtAngle(this.startAngle);for(let i=1;i<=t;i++){const a=this.startAngle+i*e,o=this.getPointAtAngle(a),c=o.x-r.x,h=o.y-r.y,d=o.z-r.z;s+=Math.sqrt(c*c+h*h+d*d),r=o}return s}calculateBoundingBox(){if(this.majorAxis.equals(w.X_AXIS)||this.majorAxis.equals(w.Y_AXIS)||this.majorAxis.isParallelTo(w.X_AXIS)||this.majorAxis.isParallelTo(w.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let c=0;c<2*Math.PI;c+=Math.PI/2)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&t.push(c);let e=1/0,s=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(const c of t){const h=this.getPointAtAngle(c);h.x<e&&(e=h.x),h.y<s&&(s=h.y),h.z<r&&(r=h.z),h.x>i&&(i=h.x),h.y>a&&(a=h.y),h.z>o&&(o=h.z)}return new O({x:e,y:s,z:r},{x:i,y:a,z:o})}else{let t=1/0,e=1/0,s=1/0,r=-1/0,i=-1/0,a=-1/0;for(let o=0;o<=100;o++){const c=this.startAngle+this.deltaAngle*(o/100),h=this.getPointAtAngle(c);t=Math.min(t,h.x),e=Math.min(e,h.y),s=Math.min(s,h.z),r=Math.max(r,h.x),i=Math.max(i,h.y),a=Math.max(a,h.z)}return new O({x:t,y:e,z:s},{x:r,y:i,z:a})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,r=this.startAngle;this.closed&&(s=H,r=0);for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(o)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),r=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),i=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(r);return new b(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}contains(t){const e=new w(t).sub(this.center),s=e.dot(this.majorAxis),r=e.dot(this.minorAxis),i=s/this.majorAxisRadius,a=r/this.minorAxisRadius;return i*i+a*a<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ss(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new w(this.center).distanceTo(Us);return new Le(this.normal,t)}}class Ce extends ae{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new L(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new L(e.x,e.y)}else{const e=this._vertices[t-1];return new L(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let s=0;s<e;++s){const r=this._vertices[s];let i=null;if(s<e-1?i=this._vertices[s+1]:s==e-1&&this.closed&&(i=this._vertices[0]),i)if(r.bulge){const a=new oe(r,i,r.bulge);t+=a.length}else t+=new L(r.x,r.y).distanceTo(i)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new L(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new K().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(r=>s.push(new b().set(r.x,r.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let r=0;r<s;++r){const i=this._vertices[r];if(i.bulge){let a=null;if(r<s-1?a=this._vertices[r+1]:r==s-1&&this.closed&&(a=this._vertices[0]),a){const o=new oe(i,a,i.bulge).getPoints(t),c=o.length;for(let h=0;h<c;++h){const d=o[h];e.push(new L(d.x,d.y))}}}else e.push(new L(i.x,i.y)),r==s-1&&this.closed&&e.push(e[0])}return e}}class ns extends ae{constructor(t,e){super(),this._start=new L(t),this._end=new L(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new L(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new L(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new K(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ns(this._start.clone(),this._end.clone())}}class li extends ae{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new L(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new K;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(r=>{e.push(new L(r.x,r.y))})}),e}}class Js{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,r){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-r,this.c3=2*t-2*e+s+r}initCatmullRom(t,e,s,r,i){this.init(e,s,i*(s-t),i*(r-e))}initNonuniformCatmullRom(t,e,s,r,i,a,o){let c=(e-t)/i-(s-t)/(i+a)+(s-e)/a,h=(s-e)/a-(r-e)/(a+o)+(r-s)/o;c*=a,h*=a,this.init(e,s,c,h)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}class hi extends ke{constructor(t=[],e=!1,s="centripetal",r=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new w,this._px=new Js,this._py=new Js,this._pz=new Js,this._points=t.map(i=>new b(i)),this._closed=e,this._curveType=s,this._tension=r}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new b}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new b}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new b){const s=e,r=this._points,i=r.length;if(i===0)return s.set(0,0,0);if(i===1)return s.copy(r[0]);const a=(i-(this._closed?0:1))*t;let o=Math.floor(a),c=a-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:c===0&&o===i-1&&(o=i-2,c=1);let h,d;this._closed||o>0?h=r[(o-1)%i]:(this._tmp.subVectors(r[0],r[1]).add(r[0]),h=new b(this._tmp.x,this._tmp.y,this._tmp.z));const u=r[o%i],m=r[(o+1)%i];if(this._closed||o+2<i?d=r[(o+2)%i]:(this._tmp.subVectors(r[i-1],r[i-2]).add(r[i-1]),d=new b(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const p=this._curveType==="chordal"?.5:.25;let y=Math.pow(h.distanceToSquared(u),p),_=Math.pow(u.distanceToSquared(m),p),x=Math.pow(m.distanceToSquared(d),p);_<1e-4&&(_=1),y<1e-4&&(y=_),x<1e-4&&(x=_),this._px.initNonuniformCatmullRom(h.x,u.x,m.x,d.x,y,_,x),this._py.initNonuniformCatmullRom(h.y,u.y,m.y,d.y,y,_,x),this._pz.initNonuniformCatmullRom(h.z,u.z,m.z,d.z,y,_,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(h.x,u.x,m.x,d.x,this._tension),this._py.initCatmullRom(h.y,u.y,m.y,d.y,this._tension),this._pz.initCatmullRom(h.z,u.z,m.z,d.z,this._tension));return s.set(this._px.calc(c),this._py.calc(c),this._pz.calc(c)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new b(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const s=new b;return s.copy(e),s.applyMatrix3d(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new O;const t=new O;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}class mt{constructor(t,e,s,r){this._degree=t,this._knots=[...e],this._controlPoints=s.map(i=>({x:i.x,y:i.y,z:i.z})),this._weights=r?[...r]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return ve(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Qr(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,r){return new mt(t,e,s,r)}static byPoints(t,e,s="Uniform"){let r;switch(s){case"Chord":r=Kr(e,t);break;case"SqrtChord":r=Zr(e,t);break;case"Uniform":default:r=$r(e,t.length);break}const i=t.map(o=>({x:o[0],y:o[1],z:o[2]})),a=new Array(i.length).fill(1);return new mt(e,r,i,a)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:r}=this.getParameterRange();for(let i=0;i<=t;i++){const a=s+(r-s)*(i/t);e.push(this.point(a))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),r=this.point(e),i=this.point(s),a=r[0]-i[0],o=r[1]-i[1],c=r[2]-i[2];return Math.sqrt(a*a+o*o+c*c)<t}static createClosedCurve(t,e,s="Chord"){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const r=new hi(t,!0,"centripetal"),i=Math.max(50,t.length*2),a=r.getPoints(i).map(o=>[o.x,o.y,o.z]);return mt.byPoints(a,e,s)}}class Dt extends ke{constructor(t,e,s,r){super();const i=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0);if(i<2||i>4)throw et.ILLEGAL_PARAMETERS;const a=3;if(this._closed=r||!1,Array.isArray(e)){if(this._controlPoints=t,i>=4&&(this._closed=r),this._controlPoints.length<4)throw et.ILLEGAL_PARAMETERS;this._nurbsCurve=mt.byKnotsControlPointsWeights(a,e,this._controlPoints,s)}else{if(this._fitPoints=t,this._knotParameterization=e,i>=3&&(this._closed=s),this._fitPoints.length<4)throw et.ILLEGAL_PARAMETERS;const o=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=mt.byPoints(o,a,this._knotParameterization),this._controlPoints=this._nurbsCurve.controlPoints()}this._closed&&this.buildCurve()}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed)this._nurbsCurve=mt.createClosedCurve(this._fitPoints,3,this._knotParameterization);else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=mt.byPoints(t,3,this._knotParameterization)}this._controlPoints=this._nurbsCurve.controlPoints()}else if(this._controlPoints)if(this._closed){const t=this._knotParameterization||"Chord";this._nurbsCurve=mt.createClosedCurve(this._controlPoints,3,t),this._controlPoints=this._nurbsCurve.controlPoints()}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._nurbsCurve=mt.byKnotsControlPointsWeights(3,t,this._controlPoints,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._nurbsCurve.degree()}get knotParameterization(){return this._knotParameterization}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],r=this._nurbsCurve.point(s);return new b(r[0],r[1],r[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],r=this._nurbsCurve.point(s);return new b(r[0],r[1],r[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,r=this._fitPoints[s];return{x:r.x,y:r.y,z:r.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],r=e.knots(),i=this._nurbsCurve.degree(),a=r[i],o=r[r.length-i-1],c=(o-a)/(t-1);for(let h=0;h<t;h++){const d=h===t-1?o:a+h*c,u=e.point(d);s.push(new b(u[0],u[1],u[2]))}return s}getCurvePoints(t,e){const s=[],r=t.knots(),i=r[3],a=(r[r.length-4]-i)/(e-1);for(let o=0;o<e;o++){const c=i+o*a;s.push(t.point(c))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new O().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,r)=>{e[r]=[s.x,s.y,s.z||0]}),e}static createClosedSpline(t,e="Uniform"){if(t.length<4)throw new Error("At least 4 points are required for a closed spline");return new Dt(t,e,!0)}}for(var $t=256,ci=[],di=256,rs;$t--;)ci[$t]=($t+256).toString(16).substring(1);function el(n){var t=0,e=11;if(!rs||$t+e>di*2)for(rs="",$t=0;t<di;t++)rs+=ci[Math.random()*256|0];return rs.substring($t,$t+++e)}class Rt{constructor(t,e){t=t||{},ee(t,{objectId:el()}),this._attrs=new fn(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:dn().workingDatabase}set database(t){this._database=t}close(){}}class pt extends Rt{constructor(){super(...arguments),this._layer="0",this._color=new zt,this._lineType=Xe,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.name.substring(4)}get layer(){return this._layer}set layer(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Xe}get lineWeight(){return this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,r,i){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const t=this.getLineType(),e=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Xe){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==Pr?qe:this.lineType;return qe}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}}class tn extends pt{constructor(t){super(),this._blockName=t,this._position=new b,this._rotation=0,this._normal=new w(0,0,1),this._scaleFactors=new b(1,1,1)}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const t=new O,e=this.blockTableRecord;if(e!=null){const i=e.newIterator();for(const a of i)t.union(a.geometricExtents)}const s=new Ct().setFromEuler(new ii(this.rotation,0,0)),r=new Yt;return r.compose(this.position,s,this.scaleFactors),t.applyMatrix4(r),t}draw(t){const e=[],s=this.blockTableRecord;if(s!=null){const r=this.computeTransformMatrix();return kt.instance.draw(t,s,this.rgbColor,!0,r,this.normal)}else return t.group(e)}computeTransformMatrix(){const t=new Ct;return t.setFromAxisAngle(w.Z_AXIS,this.rotation),new Yt().compose(this._position,t,this._scaleFactors)}}class gt extends pt{}class ui extends gt{constructor(t,e,s,r,i,a,o){super(),this._geo=new ss(t,e,s,r,i,a,o)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(t){return t.ellipticalArc(this._geo,this.lineStyle)}}class mi extends gt{constructor(t,e,s,r){super(),this._geo=new Xt(t,e,s,r,w.Z_AXIS,w.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}class gi extends gt{constructor(t,e,s=w.Z_AXIS){super(),this._geo=new Xt(t,e,0,H,s,w.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}var pi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(pi||{}),yi=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(yi||{});class _i extends pt{constructor(){super(),this._elevation=0,this._geo=new Je,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new O({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}}var fi=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(fi||{});class xi extends gt{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new b().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new O().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Dt(this._vertices,"Uniform"),this._updated=!1)}}class bi extends gt{constructor(t,e){super(),this._geo=new Nt(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,r,i){const a=this.startPoint,o=this.endPoint;switch(t){case Ut.EndPoint:i.push(a),i.push(o);break;case Ut.MidPoint:i.push(this.midPoint);break;case Ut.Nearest:{const c=this._geo.project(s);i.push(c)}break;case Ut.Perpendicular:{const c=this._geo.perpPoint(s);i.push(c)}break;case Ut.Tangent:i.push(a);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,s=this.endPoint,r=[new b(e.x,e.y,0),new b(s.x,s.y,0)];return t.lines(r,this.lineStyle)}}var en=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(en||{}),is=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(is||{}),le=(n=>(n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n))(le||{}),sn=(n=>(n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",n))(sn||{}),nn=(n=>(n[n.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",n[n.TOP=1]="TOP",n[n.BOTTOM=2]="BOTTOM",n[n.FRONT=3]="FRONT",n[n.BACK=4]="BACK",n[n.LEFT=5]="LEFT",n[n.RIGHT=6]="RIGHT",n))(nn||{}),rn=(n=>(n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",n))(rn||{});class as{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new K;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new K;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new as;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}class wi extends pt{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new b,this._attachmentPoint=le.TopLeft,this._direction=new w(1,0,0),this._drawingDirection=is.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new O}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}}class an extends gt{constructor(t,e,s,r){super();const i=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0);if(i<2||i>4)throw et.ILLEGAL_PARAMETERS;i<=3&&!Array.isArray(e)?this._geo=new Dt(t,e,s):this._geo=new Dt(t,e,s,r)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}}const sl=new w;class Ai extends tn{constructor(t,e,s){super(t),this._attachmentPoint=le.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new O}draw(t){let e=0,s=0;const r=new Uint16Array(this.numColumns*this.numRows*8),i=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let a=0;for(let m=0;m<=this.numRows;m++){e-=m>0?this.rowHeight(m-1):0,s=0;for(let p=0;p<=this.numColumns;p++)s+=p>0?this.columnWidth(p-1):0,i[a++]=s,i[a++]=e,i[a++]=0}const o=[],c=new Array(this.numRows*this.numColumns).fill(!1);s=0,a=0;let h=0;for(let m=0;m<this.numColumns;m++){s+=m>0?this.columnWidth(m-1):0,e=0;for(let p=0;p<this.numRows;p++){e+=p>0?this.rowHeight(p-1):0;const y=this.cell(p*this.numColumns+m);if(h=p*this.numColumns+m,y&&!c[h]){const _=y.borderWidth??1,x=y.borderHeight??1;this.fillVisited(c,h,this.numColumns,_,x),r[a++]=m+p*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1)+_;const f=i[r[a-1]*3]-s,M=m+(p+x)*(this.numColumns+1)+_;m+_==this.numColumns&&(r[a++]=m+p*(this.numColumns+1)+_,r[a++]=M);const T=-i[M*3+1]-e;if(p+x==this.numRows&&(r[a++]=m+(p+x)*(this.numColumns+1)+x,r[a++]=m+(p+x)*(this.numColumns+1)),r[a++]=m+(p+x)*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1),y.text){const S=y.attachmentPoint||this.attachmentPoint||le.MiddleCenter,P=this.getTableTextOffset(S,f,T),z={text:y.text,height:y.textHeight,width:f,position:sl.set(s,-e,0).clone().add(P),rotation:this.rotation,attachmentPoint:S},I={...this.getTextStyle(y),color:this.color.color};o.push(t.mtext(z,I))}}}}o.push(t.lineSegments(i,3,r,this.lineStyle));const d=t.group(o),u=new Ct;return u.setFromAxisAngle(w.Z_AXIS,this.rotation),Pi.compose(this.position,u,this.scaleFactors),d.applyMatrix(Pi),d}fillVisited(t,e,s,r,i){if(i==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<i;++o)t[e+a+o*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let s;return t.textStyle&&(s=e.getAt(t.textStyle)),s||(s=e.getAt("STANDARD")||e.getAt("Standard")),s.textStyle}getTableTextOffset(t,e,s){const r=new w;switch(t){case 1:break;case 2:r.setX(e/2);break;case 3:r.setX(e);break;case 4:r.setY(-s/2);break;case 5:r.set(e/2,-s/2,0);break;case 6:r.set(e,-s/2,0);break;case 7:r.setY(-s);break;case 8:r.set(e/2,-s,0);break;case 9:r.set(e,-s,0);break}return r}}const Pi=new Yt;var Ii=(n=>(n[n.LEFT=0]="LEFT",n[n.CENTER=1]="CENTER",n[n.RIGHT=2]="RIGHT",n[n.ALIGNED=3]="ALIGNED",n[n.MIDDLE=4]="MIDDLE",n[n.FIT=5]="FIT",n))(Ii||{}),Ei=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Ei||{});class Ti extends pt{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new b,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new O}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:is.BOTTOM_TO_TOP,attachmentPoint:le.BottomLeft},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}}class Si extends gt{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new b,new b,new b,new b]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new O().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new Ce(this._vertices,!0),s=new Je;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}}class Mi extends gt{constructor(){super(),this._elevation=0,this._geo=new Ce}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,r=-1,i=-1){const a=r<0?void 0:r,o=i<0?void 0:i,c={x:e.x,y:e.y,bulge:s,startWidth:a,endWidth:o};this._geo.addVertexAt(t,c)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new b(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new O({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(r=>e.push(new b().set(r.x,r.y,this.elevation))),t.lines(e,this.lineStyle)}}class vi extends pt{constructor(){super(),this._geo=new b}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new O().expandByPoint(this._geo)}transformBy(t){return this._geo.applyMatrix3d(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}}var Li=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(Li||{}),ki=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(ki||{});class on extends pt{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new b,this._scale=new B(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new O;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,r=new K;r.setFromPoints(this._clipBoundary);const i=new L;i.setX(this._position.x-r.min.x*e),i.setY(this._position.y-r.min.y*s),this._clipBoundary.forEach(a=>{const o=a.x*e+i.x,c=a.y*s+i.y;t.push(new b(o,c,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Ci.copy(t[1]);for(let e=1;e<4;e++)os.copy(t[e]),os.rotateAround(Ci,this._rotation),t[e].setX(os.x),t[e].setY(os.y)}t.push(t[0])}return t}}const Ci=new L,os=new L;class Oi extends gt{constructor(){super(),this._basePoint=new b,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new O;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}class Ni extends pt{constructor(){super(),this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new O}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new as;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s}}class Di extends on{draw(t){const e=this.boundaryPath(),s=new Je;return s.add(new Ce(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}}class Ri extends gt{constructor(){super(),this._basePoint=new b,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new O;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}var zi=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(zi||{});class Kt extends pt{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new b,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new Ne),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}draw(t){if(this.dimBlockId){const e=this.database.tables.blockTable.getAt(this.dimBlockId);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}return t.group([])}drawFirstArrow(t){const e=this.database.tables.blockTable.getAt(this.firstArrowType);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,s){const r=new b().subVectors(e,t).normalize();return new b(e).addScaledVector(r,s)}findPointOnLine2(t,e,s){const r=t.x+s*Math.cos(e),i=t.y+s*Math.sin(e);return{x:r,y:i}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():en.Closed}}class Fi extends Kt{constructor(t,e,s,r,i=null,a=null){super(),this._centerPoint=new b().copy(t),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(s),this._arcPoint=new b().copy(r),this.dimensionText=i,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new O}}class Bi extends Kt{constructor(t,e,s,r=null,i=null){super(),this._dimLinePoint=new b().copy(s),this._xLine1Point=new b().copy(t),this._xLine2Point=new b().copy(e),this._oblique=0,this._rotation=0,this.dimensionText=r,this.dimensionStyleName=i}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new O}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),r=this.findIntersectionPoint(e,this._dimLinePoint),i=this.findIntersectionPoint(s,this._dimLinePoint),a=new Nt(r,i);return t.push(a),e.endPoint=r,this.adjustExtensionLine(e),t.push(e),s.endPoint=i,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Nt(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,r=t.endPoint,i=new w().subVectors(r,s).normalize(),o=new w().subVectors(e,s).dot(i),c=new w().copy(i).multiplyScalar(o);return new w().addVectors(s,c)}}class nl extends Kt{constructor(t,e,s,r,i=null,a=null){super(),this._arcPoint=new b().copy(r),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(s),this._centerPoint=new b().copy(t),this.dimensionText=i,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new O}}class Vi extends Kt{constructor(t,e,s=0,r=null,i=null){super(),this._chordPoint=new b().copy(t),this._farChordPoint=new b().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=r,this.dimensionStyleName=i}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new O}drawLines(t,e){const s=[],r=e.length;return r==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):r==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(i=>{s.push(this.drawLine(t,i))}),s}drawLine(t,e,s){if(s){const r=[e.startPoint,e.endPoint];return t.lines(r,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,r)=>s.x!==r.x?s.x-r.x:s.y!==r.y?s.y-r.y:s.z-r.z;t.sort((s,r)=>{const i=e(s.startPoint,r.startPoint);return i!==0?i:e(s.endPoint,r.endPoint)})}}class ji extends Kt{constructor(t,e,s=null,r=null){super(),this._definingPoint=new b().copy(t),this._leaderEndPoint=new b().copy(e),this.dimensionText=s,this.dimensionStyleName=r}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new O}get arrowLineCount(){return 0}}class Gi extends Kt{constructor(t,e,s,r=null,i=null){super(),this._center=new b().copy(t),this._chordPoint=new b().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=r,this.dimensionStyleName=i}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new O}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}}class Hi{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"||t.type=="LWPOLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertArc(t){return new mi(t.center,t.radius,C.degToRad(t.startAngle),C.degToRad(t.endAngle))}convertCirle(t){return new gi(t.center,t.radius)}convertEllipse(t){const e=new w(t.majorAxisEndPoint),s=e.length();return new ui(t.center,w.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new bi(new b(e.x,e.y,e.z||0),new b(s.x,s.y,s.z||0))}convertSpline(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new an(t.controlPoints,t.knots,t.weights,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new an(e,"Uniform",!!(t.flag&1))}return null}convertPoint(t){const e=new vi;return e.position=t.position,e}convertSolid(t){const e=new Si;return t.points.forEach((s,r)=>e.setPointAt(r,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=new Mi;return e.closed=!!(t.flag&1),t.vertices.forEach((s,r)=>{e.addVertexAt(r,new L(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var r;const e=new _i;return(r=t.definitionLines)==null||r.forEach(i=>{e.definitionLines.push({angle:i.angle,origin:i.base,delta:i.offset,dashPattern:i.numberOfDashLengths>0?i.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(i=>{if(i.boundaryPathTypeFlag&2){const o=i,c=new Ce;c.closed=o.isClosed,o.vertices.forEach((h,d)=>{c.addVertexAt(d,{x:h.x,y:h.y,bulge:h.bulge})}),e.add(c)}else{const o=i,c=new li;o.edges.forEach(h=>{if(h.type==1){const d=h;c.add(new ns(d.start,d.end))}else if(h.type==2){const d=h;c.add(new oe(d.center,d.radius,C.degToRad(d.startAngle||0),C.degToRad(d.endAngle||0),!d.isCCW))}else if(h.type==3){const d=h;new B().subVectors(d.end,d.center);const m=Math.sqrt(Math.pow(d.end.x,2)+Math.pow(d.end.y,2)),p=m*d.lengthOfMinorAxis;let y=C.degToRad(d.startAngle||0),_=C.degToRad(d.endAngle||0);const x=Math.atan2(d.end.y,d.end.x);d.isCCW||(y=Math.PI*2-y,_=Math.PI*2-_),c.add(new es({...d.center,z:0},m,p,y,_,!d.isCCW,x))}else if(h.type==4){const d=h;if(d.numberOfControlPoints>0&&d.numberOfKnots>0){const u=d.controlPoints.map(y=>({x:y.x,y:y.y,z:0}));let m=!0;const p=d.controlPoints.map(y=>(y.weight==null&&(m=!1),y.weight||1));c.add(new Dt(u,d.knots,m?p:void 0))}else if(d.numberOfFitData>0){const u=d.fitDatum.map(m=>({x:m.x,y:m.y,z:0}));c.add(new Dt(u,"Uniform"))}}}),e.add(c)}}),e}convertTable(t){const e=new Ai(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,r)=>e.setColumnWidth(r,s)),t.rowHeightArr.forEach((s,r)=>e.setRowHeight(r,s)),t.cells.forEach((s,r)=>{e.setCell(r,s)}),e}convertText(t){const e=new Ti;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=C.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new wi;return e.contents=t.text.join(""),t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=C.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new w(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new xi;return t.vertices.forEach(s=>{e.appendVertex(s)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new Bi(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return s.rotation=C.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new Fi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new ji(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new Gi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new Vi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageDefId=t.imageDefHandle,e.isClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new L(s))}),e.clipBoundaryType=t.clippingBoundaryType,e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new on;return this.processImage(t,e),e}convertWipeout(t){const e=new Di;return this.processImage(t,e),e}convertViewport(t){const e=new Ni;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new Oi;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertXline(t){const e=new Ri;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertBlockReference(t){const e=new tn(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?C.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement}processCommonAttrs(t,e){e.layer=t.layer,e.objectId=t.handle,e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const s=t.length;let r=0;if(s/2==e?r=2:s/3==e&&(r=3),r==0)return;const i=[];for(let a=0,o=s/r;a<o;++a)i.push({x:t[a*r],y:t[a*r+1],z:r==3?t[a*r+2]:0});return i}}class ln extends Rt{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new K,this._extents=new O}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class hn extends Rt{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(t){return this.getAt(t)?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,r)=>{s===e&&this._recordsByName.delete(r)}),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new $e(this._recordsByName)}}class Ui extends hn{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Wi extends Rt{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class rl{convertLayout(t){const e=new ln;return e.layoutName=t.layoutName,e.tabOrder=t.tabOrder,e.blockTableRecordId=t.ownerObjectId,e.limits.min.copy(t.minLimit),e.limits.max.copy(t.maxLimit),e.extents.min.copy(t.minExtent),e.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,e),e}convertImageDef(t){const e=new Wi;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Yi extends Tr{parse(t){return new Wo().parseSync(t)}getFonts(t){var i;const e=new Map,s=a=>{if(a){const o=a.lastIndexOf(".");return o>=0?a.substring(0,o).toLowerCase():a.toLowerCase()}};(i=t.tables.STYLE)==null||i.entries.forEach(a=>{const o=[];let c=s(a.font);c&&o.push(c),c=s(a.bigFont),c&&o.push(c),e.set(a.name,o)});const r=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,r),Array.from(r)}getFontsInBlock(t,e,s,r){const i=/\\f(.*?)\|/g;t.forEach(a=>{if(a.type=="MTEXT"){const o=a;[...o.text.join("").matchAll(i)].forEach(d=>{r.add(d[1].toLowerCase())});const h=s.get(o.styleName);h==null||h.forEach(d=>r.add(d))}else if(a.type=="TEXT"){const o=a,c=s.get(o.styleName);c==null||c.forEach(h=>r.add(h))}else if(a.type=="INSERT"){const c=e[a.name];c&&c.entities&&this.getFontsInBlock(c.entities,e,s,r)}})}async processEntities(t,e,s,r,i){const a=new Hi,o=t.entities,c=o.length,h=new Pn(c,100-r.value,s),d=e.tables.blockTable.modelSpace,u=e.tables.blockTable;await h.processChunk(async(m,p)=>{for(let y=m;y<p;y++){const _=o[y],x=a.convert(_);if(x){let f=d;_.ownerBlockRecordSoftId!=null&&(f=u.getIdAt(_.ownerBlockRecordSoftId)||f),f.appendEntity(x)}}if(i){let y=r.value+p/c*(100-r.value);y>100&&(y=100),await i(y,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e,s){const r=new Hi,i=t.length;for(let a=0;a<i;a++){const o=t[a],c=r.convert(o);if(c){let h=e;o.ownerBlockRecordSoftId!=null&&(h=s.getIdAt(o.ownerBlockRecordSoftId)||h),h.appendEntity(c)}}}processBlocks(t,e){const s=t.blocks;for(const[r,i]of Object.entries(s)){let a=e.tables.blockTable.getAt(i.name);a||(a=new Mt,a.objectId=i.handle,a.name=r,a.origin.copy(i.position),e.tables.blockTable.add(a)),i.entities&&this.processEntitiesInBlock(i.entities,a,e.tables.blockTable)}}processHeader(t,e){const s=t.header;e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,e.aunits=s.$AUNITS,e.insunits=s.$INSUNITS,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0}processBlockTables(t,e){var r;const s=(r=t.tables.BLOCK_RECORD)==null?void 0:r.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(i=>{const a=new Mt;a.objectId=i.handle,a.name=i.name,e.tables.blockTable.add(a)}))}processObjects(t,e){const s=t.objects.byName,r=new rl;if("LAYOUT"in s){const i=e.dictionaries.layouts;s.LAYOUT.forEach(a=>{const o=r.convertLayout(a);i.setAt(o.layoutName,o)})}if("IMAGEDEF"in s){const i=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(a=>{const o=r.convertImageDef(a);i.setAt(o.objectId,o)})}}processViewports(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.VPORT)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new aa;this.processCommonTableEntryAttrs(a,o),a.circleSides&&(o.circleSides=a.circleSides),o.standardFlag=a.standardFlag,o.center.copy(a.center),o.lowerLeftCorner.copy(a.lowerLeftCorner),o.upperRightCorner.copy(a.upperRightCorner),a.snapBasePoint&&o.snapBase.copy(a.snapBasePoint),a.snapRotationAngle&&(o.snapAngle=a.snapRotationAngle),a.snapSpacing&&o.snapIncrements.copy(a.snapSpacing),a.majorGridLines&&(o.gridMajor=a.majorGridLines),a.gridSpacing&&o.gridIncrements.copy(a.gridSpacing),a.backgroundObjectId&&(o.backgroundObjectId=a.backgroundObjectId),o.gsView.center.copy(a.center),o.gsView.viewDirectionFromTarget.copy(a.viewDirectionFromTarget),o.gsView.viewTarget.copy(a.viewTarget),a.lensLength&&(o.gsView.lensLength=a.lensLength),a.frontClippingPlane&&(o.gsView.frontClippingPlane=a.frontClippingPlane),a.backClippingPlane&&(o.gsView.backClippingPlane=a.backClippingPlane),a.viewHeight&&(o.gsView.viewHeight=a.viewHeight),a.viewTwistAngle&&(o.gsView.viewTwistAngle=a.viewTwistAngle),a.frozenLayers&&(o.gsView.frozenLayers=a.frozenLayers),a.styleSheet&&(o.gsView.styleSheet=a.styleSheet),a.renderMode&&(o.gsView.renderMode=a.renderMode),a.viewMode&&(o.gsView.viewMode=a.viewMode),a.ucsIconSetting&&(o.gsView.ucsIconSetting=a.ucsIconSetting),a.ucsOrigin&&o.gsView.ucsOrigin.copy(a.ucsOrigin),a.ucsXAxis&&o.gsView.ucsXAxis.copy(a.ucsXAxis),a.ucsYAxis&&o.gsView.ucsYAxis.copy(a.ucsYAxis),a.orthographicType&&(o.gsView.orthographicType=a.orthographicType),a.shadePlotSetting&&(o.gsView.shadePlotSetting=a.shadePlotSetting),a.shadePlotObjectId&&(o.gsView.shadePlotObjectId=a.shadePlotObjectId),a.visualStyleObjectId&&(o.gsView.visualStyleObjectId=a.visualStyleObjectId),a.isDefaultLightingOn&&(o.gsView.isDefaultLightingOn=a.isDefaultLightingOn),a.defaultLightingType&&(o.gsView.defaultLightingType=a.defaultLightingType),a.brightness&&(o.gsView.brightness=a.brightness),a.contrast&&(o.gsView.contrast=a.contrast),a.ambientColor&&(o.gsView.ambientColor=a.ambientColor),e.tables.viewportTable.add(o)})}processLayers(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.LAYER)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new zt;o.colorIndex=a.colorIndex;const c=new cn({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.colorIndex<0,color:o,isPlottable:a.isPlotting});this.processCommonTableEntryAttrs(a,c),e.tables.layerTable.add(c)})}processLineTypes(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.LTYPE)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new ra(a);this.processCommonTableEntryAttrs(a,o),o.name=a.name,e.tables.linetypeTable.add(o)})}processTextStyles(t,e){var r;const s=(r=t.tables.STYLE)==null?void 0:r.entries;s&&s.length>0&&s.forEach(i=>{const a=new ia(i);this.processCommonTableEntryAttrs(i,a),e.tables.textStyleTable.add(a)})}processDimStyles(t,e){var r;const s=(r=t.tables.DIMSTYLE)==null?void 0:r.entries;s&&s.length>0&&s.forEach(i=>{const a={name:i.name,ownerId:i.ownerObjectId,dimpost:i.DIMPOST||"",dimapost:i.DIMAPOST||"",dimscale:i.DIMSCALE,dimasz:i.DIMASZ,dimexo:i.DIMEXO,dimdli:i.DIMDLI,dimexe:i.DIMEXE,dimrnd:i.DIMRND,dimdle:i.DIMDLE,dimtp:i.DIMTP,dimtm:i.DIMTM,dimtxt:i.DIMTXT,dimcen:i.DIMCEN,dimtsz:i.DIMTSZ,dimaltf:i.DIMALTF,dimlfac:i.DIMLFAC,dimtvp:i.DIMTVP,dimtfac:i.DIMTFAC,dimgap:i.DIMGAP,dimaltrnd:i.DIMALTRND,dimtol:i.DIMTOL==null||i.DIMTOL==0?0:1,dimlim:i.DIMLIM==null||i.DIMLIM==0?0:1,dimtih:i.DIMTIH==null||i.DIMTIH==0?0:1,dimtoh:i.DIMTOH==null||i.DIMTOH==0?0:1,dimse1:i.DIMSE1==null||i.DIMSE1==0?0:1,dimse2:i.DIMSE2==null||i.DIMSE2==0?0:1,dimtad:i.DIMTAD,dimzin:i.DIMZIN,dimazin:i.DIMAZIN,dimalt:i.DIMALT,dimaltd:i.DIMALTD,dimtofl:i.DIMTOFL,dimsah:i.DIMSAH,dimtix:i.DIMTIX,dimsoxd:i.DIMSOXD,dimclrd:i.DIMCLRD,dimclre:i.DIMCLRE,dimclrt:i.DIMCLRT,dimadec:i.DIMADEC||0,dimunit:i.DIMUNIT||2,dimdec:i.DIMDEC,dimtdec:i.DIMTDEC,dimaltu:i.DIMALTU,dimalttd:i.DIMALTTD,dimaunit:i.DIMAUNIT,dimfrac:i.DIMFRAC,dimlunit:i.DIMLUNIT,dimdsep:i.DIMDSEP,dimtmove:i.DIMTMOVE||0,dimjust:i.DIMJUST,dimsd1:i.DIMSD1,dimsd2:i.DIMSD2,dimtolj:i.DIMTOLJ,dimtzin:i.DIMTZIN,dimaltz:i.DIMALTZ,dimalttz:i.DIMALTTZ,dimfit:i.DIMFIT||0,dimupt:i.DIMUPT,dimatfit:i.DIMATFIT,dimtxsty:i.DIMTXSTY||"Standard",dimldrblk:i.DIMLDRBLK||"",dimblk:i.DIMBLK||"",dimblk1:i.DIMBLK1||"",dimblk2:i.DIMBLK2||"",dimlwd:i.DIMLWD,dimlwe:i.DIMLWE},o=new Ne(a);this.processCommonTableEntryAttrs(i,o),e.tables.dimStyleTable.add(o)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}}var Oe=(n=>(n.DXF="dxf",n.DWG="dwg",n))(Oe||{});class yt{constructor(){this.events={registered:new st,unregistered:new st},this._converters=new Map,this.register("dxf",new Yi)}static createInstance(){return yt._instance==null&&(yt._instance=new yt),this._instance}static get instance(){return yt._instance||(yt._instance=new yt),yt._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}class Zt extends Rt{constructor(t,e){t=t||{},ee(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const he=class he extends Zt{constructor(){super(),this._origin=new b,this._entities=new Map}get isModelSapce(){return this.name.toLowerCase()==he.MODEL_SPACE_NAME.toLowerCase()}get isPaperSapce(){return this.name.toLowerCase().startsWith(he.PAPER_SPACE_NAME_PREFIX.toLowerCase())}get origin(){return this._origin}set origin(t){this._origin.copy(t)}appendEntity(t){t.database=this.database,t.ownerId=this.objectId,this._entities.set(t.objectId,t),(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}newIterator(){return new $e(this._entities)}getIdAt(t){return this._entities.get(t)}};he.MODEL_SPACE_NAME="*Model_Space",he.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let Mt=he;class Qt extends Rt{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}add(t){t.database=this.database,this._recordsByName.set(t.name,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this._recordsByName.get(t);return e?(this._recordsById.delete(e.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t)}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new $e(this._recordsByName)}}class qi extends Qt{constructor(t){super(t)}get modelSpace(){let t=this.getAt(Mt.MODEL_SPACE_NAME);return t||(t=new Mt,t.name=Mt.MODEL_SPACE_NAME,this.add(t)),t}}class Xi extends Qt{constructor(t){super(t)}}class cn extends Zt{constructor(t,e){t=t||{},ee(t,{color:new zt,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class $i extends Qt{constructor(t){super(t);const e=new zt;e.color=16777215;const s=new cn({name:"0",standardFlags:0,linetype:qe,lineWeight:1,isOff:!1,color:e,isPlottable:!0});this.add(s)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Ki extends Qt{constructor(t){super(t)}}class Zi extends Qt{constructor(t){super(t)}get fonts(){const t=new Set,e=r=>{if(r){const i=r.lastIndexOf(".");if(i>=0){const a=r.substring(0,i).toLowerCase();t.add(a)}else t.add(r.toLowerCase())}},s=this.newIterator();for(const r of s)e(r.fileName),e(r.bigFontFileName);return Array.from(t)}}class Qi extends Qt{constructor(t){super(t)}}class il extends Rt{constructor(){super(),this.events={entityAppended:new st,entityModified:new st,layerAppended:new st,layerModified:new st,layerErased:new st,openProgress:new st,headerSysVarChanged:new st},this._angBase=0,this._angDir=0,this._aunits=Ns.DecimalDegrees,this._celtscale=1,this._cecolor=new zt,this._insunits=Ds.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new qi(this),dimStyleTable:new Xi(this),linetypeTable:new Ki(this),textStyleTable:new Zi(this),layerTable:new $i(this),viewportTable:new Qi(this)},this._dictionaries={layouts:new Ui(this),imageDefs:new hn(this)}}get tables(){return this._tables}get dictionaries(){return this._dictionaries}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this._aunits=t||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(t){this._insunits=t||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(t){this._ltscale=t||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(t){this._cecolor=t||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(t){this._celtscale=t||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(t){this._angBase=t||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(t){this._angDir=t||0,this.triggerHeaderSysVarChangedEvent("angdir")}get pdmode(){return this._pdmode}set pdmode(t){this._pdmode=t||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(t){this._pdsize=t||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(t,e,s=Oe.DXF){const r=yt.instance.get(s);if(r==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await r.read(t,this,e&&e.minimumChunkSize||10,async(i,a,o,c)=>{if(this.events.openProgress.dispatch({database:this,percentage:i,stage:a,stageStatus:o}),e&&e.fontLoader&&a=="FONT"&&o=="END"){const h=c||this.tables.textStyleTable.fonts;await e.fontLoader.load(h)}})}async openUri(t,e){const r=await(await fetch(t)).blob(),i=new FileReader;t.toLowerCase().split(".").pop()==="dwg"?(i.onload=o=>{var h;const c=(h=o.target)==null?void 0:h.result;c&&this.read(c,e,Oe.DWG)},i.readAsArrayBuffer(r)):(i.onload=o=>{var h;const c=(h=o.target)==null?void 0:h.result;c&&this.read(c,e,Oe.DXF)},i.readAsText(r))}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._dictionaries.layouts.removeAll(),this._currentSpace=void 0}triggerHeaderSysVarChangedEvent(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}}var Ji=(n=>(n[n.Center=0]="Center",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.OverFirst=3]="OverFirst",n[n.OverSecond=4]="OverSecond",n))(Ji||{}),ta=(n=>(n[n.Center=0]="Center",n[n.Above=1]="Above",n[n.Outside=2]="Outside",n[n.JIS=3]="JIS",n[n.Below=4]="Below",n))(ta||{}),ea=(n=>(n[n.Feet=0]="Feet",n[n.None=1]="None",n[n.Inch=2]="Inch",n[n.FeetAndInch=3]="FeetAndInch",n[n.Leading=4]="Leading",n[n.Trailing=8]="Trailing",n[n.LeadingAndTrailing=12]="LeadingAndTrailing",n))(ea||{}),sa=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(sa||{}),na=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(na||{});const hs=class hs extends Zt{constructor(t,e){t=t||{},ee(t,hs.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}};hs.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:"Standard",dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Ne=hs;class ra extends Zt{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class ia extends Zt{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}const al={center:new L,viewDirectionFromTarget:new b(0,0,1),viewTarget:new b(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:sn.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new b(0,0,0),ucsXAxis:new b(1,0,0),ucsYAxis:new b(0,1,0),orthographicType:nn.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:rn.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class aa extends Zt{constructor(){super(),this._circleSides=100,this._center=new L,this._lowerLeftCorner=new L(0,0),this._upperRightCorner=new L(1,1),this._snapBase=new L(0,0),this._snapAngle=0,this._snapSpacing=new L(0,0),this._standardFlag=0,this._gridSpacing=new L,this._gridMajor=10,this._gsView=al}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}}class oa{constructor(){this.events={layoutSwitched:new st}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(r,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(r,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(r,s)}renameLayout(t,e,s){const i=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return i?(i.layoutName=e,!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.remove(t)}createLayout(t,e){const s=this.getWorkingDatabase(e),r=new ln;r.layoutName=t,r.tabOrder=s.dictionaries.layouts.maxTabOrder;const i=new Mt;return i.name=`*Paper_Space${r.tabOrder}`,s.tables.blockTable.add(i),s.dictionaries.layouts.setAt(t,r),{layout:r,btr:i}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||dn().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({oldLayout:this.getActiveLayout(),newLayout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function dn(){return ls.instance}const cs=class cs{constructor(){this._workingDatabase=null,this._layoutManager=new oa}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){return this._layoutManager}};cs.instance=new cs;let ls=cs;g.AcCmColor=zt,g.AcCmErrors=et,g.AcCmEventDispatcher=ga,g.AcCmEventManager=st,g.AcCmLoader=Aa,g.AcCmLoadingManager=wn,g.AcCmObject=fn,g.AcCmPerformanceCollector=xs,g.AcCmTask=xn,g.AcCmTaskScheduler=bn,g.AcDb3PointAngularDimension=Fi,g.AcDbAlignedDimension=Bi,g.AcDbAngleUnits=Ns,g.AcDbArc=mi,g.AcDbArcDimension=nl,g.AcDbBatchProcessing=Pn,g.AcDbBlockReference=tn,g.AcDbBlockTable=qi,g.AcDbBlockTableRecord=Mt,g.AcDbCircle=gi,g.AcDbCurve=gt,g.AcDbDatabase=il,g.AcDbDatabaseConverter=Tr,g.AcDbDatabaseConverterManager=yt,g.AcDbDiametricDimension=Vi,g.AcDbDictionary=hn,g.AcDbDimArrowType=Ir,g.AcDbDimStyleTable=Xi,g.AcDbDimStyleTableRecord=Ne,g.AcDbDimTextHorizontal=Ji,g.AcDbDimTextVertical=ta,g.AcDbDimVerticalJustification=na,g.AcDbDimZeroSuppression=ea,g.AcDbDimZeroSuppressionAngular=sa,g.AcDbDimension=Kt,g.AcDbDxfConverter=Yi,g.AcDbEllipse=ui,g.AcDbEntity=pt,g.AcDbFileType=Oe,g.AcDbHatch=_i,g.AcDbHatchPatternType=pi,g.AcDbHatchStyle=yi,g.AcDbHostApplicationServices=ls,g.AcDbLayerTable=$i,g.AcDbLayerTableRecord=cn,g.AcDbLayout=ln,g.AcDbLayoutDictionary=Ui,g.AcDbLayoutManager=oa,g.AcDbLeader=xi,g.AcDbLeaderAnnotationType=fi,g.AcDbLine=bi,g.AcDbLineSpacingStyle=zi,g.AcDbLinetypeTable=Ki,g.AcDbLinetypeTableRecord=ra,g.AcDbMText=wi,g.AcDbObject=Rt,g.AcDbObjectIterator=$e,g.AcDbOrdinateDimension=ji,g.AcDbOsnapMode=Ut,g.AcDbPoint=vi,g.AcDbPolyline=Mi,g.AcDbRadialDimension=Gi,g.AcDbRasterImage=on,g.AcDbRasterImageClipBoundaryType=Li,g.AcDbRasterImageDef=Wi,g.AcDbRasterImageImageDisplayOpt=ki,g.AcDbRay=Oi,g.AcDbRenderingCache=kt,g.AcDbSpline=an,g.AcDbSymbolTable=Qt,g.AcDbSymbolTableRecord=Zt,g.AcDbTable=Ai,g.AcDbText=Ti,g.AcDbTextHorizontalMode=Ii,g.AcDbTextStyleTable=Zi,g.AcDbTextStyleTableRecord=ia,g.AcDbTextVerticalMode=Ei,g.AcDbTrace=Si,g.AcDbUnitsValue=Ds,g.AcDbViewport=Ni,g.AcDbViewportTable=Qi,g.AcDbViewportTableRecord=aa,g.AcDbWipeout=Di,g.AcDbXline=Ri,g.AcGeArea2d=Je,g.AcGeBox2d=K,g.AcGeBox3d=O,g.AcGeCatmullRomCurve3d=hi,g.AcGeCircArc2d=oe,g.AcGeCircArc3d=Xt,g.AcGeCurve2d=ae,g.AcGeEllipseArc2d=es,g.AcGeEllipseArc3d=ss,g.AcGeEuler=ii,g.AcGeGeometryUtil=Xr,g.AcGeLine2d=ns,g.AcGeLine3d=Nt,g.AcGeLoop2d=li,g.AcGeMathUtil=C,g.AcGeMatrix2d=Ke,g.AcGeMatrix3d=Yt,g.AcGeNurbsCurve=mt,g.AcGePlane=Le,g.AcGePoint2d=L,g.AcGePoint3d=b,g.AcGePolyline2d=Ce,g.AcGeQuaternion=Ct,g.AcGeShape2d=Zs,g.AcGeSpline3d=Dt,g.AcGeTol=Ws,g.AcGeVector2d=B,g.AcGeVector3d=w,g.AcGiArrowType=en,g.AcGiDefaultLightingType=rn,g.AcGiMTextAttachmentPoint=le,g.AcGiMTextFlowDirection=is,g.AcGiOrthographicType=nn,g.AcGiRenderMode=sn,g.AcGiViewport=as,g.AcTrStringUtil=wa,g.ByBlock=Pr,g.ByLayer=Xe,g.DEBUG_MODE=xa,g.DEFAULT_LINE_TYPE=qe,g.DEFAULT_TOL=Ys,g.DEG2RAD=Rs,g.DefaultLoadingManager=An,g.FLOAT_TOL=Wt,g.ORIGIN_POINT_2D=Xo,g.ORIGIN_POINT_3D=Us,g.RAD2DEG=zs,g.TAU=H,g.acdbHostApplicationServices=dn,g.basisFunction=Ze,g.calculateCurveLength=Qr,g.ceilPowerOfTwo=Gr,g.clamp=Tt,g.clone=me,g.damp=kr,g.defaults=ee,g.degToRad=Br,g.euclideanModulo=Fs,g.evaluateNurbsPoint=ve,g.floorPowerOfTwo=Hr,g.generateChordKnots=Kr,g.generateSqrtChordKnots=Zr,g.generateUUID=Mr,g.generateUniformKnots=$r,g.has=yn,g.intPartLength=Vs,g.interpolateControlPoints=$o,g.inverseLerp=Lr,g.isBetween=Ur,g.isBetweenAngle=Wr,g.isEmpty=_n,g.isEqual=se,g.isImperialUnits=qo,g.isMetricUnits=Yo,g.isPointInPolygon=qs,g.isPolygonIntersect=qr,g.isPowerOfTwo=jr,g.lerp=Bs,g.log=ue,g.mapLinear=vr,g.normalizeAngle=Me,g.pingpong=Cr,g.radToDeg=Vr,g.randFloat=Rr,g.randFloatSpread=zr,g.randInt=Dr,g.relativeEps=Yr,g.seededRandom=Fr,g.setLogLevel=ba,g.smootherstep=Nr,g.smoothstep=Or,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
1
+ (function(g,ce){typeof exports=="object"&&typeof module<"u"?ce(exports):typeof define=="function"&&define.amd?define(["exports"],ce):(g=typeof globalThis<"u"?globalThis:g||self,ce(g["data-model"]={}))})(this,function(g){"use strict";function ce(n,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in n)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}const Re={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},fs=[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];function de(n,t,e){return Math.max(t,Math.min(e,n))}const mn=class la{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(de(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=de(t,0,256),this._color=fs[t],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(t){if(t){const e=Re[t.toLowerCase()];e!==void 0?(this._colorName=t,this._color=e,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+t)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,e,s){const r=Math.round(de(t,0,255)),i=Math.round(de(e,0,255)),a=Math.round(de(s,0,255));return this.color=(r<<16)+(i<<8)+a,this}setColorName(t){const e=Re[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new la;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[e,s]of Object.entries(Re))if(s===t)return e;return null}getColorIndexByValue(t){const e=fs.length-1;for(let s=1;s<e;++s)if(fs[s]===t)return s;return null}};mn.NAMES=Re;let zt=mn;const et={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class ga{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let r=0,i=s.length;r<i;r++)s[r].call(this,t)}}}let st=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};var pa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ya(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var gn={exports:{}};(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(pa,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],i={},a=null;function o(_,x){var f=_[x];if(typeof f.bind=="function")return f.bind(_);try{return Function.prototype.bind.call(f,_)}catch{return function(){return Function.prototype.apply.apply(f,[_,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function h(_){return _==="debug"&&(_="log"),typeof console===e?!1:_==="trace"&&s?c:console[_]!==void 0?o(console,_):console.log!==void 0?o(console,"log"):t}function d(){for(var _=this.getLevel(),x=0;x<r.length;x++){var f=r[x];this[f]=x<_?t:this.methodFactory(f,_,this.name)}if(this.log=this.debug,typeof console===e&&_<this.levels.SILENT)return"No console available for logging"}function u(_){return function(){typeof console!==e&&(d.call(this),this[_].apply(this,arguments))}}function m(_,x,f){return h(_)||u.apply(this,arguments)}function p(_,x){var f=this,M,T,S,P="loglevel";typeof _=="string"?P+=":"+_:typeof _=="symbol"&&(P=void 0);function z(N){var V=(r[N]||"silent").toUpperCase();if(!(typeof window===e||!P)){try{window.localStorage[P]=V;return}catch{}try{window.document.cookie=encodeURIComponent(P)+"="+V+";"}catch{}}}function I(){var N;if(!(typeof window===e||!P)){try{N=window.localStorage[P]}catch{}if(typeof N===e)try{var V=window.document.cookie,Jt=encodeURIComponent(P),te=V.indexOf(Jt+"=");te!==-1&&(N=/^([^;]+)/.exec(V.slice(te+Jt.length+1))[1])}catch{}return f.levels[N]===void 0&&(N=void 0),N}}function W(){if(!(typeof window===e||!P)){try{window.localStorage.removeItem(P)}catch{}try{window.document.cookie=encodeURIComponent(P)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function lt(N){var V=N;if(typeof V=="string"&&f.levels[V.toUpperCase()]!==void 0&&(V=f.levels[V.toUpperCase()]),typeof V=="number"&&V>=0&&V<=f.levels.SILENT)return V;throw new TypeError("log.setLevel() called with invalid level: "+N)}f.name=_,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=x||m,f.getLevel=function(){return S??T??M},f.setLevel=function(N,V){return S=lt(N),V!==!1&&z(S),d.call(f)},f.setDefaultLevel=function(N){T=lt(N),I()||f.setLevel(N,!1)},f.resetLevel=function(){S=null,W(),d.call(f)},f.enableAll=function(N){f.setLevel(f.levels.TRACE,N)},f.disableAll=function(N){f.setLevel(f.levels.SILENT,N)},f.rebuild=function(){if(a!==f&&(M=lt(a.getLevel())),d.call(f),a===f)for(var N in i)i[N].rebuild()},M=lt(a?a.getLevel():"WARN");var vt=I();vt!=null&&(S=lt(vt)),d.call(f)}a=new p,a.getLogger=function(_){if(typeof _!="symbol"&&typeof _!="string"||_==="")throw new TypeError("You must supply a name when creating a logger.");var x=i[_];return x||(x=i[_]=new p(_,a.methodFactory)),x};var y=typeof window!==e?window.log:void 0;return a.noConflict=function(){return typeof window!==e&&window.log===a&&(window.log=y),a},a.getLoggers=function(){return i},a.default=a,a})})(gn);var pn=gn.exports;const _a=ya(pn),fa=ce({__proto__:null,default:_a},[pn]),xa=!0,ue=fa;ue.setLevel("debug");const ba=n=>{try{ue.setLevel(n)}catch(t){ue.setLevel("error"),ue.error(t)}};function me(n){return n===null||typeof n!="object"?n:Array.isArray(n)?[...n]:{...n}}function ee(n,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&n[s]===void 0&&(n[s]=e[s]);return n}function yn(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function _n(n){return n==null?!0:Array.isArray(n)||typeof n=="string"?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function se(n,t){if(n===t)return!0;if(n==null||t==null)return n===t;if(typeof n!=typeof t)return!1;if(typeof n!="object")return n===t;if(Array.isArray(n)!==Array.isArray(t))return!1;if(Array.isArray(n)){if(n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(!se(n[r],t[r]))return!1;return!0}const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(const r of e)if(!Object.prototype.hasOwnProperty.call(t,r)||!se(n[r],t[r]))return!1;return!0}let fn=class ha{constructor(t,e){this.events={attrChanged:new st,modelChanged:new st},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&ee(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let r;typeof t=="object"?(r=t,s=e):(r={},r[t]=e),s||(s={});const i=s.unset,a=s.silent,o=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=me(this.attributes),this.changed={});const h=this.attributes,d=this.changed,u=this._previousAttributes;for(const m in r)e=r[m],se(h[m],e)||o.push(m),se(u[m],e)?delete d[m]:d[m]=e,i?delete h[m]:h[m]=e;if(!a){o.length&&(this._pending=s);for(let m=0;m<o.length;m++)this.events.attrChanged.dispatch({object:this,attrName:o[m],attrValue:h[o[m]],options:s})}if(c)return this;if(!a)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!_n(this.changed):yn(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?me(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const r in t){const i=t[r];se(e[r],i)||(s[r]=i)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return me(this._previousAttributes)}clone(){const t=me(this.attributes);return new ha(t)}},xs=class De{constructor(){this.entries=new Map}static getInstance(){return De.instance||(De.instance=new De),De.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries)console.log(`${t}:`),console.log(e.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class wa{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,r=Math.max(0,e),i=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(t)/Math.log(s)),o=t/Math.pow(s,a);return`${parseFloat(o.toFixed(r))} ${i[a]}`}}class xn{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class bn{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}scheduleTask(t){return new Promise((e,s)=>{const r=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let r=0;r<e;r++){const i=this.tasks[r];try{s=await this.scheduleTask(async()=>{const a=await i.run(s);return this.onProgress((r+1)/e,i),a})}catch(a){this.onError(a,r,i);return}}this.onComplete(s)}}let wn=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const r=this.handlers[e],i=this.handlers[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return i}return null}};const An=new wn;let Aa=class{constructor(t){this.manager=t!==void 0?t:An,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,r)=>{this.load(t,s,e,r)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};class Pn{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const r=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,0)})}async processChunk(t){let e=0;const s=async()=>{const r=e,i=Math.min(e+this._chunkSize,this._count);await t(r,i),e=i,e<this._count&&await this.scheduleTask(s)};await s()}}var Y,ge,j,U,pe,ht,Z,_t,ct,Ft,ye,_e,Bt,Vt,fe,xe,be,nt,ft,R,jt,we,E,Q,Ae,J,xt,Pe,bt,dt,Ie,Gt,rt,wt,bs,ws,At,Ee,Te,Pt,Se,As,Ps,Ht,q,It,X,it,Is,Es,Ts,Ss,Ms,vs;(Y={})[Y.None=0]="None",Y[Y.Anonymous=1]="Anonymous",Y[Y.NonConstant=2]="NonConstant",Y[Y.Xref=4]="Xref",Y[Y.XrefOverlay=8]="XrefOverlay",Y[Y.ExternallyDependent=16]="ExternallyDependent",Y[Y.ResolvedOrDependent=32]="ResolvedOrDependent",Y[Y.ReferencedXref=64]="ReferencedXref",(ge={})[ge.BYBLOCK=0]="BYBLOCK",ge[ge.BYLAYER=256]="BYLAYER",(j={})[j.Rotated=0]="Rotated",j[j.Aligned=1]="Aligned",j[j.Angular=2]="Angular",j[j.Diameter=3]="Diameter",j[j.Radius=4]="Radius",j[j.Angular3Point=5]="Angular3Point",j[j.Ordinate=6]="Ordinate",j[j.ReferenceIsExclusive=32]="ReferenceIsExclusive",j[j.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",j[j.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(U={})[U.TopLeft=1]="TopLeft",U[U.TopCenter=2]="TopCenter",U[U.TopRight=3]="TopRight",U[U.MiddleLeft=4]="MiddleLeft",U[U.MiddleCenter=5]="MiddleCenter",U[U.MiddleRight=6]="MiddleRight",U[U.BottomLeft=7]="BottomLeft",U[U.BottomCenter=8]="BottomCenter",U[U.BottomRight=9]="BottomRight",(pe={})[pe.AtLeast=1]="AtLeast",pe[pe.Exact=2]="Exact";var In=((ht={})[ht.Center=0]="Center",ht[ht.Above=1]="Above",ht[ht.Outside=2]="Outside",ht[ht.JIS=3]="JIS",ht[ht.Below=4]="Below",ht),ne=((Z={})[Z.Feet=0]="Feet",Z[Z.None=1]="None",Z[Z.Inch=2]="Inch",Z[Z.FeetAndInch=3]="FeetAndInch",Z[Z.Leading=4]="Leading",Z[Z.Trailing=8]="Trailing",Z[Z.LeadingAndTrailing=12]="LeadingAndTrailing",Z),Pa=((_t={})[_t.None=0]="None",_t[_t.Leading=1]="Leading",_t[_t.Trailing=2]="Trailing",_t[_t.LeadingAndTrailing=3]="LeadingAndTrailing",_t),Ia=((ct={})[ct.Center=0]="Center",ct[ct.Left=1]="Left",ct[ct.Right=2]="Right",ct[ct.OverFirst=3]="OverFirst",ct[ct.OverSecond=4]="OverSecond",ct),Ea=((Ft={})[Ft.Bottom=0]="Bottom",Ft[Ft.Center=1]="Center",Ft[Ft.Top=2]="Top",Ft);(ye={})[ye.PatternFill=0]="PatternFill",ye[ye.SolidFill=1]="SolidFill",(_e={})[_e.NonAssociative=0]="NonAssociative",_e[_e.Associative=1]="Associative",(Bt={})[Bt.Normal=0]="Normal",Bt[Bt.Outer=1]="Outer",Bt[Bt.Ignore=2]="Ignore",(Vt={})[Vt.UserDefined=0]="UserDefined",Vt[Vt.Predefined=1]="Predefined",Vt[Vt.Custom=2]="Custom",(fe={})[fe.NotAnnotated=0]="NotAnnotated",fe[fe.Annotated=1]="Annotated",(xe={})[xe.Solid=0]="Solid",xe[xe.Gradient=1]="Gradient",(be={})[be.TwoColor=0]="TwoColor",be[be.OneColor=1]="OneColor";var Ta=((nt={})[nt.Default=0]="Default",nt[nt.External=1]="External",nt[nt.Polyline=2]="Polyline",nt[nt.Derived=4]="Derived",nt[nt.Textbox=8]="Textbox",nt[nt.Outermost=16]="Outermost",nt),ze=((ft={})[ft.Line=1]="Line",ft[ft.Circular=2]="Circular",ft[ft.Elliptic=3]="Elliptic",ft[ft.Spline=4]="Spline",ft),Sa=((R={})[R.Off=0]="Off",R[R.Solid=1]="Solid",R[R.Dashed=2]="Dashed",R[R.Dotted=3]="Dotted",R[R.ShotDash=4]="ShotDash",R[R.MediumDash=5]="MediumDash",R[R.LongDash=6]="LongDash",R[R.DoubleShortDash=7]="DoubleShortDash",R[R.DoubleMediumDash=8]="DoubleMediumDash",R[R.DoubleLongDash=9]="DoubleLongDash",R[R.DoubleMediumLongDash=10]="DoubleMediumLongDash",R[R.SparseDot=11]="SparseDot",R);Sa.Off,(jt={})[jt.Standard=-3]="Standard",jt[jt.ByLayer=-2]="ByLayer",jt[jt.ByBlock=-1]="ByBlock",(we={})[we.English=0]="English",we[we.Metric=1]="Metric",(E={})[E.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",E[E.FRONT_CLIPPING=2]="FRONT_CLIPPING",E[E.BACK_CLIPPING=4]="BACK_CLIPPING",E[E.UCS_FOLLOW=8]="UCS_FOLLOW",E[E.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",E[E.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",E[E.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",E[E.FAST_ZOOM=128]="FAST_ZOOM",E[E.SNAP_MODE=256]="SNAP_MODE",E[E.GRID_MODE=512]="GRID_MODE",E[E.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",E[E.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",E[E.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",E[E.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",E[E.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",E[E.UNUSED=32768]="UNUSED",E[E.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",E[E.VIEWPORT_OFF=131072]="VIEWPORT_OFF",E[E.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",E[E.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",E[E.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",E[E.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(Q={})[Q.OPTIMIZED_2D=0]="OPTIMIZED_2D",Q[Q.WIREFRAME=1]="WIREFRAME",Q[Q.HIDDEN_LINE=2]="HIDDEN_LINE",Q[Q.FLAT_SHADED=3]="FLAT_SHADED",Q[Q.GOURAUD_SHADED=4]="GOURAUD_SHADED",Q[Q.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",Q[Q.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(Ae={})[Ae.UCS_UNCHANGED=0]="UCS_UNCHANGED",Ae[Ae.HAS_OWN_UCS=1]="HAS_OWN_UCS",(J={})[J.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",J[J.TOP=1]="TOP",J[J.BOTTOM=2]="BOTTOM",J[J.FRONT=3]="FRONT",J[J.BACK=4]="BACK",J[J.LEFT=5]="LEFT",J[J.RIGHT=6]="RIGHT",(xt={})[xt.AS_DISPLAYED=0]="AS_DISPLAYED",xt[xt.WIREFRAME=1]="WIREFRAME",xt[xt.HIDDEN=2]="HIDDEN",xt[xt.RENDERED=3]="RENDERED",(Pe={})[Pe.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Pe[Pe.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";function k(n,t,e){return n.code===t&&(e==null||n.value===e)}function D(n){let t={};n.rewind();let e=n.next(),s=e.code;if(t.x=e.value,(e=n.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=n.next()).code!==s+20?n.rewind():t.z=e.value,t}let Ls=Symbol();function v(n,t){return(e,s,r)=>{let i=n.reduce((c,h)=>{h.pushContext&&c.push({});let d=c[c.length-1];for(let u of typeof h.code=="number"?[h.code]:h.code){let m=d[u]??(d[u]=[]);h.isMultiple&&m.length&&console.warn(`Snippet ${m.at(-1).name} for code(${u}) is shadowed by ${h.name}`),m.push(h)}return c},[{}]),a=!1,o=i.length-1;for(;!k(e,0,"EOF");){let c=function(y,_,x){return y.find((f,M)=>{var T;return M>=x&&((T=f[_])==null?void 0:T.length)})}(i,e.code,o),h=c==null?void 0:c[e.code].at(-1);if(!c||!h){s.rewind();break}h.isMultiple||c[e.code].pop();let{name:d,parser:u,isMultiple:m}=h,p=u==null?void 0:u(e,s,r);if(p===Ls){s.rewind();break}if(d){let[y,_]=function(x,f){let M=f.split("."),T=x;for(let S=0;S<M.length-1;++S){let P=M[S];Object.hasOwn(T,P)||(T[P]={}),T=T[P]}return[T,M.at(-1)]}(r,d);m?(Object.hasOwn(y,_)||(y[_]=[]),y[_].push(p)):y[_]=p}h.pushContext&&(o-=1),a=!0,e=s.next()}return t&&Object.setPrototypeOf(r,t),a}}function l({value:n}){return n}function A(n,t){return D(t)}function F({value:n}){return!!n}var En=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function Tn(n,t){var r;if(!k(n,1001))throw Error("XData must starts with code 1001");let e={appName:n.value,value:[]};n=t.next();let s=[e.value];for(;!k(n,0,"EOF")&&n.code>=1e3;){let i=s.at(-1);switch(n.code){case 1002:n.value==="{"?s.push([]):(s.pop(),(r=s.at(-1))==null||r.push(i));break;case 1e3:case 1004:case 1040:case 1070:case 1071:i.push({type:Et(n.code),value:n.value});break;case 1003:i.push({name:"layer",type:Et(n.code),value:n.value});break;case 1005:i.push({name:"handle",type:Et(n.code),value:n.value});break;case 1010:i.push({type:Et(n.code),value:D(t)});break;case 1011:i.push({name:"worldSpacePosition",type:Et(n.code),value:D(t)});break;case 1012:i.push({name:"worldSpaceDisplacement",type:Et(n.code),value:D(t)});break;case 1013:i.push({name:"worldSpaceDirection",type:Et(n.code),value:D(t)});break;case 1041:i.push({name:"distance",type:Et(n.code),value:n.value});break;case 1042:i.push({name:"scale",type:Et(n.code),value:n.value})}n=t.next()}return t.rewind(),e}function Et(n){switch(n){case 1e3:case 1003:case 1005:return"string";case 1004:return"hex";case 1040:case 1041:case 1042:return"real";case 1070:return"integer";case 1071:return"long";case 1010:case 1011:case 1012:case 1013:return"point";default:return""}}function ks(n,t,e){if(k(t,102))return Fe(t,e),!0;switch(t.code){case 0:n.type=t.value;break;case 5:n.handle=t.value;break;case 330:n.ownerDictionarySoftId?n.ownerBlockRecordSoftId=t.value:n.ownerDictionarySoftId=t.value;break;case 360:n.ownerdictionaryHardId=t.value;break;case 67:n.isInPaperSpace=!!t.value;break;case 8:n.layer=t.value;break;case 6:n.lineType=t.value;break;case 347:n.materialObjectHardId=t.value;break;case 62:n.colorIndex=t.value,n.color=En[Math.abs(t.value)];break;case 370:n.lineweight=t.value;break;case 48:n.lineTypeScale=t.value;break;case 60:n.isVisible=!!t.value;break;case 92:n.proxyByte=t.value;break;case 310:n.proxyEntity=t.value;break;case 100:break;case 420:n.color=t.value;break;case 430:n.transparency=t.value;break;case 390:n.plotStyleHardId=t.value;break;case 284:n.shadowMode=t.value;break;case 1001:n.xdata=Tn(t,e);break;default:return!1}return!0}let Ma=0;function Sn(n){if(!n)throw TypeError("entity cannot be undefined or null");n.handle||(n.handle=Ma++)}(bt={})[bt.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",bt[bt.CAST=1]="CAST",bt[bt.RECEIVE=2]="RECEIVE",bt[bt.IGNORE=3]="IGNORE";let G=[{code:1001,name:"xdata",parser:Tn},{code:284,name:"shadowMode",parser:l},{code:390,name:"plotStyleHardId",parser:l},{code:440,name:"transparency",parser:l},{code:430,name:"colorName",parser:l},{code:420,name:"color",parser:l},{code:310,name:"proxyEntity",isMultiple:!0,parser:l},{code:92,name:"proxyByte",parser:l},{code:60,name:"isVisible",parser:F},{code:48,name:"lineTypeScale",parser:l},{code:370,name:"lineweight",parser:l},{code:62,name:"colorIndex",parser(n,t,e){let s=n.value;return e.color=En[Math.abs(s)],s}},{code:347,name:"materialObjectHardId",parser:l},{code:6,name:"lineType",parser:l},{code:8,name:"layer",parser:l},{code:410,name:"layoutTabName",parser:l},{code:67,name:"isInPaperSpace",parser:F},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:l},{code:102,parser:Fe},{code:102,parser:Fe},{code:102,parser:Fe},{code:5,name:"handle",parser:l}];function Fe(n,t){for(n=t.next();!k(n,102)&&!k(n,0,"EOF");)n=t.next()}function Mn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let va={extrusionDirection:{x:0,y:0,z:1}},La=[{code:210,name:"extrusionDirection",parser:A},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:100,name:"subclassMarker",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:A},{code:39,name:"thickness",parser:l},{code:100},...G];class vn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Mn(this,"parser",v(La,va))}}Mn(vn,"ForEntityName","ARC"),(dt={})[dt.NONE=0]="NONE",dt[dt.INVISIBLE=1]="INVISIBLE",dt[dt.CONSTANT=2]="CONSTANT",dt[dt.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",dt[dt.PRESET=8]="PRESET",(Ie={})[Ie.MULTILINE=2]="MULTILINE",Ie[Ie.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Gt={})[Gt.NONE=0]="NONE",Gt[Gt.MIRRORED_X=2]="MIRRORED_X",Gt[Gt.MIRRORED_Y=4]="MIRRORED_Y";var ka=((rt={})[rt.LEFT=0]="LEFT",rt[rt.CENTER=1]="CENTER",rt[rt.RIGHT=2]="RIGHT",rt[rt.ALIGNED=3]="ALIGNED",rt[rt.MIDDLE=4]="MIDDLE",rt[rt.FIT=5]="FIT",rt),Ca=((wt={})[wt.BASELINE=0]="BASELINE",wt[wt.BOTTOM=1]="BOTTOM",wt[wt.MIDDLE=2]="MIDDLE",wt[wt.TOP=3]="TOP",wt);function Ln(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let kn={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:ka.LEFT,valign:Ca.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Cn=[{code:73,name:"valign",parser:l},{code:100},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"endPoint",parser:A},{code:72,name:"valign",parser:l},{code:72,name:"halign",parser:l},{code:71,name:"generationFlag",parser:l},{code:7,name:"styleName",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"xScale",parser:l},{code:50,name:"rotation",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class On{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ln(this,"parser",v(Cn,kn))}}function Nn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Ln(On,"ForEntityName","TEXT");let Oa={...kn},Na=[{code:2},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:A},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:F},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedRecord",parser:F},{code:100},{code:280,name:"isLocked",parser:F},{code:74,name:"valign",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:3,name:"prompt",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},...Cn.slice(2)];class Dn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Nn(this,"parser",v(Na,Oa))}}function Rn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Nn(Dn,"ForEntityName","ATTDEF");let Da={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Ra=[{code:210,name:"extrusionDirection",parser:A},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:A},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class zn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Rn(this,"parser",v(Ra,Da))}}Rn(zn,"ForEntityName","CIRCLE");let Be=class{parseEntity(t,e){let s={};for(;!k(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(r,i,a){switch(i.code){case 100:r.subclassMarker=i.value;break;case 280:r.version=i.value;break;case 2:r.name=i.value;break;case 10:r.definitionPoint=D(a);break;case 11:r.textPoint=D(a);break;case 12:r.insertionPoint=D(a);break;case 13:r.subDefinitionPoint1=D(a);break;case 14:r.subDefinitionPoint2=D(a);break;case 15:r.centerPoint=D(a);break;case 16:r.arcPoint=D(a);break;case 70:r.dimensionType=i.value;break;case 71:r.attachmentPoint=i.value;break;case 72:r.textLineSpacingStyle=i.value;break;case 40:r.leaderLength=i.value;break;case 41:r.textLineSpacingFactor=i.value;break;case 42:r.measurement=i.value;break;case 1:r.text=i.value;break;case 50:r.rotationAngle=i.value;break;case 52:r.obliqueAngle=i.value;break;case 53:r.textRotation=i.value;break;case 51:r.ocsRotation=i.value;break;case 210:r.extrusionDirection=D(a);break;case 3:r.styleName=i.value;break;default:ks(r,i,a)}})(s,e,t),e=t.next()}return s}};function Fn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ws="DIMENSION",(bs="ForEntityName")in Be?Object.defineProperty(Be,bs,{value:ws,enumerable:!0,configurable:!0,writable:!0}):Be[bs]=ws;let za={extrusionDirection:{x:0,y:0,z:1}},Fa=[{code:42,name:"endAngle",parser:l},{code:41,name:"startAngle",parser:l},{code:40,name:"axisRatio",parser:l},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"majorAxisEndPoint",parser:A},{code:10,name:"center",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class Bn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Fn(this,"parser",v(Fa,za))}}Fn(Bn,"ForEntityName","ELLIPSE");let Vn=[{code:330,name:"sourceBoundaryObjects",parser:l,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:l}],Ba=[{code:11,name:"end",parser:A},{code:10,name:"start",parser:A}],Va=[{code:73,name:"isCCW",parser:F},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:A}],ja=[{code:73,name:"isCCW",parser:F},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"lengthOfMinorAxis",parser:l},{code:11,name:"end",parser:A},{code:10,name:"center",parser:A}],Ga=[{code:13,name:"endTangent",parser:A},{code:12,name:"startTangent",parser:A},{code:11,name:"fitDatum",isMultiple:!0,parser:A},{code:97,name:"numberOfFitData",parser:l},{code:10,name:"controlPoints",isMultiple:!0,parser(n,t){let e={...D(t),weight:1};return(n=t.next()).code===42?e.weight=n.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:l},{code:96,name:"numberOfControlPoints",parser:l},{code:95,name:"numberOfKnots",parser:l},{code:74,name:"isPeriodic",parser:F},{code:73,name:"splineFlag",parser:l},{code:94,name:"degree",parser:l}],Ha={[ze.Line]:Ba,[ze.Circular]:Va,[ze.Elliptic]:ja,[ze.Spline]:Ga},Ua=[...Vn,{code:72,name:"edges",parser(n,t){let e={type:n.value},s=v(Ha[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(n=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:l}],Wa=[...Vn,{code:10,name:"vertices",parser(n,t){let e={...D(t),bulge:0};return(n=t.next()).code===42?e.bulge=n.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:l},{code:73,name:"isClosed",parser:F},{code:72,name:"hasBulge",parser:F}],Ya=[{code:49,name:"dashLengths",parser:l,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:l},{code:45,name:"offset",parser:jn},{code:43,name:"base",parser:jn},{code:53,name:"angle",parser:l}];function jn(n,t){let e=n.code+1,s={x:n.value,y:1};return(n=t.next()).code===e?s.y=n.value:t.rewind(),s}function Gn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let qa={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Xa=[{code:470},{code:463},{code:462,name:"colorTint",parser:l},{code:461,name:"gradientDefinition",parser:l},{code:460,name:"gradientRotation",parser:l},{code:453,name:"numberOfColors",parser:l},{code:452,name:"gradientColorFlag",parser:l},{code:451},{code:450,name:"gradientFlag",parser:l},{code:10,name:"seedPoints",parser:A,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:A},{code:98,name:"numberOfSeedPoints",parser:l},{code:47,name:"pixelSize",parser:l},{code:53,name:"definitionLines",parser:function(n,t){let e={};return v(Ya)(n,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:l},{code:77,name:"isDouble",parser:F},{code:73,name:"isAnnotated",parser:F},{code:41,name:"patternScale",parser:l},{code:52,name:"patternAngle",parser:l},{code:76,name:"patternType",parser:l},{code:75,name:"hatchStyle",parser:l},{code:92,name:"boundaryPaths",parser:function(n,t){let e={boundaryPathTypeFlag:n.value},s=e.boundaryPathTypeFlag&Ta.Polyline;return n=t.next(),s?v(Wa)(n,t,e):v(Ua)(n,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:l},{code:71,name:"associativity",parser:l},{code:63,name:"patternFillColor",parser:l},{code:70,name:"solidFill",parser:l},{code:2,name:"patternName",parser:l},{code:210,name:"extrusionDirection",parser:A},{code:10,name:"elevationPoint",parser:A},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...G];class Hn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gn(this,"parser",v(Xa,qa))}}Gn(Hn,"ForEntityName","HATCH"),(At={})[At.ShowImage=1]="ShowImage",At[At.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",At[At.UseClippingBoundary=4]="UseClippingBoundary",At[At.TransparencyIsOn=8]="TransparencyIsOn",(Ee={})[Ee.Rectangular=1]="Rectangular",Ee[Ee.Polygonal=2]="Polygonal",(Te={})[Te.Outside=0]="Outside",Te[Te.Inside=1]="Inside";function Un(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let $a={clippingBoundaryPath:[]},Ka=[{code:90,name:"version",parser:l},{code:10,name:"position",parser:A},{code:11,name:"uPixel",parser:A},{code:12,name:"vPixel",parser:A},{code:13,name:"imageSize",parser:A},{code:340,name:"imageDefHandle",parser:l},{code:70,name:"flags",parser:l},{code:280,name:"clipping",parser:l},{code:281,name:"brightness",parser:l},{code:282,name:"contrast",parser:l},{code:283,name:"fade",parser:l},{code:360,name:"imageDefReactorHandle",parser:l},{code:71,name:"clippingBoundaryType",parser:l},{code:91,name:"countBoundaryPoints",parser:l},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:A},{code:290,name:"clipMode",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Cs{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Un(this,"parser",v(Ka,$a))}}function Wn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Un(Cs,"ForEntityName","IMAGE");let Za={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Qa=[{code:210,name:"extrusionDirection",parser:A},{code:45,name:"rowSpacing",parser:l},{code:44,name:"columnSpacing",parser:l},{code:71,name:"rowCount",parser:l},{code:70,name:"columnCount",parser:l},{code:50,name:"rotation",parser:l},{code:43,name:"zScale",parser:l},{code:42,name:"yScale",parser:l},{code:41,name:"xScale",parser:l},{code:10,name:"insertionPoint",parser:A},{code:2,name:"name",parser:l},{code:66,name:"isVariableAttributes",parser:F},{code:100,name:"subclassMarker",parser:l},...G];class Yn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wn(this,"parser",v(Qa,Za))}}function qn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Wn(Yn,"ForEntityName","INSERT");let Ja={isArrowheadEnabled:!0},to=[{code:213,name:"offsetFromAnnotation",parser:A},{code:212,name:"offsetFromBlock",parser:A},{code:211,name:"horizontalDirection",parser:A},{code:210,name:"normal",parser:A},{code:340,name:"associatedAnnotation",parser:l},{code:77,name:"byBlockColor",parser:l},{code:10,name:"vertices",parser:A,isMultiple:!0},{code:76,name:"numberOfVertices",parser:l},{code:41,name:"textWidth",parser:l},{code:40,name:"textHeight",parser:l},{code:75,name:"isHooklineExists",parser:F},{code:74,name:"isHooklineSameDirection",parser:F},{code:73,name:"leaderCreationFlag",parser:l},{code:72,name:"isSpline",parser:F},{code:71,name:"isArrowheadEnabled",parser:F},{code:3,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Xn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){qn(this,"parser",v(to,Ja))}}qn(Xn,"ForEntityName","LEADER"),(Pt={})[Pt.TextAnnotation=0]="TextAnnotation",Pt[Pt.ToleranceAnnotation=1]="ToleranceAnnotation",Pt[Pt.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Pt[Pt.NoAnnotation=3]="NoAnnotation";function $n(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let eo={thickness:0,extrusionDirection:{x:0,y:0,z:1}},so=[{code:210,name:"extrusionDirection",parser:A},{code:11,name:"endPoint",parser:A},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Kn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){$n(this,"parser",v(so,eo))}}$n(Kn,"ForEntityName","LINE"),(Se={})[Se.IS_CLOSED=1]="IS_CLOSED",Se[Se.PLINE_GEN=128]="PLINE_GEN";let no={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},ro={bulge:0},io=[{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:91,name:"id",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l}],ao=[{code:210,name:"extrusionDirection",parser:A},{code:10,name:"vertices",isMultiple:!0,parser(n,t){let e={};return v(io,ro)(n,t,e),e}},{code:39,name:"thickness",parser:l},{code:38,name:"elevation",parser:l},{code:43,name:"constantWidth",parser:l},{code:70,name:"flag",parser:l},{code:90,name:"numberOfVertices",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class Ve{parseEntity(t,e){let s={};return v(ao,no)(e,t,s),s}}Ps="LWPOLYLINE",(As="ForEntityName")in Ve?Object.defineProperty(Ve,As,{value:Ps,enumerable:!0,configurable:!0,writable:!0}):Ve[As]=Ps,(Ht={})[Ht.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ht[Ht.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ht[Ht.BY_STYLE=5]="BY_STYLE";function oo(n,t){let e={};for(let s of n){let r=t(s);r!=null&&(e[r]??(e[r]=[]),e[r].push(s))}return e}function*je(n,t=1/0,e=1){for(let s=n;s!==t;s+=e)yield s}function Lt(n){return{x:n.x??0,y:n.y??0,z:n.z??0}}function Zn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let lo={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Ge=[{code:46,name:"annotationHeight",parser:l},{code:101,parser(n,t){(function(e){e.rewind();let s=e.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=e.next();while(s.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:l},{code:49,name:"columnGutter",parser:l},{code:48,name:"columnWidth",parser:l},{code:79,name:"columnAutoHeight",parser:l},{code:78,name:"columnFlowReversed",parser:l},{code:76,name:"columnCount",parser:l},{code:75,name:"columnType",parser:l},{code:441,name:"backgroundFillTransparency",parser:l},{code:63,name:"backgroundFillColor",parser:l},{code:45,name:"fillBoxScale",parser:l},{code:[...je(430,440)],name:"backgroundColor",parser:l},{code:[...je(420,430)],name:"backgroundColor",parser:l},{code:90,name:"backgroundFill",parser:l},{code:44,name:"lineSpacing",parser:l},{code:73,name:"lineSpacingStyle",parser:l},{code:50,name:"rotation",parser:l},{code:43},{code:42},{code:11,name:"direction",parser:A},{code:210,name:"extrusionDirection",parser:A},{code:7,name:"styleName",parser:l},{code:3,name:"text",isMultiple:!0,parser:l},{code:1,name:"text",isMultiple:!0,parser:l},{code:72,name:"drawingDirection",parser:l},{code:71,name:"attachmentPoint",parser:l},{code:41,name:"width",parser:l},{code:40,name:"height",parser:l},{code:10,name:"insertionPoint",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class Qn{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zn(this,"parser",v(Ge,lo))}}function Jn(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}Zn(Qn,"ForEntityName","MTEXT");let ho={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},co=[{code:50,name:"angle",parser:l},{code:210,name:"extrusionDirection",parser:A},{code:39,name:"thickness",parser:l},{code:10,name:"position",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class tr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Jn(this,"parser",v(co,ho))}}Jn(tr,"ForEntityName","POINT"),(q={})[q.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",q[q.CURVE_FIT=2]="CURVE_FIT",q[q.SPLINE_FIT=4]="SPLINE_FIT",q[q.POLYLINE_3D=8]="POLYLINE_3D",q[q.POLYGON_3D=16]="POLYGON_3D",q[q.CLOSED_POLYGON=32]="CLOSED_POLYGON",q[q.POLYFACE=64]="POLYFACE",q[q.CONTINUOUS=128]="CONTINUOUS",(It={})[It.NONE=0]="NONE",It[It.QUADRATIC=5]="QUADRATIC",It[It.CUBIC=6]="CUBIC",It[It.BEZIER=8]="BEZIER",(X={})[X.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",X[X.TANGENT_DEFINED=2]="TANGENT_DEFINED",X[X.NOT_USED=4]="NOT_USED",X[X.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",X[X.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",X[X.FOR_POLYLINE=32]="FOR_POLYLINE",X[X.FOR_POLYGON=64]="FOR_POLYGON",X[X.POLYFACE=128]="POLYFACE";function er(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let uo={startWidth:0,endWidth:0,bulge:0},mo=[{code:91,name:"id",parser:l},{code:[...je(71,75)],name:"faces",isMultiple:!0,parser:l},{code:50,name:"tangentDirection",parser:l},{code:70,name:"flag",parser:l},{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:30,name:"z",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l},{code:100,name:"subclassMarker",parser:l},{code:100},...G],sr=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){er(this,"parser",v(mo,uo))}};function nr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}er(sr,"ForEntityName","VERTEX");let go={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},po=[{code:0,name:"vertices",isMultiple:!0,parser:(n,t)=>k(n,0,"VERTEX")?(n=t.next(),new sr().parseEntity(t,n)):Ls},{code:210,name:"extrusionDirection",parser:A},{code:75,name:"smoothType",parser:l},{code:74,name:"surfaceNDensity",parser:l},{code:73,name:"surfaceMDensity",parser:l},{code:72,name:"meshNVertexCount",parser:l},{code:71,name:"meshMVertexCount",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:70,name:"flag",parser:l},{code:39,name:"thickness",parser:l},{code:30,name:"elevation",parser:l},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:l},...G];class rr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nr(this,"parser",v(po,go))}}function ir(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}nr(rr,"ForEntityName","POLYLINE");let yo={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},_o=[{code:10,name:"firstPoint",parser:A},{code:11,name:"unitDirection",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class ar{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ir(this,"parser",v(_o,yo))}}function or(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}ir(ar,"ForEntityName","RAY");let fo={vertices:[],backLineVertices:[]},xo=[{code:360,name:"geometrySettingHardId",parser:l},{code:12,name:"backLineVertices",isMultiple:!0,parser:A},{code:93,name:"numberOfBackLineVertices",parser:l},{code:11,name:"vertices",isMultiple:!0,parser:A},{code:92,name:"verticesCount",parser:l},{code:[63,411],name:"indicatorColor",parser:l},{code:70,name:"indicatorTransparency",parser:l},{code:41,name:"bottomHeight",parser:l},{code:40,name:"topHeight",parser:l},{code:10,name:"verticalDirection",parser:A},{code:1,name:"name",parser:l},{code:91,name:"flag",parser:l},{code:90,name:"state",parser:l},{code:100,name:"subclassMarker",parser:l},...G];class lr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){or(this,"parser",v(xo,fo))}}function hr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}or(lr,"ForEntityName","SECTION");let bo={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},wo=[{code:210,name:"extrusionDirection",parser:A},{code:39,name:"thickness",parser:l},{code:[...je(10,14)],name:"points",isMultiple:!0,parser:A},{code:100,name:"subclassMarker",parser:l},...G];class cr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){hr(this,"parser",v(wo,bo))}}hr(cr,"ForEntityName","SOLID"),(it={})[it.NONE=0]="NONE",it[it.CLOSED=1]="CLOSED",it[it.PERIODIC=2]="PERIODIC",it[it.RATIONAL=4]="RATIONAL",it[it.PLANAR=8]="PLANAR",it[it.LINEAR=16]="LINEAR";function dr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Ao={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Po=[{code:11,name:"fitPoints",isMultiple:!0,parser:A},{code:10,name:"controlPoints",isMultiple:!0,parser:A},{code:41,name:"weights",isMultiple:!0,parser:l},{code:40,name:"knots",isMultiple:!0,parser:l},{code:13,name:"endTangent",parser:A},{code:12,name:"startTangent",parser:A},{code:44,name:"fitTolerance",parser:l},{code:43,name:"controlTolerance",parser:l},{code:42,name:"knotTolerance",parser:l},{code:74,name:"numberOfFitPoints",parser:l},{code:73,name:"numberOfControlPoints",parser:l},{code:72,name:"numberOfKnots",parser:l},{code:71,name:"degree",parser:l},{code:70,name:"flag",parser:l},{code:210,name:"normal",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class ur{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dr(this,"parser",v(Po,Ao))}}dr(ur,"ForEntityName","SPLINE");class He{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=Lt(D(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Lt(D(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerDictionaryId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(r,i){let a=!1,o=!1,c={};for(;!r.isEOF()&&i.code!==0&&!o;)switch(i.code){case 171:if(a){o=!0;continue}c.cellType=i.value,a=!0,i=r.next();break;case 172:c.flagValue=i.value,i=r.next();break;case 173:c.mergedValue=i.value,i=r.next();break;case 174:c.autoFit=i.value,i=r.next();break;case 175:c.borderWidth=i.value,i=r.next();break;case 176:c.borderHeight=i.value,i=r.next();break;case 91:c.overrideFlag=i.value,i=r.next();break;case 178:c.virtualEdgeFlag=i.value,i=r.next();break;case 145:c.rotation=i.value,i=r.next();break;case 345:c.fieldObjetId=i.value,i=r.next();break;case 340:c.blockTableRecordId=i.value,i=r.next();break;case 146:c.blockScale=i.value,i=r.next();break;case 177:c.blockAttrNum=i.value,i=r.next();break;case 7:c.textStyle=i.value,i=r.next();break;case 140:c.textHeight=i.value,i=r.next();break;case 170:c.attachmentPoint=i.value,i=r.next();break;case 92:c.extendedCellFlags=i.value,i=r.next();break;case 285:c.rightBorderVisibility=!!(i.value??!0),i=r.next();break;case 286:c.bottomBorderVisibility=!!(i.value??!0),i=r.next();break;case 288:c.leftBorderVisibility=!!(i.value??!0),i=r.next();break;case 289:c.topBorderVisibility=!!(i.value??!0),i=r.next();break;case 301:(function(h,d,u){for(;u.code!==304;)switch(u.code){case 301:case 93:case 90:case 94:u=d.next();break;case 1:h.text=u.value,u=d.next();break;case 300:h.attrText=u.value,u=d.next();break;case 302:h.text=u.value?u.value:h.text,u=d.next();break;default:console.log(`Ignore code: ${u.code}, value: ${u.value}`),u=d.next()}})(c,r,i),i=r.next();break;default:return c}return a=!1,o=!1,c}(t,e)),e=t.lastReadGroup;break;default:ks(s,e,t),e=t.next()}}return s}}Es="ACAD_TABLE",(Is="ForEntityName")in He?Object.defineProperty(He,Is,{value:Es,enumerable:!0,configurable:!0,writable:!0}):He[Is]=Es;class Ue{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(r,i,a){if(a==="EOF")return!1;switch(a.code){case 0:default:return!1;case 100:r.subclassMarker=a.value;break;case 10:r.viewportCenter=Lt(D(i));break;case 40:r.width=a.value;break;case 41:r.height=a.value;break;case 68:r.status=a.value;break;case 69:r.viewportId=a.value;break;case 12:r.displayCenter=D(i);break;case 13:r.snapBase=D(i);break;case 14:r.snapSpacing=D(i);break;case 15:r.gridSpacing=D(i);break;case 16:r.viewDirection=Lt(D(i));break;case 17:r.targetPoint=Lt(D(i));break;case 42:r.perspectiveLensLength=a.value;break;case 43:r.frontClipZ=a.value;break;case 44:r.backClipZ=a.value;break;case 45:r.viewHeight=a.value;break;case 50:r.snapAngle=a.value;break;case 51:r.viewTwistAngle=a.value;break;case 72:r.circleZoomPercent=a.value;break;case 331:r.frozenLayerIds??(r.frozenLayerIds=[]),r.frozenLayerIds.push(a.value);break;case 90:r.statusBitFlags=a.value;break;case 330:r.ownerBlockRecordSoftId=a.value;break;case 340:r.clippingBoundaryId=a.value;break;case 1:r.sheetName=a.value;break;case 281:r.renderMode=a.value;break;case 71:r.ucsPerViewport=a.value;break;case 110:r.ucsOrigin=Lt(D(i));break;case 111:r.ucsXAxis=Lt(D(i));break;case 112:r.ucsYAxis=Lt(D(i));break;case 345:r.ucsId=a.value;break;case 346:r.ucsBaseId=a.value;break;case 79:r.orthographicType=a.value;break;case 146:r.elevation=a.value;break;case 170:r.shadePlotMode=a.value;break;case 61:r.majorGridFrequency=a.value;break;case 332:r.backgroundId=a.value;break;case 333:r.shadePlotId=a.value;break;case 348:r.visualStyleId=a.value;break;case 292:r.isDefaultLighting=!!a.value;break;case 282:r.defaultLightingType=a.value;break;case 141:r.brightness=a.value;break;case 142:r.contrast=a.value;break;case 63:case 421:case 431:r.ambientLightColor=a.value;break;case 361:r.sunId=a.value;break;case 335:case 343:case 344:case 91:r.softPointer=a.value}return!0}(s,t,e)&&ks(s,e,t),e=t.next()}return s}}Ss="VIEWPORT",(Ts="ForEntityName")in Ue?Object.defineProperty(Ue,Ts,{value:Ss,enumerable:!0,configurable:!0,writable:!0}):Ue[Ts]=Ss;class We extends Cs{parseEntity(t,e){return super.parseEntity(t,e)}}function mr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}vs="WIPEOUT",(Ms="ForEntityName")in We?Object.defineProperty(We,Ms,{value:vs,enumerable:!0,configurable:!0,writable:!0}):We[Ms]=vs;let Io={firstPoint:{x:0,y:0,z:1},extrusionDirection:{x:0,y:0,z:1}},Eo=[{code:10,name:"firstPoint",parser:A},{code:11,name:"unitDirection",parser:A},{code:100,name:"subclassMarker",parser:l},...G];class gr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){mr(this,"parser",v(Eo,Io))}}function pr(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}mr(gr,"ForEntityName","XLINE");let To={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},So=[...Ge.slice(Ge.findIndex(({name:n})=>n==="columnType"),Ge.findIndex(({name:n})=>n==="subclassMarker")+1),{code:100},{code:0,parser(n){if(!k(n,0,"MTEXT"))return Ls}},{code:2,name:"definitionTag",parser:l},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:A},{code:340,name:"secondaryAttributesHardId",parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:F},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedEntriesKeep",parser:F},{code:100},{code:280,name:"lockPositionFlag",parser:F},{code:210,name:"extrusionDirection",parser:A},{code:11,name:"alignmentPoint",parser:A},{code:74,name:"verticalJustification",parser:l},{code:72,name:"horizontalJustification",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:7,name:"textStyle",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"scale",parser:l},{code:50,name:"rotation",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:A},{code:39,name:"thickness",parser:l},{code:100},...G];class yr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){pr(this,"parser",v(So,To))}}pr(yr,"ForEntityName","ATTRIB");let Mo=Object.fromEntries([vn,Dn,yr,zn,Be,Bn,Cs,Yn,Xn,Kn,Ve,Qn,tr,rr,ar,lr,cr,ur,He,On,Hn,Ue,We,gr].map(n=>[n.ForEntityName,new n]));function _r(n,t){let e=[];for(;!k(n,0,"EOF");){if(n.code===0){if(n.value==="ENDBLK"||n.value==="ENDSEC"){t.rewind();break}let s=Mo[n.value];if(s){let r=n.value;n=t.next();let i=s.parseEntity(t,n);i.type=r,Sn(i),e.push(i)}else console.warn(`Unsupported ENTITY type: ${n.value}`)}n=t.next()}return e}function vo(n,t){let e={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");){if(k(n,0,"BLOCK")){let s=Lo(n=t.next(),t);Sn(s),s.name&&(e[s.name]=s)}n=t.next()}return e}function Lo(n,t){let e={};for(;!k(n,0,"EOF");){if(k(n,0,"ENDBLK")){for(n=t.next();!k(n,0,"EOF");){if(k(n,100,"AcDbBlockEnd"))return e;n=t.next()}break}switch(n.code){case 1:e.xrefPath=n.value;break;case 2:e.name=n.value;break;case 3:e.name2=n.value;break;case 5:e.handle=n.value;break;case 8:e.layer=n.value;break;case 10:e.position=D(t);break;case 67:e.paperSpace=!!n.value&&n.value==1;break;case 70:n.value!==0&&(e.type=n.value);break;case 100:break;case 330:e.ownerHandle=n.value;break;case 0:e.entities=_r(n,t)}n=t.next()}return e}function ko(n,t){let e=null,s={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");)n.code===9?e=n.value:n.code===10?s[e]=D(t):s[e]=n.value,n=t.next();return s}let Co=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:l},{code:90,name:"version",parser:l},{code:1,name:"fileName",parser:l},{code:10,name:"size",parser:A},{code:11,name:"sizeOfOnePixel",parser:A},{code:280,name:"isLoaded",parser:l},{code:281,name:"resolutionUnits",parser:l},{code:100,name:"subclassMarker",parser:l}],fr=[{code:333,name:"shadePlotId",parser:l},{code:149,name:"imageOriginY",parser:l},{code:148,name:"imageOriginX",parser:l},{code:147,name:"scaleFactor",parser:l},{code:78,name:"shadePlotCustomDPI",parser:l},{code:77,name:"shadePlotResolution",parser:l},{code:76,name:"shadePlotMode",parser:l},{code:75,name:"standardScaleType",parser:l},{code:7,name:"currentStyleSheet",parser:l},{code:74,name:"plotType",parser:l},{code:73,name:"plotRotation",parser:l},{code:72,name:"paperUnit",parser:l},{code:70,name:"layoutFlag",parser:l},{code:143,name:"printScaleDenominator",parser:l},{code:142,name:"printScaleNominator",parser:l},{code:141,name:"windowAreaYMax",parser:l},{code:140,name:"windowAreaYMin",parser:l},{code:49,name:"windowAreaXMax",parser:l},{code:48,name:"windowAreaXMin",parser:l},{code:47,name:"plotOriginY",parser:l},{code:46,name:"plotOriginX",parser:l},{code:45,name:"paperHeight",parser:l},{code:44,name:"paperWidth",parser:l},{code:43,name:"marginTop",parser:l},{code:42,name:"marginRight",parser:l},{code:41,name:"marginBottom",parser:l},{code:40,name:"marginLeft",parser:l},{code:6,name:"plotViewName",parser:l},{code:4,name:"paperSize",parser:l},{code:2,name:"configName",parser:l},{code:1,name:"pageSetupName",parser:l},{code:100,name:"subclassMarker",parser:l}],Oo=[{code:333,name:"shadePlotId",parser:l},{code:346,name:"orthographicUcsId",parser:l},{code:345,name:"namedUcsId",parser:l},{code:331,name:"viewportId",parser:l},{code:330,name:"paperSpaceTableId",parser:l},{code:76,name:"orthographicType",parser:l},{code:17,name:"ucsYAxis",parser:A},{code:16,name:"ucsXAxis",parser:A},{code:13,name:"ucsOrigin",parser:A},{code:146,name:"elevation",parser:l},{code:15,name:"maxExtent",parser:A},{code:14,name:"minExtent",parser:A},{code:12,name:"insertionBase",parser:A},{code:11,name:"maxLimit",parser:A},{code:10,name:"minLimit",parser:A},{code:71,name:"tabOrder",parser:l},{code:70,name:"controlFlag",parser:l},{code:1,name:"layoutName",parser:l},{code:100,name:"subclassMarker",parser:l},...fr],No=[{code:330,name:"ownerObjectId",parser:l},{code:102},{code:360,name:"ownerDictionaryIdHard",parser:l},{code:102},{code:102},{code:330,name:"ownerDictionaryIdSoft",parser:l},{code:102},{code:102},{code:102},{code:5,name:"handle",parser:l}];function xr(n){return n.subclassMarker==="AcDbDictionary"}let Do={LAYOUT:Oo,PLOTSETTINGS:fr,DICTIONARY:[{code:3,name:"entries",parser:(n,t)=>{let e={name:n.value};return(n=t.next()).code===350?e.objectId=n.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:l},{code:280,name:"isHardOwned",parser:F},{code:100,name:"subclassMarker",parser:l}],IMAGEDEF:Co};function Ro(n,t){let e=[];for(;n.code!==0||!["EOF","ENDSEC"].includes(n.value);){let s=n.value,r=Do[s];if(n.code===0&&(r!=null&&r.length)){let i=v([...No,...r]),a={name:s};i(n=t.next(),t,a)?(e.push(a),n=t.peek()):n=t.next()}else n=t.next()}return{byName:oo(e,({name:s})=>s),byTree:function(s){let r=Object.fromEntries(s.map(i=>[i.handle,i]));for(let i of s)(!xr(i)||i.ownerDictionaryIdSoft!=="0")&&(i.ownerDictionaryIdSoft&&(i.ownerDictionarySoft=r[i.ownerDictionaryIdSoft]),i.ownerDictionaryIdHard&&(i.ownerDictionaryHard=r[i.ownerDictionaryIdHard]),i.ownerObjectId&&(i.ownerObject=r[i.ownerObjectId])),function(a,o){xr(a)&&a.entries&&(a.entries=Object.fromEntries(a.entries.map(({name:c,objectId:h})=>[c,o[h]])))}(i,r);return s[0]}(e)}}let re=[{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102,parser(n,t){for(;!k(n,0,"EOF")&&!k(n,102,"}");)n=t.next()}},{code:5,name:"handle",parser:l}],zo=v([{code:310,name:"bmpPreview",parser:l},{code:281,name:"scalability",parser:l},{code:280,name:"explodability",parser:l},{code:70,name:"insertionUnits",parser:l},{code:340,name:"layoutObjects",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),Fo=v([...[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:In.Above,defaultValueImperial:In.Center},{name:"DIMZIN",code:78,defaultValue:ne.Trailing,defaultValueImperial:ne.Feet},{name:"DIMAZIN",code:79,defaultValue:Pa.None},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:2,defaultValueImperial:4},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:",",defaultValueImperial:"."},{name:"DIMJUST",code:280,defaultValue:Ia.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Ea.Center},{name:"DIMTZIN",code:284,defaultValue:ne.Trailing,defaultValueImperial:ne.Feet},{name:"DIMALTZ",code:285,defaultValue:ne.Trailing},{name:"DIMALTTZ",code:286,defaultValue:ne.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}].map(n=>({...n,parser:l})),{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},{code:105,name:"handle",parser:l},...re.filter(n=>n.code!==5)]),Bo=v([{code:347,name:"materialObjectId",parser:l},{code:390,name:"plotStyleNameObjectId",parser:l},{code:370,name:"lineweight",parser:l},{code:290,name:"isPlotting",parser:F},{code:6,name:"lineType",parser:l},{code:62,name:"colorIndex",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),Vo=v([{code:9,name:"text",parser:l},{code:45,name:"offsetY",parser:l},{code:44,name:"offsetX",parser:l},{code:50,name:"rotation",parser:l},{code:46,name:"scale",parser:l},{code:340,name:"styleObjectId",parser:l},{code:75,name:"shapeNumber",parser:l},{code:74,name:"elementTypeFlag",parser:l},{code:49,name:"elementLength",parser:l}],{elementTypeFlag:0,elementLength:0}),jo={BLOCK_RECORD:zo,DIMSTYLE:Fo,LAYER:Bo,LTYPE:v([{code:49,name:"pattern",parser(n,t){let e={};return Vo(n,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:l},{code:73,name:"numberOfLineTypes",parser:l},{code:72,parser:l},{code:3,name:"description",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),STYLE:v([{code:1e3,name:"extendedFont",parser:l},{code:1001},{code:4,name:"bigFont",parser:l},{code:3,name:"font",parser:l},{code:42,name:"lastHeight",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:50,name:"obliqueAngle",parser:l},{code:41,name:"widthFactor",parser:l},{code:40,name:"fixedTextHeight",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re]),VPORT:v([{code:[63,421,431],name:"ambientColor",parser:l},{code:142,name:"contrast",parser:l},{code:141,name:"brightness",parser:l},{code:282,name:"defaultLightingType",parser:l},{code:292,name:"isDefaultLightingOn",parser:F},{code:348,name:"visualStyleObjectId",parser:l},{code:333,name:"shadePlotObjectId",parser:l},{code:332,name:"backgroundObjectId",parser:l},{code:61,name:"majorGridLines",parser:l},{code:170,name:"shadePlotSetting",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:112,name:"ucsYAxis",parser:A},{code:111,name:"ucsXAxis",parser:A},{code:110,name:"ucsOrigin",parser:A},{code:74,name:"ucsIconSetting",parser:l},{code:71,name:"viewMode",parser:l},{code:281,name:"renderMode",parser:l},{code:1,name:"styleSheet",parser:l},{code:[331,441],name:"frozenLayers",parser:l,isMultiple:!0},{code:72,name:"circleSides",parser:l},{code:51,name:"viewTwistAngle",parser:l},{code:50,name:"snapRotationAngle",parser:l},{code:45,name:"viewHeight",parser:l},{code:44,name:"backClippingPlane",parser:l},{code:43,name:"frontClippingPlane",parser:l},{code:42,name:"lensLength",parser:l},{code:17,name:"viewTarget",parser:A},{code:16,name:"viewDirectionFromTarget",parser:A},{code:15,name:"gridSpacing",parser:A},{code:14,name:"snapSpacing",parser:A},{code:13,name:"snapBasePoint",parser:A},{code:12,name:"center",parser:A},{code:11,name:"upperRightCorner",parser:A},{code:10,name:"lowerLeftCorner",parser:A},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...re])},Go=v([{code:70,name:"maxNumberOfEntries",parser:l},{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:l},{code:2,name:"name",parser:l}]);function Ho(n,t){var s;let e={};for(;!k(n,0,"EOF")&&!k(n,0,"ENDSEC");){if(k(n,0,"TABLE")){n=t.next();let r={entries:[]};Go(n,t,r),e[r.name]=r}if(k(n,0)&&!k(n,0,"ENDTAB")){let r=n.value;n=t.next();let i=jo[r];if(!i){console.warn(`parseTable: Invalid table name '${r}'`),n=t.next();continue}let a={};i(n,t,a),(s=e[r])==null||s.entries.push(a)}n=t.next()}return e}function Ye(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}class br{next(){if(!this.hasNext())return this._eof?console.warn("Cannot call 'next' after EOF group has been read"):console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=wr(t,this._data[this._pointer++]),s={code:t,value:e};return k(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=wr(t.code,this._data[this._pointer+1]),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t){Ye(this,"_pointer",void 0),Ye(this,"_data",void 0),Ye(this,"_eof",void 0),Ye(this,"lastReadGroup",{code:0,value:0}),this._pointer=0,this._data=t,this._eof=!1}}function wr(n,t){return n<=9?t:n>=10&&n<=59?parseFloat(t.trim()):n>=60&&n<=99?parseInt(t.trim()):n>=100&&n<=109?t:n>=110&&n<=149?parseFloat(t.trim()):n>=160&&n<=179?parseInt(t.trim()):n>=210&&n<=239?parseFloat(t.trim()):n>=270&&n<=289?parseInt(t.trim()):n>=290&&n<=299?function(e){if(e==="0")return!1;if(e==="1")return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}(t.trim()):n>=300&&n<=369?t:n>=370&&n<=389?parseInt(t.trim()):n>=390&&n<=399?t:n>=400&&n<=409?parseInt(t.trim()):n>=410&&n<=419?t:n>=420&&n<=429?parseInt(t.trim()):n>=430&&n<=439?t:n>=440&&n<=459?parseInt(t.trim()):n>=460&&n<=469?parseFloat(t.trim()):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?t:n>=1010&&n<=1059?parseFloat(t.trim()):n>=1060&&n<=1071?parseInt(t.trim()):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:t}),t)}function Os(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}let Uo=class{constructor(){Os(this,"encoding","utf-8"),Os(this,"encodingFailureFatal",!1)}};class Wo extends EventTarget{parseSync(t){let e=new br(t.split(/\r\n|\r|\n/g));if(!e.hasNext())throw Error("Empty file");return this.parseAll(e)}parseStream(t){let e="",s=this;return new Promise((r,i)=>{t.on("data",a=>{e+=a}),t.on("end",()=>{try{let a=e.split(/\r\n|\r|\n/g),o=new br(a);if(!o.hasNext())throw Error("Empty file");r(s.parseAll(o))}catch(a){i(a)}}),t.on("error",a=>{i(a)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let r=s.body.getReader(),i="";for(;;){let{done:a,value:o}=await r.read();if(a){i+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}i+=this._decoder.decode(o,{stream:!0})}return this.parseSync(i)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!k(s,0,"EOF");)k(s,0,"SECTION")&&(k(s=t.next(),2,"HEADER")?(s=t.next(),e.header=ko(s,t)):k(s,2,"BLOCKS")?(s=t.next(),e.blocks=vo(s,t)):k(s,2,"ENTITIES")?(s=t.next(),e.entities=_r(s,t)):k(s,2,"TABLES")?(s=t.next(),e.tables=Ho(s,t)):k(s,2,"OBJECTS")&&(s=t.next(),e.objects=Ro(s,t))),s=t.next();return e}constructor(t=new Uo){super(),Os(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}var Ns=(n=>(n[n.DecimalDegrees=0]="DecimalDegrees",n[n.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",n[n.Gradians=2]="Gradians",n[n.Radians=3]="Radians",n[n.SurveyorsUnits=4]="SurveyorsUnits",n))(Ns||{});class kt{static get instance(){return this._instance||(this._instance=new kt),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,r=!0,i,a){const o=[];if(e!=null){const c=this.createKey(e.name,s);let h;if(this.has(c))h=this.get(c);else{const d=e.newIterator();for(const u of d)if(u.color.isByBlock&&s){Ar.copy(u.color),u.color.color=s;const m=u.draw(t);m&&o.push(m),u.color.copy(Ar)}else{const m=u.draw(t);m&&o.push(m)}h=t.group(o),h&&r&&this.set(c,h)}return h&&i&&(h.applyMatrix(i),a&&(a.x!=0||a.y!=0||a.z!=1)&&(i.setFromExtrusionDirection(a),h.applyMatrix(i))),h}else return t.group(o)}}const Ar=new zt,qe="Continuous",Xe="ByLayer",Pr="ByBlock";var Ut=(n=>(n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(Ut||{}),Ds=(n=>(n[n.Undefined=0]="Undefined",n[n.Inches=1]="Inches",n[n.Feet=2]="Feet",n[n.Miles=3]="Miles",n[n.Millimeters=4]="Millimeters",n[n.Centimeters=5]="Centimeters",n[n.Meters=6]="Meters",n[n.Kilometers=7]="Kilometers",n[n.Microinches=8]="Microinches",n[n.Mils=9]="Mils",n[n.Yards=10]="Yards",n[n.Angstroms=11]="Angstroms",n[n.Nanometers=12]="Nanometers",n[n.Microns=13]="Microns",n[n.Decimeters=14]="Decimeters",n[n.Dekameters=15]="Dekameters",n[n.Hectometers=16]="Hectometers",n[n.Gigameters=17]="Gigameters",n[n.Astronomical=18]="Astronomical",n[n.LightYears=19]="LightYears",n[n.Parsecs=20]="Parsecs",n[n.USSurveyFeet=21]="USSurveyFeet",n[n.USSurveyInch=22]="USSurveyInch",n[n.USSurveyYard=23]="USSurveyYard",n[n.USSurveyMile=24]="USSurveyMile",n[n.Max=24]="Max",n))(Ds||{});function Yo(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function qo(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}var Ir=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(Ir||{});class $e{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const Er="Load Database";class tt extends xn{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=xs.getInstance().getEntry(Er),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const r=await this.data.task(t);if(this.progress){const i=r.data;await this.progress(this.data.progress.value,this.data.stage,"END",i),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)}return e&&(e.data[this.name]=Date.now()-s),r}}class Tr{async read(t,e,s,r){const i={name:Er,data:{total:0},format(){let h="";return Object.keys(this.data).forEach(d=>{d!=="total"&&(h+=`- ${d}: ${this.data[d]} ms
2
+ `)}),h+=`- total: ${this.data.total} ms`,h}};xs.getInstance().collect(i),this.progress=r;const a={value:0},o=new bn;o.setCompleteCallback(()=>this.onFinished()),o.setErrorCallback(()=>this.onFinished()),o.addTask(new tt({stage:"START",step:1,progress:a,task:async h=>h},r)),o.addTask(new tt({stage:"PARSE",step:5,progress:a,task:async h=>({model:await this.parse(h)})},r)),o.addTask(new tt({stage:"FONT",step:5,progress:a,task:async h=>{const d=this.getFonts(h.model);return{model:h.model,data:d}}},r)),o.addTask(new tt({stage:"LTYPE",step:1,progress:a,task:async h=>(this.processLineTypes(h.model,e),h)},r)),o.addTask(new tt({stage:"STYLE",step:1,progress:a,task:async h=>(this.processTextStyles(h.model,e),h)},r)),o.addTask(new tt({stage:"DIMSTYLE",step:1,progress:a,task:async h=>(this.processDimStyles(h.model,e),h)},r)),o.addTask(new tt({stage:"LAYER",step:1,progress:a,task:async h=>(this.processLayers(h.model,e),h)},r)),o.addTask(new tt({stage:"VPORT",step:1,progress:a,task:async h=>(this.processViewports(h.model,e),h)},r)),o.addTask(new tt({stage:"HEADER",step:1,progress:a,task:async h=>(this.processHeader(h.model,e),h)},r)),o.addTask(new tt({stage:"BLOCK_RECORD",step:5,progress:a,task:async h=>(this.processBlockTables(h.model,e),h)},r)),o.addTask(new tt({stage:"OBJECT",step:5,progress:a,task:async h=>(this.processObjects(h.model,e),h)},r)),o.addTask(new tt({stage:"BLOCK",step:5,progress:a,task:async h=>(await this.processBlocks(h.model,e),h)},r)),o.addTask(new tt({stage:"ENTITY",step:100,progress:a,task:async h=>(await this.processEntities(h.model,e,s,a,r),h)},r)),o.addTask(new tt({stage:"END",step:0,progress:a,task:async h=>h},r));const c=Date.now();await o.run(t),i.data.total=Date.now()-c}onFinished(){this.progress&&(this.progress(100,"END","END"),kt.instance.clear())}parse(t){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,r,i){throw new Error("Not impelemented yet!")}}const $=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Sr=1234567;const Rs=Math.PI/180,zs=180/Math.PI;function Mr(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return($[n&255]+$[n>>8&255]+$[n>>16&255]+$[n>>24&255]+"-"+$[t&255]+$[t>>8&255]+"-"+$[t>>16&15|64]+$[t>>24&255]+"-"+$[e&63|128]+$[e>>8&255]+"-"+$[e>>16&255]+$[e>>24&255]+$[s&255]+$[s>>8&255]+$[s>>16&255]+$[s>>24&255]).toLowerCase()}function Tt(n,t,e){return Math.max(t,Math.min(e,n))}function Fs(n,t){return(n%t+t)%t}function vr(n,t,e,s,r){return s+(n-t)*(r-s)/(e-t)}function Lr(n,t,e){return n!==t?(e-n)/(t-n):0}function Bs(n,t,e){return(1-e)*n+e*t}function kr(n,t,e,s){return Bs(n,t,1-Math.exp(-e*s))}function Cr(n,t=1){return t-Math.abs(Fs(n,t*2)-t)}function Or(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function Nr(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function Dr(n,t){return n+Math.floor(Math.random()*(t-n+1))}function Rr(n,t){return n+Math.random()*(t-n)}function zr(n){return n*(.5-Math.random())}function Fr(n){n!==void 0&&(Sr=n);let t=Sr+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Br(n){return n*Rs}function Vr(n){return n*zs}function jr(n){return(n&n-1)===0&&n!==0}function Gr(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Hr(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Me(n){const t=Math.PI*2;return(n%t+t)%t}function Ur(n,t,e){return n>t&&n<e||n>e&&n<t}function Wr(n,t,e,s=!1){return n=Me(n),t=Me(t),e=Me(e),s?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function Vs(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function Yr(n,t=1e-7){const e=Vs(n);return Math.max(Math.pow(10,e)*t,t)}const C={DEG2RAD:Rs,RAD2DEG:zs,generateUUID:Mr,clamp:Tt,euclideanModulo:Fs,mapLinear:vr,inverseLerp:Lr,lerp:Bs,damp:kr,pingpong:Cr,smoothstep:Or,smootherstep:Nr,randInt:Dr,randFloat:Rr,randFloatSpread:zr,seededRandom:Fr,degToRad:Br,radToDeg:Vr,isPowerOfTwo:jr,ceilPowerOfTwo:Gr,floorPowerOfTwo:Hr,normalizeAngle:Me,isBetween:Ur,isBetweenAngle:Wr,intPartLength:Vs,relativeEps:Yr},js=class ca{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:r,y:i}=t;this.x=r,this.y=i;return}if(s===2){this.x=t,this.y=e;return}throw et.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new ca(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6],this.y=r[1]*e+r[4]*s+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*s-a*r+t.x,this.y=i*r+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(C.relativeEps(this.x,t),C.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};js.EMPTY=Object.freeze(new js(0,0));let B=js;const Gs=class da{constructor(t,e,s,r,i,a,o,c,h){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&r!=null&&i!=null&&a!=null&&o!=null&&c!=null&&h!=null&&this.set(t,e,s,r,i,a,o,c,h)}set(t,e,s,r,i,a,o,c,h){const d=this.elements;return d[0]=t,d[1]=r,d[2]=o,d[3]=e,d[4]=i,d[5]=c,d[6]=s,d[7]=a,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,i=this.elements,a=s[0],o=s[3],c=s[6],h=s[1],d=s[4],u=s[7],m=s[2],p=s[5],y=s[8],_=r[0],x=r[3],f=r[6],M=r[1],T=r[4],S=r[7],P=r[2],z=r[5],I=r[8];return i[0]=a*_+o*M+c*P,i[3]=a*x+o*T+c*z,i[6]=a*f+o*S+c*I,i[1]=h*_+d*M+u*P,i[4]=h*x+d*T+u*z,i[7]=h*f+d*S+u*I,i[2]=m*_+p*M+y*P,i[5]=m*x+p*T+y*z,i[8]=m*f+p*S+y*I,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],h=t[7],d=t[8];return e*a*d-e*o*h-s*i*d+s*o*c+r*i*h-r*a*c}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],h=t[7],d=t[8],u=d*a-o*h,m=o*c-d*i,p=h*i-a*c,y=e*u+s*m+r*p;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return t[0]=u*_,t[1]=(r*h-d*s)*_,t[2]=(o*s-r*a)*_,t[3]=m*_,t[4]=(d*e-r*c)*_,t[5]=(r*i-o*e)*_,t[6]=p*_,t[7]=(s*c-h*e)*_,t[8]=(a*e-s*i)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,r,i,a,o){const c=Math.cos(i),h=Math.sin(i);return this.set(s*c,s*h,-s*(c*a+h*o)+a+t,-r*h,r*c,-r*(-h*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Hs.makeScale(t,e)),this}rotate(t){return this.premultiply(Hs.makeRotation(-t)),this}translate(t,e){return this.premultiply(Hs.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof B?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let r=0;r<9;r++)if(e[r]!==s[r])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new da().fromArray(this.elements)}};Gs.IDENTITY=Object.freeze(new Gs);let Ke=Gs;const Hs=new Ke,Wt=1e-6,H=2*Math.PI,Xo={x:0,y:0},Us={x:0,y:0,z:0};class Ws{constructor(){this.equalPointTol=Wt,this.equalVectorTol=Wt}equalPoint2d(t,e){return new B(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new w(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=Wt){return t<e&&t>-e}static equal(t,e,s=Wt){return Math.abs(t-e)<s}static great(t,e,s=Wt){return t-e>s}static less(t,e,s=Wt){return t-e<s}}const Ys=new Ws;function qs(n,t,e=!1){const s=n.x,r=n.y;let i=!1;const a=t.length;for(let o=0,c=a-1;o<a;c=o++){const h=t[o].x,d=t[o].y,u=t[c].x,m=t[c].y;let p=d>r!=m>r;e&&(p=d>=r!=m>=r),p&&s<(u-h)*(r-d)/(m-d)+h&&(i=!i)}return i}function qr(n,t){if(n.length===0||t.length===0)return!1;const e=new K().setFromPoints(n),s=new K().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let r=0;r<n.length;){if(qs(n[r],t,!0))return!0;r<n.length-1&&Ys.equalPoint2d(n[r+1],n[r])&&++r,++r}return!1}const Xr={isPointInPolygon:qs,isPolygonIntersect:qr};function $r(n,t){const e=[],s=t-1,r=n;for(let i=0;i<=r;i++)e.push(0);for(let i=1;i<=s-r;i++)e.push(i);for(let i=0;i<=r;i++)e.push(s-r+1);return e}function Kr(n,t){const e=t.length-1,s=n,r=[0];let i=0;for(let o=1;o<=e;o++){const c=t[o][0]-t[o-1][0],h=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(c*c+h*h+d*d);i+=u,r.push(i)}const a=[];for(let o=0;o<=s;o++)a.push(0);for(let o=1;o<=e-s;o++){const c=r[o]/i;a.push(c*(e-s+1))}for(let o=0;o<=s;o++)a.push(e-s+1);return a}function Zr(n,t){const e=t.length-1,s=n,r=[0];let i=0;for(let o=1;o<=e;o++){const c=t[o][0]-t[o-1][0],h=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(c*c+h*h+d*d),m=Math.sqrt(u);i+=m,r.push(i)}const a=[];for(let o=0;o<=s;o++)a.push(0);for(let o=1;o<=e-s;o++){const c=r[o]/i;a.push(c*(e-s+1))}for(let o=0;o<=s;o++)a.push(e-s+1);return a}function Ze(n,t,e,s){if(t===0)return e>=s[n]&&e<s[n+1]?1:0;const r=s[n+t]-s[n],i=s[n+t+1]-s[n+1],a=r>1e-10?(e-s[n])/r:0,o=i>1e-10?(s[n+t+1]-e)/i:0;return a*Ze(n,t-1,e,s)+o*Ze(n+1,t-1,e,s)}function ve(n,t,e,s,r){const i=s.length-1,a=t;if(n=Math.max(e[a],Math.min(e[i+1],n)),Math.abs(n-e[i+1])<1e-8)return[...s[i]];if(Math.abs(n-e[a])<1e-8)return[...s[0]];const o=[0,0,0];let c=0;for(let h=0;h<=i;h++){const d=Ze(h,a,n,e),u=r[h]*d;o[0]+=s[h][0]*u,o[1]+=s[h][1]*u,o[2]+=s[h][2]*u,c+=u}if(c<1e-10){const h=e[e.length-a-1];if(Math.abs(n-h)<1e-8)return[...s[i]];if(Math.abs(n-e[a])<1e-8)return[...s[0]]}return c>1e-10&&(o[0]/=c,o[1]/=c,o[2]/=c),o}function Qr(n,t,e,s){const r=n,i=t[r],a=t[t.length-r-1];let o=0;const c=1e3,h=(a-i)/c;let d=ve(i,n,t,e,s);for(let _=1;_<=c;_++){const x=i+_*h,f=ve(x,n,t,e,s),M=f[0]-d[0],T=f[1]-d[1],S=f[2]-d[2];o+=Math.sqrt(M*M+T*T+S*S),d=f}const u=ve(a,n,t,e,s),m=u[0]-d[0],p=u[1]-d[1],y=u[2]-d[2];return o+=Math.sqrt(m*m+p*p+y*y),o}function $o(n){return n.map(t=>[...t])}class Ct{constructor(t=0,e=0,s=0,r=1){this._x=t,this._y=e,this._z=s,this._w=r}static slerpFlat(t,e,s,r,i,a,o){let c=s[r+0],h=s[r+1],d=s[r+2],u=s[r+3];const m=i[a+0],p=i[a+1],y=i[a+2],_=i[a+3];if(o===0){t[e+0]=c,t[e+1]=h,t[e+2]=d,t[e+3]=u;return}if(o===1){t[e+0]=m,t[e+1]=p,t[e+2]=y,t[e+3]=_;return}if(u!==_||c!==m||h!==p||d!==y){let x=1-o;const f=c*m+h*p+d*y+u*_,M=f>=0?1:-1,T=1-f*f;if(T>Number.EPSILON){const P=Math.sqrt(T),z=Math.atan2(P,f*M);x=Math.sin(x*z)/P,o=Math.sin(o*z)/P}const S=o*M;if(c=c*x+m*S,h=h*x+p*S,d=d*x+y*S,u=u*x+_*S,x===1-o){const P=1/Math.sqrt(c*c+h*h+d*d+u*u);c*=P,h*=P,d*=P,u*=P}}t[e]=c,t[e+1]=h,t[e+2]=d,t[e+3]=u}static multiplyQuaternionsFlat(t,e,s,r,i,a){const o=s[r],c=s[r+1],h=s[r+2],d=s[r+3],u=i[a],m=i[a+1],p=i[a+2],y=i[a+3];return t[e]=o*y+d*u+c*p-h*m,t[e+1]=c*y+d*m+h*u-o*p,t[e+2]=h*y+d*p+o*m-c*u,t[e+3]=d*y-o*u-c*m-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,r){return this._x=t,this._y=e,this._z=s,this._w=r,this._onChangeCallback(),this}clone(){return new Ct(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t.x,r=t.y,i=t.z,a=t.order,o=Math.cos,c=Math.sin,h=o(s/2),d=o(r/2),u=o(i/2),m=c(s/2),p=c(r/2),y=c(i/2);switch(a){case"XYZ":this._x=m*d*u+h*p*y,this._y=h*p*u-m*d*y,this._z=h*d*y+m*p*u,this._w=h*d*u-m*p*y;break;case"YXZ":this._x=m*d*u+h*p*y,this._y=h*p*u-m*d*y,this._z=h*d*y-m*p*u,this._w=h*d*u+m*p*y;break;case"ZXY":this._x=m*d*u-h*p*y,this._y=h*p*u+m*d*y,this._z=h*d*y+m*p*u,this._w=h*d*u-m*p*y;break;case"ZYX":this._x=m*d*u-h*p*y,this._y=h*p*u+m*d*y,this._z=h*d*y-m*p*u,this._w=h*d*u+m*p*y;break;case"YZX":this._x=m*d*u+h*p*y,this._y=h*p*u+m*d*y,this._z=h*d*y-m*p*u,this._w=h*d*u-m*p*y;break;case"XZY":this._x=m*d*u-h*p*y,this._y=h*p*u-m*d*y,this._z=h*d*y+m*p*u,this._w=h*d*u+m*p*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,r=Math.sin(s);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],r=e[4],i=e[8],a=e[1],o=e[5],c=e[9],h=e[2],d=e[6],u=e[10],m=s+o+u;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-c)*p,this._y=(i-h)*p,this._z=(a-r)*p}else if(s>o&&s>u){const p=2*Math.sqrt(1+s-o-u);this._w=(d-c)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(i+h)/p}else if(o>u){const p=2*Math.sqrt(1+o-s-u);this._w=(i-h)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+u-s-o);this._w=(a-r)/p,this._x=(i+h)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Tt(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const r=Math.min(1,e/s);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,r=t._y,i=t._z,a=t._w,o=e._x,c=e._y,h=e._z,d=e._w;return this._x=s*d+a*o+r*h-i*c,this._y=r*d+a*c+i*o-s*h,this._z=i*d+a*h+s*c-r*o,this._w=a*d-s*o-r*c-i*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,r=this._y,i=this._z,a=this._w;let o=a*t._w+s*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=s,this._y=r,this._z=i,this;const c=1-o*o;if(c<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*s+e*this._x,this._y=p*r+e*this._y,this._z=p*i+e*this._z,this.normalize(),this}const h=Math.sqrt(c),d=Math.atan2(h,o),u=Math.sin((1-e)*d)/h,m=Math.sin(e*d)/h;return this._w=a*u+this._w*m,this._x=s*u+this._x*m,this._y=r*u+this._y*m,this._z=i*u+this._z*m,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),r=Math.sqrt(1-s),i=Math.sqrt(s);return this.set(r*Math.sin(t),r*Math.cos(t),i*Math.sin(e),i*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const at=class ua{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const r=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0);if(r!==0){if(r===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(r===1){const{x:i,y:a,z:o}=t;this.x=i,this.y=a,this.z=o||0;return}if(r===3){this.x=t,this.y=e,this.z=s;return}throw et.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new ua(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Jr.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Jr.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6]*r,this.y=i[1]*e+i[4]*s+i[7]*r,this.z=i[2]*e+i[5]*s+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix3d(t){const e=this.x,s=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*s+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*s+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*s+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*s+i[10]*r+i[14])*a,this}applyQuaternion(t){const e=this.x,s=this.y,r=this.z,i=t.x,a=t.y,o=t.z,c=t.w,h=2*(a*r-o*s),d=2*(o*e-i*r),u=2*(i*s-a*e);return this.x=e+c*h+a*u-o*d,this.y=s+c*d+o*h-i*u,this.z=r+c*u+i*d-a*h,this}transformDirection(t){const e=this.x,s=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*s+i[8]*r,this.y=i[1]*e+i[5]*s+i[9]*r,this.z=i[2]*e+i[6]*s+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),s=this.length(),r=t.length();return Math.abs(e)===s*r}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,r=t.y,i=t.z,a=e.x,o=e.y,c=e.z;return this.x=r*c-i*o,this.y=i*a-s*c,this.z=s*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return Xs.copy(this).projectOnVector(t),this.sub(Xs)}reflect(t){return this.sub(Xs.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,r=this.z-t.z;return e*e+s*s+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};at.X_AXIS=Object.freeze(new at(1,0,0)),at.NEGATIVE_X_AXIS=Object.freeze(new at(-1,0,0)),at.Y_AXIS=Object.freeze(new at(0,1,0)),at.NEGATIVE_Y_AXIS=Object.freeze(new at(0,-1,0)),at.Z_AXIS=Object.freeze(new at(0,0,1)),at.NEGATIVE_Z_AXIS=Object.freeze(new at(0,0,-1));let w=at;const Xs=new w,Jr=new Ct,$s=class ma{constructor(t,e,s,r,i,a,o,c,h,d,u,m,p,y,_,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&r!=null&&i!=null&&a!=null&&o!=null&&c!=null&&h!=null&&d!=null&&u!=null&&m!=null&&p!=null&&y!=null&&_!=null&&x!=null&&this.set(t,e,s,r,i,a,o,c,h,d,u,m,p,y,_,x)}set(t,e,s,r,i,a,o,c,h,d,u,m,p,y,_,x){const f=this.elements;return f[0]=t,f[4]=e,f[8]=s,f[12]=r,f[1]=i,f[5]=a,f[9]=o,f[13]=c,f[2]=h,f[6]=d,f[10]=u,f[14]=m,f[3]=p,f[7]=y,f[11]=_,f[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ma().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(Ys.equalPoint3d(t,w.Z_AXIS))this.identity();else{const e=new w(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(w.Y_AXIS,t).normalize():e.crossVectors(w.Z_AXIS,t).normalize();const s=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,s.x,s.y,s.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,r=1/ie.setFromMatrixColumn(t,0).length(),i=1/ie.setFromMatrixColumn(t,1).length(),a=1/ie.setFromMatrixColumn(t,2).length();return e[0]=s[0]*r,e[1]=s[1]*r,e[2]=s[2]*r,e[3]=0,e[4]=s[4]*i,e[5]=s[5]*i,e[6]=s[6]*i,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ko,t,Zo)}lookAt(t,e,s){const r=this.elements;return ot.subVectors(t,e),ot.lengthSq()===0&&(ot.z=1),ot.normalize(),Ot.crossVectors(s,ot),Ot.lengthSq()===0&&(Math.abs(s.z)===1?ot.x+=1e-4:ot.z+=1e-4,ot.normalize(),Ot.crossVectors(s,ot)),Ot.normalize(),Qe.crossVectors(ot,Ot),r[0]=Ot.x,r[4]=Qe.x,r[8]=ot.x,r[1]=Ot.y,r[5]=Qe.y,r[9]=ot.y,r[2]=Ot.z,r[6]=Qe.z,r[10]=ot.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,i=this.elements,a=s[0],o=s[4],c=s[8],h=s[12],d=s[1],u=s[5],m=s[9],p=s[13],y=s[2],_=s[6],x=s[10],f=s[14],M=s[3],T=s[7],S=s[11],P=s[15],z=r[0],I=r[4],W=r[8],lt=r[12],vt=r[1],N=r[5],V=r[9],Jt=r[13],te=r[2],ds=r[6],us=r[10],ms=r[14],gs=r[3],ps=r[7],ys=r[11],_s=r[15];return i[0]=a*z+o*vt+c*te+h*gs,i[4]=a*I+o*N+c*ds+h*ps,i[8]=a*W+o*V+c*us+h*ys,i[12]=a*lt+o*Jt+c*ms+h*_s,i[1]=d*z+u*vt+m*te+p*gs,i[5]=d*I+u*N+m*ds+p*ps,i[9]=d*W+u*V+m*us+p*ys,i[13]=d*lt+u*Jt+m*ms+p*_s,i[2]=y*z+_*vt+x*te+f*gs,i[6]=y*I+_*N+x*ds+f*ps,i[10]=y*W+_*V+x*us+f*ys,i[14]=y*lt+_*Jt+x*ms+f*_s,i[3]=M*z+T*vt+S*te+P*gs,i[7]=M*I+T*N+S*ds+P*ps,i[11]=M*W+T*V+S*us+P*ys,i[15]=M*lt+T*Jt+S*ms+P*_s,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],r=t[8],i=t[12],a=t[1],o=t[5],c=t[9],h=t[13],d=t[2],u=t[6],m=t[10],p=t[14],y=t[3],_=t[7],x=t[11],f=t[15];return y*(+i*c*u-r*h*u-i*o*m+s*h*m+r*o*p-s*c*p)+_*(+e*c*p-e*h*m+i*a*m-r*a*p+r*h*d-i*c*d)+x*(+e*h*u-e*o*p-i*a*u+s*a*p+i*o*d-s*h*d)+f*(-r*o*d-e*c*u+e*o*m+r*a*u-s*a*m+s*c*d)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const r=this.elements;return t instanceof w?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],h=t[7],d=t[8],u=t[9],m=t[10],p=t[11],y=t[12],_=t[13],x=t[14],f=t[15],M=u*x*h-_*m*h+_*c*p-o*x*p-u*c*f+o*m*f,T=y*m*h-d*x*h-y*c*p+a*x*p+d*c*f-a*m*f,S=d*_*h-y*u*h+y*o*p-a*_*p-d*o*f+a*u*f,P=y*u*c-d*_*c-y*o*m+a*_*m+d*o*x-a*u*x,z=e*M+s*T+r*S+i*P;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/z;return t[0]=M*I,t[1]=(_*m*i-u*x*i-_*r*p+s*x*p+u*r*f-s*m*f)*I,t[2]=(o*x*i-_*c*i+_*r*h-s*x*h-o*r*f+s*c*f)*I,t[3]=(u*c*i-o*m*i-u*r*h+s*m*h+o*r*p-s*c*p)*I,t[4]=T*I,t[5]=(d*x*i-y*m*i+y*r*p-e*x*p-d*r*f+e*m*f)*I,t[6]=(y*c*i-a*x*i-y*r*h+e*x*h+a*r*f-e*c*f)*I,t[7]=(a*m*i-d*c*i+d*r*h-e*m*h-a*r*p+e*c*p)*I,t[8]=S*I,t[9]=(y*u*i-d*_*i-y*s*p+e*_*p+d*s*f-e*u*f)*I,t[10]=(a*_*i-y*o*i+y*s*h-e*_*h-a*s*f+e*o*f)*I,t[11]=(d*o*i-a*u*i-d*s*h+e*u*h+a*s*p-e*o*p)*I,t[12]=P*I,t[13]=(d*_*r-y*u*r+y*s*m-e*_*m-d*s*x+e*u*x)*I,t[14]=(y*o*r-a*_*r-y*s*c+e*_*c+a*s*x-e*o*x)*I,t[15]=(a*u*r-d*o*r+d*s*c-e*u*c-a*s*m+e*o*m)*I,this}scale(t){const e=this.elements,s=t.x,r=t.y,i=t.z;return e[0]*=s,e[4]*=r,e[8]*=i,e[1]*=s,e[5]*=r,e[9]*=i,e[2]*=s,e[6]*=r,e[10]*=i,e[3]*=s,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,r))}makeTranslation(t,e,s){return t instanceof w?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),r=Math.sin(e),i=1-s,a=t.x,o=t.y,c=t.z,h=i*a,d=i*o;return this.set(h*a+s,h*o-r*c,h*c+r*o,0,h*o+r*c,d*o+s,d*c-r*a,0,h*c-r*o,d*c+r*a,i*c*c+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,r,i,a){return this.set(1,s,i,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,s){const r=this.elements,i=e.x,a=e.y,o=e.z,c=e.w,h=i+i,d=a+a,u=o+o,m=i*h,p=i*d,y=i*u,_=a*d,x=a*u,f=o*u,M=c*h,T=c*d,S=c*u,P=s.x,z=s.y,I=s.z;return r[0]=(1-(_+f))*P,r[1]=(p+S)*P,r[2]=(y-T)*P,r[3]=0,r[4]=(p-S)*z,r[5]=(1-(m+f))*z,r[6]=(x+M)*z,r[7]=0,r[8]=(y+T)*I,r[9]=(x-M)*I,r[10]=(1-(m+_))*I,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,s){const r=this.elements;let i=ie.set(r[0],r[1],r[2]).length();const a=ie.set(r[4],r[5],r[6]).length(),o=ie.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],ut.copy(this);const c=1/i,h=1/a,d=1/o;return ut.elements[0]*=c,ut.elements[1]*=c,ut.elements[2]*=c,ut.elements[4]*=h,ut.elements[5]*=h,ut.elements[6]*=h,ut.elements[8]*=d,ut.elements[9]*=d,ut.elements[10]*=d,e.setFromRotationMatrix(ut),s.x=i,s.y=a,s.z=o,this}equals(t){const e=this.elements,s=t.elements;for(let r=0;r<16;r++)if(e[r]!==s[r])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};$s.IDENTITY=Object.freeze(new $s);let Yt=$s;const ie=new w,ut=new Yt,Ko=new w(0,0,0),Zo=new w(1,1,1),Ot=new w,Qe=new w,ot=new w;class O{constructor(t=void 0,e=void 0){this.min=t==null?new w(1/0,1/0,1/0):new w(t.x,t.y,t.z),this.max=e==null?new w(-1/0,-1/0,-1/0):new w(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Ks.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Ks.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new O().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ks).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(St[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(t),St[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(t),St[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(t),St[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(t),St[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(t),St[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(t),St[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(t),St[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(t),this.setFromPoints(St),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const St=[new w,new w,new w,new w,new w,new w,new w,new w],Ks=new w,ti=new B;class K{constructor(t=void 0,e=void 0){this.min=t==null?new B(1/0,1/0):new B(t.x,t.y),this.max=e==null?new B(-1/0,-1/0):new B(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=ti.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new K().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new B(0,0):new B(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new B(0,0):new B(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ti).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ei=new w,Qo=new w,Jo=new Ke;class Le{constructor(t=new w(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,r){return this.normal.set(t,e,s),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const r=ei.subVectors(s,e).cross(Qo.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||Jo.getNormalMatrix(t),r=this.coplanarPoint(ei).applyMatrix3d(t),i=this.normal.applyMatrix3(s).normalize();return this.constant=-r.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new Le().copy(this)}}class L extends B{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,r)=>{s.toArray(e,r*2)}),e}}class b extends w{static pointArrayToNumberArray(t,e=!0){const s=e?3:2,r=new Array(t.length*s);return t.forEach((i,a)=>{i.toArray(r,a*s)}),r}}const si=new Yt,ni=new Ct,ri=class un{constructor(t=0,e=0,s=0,r=un.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,r=this._order){return this._x=t,this._y=e,this._z=s,this._order=r,this._onChangeCallback(),this}clone(){return new un(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const r=t.elements,i=r[0],a=r[4],o=r[8],c=r[1],h=r[5],d=r[9],u=r[2],m=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(Tt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Tt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Tt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(c,i));break;case"ZYX":this._y=Math.asin(-Tt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(c,i)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(Tt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,h),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Tt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return si.makeRotationFromQuaternion(t),this.setFromRotationMatrix(si,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ni.setFromEuler(this),this.setFromQuaternion(ni,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ri.DEFAULT_ORDER="XYZ";let ii=ri;class ai{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Zs extends ai{translate(t){return this.transform(new Ke().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Je extends Zs{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new K}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const r=this.loops[s].getPoints(t);e.push(r)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),r=this.sortBoundaryBoxesByAreas(s),i=new Map,a=r.length;for(let c=0;c<a;c++)i.set(r[c],{index:r[c],children:[]});const o={index:-1,children:[]};for(let c=0;c<a;c++){const h=r[c],d=e[h],u=s[h];let m=c+1;for(;m<a;m++){const p=r[m],y=e[p];if(s[p].containsBox(u)&&Xr.isPointInPolygon(d[C.randInt(0,d.length-1)],y)){(t=i.get(p))==null||t.children.push(i.get(h));break}}m===a&&o.children.push(i.get(h))}return o}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new K().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((r,i)=>{const a=r.size,o=a.width*a.height;e.push({area:o,index:i})}),e.sort((r,i)=>r.area-i.area);const s=[];return e.forEach(r=>{s.push(r.index)}),s}}class ae extends Zs{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,r=this.getPoint(0),i=0;e.push(0);for(let a=1;a<=t;a++)s=this.getPoint(a/t),i+=s.distanceTo(r),e.push(i),r=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let r=0;const i=s.length;let a;e?a=e:a=t*s[i-1];let o=0,c=i-1,h;for(;o<=c;)if(r=Math.floor(o+(c-o)/2),h=s[r]-a,h<0)o=r+1;else if(h>0)c=r-1;else{c=r;break}if(r=c,s[r]===a)return r/(i-1);const d=s[r],u=s[r+1]-d,m=(a-d)/u;return(r+m)/(i-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const r=this.getPoint(e),i=this.getPoint(s),a=new L;return a.copy(i).sub(r).normalize(),a}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class oe extends ae{constructor(t,e,s,r,i){super();const a=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0)+ +(i!==void 0);if(a==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(a==5){const o=t;this.center=new L(o.x,o.y),this.radius=e,this.startAngle=s,this.endAngle=r,this.clockwise=i}else throw et.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const r=(I,W)=>({x:(I.x+W.x)/2,y:(I.y+W.y)/2}),i=(I,W)=>(W.y-I.y)/(W.x-I.x),a=I=>-1/I,o=r(t,e),c=r(e,s),h=i(t,e),d=i(e,s),u=a(h),m=a(d),p=(I,W,lt,vt)=>{const N=(vt-W)/(I-lt),V=I*N+W;return{x:N,y:V}},y=o.y-u*o.x,_=c.y-m*c.x,x=p(u,y,m,_),f=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),M=(I,W)=>Math.atan2(I.y-W.y,I.x-W.x),T=M(t,x),S=M(e,x),P=M(s,x),z=P>T&&P<S||T>P&&T<S||S>P&&S<T;this.center=x,this.radius=f,this.startAngle=T,this.endAngle=P,this.clockwise=!z}createByStartEndPointsAndBulge(t,e,s){let r,i,a;s<0?(r=Math.atan(-s)*4,i=new B(t),a=new B(e)):(r=Math.atan(s)*4,i=new B(e),a=new B(t));const o=new B().subVectors(a,i),c=o.length(),h=new B().addVectors(i,o.multiplyScalar(.5)),d=Math.abs(c/2/Math.tan(r/2)),u=o.normalize();let m;if(r<Math.PI){const p=new B(u.x*Math.cos(Math.PI/2)-u.y*Math.sin(Math.PI/2),u.y*Math.cos(Math.PI/2)+u.x*Math.sin(Math.PI/2));m=h.add(p.multiplyScalar(-d))}else{const p=new B(u.x*Math.cos(Math.PI/2)-u.y*Math.sin(Math.PI/2),u.y*Math.cos(Math.PI/2)+u.x*Math.sin(Math.PI/2));m=h.add(p.multiplyScalar(d))}s<0?(this.startAngle=Math.atan2(i.y-m.y,i.x-m.x),this.endAngle=Math.atan2(a.y-m.y,a.x-m.x)):(this.startAngle=Math.atan2(a.y-m.y,a.x-m.x),this.endAngle=Math.atan2(i.y-m.y,i.x-m.x)),this.clockwise=s<0,this.center=m,this.radius=a.sub(m).length()}get center(){return this._center}set center(t){this._center=new L(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return this.clockwise?C.normalizeAngle(this.startAngle-this.endAngle):C.normalizeAngle(this.endAngle-this.startAngle)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=C.normalizeAngle((this.startAngle+this.endAngle)/2);return this.getPointAtAngle(t)}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of e)C.isBetweenAngle(i,this.startAngle,this.endAngle,this.clockwise)&&t.push(this.getPointAtAngle(i));const s=t.map(i=>i.x),r=t.map(i=>i.y);return new K(new L(Math.min(...s),Math.min(...r)),new L(Math.max(...s),Math.max(...r)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new oe(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.clockwise)}getPointAtAngle(t){const e=this.center.x+this.radius*Math.cos(t),s=this.center.y+this.radius*Math.sin(t);return new L(e,s)}getPoints(t=100){const e=[];let s=this.deltaAngle,r=this.startAngle;if(this.closed&&(s=H,r=0),this.clockwise)for(let i=0;i<=t;i++){const a=r-s*(i/t),o=this.getPointAtAngle(a);e.push(new L(o.x,o.y))}else for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(new L(o.x,o.y))}return e}}class tl extends ai{translate(t){return this.transform(new Yt().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ke extends tl{}class Nt extends ke{constructor(t,e){super(),this._start=new b(t),this._end=new b(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new w().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new b((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const s=this.delta(qt).normalize();return new b(this._start).addScaledVector(s,t)}else{const s=this.delta(qt).normalize();return new b(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=qt.subVectors(this._start,this._end).normalize();this._start=new b(this._start).addScaledVector(s,t)}else{const s=this.delta(qt).normalize();this._end=new b(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){oi.subVectors(t,this._start),ts.subVectors(this.endPoint,this.startPoint);const s=ts.dot(ts);let r=ts.dot(oi)/s;return e&&(r=C.clamp(r,0,1)),r}closestPointToPoint(t,e,s){const r=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(r).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=qt.subVectors(t,this.startPoint).dot(e);return new b().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,r=qt.subVectors(t,s).dot(e),i=qt.copy(e).multiplyScalar(r);return new b().addVectors(s,i)}calculateBoundingBox(){const t=new b(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new b(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new O(t,e)}transform(t){return this._start.applyMatrix3d(t),this._end.applyMatrix3d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Nt(this._start.clone(),this._end.clone())}}const qt=new w,oi=new w,ts=new w;class Xt extends ke{static computeCenterPoint(t,e,s){const r=new w().addVectors(t,e).multiplyScalar(.5),i=new w().addVectors(t,s).multiplyScalar(.5),a=new w().subVectors(e,t),o=new w().subVectors(s,t),c=new w().crossVectors(a,o).normalize();if(c.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const h=new w().crossVectors(a,c).normalize(),d=new w().crossVectors(o,c).normalize(),u=h.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=d.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=new Nt(r,r.clone().add(u)),y=new Nt(i,i.clone().add(m)),_=new w;return p.closestPointToPoint(y.startPoint,!0,_)?_:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const r=Xt.computeCenterPoint(t,e,s);if(r){const i=r.distanceTo(t),a=new w().subVectors(t,r),o=new w().subVectors(e,r),c=Math.atan2(a.y,a.x),h=Math.atan2(o.y,o.x);return new Xt(r,i,c,h,w.Z_AXIS)}}constructor(t,e,s,r,i,a=w.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=r,this.normal=i,this.refVec=a,(r-s)%H==0?(this.startAngle=0,this.endAngle=H):(this.startAngle=s,this.endAngle=r)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return C.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new w(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new w(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get length(){return Math.abs(this.deltaAngle*this.radius)}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let c=0;c<2*Math.PI;c+=Math.PI/2)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&t.push(c);let e=1/0,s=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(const c of t){const h=this.getPointAtAngle(c);h.x<e&&(e=h.x),h.y<s&&(s=h.y),h.z<r&&(r=h.z),h.x>i&&(i=h.x),h.y>a&&(a=h.y),h.z>o&&(o=h.z)}return new O({x:e,y:s,z:r},{x:i,y:a,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,r=this.startAngle;this.closed&&(s=H,r=0);for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(o)}return e}transform(t){const e=Qs.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=Qs.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(t),e.applyMatrix3d(t),s.applyMatrix3d(t),this.normal.applyMatrix3d(t).normalize(),this.refVec.applyMatrix3d(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Xt(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Qs.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,r={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},i=this.center,a=this.radius;return new b(i.x+a*(s.x*Math.cos(t)+r.x*Math.sin(t)),i.y+a*(s.y*Math.cos(t)+r.y*Math.sin(t)),i.z+a*(s.z*Math.cos(t)+r.z*Math.sin(t)))}get plane(){const t=new w(this.center).distanceTo(Us);return new Le(this.normal,t)}}const Qs=new w;class es extends ae{constructor(t,e,s,r=0,i=H,a=!1,o=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(i-r)%H==0?(this.startAngle=0,this.endAngle=H):(this.startAngle=r,this.endAngle=i),this.clockwise=a,this.rotation=o}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return C.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,r=-1/0;for(let i=0;i<=100;i++){const a=this.getPoint(i/100);t=Math.min(t,a.x),e=Math.min(e,a.y),s=Math.max(s,a.x),r=Math.max(r,a.y)}return new K({x:t,y:e},{x:s,y:r})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const r=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(r?s=0:s=e),this.clockwise===!0&&!r&&(s===e?s=-e:s=s-e);const i=this.startAngle+t*s;let a=this.center.x+this.majorAxisRadius*Math.cos(i),o=this.center.y+this.minorAxisRadius*Math.sin(i);if(this.rotation!==0){const c=Math.cos(this.rotation),h=Math.sin(this.rotation),d=a-this.center.x,u=o-this.center.y;a=d*c-u*h+this.center.x,o=d*h+u*c+this.center.y}return new L(a,o)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new es(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class ss extends ke{constructor(t,e,s,r,i,a=0,o=H){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=r,this.minorAxisRadius=i;const c=Math.abs(o-a);Math.abs(c-H)<1e-10||Math.abs(c-2*H)<1e-10?(this.startAngle=0,this.endAngle=H):(this.startAngle=a,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw et.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==H?t:C.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-H)<1e-10?H:C.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new w(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new w(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new w().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get isCircular(){return Ws.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let s=0,r=this.getPointAtAngle(this.startAngle);for(let i=1;i<=t;i++){const a=this.startAngle+i*e,o=this.getPointAtAngle(a),c=o.x-r.x,h=o.y-r.y,d=o.z-r.z;s+=Math.sqrt(c*c+h*h+d*d),r=o}return s}calculateBoundingBox(){if(this.majorAxis.equals(w.X_AXIS)||this.majorAxis.equals(w.Y_AXIS)||this.majorAxis.isParallelTo(w.X_AXIS)||this.majorAxis.isParallelTo(w.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let c=0;c<2*Math.PI;c+=Math.PI/2)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&t.push(c);let e=1/0,s=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(const c of t){const h=this.getPointAtAngle(c);h.x<e&&(e=h.x),h.y<s&&(s=h.y),h.z<r&&(r=h.z),h.x>i&&(i=h.x),h.y>a&&(a=h.y),h.z>o&&(o=h.z)}return new O({x:e,y:s,z:r},{x:i,y:a,z:o})}else{let t=1/0,e=1/0,s=1/0,r=-1/0,i=-1/0,a=-1/0;for(let o=0;o<=100;o++){const c=this.startAngle+this.deltaAngle*(o/100),h=this.getPointAtAngle(c);t=Math.min(t,h.x),e=Math.min(e,h.y),s=Math.min(s,h.z),r=Math.max(r,h.x),i=Math.max(i,h.y),a=Math.max(a,h.z)}return new O({x:t,y:e,z:s},{x:r,y:i,z:a})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,r=this.startAngle;this.closed&&(s=H,r=0);for(let i=0;i<=t;i++){const a=r+s*(i/t),o=this.getPointAtAngle(a);e.push(o)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),r=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),i=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(r);return new b(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}contains(t){const e=new w(t).sub(this.center),s=e.dot(this.majorAxis),r=e.dot(this.minorAxis),i=s/this.majorAxisRadius,a=r/this.minorAxisRadius;return i*i+a*a<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ss(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new w(this.center).distanceTo(Us);return new Le(this.normal,t)}}class Ce extends ae{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new L(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new L(e.x,e.y)}else{const e=this._vertices[t-1];return new L(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let s=0;s<e;++s){const r=this._vertices[s];let i=null;if(s<e-1?i=this._vertices[s+1]:s==e-1&&this.closed&&(i=this._vertices[0]),i)if(r.bulge){const a=new oe(r,i,r.bulge);t+=a.length}else t+=new L(r.x,r.y).distanceTo(i)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new L(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new K().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(r=>s.push(new b().set(r.x,r.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let r=0;r<s;++r){const i=this._vertices[r];if(i.bulge){let a=null;if(r<s-1?a=this._vertices[r+1]:r==s-1&&this.closed&&(a=this._vertices[0]),a){const o=new oe(i,a,i.bulge).getPoints(t),c=o.length;for(let h=0;h<c;++h){const d=o[h];e.push(new L(d.x,d.y))}}}else e.push(new L(i.x,i.y)),r==s-1&&this.closed&&e.push(e[0])}return e}}class ns extends ae{constructor(t,e){super(),this._start=new L(t),this._end=new L(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new L(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new L(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new K(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ns(this._start.clone(),this._end.clone())}}class li extends ae{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new L(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new K;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(r=>{e.push(new L(r.x,r.y))})}),e}}class Js{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,r){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-r,this.c3=2*t-2*e+s+r}initCatmullRom(t,e,s,r,i){this.init(e,s,i*(s-t),i*(r-e))}initNonuniformCatmullRom(t,e,s,r,i,a,o){let c=(e-t)/i-(s-t)/(i+a)+(s-e)/a,h=(s-e)/a-(r-e)/(a+o)+(r-s)/o;c*=a,h*=a,this.init(e,s,c,h)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}class hi extends ke{constructor(t=[],e=!1,s="centripetal",r=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new w,this._px=new Js,this._py=new Js,this._pz=new Js,this._points=t.map(i=>new b(i)),this._closed=e,this._curveType=s,this._tension=r}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new b}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new b}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new b){const s=e,r=this._points,i=r.length;if(i===0)return s.set(0,0,0);if(i===1)return s.copy(r[0]);const a=(i-(this._closed?0:1))*t;let o=Math.floor(a),c=a-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:c===0&&o===i-1&&(o=i-2,c=1);let h,d;this._closed||o>0?h=r[(o-1)%i]:(this._tmp.subVectors(r[0],r[1]).add(r[0]),h=new b(this._tmp.x,this._tmp.y,this._tmp.z));const u=r[o%i],m=r[(o+1)%i];if(this._closed||o+2<i?d=r[(o+2)%i]:(this._tmp.subVectors(r[i-1],r[i-2]).add(r[i-1]),d=new b(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const p=this._curveType==="chordal"?.5:.25;let y=Math.pow(h.distanceToSquared(u),p),_=Math.pow(u.distanceToSquared(m),p),x=Math.pow(m.distanceToSquared(d),p);_<1e-4&&(_=1),y<1e-4&&(y=_),x<1e-4&&(x=_),this._px.initNonuniformCatmullRom(h.x,u.x,m.x,d.x,y,_,x),this._py.initNonuniformCatmullRom(h.y,u.y,m.y,d.y,y,_,x),this._pz.initNonuniformCatmullRom(h.z,u.z,m.z,d.z,y,_,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(h.x,u.x,m.x,d.x,this._tension),this._py.initCatmullRom(h.y,u.y,m.y,d.y,this._tension),this._pz.initCatmullRom(h.z,u.z,m.z,d.z,this._tension));return s.set(this._px.calc(c),this._py.calc(c),this._pz.calc(c)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new b(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}transform(t){return this._points=this._points.map(e=>{const s=new b;return s.copy(e),s.applyMatrix3d(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new O;const t=new O;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}class mt{constructor(t,e,s,r){this._degree=t,this._knots=[...e],this._controlPoints=s.map(i=>({x:i.x,y:i.y,z:i.z})),this._weights=r?[...r]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return ve(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Qr(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,r){return new mt(t,e,s,r)}static byPoints(t,e,s="Uniform"){let r;switch(s){case"Chord":r=Kr(e,t);break;case"SqrtChord":r=Zr(e,t);break;case"Uniform":default:r=$r(e,t.length);break}const i=t.map(o=>({x:o[0],y:o[1],z:o[2]})),a=new Array(i.length).fill(1);return new mt(e,r,i,a)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:r}=this.getParameterRange();for(let i=0;i<=t;i++){const a=s+(r-s)*(i/t);e.push(this.point(a))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),r=this.point(e),i=this.point(s),a=r[0]-i[0],o=r[1]-i[1],c=r[2]-i[2];return Math.sqrt(a*a+o*o+c*c)<t}static createClosedCurve(t,e,s="Chord"){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const r=new hi(t,!0,"centripetal"),i=Math.max(50,t.length*2),a=r.getPoints(i).map(o=>[o.x,o.y,o.z]);return mt.byPoints(a,e,s)}}class Dt extends ke{constructor(t,e,s,r){super();const i=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0);if(i<2||i>4)throw et.ILLEGAL_PARAMETERS;const a=3;if(this._closed=r||!1,Array.isArray(e)){if(this._controlPoints=t,i>=4&&(this._closed=r),this._controlPoints.length<4)throw et.ILLEGAL_PARAMETERS;this._nurbsCurve=mt.byKnotsControlPointsWeights(a,e,this._controlPoints,s)}else{if(this._fitPoints=t,this._knotParameterization=e,i>=3&&(this._closed=s),this._fitPoints.length<4)throw et.ILLEGAL_PARAMETERS;const o=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=mt.byPoints(o,a,this._knotParameterization),this._controlPoints=this._nurbsCurve.controlPoints()}this._closed&&this.buildCurve()}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed)this._nurbsCurve=mt.createClosedCurve(this._fitPoints,3,this._knotParameterization);else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=mt.byPoints(t,3,this._knotParameterization)}this._controlPoints=this._nurbsCurve.controlPoints()}else if(this._controlPoints)if(this._closed){const t=this._knotParameterization||"Chord";this._nurbsCurve=mt.createClosedCurve(this._controlPoints,3,t),this._controlPoints=this._nurbsCurve.controlPoints()}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._nurbsCurve=mt.byKnotsControlPointsWeights(3,t,this._controlPoints,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._nurbsCurve.degree()}get knotParameterization(){return this._knotParameterization}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],r=this._nurbsCurve.point(s);return new b(r[0],r[1],r[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],r=this._nurbsCurve.point(s);return new b(r[0],r[1],r[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,r=this._fitPoints[s];return{x:r.x,y:r.y,z:r.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],r=e.knots(),i=this._nurbsCurve.degree(),a=r[i],o=r[r.length-i-1],c=(o-a)/(t-1);for(let h=0;h<t;h++){const d=h===t-1?o:a+h*c,u=e.point(d);s.push(new b(u[0],u[1],u[2]))}return s}getCurvePoints(t,e){const s=[],r=t.knots(),i=r[3],a=(r[r.length-4]-i)/(e-1);for(let o=0;o<e;o++){const c=i+o*a;s.push(t.point(c))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new O().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,r)=>{e[r]=[s.x,s.y,s.z||0]}),e}static createClosedSpline(t,e="Uniform"){if(t.length<4)throw new Error("At least 4 points are required for a closed spline");return new Dt(t,e,!0)}}for(var $t=256,ci=[],di=256,rs;$t--;)ci[$t]=($t+256).toString(16).substring(1);function el(n){var t=0,e=11;if(!rs||$t+e>di*2)for(rs="",$t=0;t<di;t++)rs+=ci[Math.random()*256|0];return rs.substring($t,$t+++e)}class Rt{constructor(t,e){t=t||{},ee(t,{objectId:el()}),this._attrs=new fn(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:dn().workingDatabase}set database(t){this._database=t}close(){}}class pt extends Rt{constructor(){super(...arguments),this._layer="0",this._color=new zt,this._lineType=Xe,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.name.substring(4)}get layer(){return this._layer}set layer(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Xe}get lineWeight(){return this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,r,i){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const t=this.getLineType(),e=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Xe){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==Pr?qe:this.lineType;return qe}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}}class tn extends pt{constructor(t){super(),this._blockName=t,this._position=new b,this._rotation=0,this._normal=new w(0,0,1),this._scaleFactors=new b(1,1,1)}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const t=new O,e=this.blockTableRecord;if(e!=null){const i=e.newIterator();for(const a of i)t.union(a.geometricExtents)}const s=new Ct().setFromEuler(new ii(this.rotation,0,0)),r=new Yt;return r.compose(this.position,s,this.scaleFactors),t.applyMatrix4(r),t}draw(t){const e=[],s=this.blockTableRecord;if(s!=null){const r=this.computeTransformMatrix();return kt.instance.draw(t,s,this.rgbColor,!0,r,this.normal)}else return t.group(e)}computeTransformMatrix(){const t=new Ct;return t.setFromAxisAngle(w.Z_AXIS,this.rotation),new Yt().compose(this._position,t,this._scaleFactors)}}class gt extends pt{}class ui extends gt{constructor(t,e,s,r,i,a,o){super(),this._geo=new ss(t,e,s,r,i,a,o)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(t){return t.ellipticalArc(this._geo,this.lineStyle)}}class mi extends gt{constructor(t,e,s,r){super(),this._geo=new Xt(t,e,s,r,w.Z_AXIS,w.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}class gi extends gt{constructor(t,e,s=w.Z_AXIS){super(),this._geo=new Xt(t,e,0,H,s,w.X_AXIS)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}draw(t){return t.circularArc(this._geo,this.lineStyle)}}var pi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(pi||{}),yi=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(yi||{});class _i extends pt{constructor(){super(),this._elevation=0,this._geo=new Je,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new O({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}}var fi=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(fi||{});class xi extends gt{constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}appendVertex(t){this._vertices.push(new b().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new O().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Dt(this._vertices,"Uniform"),this._updated=!1)}}class bi extends gt{constructor(t,e){super(),this._geo=new Nt(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,r,i){const a=this.startPoint,o=this.endPoint;switch(t){case Ut.EndPoint:i.push(a),i.push(o);break;case Ut.MidPoint:i.push(this.midPoint);break;case Ut.Nearest:{const c=this._geo.project(s);i.push(c)}break;case Ut.Perpendicular:{const c=this._geo.perpPoint(s);i.push(c)}break;case Ut.Tangent:i.push(a);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,s=this.endPoint,r=[new b(e.x,e.y,0),new b(s.x,s.y,0)];return t.lines(r,this.lineStyle)}}var en=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(en||{}),is=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(is||{}),le=(n=>(n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n))(le||{}),sn=(n=>(n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",n))(sn||{}),nn=(n=>(n[n.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",n[n.TOP=1]="TOP",n[n.BOTTOM=2]="BOTTOM",n[n.FRONT=3]="FRONT",n[n.BACK=4]="BACK",n[n.LEFT=5]="LEFT",n[n.RIGHT=6]="RIGHT",n))(nn||{}),rn=(n=>(n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",n))(rn||{});class as{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new K;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new K;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new as;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}class wi extends pt{constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new b,this._attachmentPoint=le.TopLeft,this._direction=new w(1,0,0),this._drawingDirection=is.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new O}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}}class an extends gt{constructor(t,e,s,r){super();const i=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0);if(i<2||i>4)throw et.ILLEGAL_PARAMETERS;i<=3&&!Array.isArray(e)?this._geo=new Dt(t,e,s):this._geo=new Dt(t,e,s,r)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}}const sl=new w;class Ai extends tn{constructor(t,e,s){super(t),this._attachmentPoint=le.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new O}draw(t){let e=0,s=0;const r=new Uint16Array(this.numColumns*this.numRows*8),i=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let a=0;for(let m=0;m<=this.numRows;m++){e-=m>0?this.rowHeight(m-1):0,s=0;for(let p=0;p<=this.numColumns;p++)s+=p>0?this.columnWidth(p-1):0,i[a++]=s,i[a++]=e,i[a++]=0}const o=[],c=new Array(this.numRows*this.numColumns).fill(!1);s=0,a=0;let h=0;for(let m=0;m<this.numColumns;m++){s+=m>0?this.columnWidth(m-1):0,e=0;for(let p=0;p<this.numRows;p++){e+=p>0?this.rowHeight(p-1):0;const y=this.cell(p*this.numColumns+m);if(h=p*this.numColumns+m,y&&!c[h]){const _=y.borderWidth??1,x=y.borderHeight??1;this.fillVisited(c,h,this.numColumns,_,x),r[a++]=m+p*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1)+_;const f=i[r[a-1]*3]-s,M=m+(p+x)*(this.numColumns+1)+_;m+_==this.numColumns&&(r[a++]=m+p*(this.numColumns+1)+_,r[a++]=M);const T=-i[M*3+1]-e;if(p+x==this.numRows&&(r[a++]=m+(p+x)*(this.numColumns+1)+x,r[a++]=m+(p+x)*(this.numColumns+1)),r[a++]=m+(p+x)*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1),y.text){const S=y.attachmentPoint||this.attachmentPoint||le.MiddleCenter,P=this.getTableTextOffset(S,f,T),z={text:y.text,height:y.textHeight,width:f,position:sl.set(s,-e,0).clone().add(P),rotation:this.rotation,attachmentPoint:S},I={...this.getTextStyle(y),color:this.color.color};o.push(t.mtext(z,I))}}}}o.push(t.lineSegments(i,3,r,this.lineStyle));const d=t.group(o),u=new Ct;return u.setFromAxisAngle(w.Z_AXIS,this.rotation),Pi.compose(this.position,u,this.scaleFactors),d.applyMatrix(Pi),d}fillVisited(t,e,s,r,i){if(i==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<i;++o)t[e+a+o*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let s;return t.textStyle&&(s=e.getAt(t.textStyle)),s||(s=e.getAt("STANDARD")||e.getAt("Standard")),s.textStyle}getTableTextOffset(t,e,s){const r=new w;switch(t){case 1:break;case 2:r.setX(e/2);break;case 3:r.setX(e);break;case 4:r.setY(-s/2);break;case 5:r.set(e/2,-s/2,0);break;case 6:r.set(e,-s/2,0);break;case 7:r.setY(-s);break;case 8:r.set(e/2,-s,0);break;case 9:r.set(e,-s,0);break}return r}}const Pi=new Yt;var Ii=(n=>(n[n.LEFT=0]="LEFT",n[n.CENTER=1]="CENTER",n[n.RIGHT=2]="RIGHT",n[n.ALIGNED=3]="ALIGNED",n[n.MIDDLE=4]="MIDDLE",n[n.FIT=5]="FIT",n))(Ii||{}),Ei=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Ei||{});class Ti extends pt{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new b,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new O}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t){const e={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:is.BOTTOM_TO_TOP,attachmentPoint:le.BottomLeft},s={...this.getTextStyle(),color:this.rgbColor};return t.mtext(e,s)}}class Si extends gt{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new b,new b,new b,new b]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new O().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new Ce(this._vertices,!0),s=new Je;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}}class Mi extends gt{constructor(){super(),this._elevation=0,this._geo=new Ce}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,r=-1,i=-1){const a=r<0?void 0:r,o=i<0?void 0:i,c={x:e.x,y:e.y,bulge:s,startWidth:a,endWidth:o};this._geo.addVertexAt(t,c)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new b(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new O({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(r=>e.push(new b().set(r.x,r.y,this.elevation))),t.lines(e,this.lineStyle)}}class vi extends pt{constructor(){super(),this._geo=new b}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new O().expandByPoint(this._geo)}transformBy(t){return this._geo.applyMatrix3d(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}}var Li=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(Li||{}),ki=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(ki||{});class on extends pt{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new b,this._scale=new B(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new O;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,r=new K;r.setFromPoints(this._clipBoundary);const i=new L;i.setX(this._position.x-r.min.x*e),i.setY(this._position.y-r.min.y*s),this._clipBoundary.forEach(a=>{const o=a.x*e+i.x,c=a.y*s+i.y;t.push(new b(o,c,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Ci.copy(t[1]);for(let e=1;e<4;e++)os.copy(t[e]),os.rotateAround(Ci,this._rotation),t[e].setX(os.x),t[e].setY(os.y)}t.push(t[0])}return t}}const Ci=new L,os=new L;class Oi extends gt{constructor(){super(),this._basePoint=new b,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new O;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}class Ni extends pt{constructor(){super(),this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new O}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new as;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s}}class Di extends on{draw(t){const e=this.boundaryPath(),s=new Je;return s.add(new Ce(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}}class Ri extends gt{constructor(){super(),this._basePoint=new b,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new O;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e,this.lineStyle)}}var zi=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(zi||{});class Kt extends pt{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new b,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new Ne),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}draw(t){if(this.dimBlockId){const e=this.database.tables.blockTable.getAt(this.dimBlockId);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}return t.group([])}drawFirstArrow(t){const e=this.database.tables.blockTable.getAt(this.firstArrowType);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return kt.instance.draw(t,e,this.rgbColor,!1)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}getLineArrowStyle(t){}findPointOnLine1(t,e,s){const r=new b().subVectors(e,t).normalize();return new b(e).addScaledVector(r,s)}findPointOnLine2(t,e,s){const r=t.x+s*Math.cos(e),i=t.y+s*Math.sin(e);return{x:r,y:i}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():en.Closed}}class Fi extends Kt{constructor(t,e,s,r,i=null,a=null){super(),this._centerPoint=new b().copy(t),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(s),this._arcPoint=new b().copy(r),this.dimensionText=i,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new O}}class Bi extends Kt{constructor(t,e,s,r=null,i=null){super(),this._dimLinePoint=new b().copy(s),this._xLine1Point=new b().copy(t),this._xLine2Point=new b().copy(e),this._oblique=0,this._rotation=0,this.dimensionText=r,this.dimensionStyleName=i}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new O}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),r=this.findIntersectionPoint(e,this._dimLinePoint),i=this.findIntersectionPoint(s,this._dimLinePoint),a=new Nt(r,i);return t.push(a),e.endPoint=r,this.adjustExtensionLine(e),t.push(e),s.endPoint=i,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Nt(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,r=t.endPoint,i=new w().subVectors(r,s).normalize(),o=new w().subVectors(e,s).dot(i),c=new w().copy(i).multiplyScalar(o);return new w().addVectors(s,c)}}class nl extends Kt{constructor(t,e,s,r,i=null,a=null){super(),this._arcPoint=new b().copy(r),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(s),this._centerPoint=new b().copy(t),this.dimensionText=i,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new O}}class Vi extends Kt{constructor(t,e,s=0,r=null,i=null){super(),this._chordPoint=new b().copy(t),this._farChordPoint=new b().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=r,this.dimensionStyleName=i}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new O}drawLines(t,e){const s=[],r=e.length;return r==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):r==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(i=>{s.push(this.drawLine(t,i))}),s}drawLine(t,e,s){if(s){const r=[e.startPoint,e.endPoint];return t.lines(r,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,r)=>s.x!==r.x?s.x-r.x:s.y!==r.y?s.y-r.y:s.z-r.z;t.sort((s,r)=>{const i=e(s.startPoint,r.startPoint);return i!==0?i:e(s.endPoint,r.endPoint)})}}class ji extends Kt{constructor(t,e,s=null,r=null){super(),this._definingPoint=new b().copy(t),this._leaderEndPoint=new b().copy(e),this.dimensionText=s,this.dimensionStyleName=r}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get geometricExtents(){return new O}get arrowLineCount(){return 0}}class Gi extends Kt{constructor(t,e,s,r=null,i=null){super(),this._center=new b().copy(t),this._chordPoint=new b().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=r,this.dimensionStyleName=i}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new O}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}}class Hi{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"||t.type=="LWPOLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertArc(t){return new mi(t.center,t.radius,C.degToRad(t.startAngle),C.degToRad(t.endAngle))}convertCirle(t){return new gi(t.center,t.radius)}convertEllipse(t){const e=new w(t.majorAxisEndPoint),s=e.length();return new ui(t.center,w.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new bi(new b(e.x,e.y,e.z||0),new b(s.x,s.y,s.z||0))}convertSpline(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new an(t.controlPoints,t.knots,t.weights,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new an(e,"Uniform",!!(t.flag&1))}return null}convertPoint(t){const e=new vi;return e.position=t.position,e}convertSolid(t){const e=new Si;return t.points.forEach((s,r)=>e.setPointAt(r,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=new Mi;return e.closed=!!(t.flag&1),t.vertices.forEach((s,r)=>{e.addVertexAt(r,new L(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var r;const e=new _i;return(r=t.definitionLines)==null||r.forEach(i=>{e.definitionLines.push({angle:i.angle,origin:i.base,delta:i.offset,dashPattern:i.numberOfDashLengths>0?i.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(i=>{if(i.boundaryPathTypeFlag&2){const o=i,c=new Ce;c.closed=o.isClosed,o.vertices.forEach((h,d)=>{c.addVertexAt(d,{x:h.x,y:h.y,bulge:h.bulge})}),e.add(c)}else{const o=i,c=new li;o.edges.forEach(h=>{if(h.type==1){const d=h;c.add(new ns(d.start,d.end))}else if(h.type==2){const d=h;c.add(new oe(d.center,d.radius,C.degToRad(d.startAngle||0),C.degToRad(d.endAngle||0),!d.isCCW))}else if(h.type==3){const d=h;new B().subVectors(d.end,d.center);const m=Math.sqrt(Math.pow(d.end.x,2)+Math.pow(d.end.y,2)),p=m*d.lengthOfMinorAxis;let y=C.degToRad(d.startAngle||0),_=C.degToRad(d.endAngle||0);const x=Math.atan2(d.end.y,d.end.x);d.isCCW||(y=Math.PI*2-y,_=Math.PI*2-_),c.add(new es({...d.center,z:0},m,p,y,_,!d.isCCW,x))}else if(h.type==4){const d=h;if(d.numberOfControlPoints>0&&d.numberOfKnots>0){const u=d.controlPoints.map(y=>({x:y.x,y:y.y,z:0}));let m=!0;const p=d.controlPoints.map(y=>(y.weight==null&&(m=!1),y.weight||1));c.add(new Dt(u,d.knots,m?p:void 0))}else if(d.numberOfFitData>0){const u=d.fitDatum.map(m=>({x:m.x,y:m.y,z:0}));c.add(new Dt(u,"Uniform"))}}}),e.add(c)}}),e}convertTable(t){const e=new Ai(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,r)=>e.setColumnWidth(r,s)),t.rowHeightArr.forEach((s,r)=>e.setRowHeight(r,s)),t.cells.forEach((s,r)=>{e.setCell(r,s)}),e}convertText(t){const e=new Ti;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=C.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new wi;return e.contents=t.text.join(""),t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=C.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new w(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new xi;return t.vertices.forEach(s=>{e.appendVertex(s)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new Bi(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return s.rotation=C.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new Fi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new ji(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new Gi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new Vi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageDefId=t.imageDefHandle,e.isClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new L(s))}),e.clipBoundaryType=t.clippingBoundaryType,e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new on;return this.processImage(t,e),e}convertWipeout(t){const e=new Di;return this.processImage(t,e),e}convertViewport(t){const e=new Ni;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new Oi;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertXline(t){const e=new Ri;return e.basePoint.copy(t.firstPoint),e.unitDir.copy(t.unitDirection),e}convertBlockReference(t){const e=new tn(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?C.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement}processCommonAttrs(t,e){e.layer=t.layer,e.objectId=t.handle,e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const s=t.length;let r=0;if(s/2==e?r=2:s/3==e&&(r=3),r==0)return;const i=[];for(let a=0,o=s/r;a<o;++a)i.push({x:t[a*r],y:t[a*r+1],z:r==3?t[a*r+2]:0});return i}}class ln extends Rt{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new K,this._extents=new O}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class hn extends Rt{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(t){return this.getAt(t)?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,r)=>{s===e&&this._recordsByName.delete(r)}),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new $e(this._recordsByName)}}class Ui extends hn{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Wi extends Rt{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class rl{convertLayout(t){const e=new ln;return e.layoutName=t.layoutName,e.tabOrder=t.tabOrder,e.blockTableRecordId=t.ownerObjectId,e.limits.min.copy(t.minLimit),e.limits.max.copy(t.maxLimit),e.extents.min.copy(t.minExtent),e.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,e),e}convertImageDef(t){const e=new Wi;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Yi extends Tr{parse(t){return new Wo().parseSync(t)}getFonts(t){var i;const e=new Map,s=a=>{if(a){const o=a.lastIndexOf(".");return o>=0?a.substring(0,o).toLowerCase():a.toLowerCase()}};(i=t.tables.STYLE)==null||i.entries.forEach(a=>{const o=[];let c=s(a.font);c&&o.push(c),c=s(a.bigFont),c&&o.push(c),e.set(a.name,o)});const r=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,r),Array.from(r)}getFontsInBlock(t,e,s,r){const i=/\\f(.*?)\|/g;t.forEach(a=>{if(a.type=="MTEXT"){const o=a;[...o.text.join("").matchAll(i)].forEach(d=>{r.add(d[1].toLowerCase())});const h=s.get(o.styleName);h==null||h.forEach(d=>r.add(d))}else if(a.type=="TEXT"){const o=a,c=s.get(o.styleName);c==null||c.forEach(h=>r.add(h))}else if(a.type=="INSERT"){const c=e[a.name];c&&c.entities&&this.getFontsInBlock(c.entities,e,s,r)}})}async processEntities(t,e,s,r,i){const a=new Hi,o=t.entities,c=o.length,h=new Pn(c,100-r.value,s),d=e.tables.blockTable.modelSpace,u=e.tables.blockTable;await h.processChunk(async(m,p)=>{for(let y=m;y<p;y++){const _=o[y],x=a.convert(_);if(x){let f=d;_.ownerBlockRecordSoftId!=null&&(f=u.getIdAt(_.ownerBlockRecordSoftId)||f),f.appendEntity(x)}}if(i){let y=r.value+p/c*(100-r.value);y>100&&(y=100),await i(y,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e,s){const r=new Hi,i=t.length;for(let a=0;a<i;a++){const o=t[a],c=r.convert(o);if(c){let h=e;o.ownerBlockRecordSoftId!=null&&(h=s.getIdAt(o.ownerBlockRecordSoftId)||h),h.appendEntity(c)}}}processBlocks(t,e){const s=t.blocks;for(const[r,i]of Object.entries(s)){let a=e.tables.blockTable.getAt(i.name);a||(a=new Mt,a.objectId=i.handle,a.name=r,a.origin.copy(i.position),e.tables.blockTable.add(a)),i.entities&&this.processEntitiesInBlock(i.entities,a,e.tables.blockTable)}}processHeader(t,e){const s=t.header;e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,e.aunits=s.$AUNITS,e.insunits=s.$INSUNITS,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0}processBlockTables(t,e){var r;const s=(r=t.tables.BLOCK_RECORD)==null?void 0:r.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(i=>{const a=new Mt;a.objectId=i.handle,a.name=i.name,e.tables.blockTable.add(a)}))}processObjects(t,e){const s=t.objects.byName,r=new rl;if("LAYOUT"in s){const i=e.dictionaries.layouts;s.LAYOUT.forEach(a=>{const o=r.convertLayout(a);i.setAt(o.layoutName,o)})}if("IMAGEDEF"in s){const i=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(a=>{const o=r.convertImageDef(a);i.setAt(o.objectId,o)})}}processViewports(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.VPORT)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new aa;this.processCommonTableEntryAttrs(a,o),a.circleSides&&(o.circleSides=a.circleSides),o.standardFlag=a.standardFlag,o.center.copy(a.center),o.lowerLeftCorner.copy(a.lowerLeftCorner),o.upperRightCorner.copy(a.upperRightCorner),a.snapBasePoint&&o.snapBase.copy(a.snapBasePoint),a.snapRotationAngle&&(o.snapAngle=a.snapRotationAngle),a.snapSpacing&&o.snapIncrements.copy(a.snapSpacing),a.majorGridLines&&(o.gridMajor=a.majorGridLines),a.gridSpacing&&o.gridIncrements.copy(a.gridSpacing),a.backgroundObjectId&&(o.backgroundObjectId=a.backgroundObjectId),o.gsView.center.copy(a.center),o.gsView.viewDirectionFromTarget.copy(a.viewDirectionFromTarget),o.gsView.viewTarget.copy(a.viewTarget),a.lensLength&&(o.gsView.lensLength=a.lensLength),a.frontClippingPlane&&(o.gsView.frontClippingPlane=a.frontClippingPlane),a.backClippingPlane&&(o.gsView.backClippingPlane=a.backClippingPlane),a.viewHeight&&(o.gsView.viewHeight=a.viewHeight),a.viewTwistAngle&&(o.gsView.viewTwistAngle=a.viewTwistAngle),a.frozenLayers&&(o.gsView.frozenLayers=a.frozenLayers),a.styleSheet&&(o.gsView.styleSheet=a.styleSheet),a.renderMode&&(o.gsView.renderMode=a.renderMode),a.viewMode&&(o.gsView.viewMode=a.viewMode),a.ucsIconSetting&&(o.gsView.ucsIconSetting=a.ucsIconSetting),a.ucsOrigin&&o.gsView.ucsOrigin.copy(a.ucsOrigin),a.ucsXAxis&&o.gsView.ucsXAxis.copy(a.ucsXAxis),a.ucsYAxis&&o.gsView.ucsYAxis.copy(a.ucsYAxis),a.orthographicType&&(o.gsView.orthographicType=a.orthographicType),a.shadePlotSetting&&(o.gsView.shadePlotSetting=a.shadePlotSetting),a.shadePlotObjectId&&(o.gsView.shadePlotObjectId=a.shadePlotObjectId),a.visualStyleObjectId&&(o.gsView.visualStyleObjectId=a.visualStyleObjectId),a.isDefaultLightingOn&&(o.gsView.isDefaultLightingOn=a.isDefaultLightingOn),a.defaultLightingType&&(o.gsView.defaultLightingType=a.defaultLightingType),a.brightness&&(o.gsView.brightness=a.brightness),a.contrast&&(o.gsView.contrast=a.contrast),a.ambientColor&&(o.gsView.ambientColor=a.ambientColor),e.tables.viewportTable.add(o)})}processLayers(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.LAYER)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new zt;o.colorIndex=a.colorIndex;const c=new cn({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.colorIndex<0,color:o,isPlottable:a.isPlotting});this.processCommonTableEntryAttrs(a,c),e.tables.layerTable.add(c)})}processLineTypes(t,e){var r,i;const s=(i=(r=t.tables)==null?void 0:r.LTYPE)==null?void 0:i.entries;s&&s.length>0&&s.forEach(a=>{const o=new ra(a);this.processCommonTableEntryAttrs(a,o),o.name=a.name,e.tables.linetypeTable.add(o)})}processTextStyles(t,e){var r;const s=(r=t.tables.STYLE)==null?void 0:r.entries;s&&s.length>0&&s.forEach(i=>{const a=new ia(i);this.processCommonTableEntryAttrs(i,a),e.tables.textStyleTable.add(a)})}processDimStyles(t,e){var r;const s=(r=t.tables.DIMSTYLE)==null?void 0:r.entries;s&&s.length>0&&s.forEach(i=>{const a={name:i.name,ownerId:i.ownerObjectId,dimpost:i.DIMPOST||"",dimapost:i.DIMAPOST||"",dimscale:i.DIMSCALE,dimasz:i.DIMASZ,dimexo:i.DIMEXO,dimdli:i.DIMDLI,dimexe:i.DIMEXE,dimrnd:i.DIMRND,dimdle:i.DIMDLE,dimtp:i.DIMTP,dimtm:i.DIMTM,dimtxt:i.DIMTXT,dimcen:i.DIMCEN,dimtsz:i.DIMTSZ,dimaltf:i.DIMALTF,dimlfac:i.DIMLFAC,dimtvp:i.DIMTVP,dimtfac:i.DIMTFAC,dimgap:i.DIMGAP,dimaltrnd:i.DIMALTRND,dimtol:i.DIMTOL==null||i.DIMTOL==0?0:1,dimlim:i.DIMLIM==null||i.DIMLIM==0?0:1,dimtih:i.DIMTIH==null||i.DIMTIH==0?0:1,dimtoh:i.DIMTOH==null||i.DIMTOH==0?0:1,dimse1:i.DIMSE1==null||i.DIMSE1==0?0:1,dimse2:i.DIMSE2==null||i.DIMSE2==0?0:1,dimtad:i.DIMTAD,dimzin:i.DIMZIN,dimazin:i.DIMAZIN,dimalt:i.DIMALT,dimaltd:i.DIMALTD,dimtofl:i.DIMTOFL,dimsah:i.DIMSAH,dimtix:i.DIMTIX,dimsoxd:i.DIMSOXD,dimclrd:i.DIMCLRD,dimclre:i.DIMCLRE,dimclrt:i.DIMCLRT,dimadec:i.DIMADEC||0,dimunit:i.DIMUNIT||2,dimdec:i.DIMDEC,dimtdec:i.DIMTDEC,dimaltu:i.DIMALTU,dimalttd:i.DIMALTTD,dimaunit:i.DIMAUNIT,dimfrac:i.DIMFRAC,dimlunit:i.DIMLUNIT,dimdsep:i.DIMDSEP,dimtmove:i.DIMTMOVE||0,dimjust:i.DIMJUST,dimsd1:i.DIMSD1,dimsd2:i.DIMSD2,dimtolj:i.DIMTOLJ,dimtzin:i.DIMTZIN,dimaltz:i.DIMALTZ,dimalttz:i.DIMALTTZ,dimfit:i.DIMFIT||0,dimupt:i.DIMUPT,dimatfit:i.DIMATFIT,dimtxsty:i.DIMTXSTY||"Standard",dimldrblk:i.DIMLDRBLK||"",dimblk:i.DIMBLK||"",dimblk1:i.DIMBLK1||"",dimblk2:i.DIMBLK2||"",dimlwd:i.DIMLWD,dimlwe:i.DIMLWE},o=new Ne(a);this.processCommonTableEntryAttrs(i,o),e.tables.dimStyleTable.add(o)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}}var Oe=(n=>(n.DXF="dxf",n.DWG="dwg",n))(Oe||{});class yt{constructor(){this.events={registered:new st,unregistered:new st},this._converters=new Map,this.register("dxf",new Yi)}static createInstance(){return yt._instance==null&&(yt._instance=new yt),this._instance}static get instance(){return yt._instance||(yt._instance=new yt),yt._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}class Zt extends Rt{constructor(t,e){t=t||{},ee(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const he=class he extends Zt{constructor(){super(),this._origin=new b,this._entities=new Map}get isModelSapce(){return this.name.toLowerCase()==he.MODEL_SPACE_NAME.toLowerCase()}get isPaperSapce(){return this.name.toLowerCase().startsWith(he.PAPER_SPACE_NAME_PREFIX.toLowerCase())}get origin(){return this._origin}set origin(t){this._origin.copy(t)}appendEntity(t){t.database=this.database,t.ownerId=this.objectId,this._entities.set(t.objectId,t),(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}newIterator(){return new $e(this._entities)}getIdAt(t){return this._entities.get(t)}};he.MODEL_SPACE_NAME="*Model_Space",he.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let Mt=he;class Qt extends Rt{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}add(t){t.database=this.database,this._recordsByName.set(t.name,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this._recordsByName.get(t);return e?(this._recordsById.delete(e.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t)}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new $e(this._recordsByName)}}class qi extends Qt{constructor(t){super(t)}get modelSpace(){let t=this.getAt(Mt.MODEL_SPACE_NAME);return t||(t=new Mt,t.name=Mt.MODEL_SPACE_NAME,this.add(t)),t}}class Xi extends Qt{constructor(t){super(t)}}class cn extends Zt{constructor(t,e){t=t||{},ee(t,{color:new zt,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class $i extends Qt{constructor(t){super(t);const e=new zt;e.color=16777215;const s=new cn({name:"0",standardFlags:0,linetype:qe,lineWeight:1,isOff:!1,color:e,isPlottable:!0});this.add(s)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Ki extends Qt{constructor(t){super(t)}}class Zi extends Qt{constructor(t){super(t)}get fonts(){const t=new Set,e=r=>{if(r){const i=r.lastIndexOf(".");if(i>=0){const a=r.substring(0,i).toLowerCase();t.add(a)}else t.add(r.toLowerCase())}},s=this.newIterator();for(const r of s)e(r.fileName),e(r.bigFontFileName);return Array.from(t)}}class Qi extends Qt{constructor(t){super(t)}}class il extends Rt{constructor(){super(),this.events={entityAppended:new st,entityModified:new st,layerAppended:new st,layerModified:new st,layerErased:new st,openProgress:new st,headerSysVarChanged:new st},this._angBase=0,this._angDir=0,this._aunits=Ns.DecimalDegrees,this._celtscale=1,this._cecolor=new zt,this._insunits=Ds.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new qi(this),dimStyleTable:new Xi(this),linetypeTable:new Ki(this),textStyleTable:new Zi(this),layerTable:new $i(this),viewportTable:new Qi(this)},this._dictionaries={layouts:new Ui(this),imageDefs:new hn(this)}}get tables(){return this._tables}get dictionaries(){return this._dictionaries}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this._aunits=t||0,this.triggerHeaderSysVarChangedEvent("aunits")}get insunits(){return this._insunits}set insunits(t){this._insunits=t||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(t){this._ltscale=t||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(t){this._cecolor=t||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(t){this._celtscale=t||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(t){this._angBase=t||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(t){this._angDir=t||0,this.triggerHeaderSysVarChangedEvent("angdir")}get pdmode(){return this._pdmode}set pdmode(t){this._pdmode=t||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(t){this._pdsize=t||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(t,e,s=Oe.DXF){const r=yt.instance.get(s);if(r==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await r.read(t,this,e&&e.minimumChunkSize||10,async(i,a,o,c)=>{if(this.events.openProgress.dispatch({database:this,percentage:i,stage:"CONVERSION",subStage:a,stageStatus:o}),e&&e.fontLoader&&a=="FONT"&&o=="END"){const h=c||this.tables.textStyleTable.fonts;await e.fontLoader.load(h)}})}async openUri(t,e){this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",stageStatus:"START"});const s=await fetch(t);if(this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",stageStatus:"END"}),!s.ok)throw new Error(`Failed to fetch file '${t}' with HTTP status codee '${s.status}'!`);if(t.toLowerCase().split(".").pop()==="dwg"){const i=await s.arrayBuffer();await this.read(i,e,Oe.DWG)}else{const i=await s.text();await this.read(i,e,Oe.DXF)}}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._dictionaries.layouts.removeAll(),this._currentSpace=void 0}triggerHeaderSysVarChangedEvent(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}}var Ji=(n=>(n[n.Center=0]="Center",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.OverFirst=3]="OverFirst",n[n.OverSecond=4]="OverSecond",n))(Ji||{}),ta=(n=>(n[n.Center=0]="Center",n[n.Above=1]="Above",n[n.Outside=2]="Outside",n[n.JIS=3]="JIS",n[n.Below=4]="Below",n))(ta||{}),ea=(n=>(n[n.Feet=0]="Feet",n[n.None=1]="None",n[n.Inch=2]="Inch",n[n.FeetAndInch=3]="FeetAndInch",n[n.Leading=4]="Leading",n[n.Trailing=8]="Trailing",n[n.LeadingAndTrailing=12]="LeadingAndTrailing",n))(ea||{}),sa=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(sa||{}),na=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(na||{});const hs=class hs extends Zt{constructor(t,e){t=t||{},ee(t,hs.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}};hs.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:"Standard",dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Ne=hs;class ra extends Zt{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class ia extends Zt{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}const al={center:new L,viewDirectionFromTarget:new b(0,0,1),viewTarget:new b(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:sn.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new b(0,0,0),ucsXAxis:new b(1,0,0),ucsYAxis:new b(0,1,0),orthographicType:nn.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:rn.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class aa extends Zt{constructor(){super(),this._circleSides=100,this._center=new L,this._lowerLeftCorner=new L(0,0),this._upperRightCorner=new L(1,1),this._snapBase=new L(0,0),this._snapAngle=0,this._snapSpacing=new L(0,0),this._standardFlag=0,this._gridSpacing=new L,this._gridMajor=10,this._gsView=al}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get gsView(){return this._gsView}}class oa{constructor(){this.events={layoutSwitched:new st}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(r,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(r,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),r=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(r,s)}renameLayout(t,e,s){const i=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return i?(i.layoutName=e,!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.remove(t)}createLayout(t,e){const s=this.getWorkingDatabase(e),r=new ln;r.layoutName=t,r.tabOrder=s.dictionaries.layouts.maxTabOrder;const i=new Mt;return i.name=`*Paper_Space${r.tabOrder}`,s.tables.blockTable.add(i),s.dictionaries.layouts.setAt(t,r),{layout:r,btr:i}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||dn().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({oldLayout:this.getActiveLayout(),newLayout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function dn(){return ls.instance}const cs=class cs{constructor(){this._workingDatabase=null,this._layoutManager=new oa}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){return this._layoutManager}};cs.instance=new cs;let ls=cs;g.AcCmColor=zt,g.AcCmErrors=et,g.AcCmEventDispatcher=ga,g.AcCmEventManager=st,g.AcCmLoader=Aa,g.AcCmLoadingManager=wn,g.AcCmObject=fn,g.AcCmPerformanceCollector=xs,g.AcCmTask=xn,g.AcCmTaskScheduler=bn,g.AcDb3PointAngularDimension=Fi,g.AcDbAlignedDimension=Bi,g.AcDbAngleUnits=Ns,g.AcDbArc=mi,g.AcDbArcDimension=nl,g.AcDbBatchProcessing=Pn,g.AcDbBlockReference=tn,g.AcDbBlockTable=qi,g.AcDbBlockTableRecord=Mt,g.AcDbCircle=gi,g.AcDbCurve=gt,g.AcDbDatabase=il,g.AcDbDatabaseConverter=Tr,g.AcDbDatabaseConverterManager=yt,g.AcDbDiametricDimension=Vi,g.AcDbDictionary=hn,g.AcDbDimArrowType=Ir,g.AcDbDimStyleTable=Xi,g.AcDbDimStyleTableRecord=Ne,g.AcDbDimTextHorizontal=Ji,g.AcDbDimTextVertical=ta,g.AcDbDimVerticalJustification=na,g.AcDbDimZeroSuppression=ea,g.AcDbDimZeroSuppressionAngular=sa,g.AcDbDimension=Kt,g.AcDbDxfConverter=Yi,g.AcDbEllipse=ui,g.AcDbEntity=pt,g.AcDbFileType=Oe,g.AcDbHatch=_i,g.AcDbHatchPatternType=pi,g.AcDbHatchStyle=yi,g.AcDbHostApplicationServices=ls,g.AcDbLayerTable=$i,g.AcDbLayerTableRecord=cn,g.AcDbLayout=ln,g.AcDbLayoutDictionary=Ui,g.AcDbLayoutManager=oa,g.AcDbLeader=xi,g.AcDbLeaderAnnotationType=fi,g.AcDbLine=bi,g.AcDbLineSpacingStyle=zi,g.AcDbLinetypeTable=Ki,g.AcDbLinetypeTableRecord=ra,g.AcDbMText=wi,g.AcDbObject=Rt,g.AcDbObjectIterator=$e,g.AcDbOrdinateDimension=ji,g.AcDbOsnapMode=Ut,g.AcDbPoint=vi,g.AcDbPolyline=Mi,g.AcDbRadialDimension=Gi,g.AcDbRasterImage=on,g.AcDbRasterImageClipBoundaryType=Li,g.AcDbRasterImageDef=Wi,g.AcDbRasterImageImageDisplayOpt=ki,g.AcDbRay=Oi,g.AcDbRenderingCache=kt,g.AcDbSpline=an,g.AcDbSymbolTable=Qt,g.AcDbSymbolTableRecord=Zt,g.AcDbTable=Ai,g.AcDbText=Ti,g.AcDbTextHorizontalMode=Ii,g.AcDbTextStyleTable=Zi,g.AcDbTextStyleTableRecord=ia,g.AcDbTextVerticalMode=Ei,g.AcDbTrace=Si,g.AcDbUnitsValue=Ds,g.AcDbViewport=Ni,g.AcDbViewportTable=Qi,g.AcDbViewportTableRecord=aa,g.AcDbWipeout=Di,g.AcDbXline=Ri,g.AcGeArea2d=Je,g.AcGeBox2d=K,g.AcGeBox3d=O,g.AcGeCatmullRomCurve3d=hi,g.AcGeCircArc2d=oe,g.AcGeCircArc3d=Xt,g.AcGeCurve2d=ae,g.AcGeEllipseArc2d=es,g.AcGeEllipseArc3d=ss,g.AcGeEuler=ii,g.AcGeGeometryUtil=Xr,g.AcGeLine2d=ns,g.AcGeLine3d=Nt,g.AcGeLoop2d=li,g.AcGeMathUtil=C,g.AcGeMatrix2d=Ke,g.AcGeMatrix3d=Yt,g.AcGeNurbsCurve=mt,g.AcGePlane=Le,g.AcGePoint2d=L,g.AcGePoint3d=b,g.AcGePolyline2d=Ce,g.AcGeQuaternion=Ct,g.AcGeShape2d=Zs,g.AcGeSpline3d=Dt,g.AcGeTol=Ws,g.AcGeVector2d=B,g.AcGeVector3d=w,g.AcGiArrowType=en,g.AcGiDefaultLightingType=rn,g.AcGiMTextAttachmentPoint=le,g.AcGiMTextFlowDirection=is,g.AcGiOrthographicType=nn,g.AcGiRenderMode=sn,g.AcGiViewport=as,g.AcTrStringUtil=wa,g.ByBlock=Pr,g.ByLayer=Xe,g.DEBUG_MODE=xa,g.DEFAULT_LINE_TYPE=qe,g.DEFAULT_TOL=Ys,g.DEG2RAD=Rs,g.DefaultLoadingManager=An,g.FLOAT_TOL=Wt,g.ORIGIN_POINT_2D=Xo,g.ORIGIN_POINT_3D=Us,g.RAD2DEG=zs,g.TAU=H,g.acdbHostApplicationServices=dn,g.basisFunction=Ze,g.calculateCurveLength=Qr,g.ceilPowerOfTwo=Gr,g.clamp=Tt,g.clone=me,g.damp=kr,g.defaults=ee,g.degToRad=Br,g.euclideanModulo=Fs,g.evaluateNurbsPoint=ve,g.floorPowerOfTwo=Hr,g.generateChordKnots=Kr,g.generateSqrtChordKnots=Zr,g.generateUUID=Mr,g.generateUniformKnots=$r,g.has=yn,g.intPartLength=Vs,g.interpolateControlPoints=$o,g.inverseLerp=Lr,g.isBetween=Ur,g.isBetweenAngle=Wr,g.isEmpty=_n,g.isEqual=se,g.isImperialUnits=qo,g.isMetricUnits=Yo,g.isPointInPolygon=qs,g.isPolygonIntersect=qr,g.isPowerOfTwo=jr,g.lerp=Bs,g.log=ue,g.mapLinear=vr,g.normalizeAngle=Me,g.pingpong=Cr,g.radToDeg=Vr,g.randFloat=Rr,g.randFloatSpread=zr,g.randInt=Dr,g.relativeEps=Yr,g.seededRandom=Fr,g.setLogLevel=ba,g.smootherstep=Nr,g.smoothstep=Or,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});