@mlightcad/data-model 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-model.cjs +4 -4
- package/dist/data-model.js +3074 -2526
- package/lib/converter/AcDbDxfConverter.d.ts.map +1 -1
- package/lib/converter/AcDbDxfConverter.js +15 -6
- package/lib/converter/AcDbDxfConverter.js.map +1 -1
- package/lib/converter/AcDbEntitiyConverter.d.ts +1 -0
- package/lib/converter/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/converter/AcDbEntitiyConverter.js +56 -2
- package/lib/converter/AcDbEntitiyConverter.js.map +1 -1
- package/lib/entity/AcDb2dPolyline.d.ts +146 -0
- package/lib/entity/AcDb2dPolyline.d.ts.map +1 -0
- package/lib/entity/AcDb2dPolyline.js +220 -0
- package/lib/entity/AcDb2dPolyline.js.map +1 -0
- package/lib/entity/AcDb2dVertex.d.ts +143 -0
- package/lib/entity/AcDb2dVertex.d.ts.map +1 -0
- package/lib/entity/AcDb2dVertex.js +210 -0
- package/lib/entity/AcDb2dVertex.js.map +1 -0
- package/lib/entity/AcDb3dPolyline.d.ts +102 -0
- package/lib/entity/AcDb3dPolyline.d.ts.map +1 -0
- package/lib/entity/AcDb3dPolyline.js +158 -0
- package/lib/entity/AcDb3dPolyline.js.map +1 -0
- package/lib/entity/AcDb3dVertex.d.ts +83 -0
- package/lib/entity/AcDb3dVertex.d.ts.map +1 -0
- package/lib/entity/AcDb3dVertex.js +133 -0
- package/lib/entity/AcDb3dVertex.js.map +1 -0
- package/lib/entity/AcDbBlockReference.d.ts +2 -2
- package/lib/entity/AcDbBlockReference.d.ts.map +1 -1
- package/lib/entity/AcDbBlockReference.js.map +1 -1
- package/lib/entity/AcDbPoint.js +1 -1
- package/lib/entity/AcDbPoint.js.map +1 -1
- package/lib/entity/dimension/AcDbDimension.d.ts +61 -1
- package/lib/entity/dimension/AcDbDimension.d.ts.map +1 -1
- package/lib/entity/dimension/AcDbDimension.js +77 -2
- package/lib/entity/dimension/AcDbDimension.js.map +1 -1
- package/lib/entity/index.d.ts +4 -0
- package/lib/entity/index.d.ts.map +1 -1
- package/lib/entity/index.js +4 -0
- package/lib/entity/index.js.map +1 -1
- package/package.json +4 -4
package/dist/data-model.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ku(i,e){for(var t=0;t<e.length;t++){const s=e[t];if(typeof s!="string"&&!Array.isArray(s)){for(const o in s)if(o!=="default"&&!(o in i)){const h=Object.getOwnPropertyDescriptor(s,o);h&&Object.defineProperty(i,o,h.get?h:{enumerable:!0,get:()=>s[o]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}const Ys={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},Xi=[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 hs(i,e,t){return Math.max(e,Math.min(t,i))}const Qo=class Jo{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(e){e==null?this._color=null:(this._color=Math.round(hs(e,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 e=this._color.toString(16).toUpperCase();for(;e.length<6;)e="0"+e;return`0x${e}`}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(e){e==null?this._colorIndex=null:(this._colorIndex=hs(e,0,256),this._colorIndex>0&&this._colorIndex<256?(this._color=Xi[e],this._colorName=this.getColorNameByValue(this._color)):(this._color=null,this._colorName=null))}get colorName(){return this._colorName}set colorName(e){if(e){const t=Ys[e.toLowerCase()];t!==void 0?(this._colorName=e,this._color=t,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+e)}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(e){return this.setRGB(e,e,e),this}setRGB(e,t,s){const o=Math.round(hs(e,0,255)),h=Math.round(hs(t,0,255)),c=Math.round(hs(s,0,255));return this.color=(o<<16)+(h<<8)+c,this}setColorName(e){const t=Ys[e.toLowerCase()];return t!==void 0?this.color=t:console.warn("Unknown color "+e),this}clone(){const e=new Jo;return e.colorIndex=this.colorIndex,e.color=this.color,e._colorName=this._colorName,this}copy(e){return this.colorIndex=e.colorIndex,this.color=e.color,this._colorName=e._colorName,this}equals(e){return e.color==this.color&&e.colorIndex==this.colorIndex&&e._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(e){for(const[t,s]of Object.entries(Ys))if(s===e)return t;return null}getColorIndexByValue(e){const t=Xi.length-1;for(let s=1;s<t;++s)if(Xi[s]===e)return s;return null}};Qo.NAMES=Ys;let Wr=Qo;const Ut={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")}};let $u=class{constructor(){this._listeners={}}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const s=t.slice(0);for(let o=0,h=s.length;o<h;o++)s[o].call(this,e)}}},it=class{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const s of this.listeners)s.call(null,e,...t)}};var Zu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qu(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var el={exports:{}};(function(i){(function(e,t){i.exports?i.exports=t():e.log=t()})(Zu,function(){var e=function(){},t="undefined",s=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],h={},c=null;function f(z,U){var D=z[U];if(typeof D.bind=="function")return D.bind(z);try{return Function.prototype.bind.call(D,z)}catch{return function(){return Function.prototype.apply.apply(D,[z,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function g(z){return z==="debug"&&(z="log"),typeof console===t?!1:z==="trace"&&s?b:console[z]!==void 0?f(console,z):console.log!==void 0?f(console,"log"):e}function A(){for(var z=this.getLevel(),U=0;U<o.length;U++){var D=o[U];this[D]=U<z?e:this.methodFactory(D,z,this.name)}if(this.log=this.debug,typeof console===t&&z<this.levels.SILENT)return"No console available for logging"}function x(z){return function(){typeof console!==t&&(A.call(this),this[z].apply(this,arguments))}}function E(z,U,D){return g(z)||x.apply(this,arguments)}function T(z,U){var D=this,de,ve,oe,W="loglevel";typeof z=="string"?W+=":"+z:typeof z=="symbol"&&(W=void 0);function ue(xe){var Le=(o[xe]||"silent").toUpperCase();if(!(typeof window===t||!W)){try{window.localStorage[W]=Le;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Le+";"}catch{}}}function se(){var xe;if(!(typeof window===t||!W)){try{xe=window.localStorage[W]}catch{}if(typeof xe===t)try{var Le=window.document.cookie,dt=encodeURIComponent(W),mt=Le.indexOf(dt+"=");mt!==-1&&(xe=/^([^;]+)/.exec(Le.slice(mt+dt.length+1))[1])}catch{}return D.levels[xe]===void 0&&(xe=void 0),xe}}function Ve(){if(!(typeof window===t||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Ye(xe){var Le=xe;if(typeof Le=="string"&&D.levels[Le.toUpperCase()]!==void 0&&(Le=D.levels[Le.toUpperCase()]),typeof Le=="number"&&Le>=0&&Le<=D.levels.SILENT)return Le;throw new TypeError("log.setLevel() called with invalid level: "+xe)}D.name=z,D.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},D.methodFactory=U||E,D.getLevel=function(){return oe??ve??de},D.setLevel=function(xe,Le){return oe=Ye(xe),Le!==!1&&ue(oe),A.call(D)},D.setDefaultLevel=function(xe){ve=Ye(xe),se()||D.setLevel(xe,!1)},D.resetLevel=function(){oe=null,Ve(),A.call(D)},D.enableAll=function(xe){D.setLevel(D.levels.TRACE,xe)},D.disableAll=function(xe){D.setLevel(D.levels.SILENT,xe)},D.rebuild=function(){if(c!==D&&(de=Ye(c.getLevel())),A.call(D),c===D)for(var xe in h)h[xe].rebuild()},de=Ye(c?c.getLevel():"WARN");var We=se();We!=null&&(oe=Ye(We)),A.call(D)}c=new T,c.getLogger=function(z){if(typeof z!="symbol"&&typeof z!="string"||z==="")throw new TypeError("You must supply a name when creating a logger.");var U=h[z];return U||(U=h[z]=new T(z,c.methodFactory)),U};var O=typeof window!==t?window.log:void 0;return c.noConflict=function(){return typeof window!==t&&window.log===c&&(window.log=O),c},c.getLoggers=function(){return h},c.default=c,c})})(el);var tl=el.exports;const Ju=Qu(tl),ec=Ku({__proto__:null,default:Ju},[tl]),tc=!0,ks=ec;ks.setLevel("debug");const rc=i=>{try{ks.setLevel(i)}catch(e){ks.setLevel("error"),ks.error(e)}};function Ps(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function Fn(i,...e){for(const t of e)if(t)for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&i[s]===void 0&&(i[s]=t[s]);return i}function rl(i,e){return i!=null&&Object.prototype.hasOwnProperty.call(i,e)}function nl(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function zn(i,e){if(i===e)return!0;if(i==null||e==null)return i===e;if(typeof i!=typeof e)return!1;if(typeof i!="object")return i===e;if(Array.isArray(i)!==Array.isArray(e))return!1;if(Array.isArray(i)){if(i.length!==e.length)return!1;for(let o=0;o<i.length;o++)if(!zn(i[o],e[o]))return!1;return!0}const t=Object.keys(i),s=Object.keys(e);if(t.length!==s.length)return!1;for(const o of t)if(!Object.prototype.hasOwnProperty.call(e,o)||!zn(i[o],e[o]))return!1;return!0}let sl=class il{constructor(e,t){this.events={attrChanged:new it,modelChanged:new it},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=e||{};t&&Fn(s,t),this.attributes=s,this.changed={}}get(e){return this.attributes[e]}set(e,t,s){if(e==null)return this;let o;typeof e=="object"?(o=e,s=t):(o={},o[e]=t),s||(s={});const h=s.unset,c=s.silent,f=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=Ps(this.attributes),this.changed={});const g=this.attributes,A=this.changed,x=this._previousAttributes;for(const E in o)t=o[E],zn(g[E],t)||f.push(E),zn(x[E],t)?delete A[E]:A[E]=t,h?delete g[E]:g[E]=t;if(!c){f.length&&(this._pending=s);for(let E=0;E<f.length;E++)this.events.attrChanged.dispatch({object:this,attrName:f[E],attrValue:g[f[E]],options:s})}if(b)return this;if(!c)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(e){return this.get(e)!=null}hasChanged(e){return e==null?!nl(this.changed):rl(this.changed,e)}changedAttributes(e){if(!e)return this.hasChanged()?Ps(this.changed):{};const t=this._changing?this._previousAttributes:this.attributes,s={};for(const o in e){const h=e[o];zn(t[o],h)||(s[o]=h)}return s}previous(e){return e==null||!this._previousAttributes?null:this._previousAttributes[e]}previousAttributes(){return Ps(this._previousAttributes)}clone(){const e=Ps(this.attributes);return new il(e)}},fa=class Es{constructor(){this.entries=new Map}static getInstance(){return Es.instance||(Es.instance=new Es),Es.instance}collect(e){this.entries.set(e.name,e)}printAll(){for(const[e,t]of this.entries)console.log(`${e}:`),console.log(t.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(e){return this.entries.get(e)}remove(e){return this.entries.delete(e)}};class nc{static formatBytes(e,t=2){if(e===0)return"0 B";const s=1024,o=Math.max(0,t),h=["B","KB","MB","GB","TB"],c=Math.floor(Math.log(e)/Math.log(s)),f=e/Math.pow(s,c);return`${parseFloat(f.toFixed(o))} ${h[c]}`}}class al{constructor(e){this.name=e}run(e){throw new Error("run() must be implemented by subclass")}}class ol{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(e){return new Promise((t,s)=>{const o=()=>{Promise.resolve(e()).then(t).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}addTask(e){this.tasks.push(e)}setProgressCallback(e){this.onProgress=e}setCompleteCallback(e){this.onComplete=e}setErrorCallback(e){this.onError=e}async run(e){const t=this.tasks.length;let s=e;for(let o=0;o<t;o++){const h=this.tasks[o];try{s=await this.scheduleTask(async()=>{const c=await h.run(s);return this.onProgress((o+1)/t,h),c})}catch(c){if(this.onError({error:c,taskIndex:o,task:h}))break}}this.onComplete(s)}}let ll=class{constructor(e,t,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=s}itemStart(e){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(e){this.onError!==void 0&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return t!==-1&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,s=this.handlers.length;t<s;t+=2){const o=this.handlers[t],h=this.handlers[t+1];if(o.global&&(o.lastIndex=0),o.test(e))return h}return null}};const hl=new ll;let sc=class{constructor(e){this.manager=e!==void 0?e:hl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(e,t){return new Promise((s,o)=>{this.load(e,s,t,o)})}parse(e){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};class ga{constructor(e,t,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=e,this._numerOfChunk=t<1?1:t,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(e){this._minimumChunkSize=e,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let e=this._count/this._numerOfChunk;e<this._minimumChunkSize&&(e=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=e<1?this._count:Math.floor(e)}scheduleTask(e){return new Promise((t,s)=>{const o=()=>{Promise.resolve(e()).then(t).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(e){let t=0;const s=async()=>{const o=t,h=Math.min(t+this._chunkSize,this._count);await e(o,h),t=h,t<this._count&&await this.scheduleTask(s)};await s()}}var _a=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(_a||{});class Gr{static get instance(){return this._instance||(this._instance=new Gr),this._instance}constructor(){this._blocks=new Map}createKey(e,t){return`${e}_${t}`}set(e,t){return t=t.fastDeepClone(),this._blocks.set(e,t),t}get(e){let t=this._blocks.get(e);return t&&(t=t.fastDeepClone()),t}has(e){return this._blocks.has(e)}clear(){this._blocks.clear()}draw(e,t,s,o=!0,h,c){const f=[];if(t!=null){const b=this.createKey(t.name,s);let g;if(this.has(b))g=this.get(b);else{const A=t.newIterator();for(const x of A)x.color.isByBlock&&s?(Oo.copy(x.color),x.color.color=s,this.addEntity(x,f,e),x.color.copy(Oo)):this.addEntity(x,f,e);g=e.group(f),g&&o&&this.set(b,g)}return g&&h&&(g.applyMatrix(h),c&&(c.x!=0||c.y!=0||c.z!=1)&&(h.setFromExtrusionDirection(c),g.applyMatrix(h))),g}else return e.group(f)}addEntity(e,t,s){const o=e.draw(s);o&&(this.attachEntityInfo(o,e),t.push(o))}attachEntityInfo(e,t){e.objectId=t.objectId,e.ownerId=t.ownerId,e.layerName=t.layer,e.visible=t.visibility}}const Oo=new Wr;var va=(i=>(i[i.UTF8=0]="UTF8",i[i.US_ASCII=1]="US_ASCII",i[i.ISO_8859_1=2]="ISO_8859_1",i[i.ISO_8859_2=3]="ISO_8859_2",i[i.ISO_8859_3=4]="ISO_8859_3",i[i.ISO_8859_4=5]="ISO_8859_4",i[i.ISO_8859_5=6]="ISO_8859_5",i[i.ISO_8859_6=7]="ISO_8859_6",i[i.ISO_8859_7=8]="ISO_8859_7",i[i.ISO_8859_8=9]="ISO_8859_8",i[i.ISO_8859_9=10]="ISO_8859_9",i[i.CP437=11]="CP437",i[i.CP850=12]="CP850",i[i.CP852=13]="CP852",i[i.CP855=14]="CP855",i[i.CP857=15]="CP857",i[i.CP860=16]="CP860",i[i.CP861=17]="CP861",i[i.CP863=18]="CP863",i[i.CP864=19]="CP864",i[i.CP865=20]="CP865",i[i.CP869=21]="CP869",i[i.CP932=22]="CP932",i[i.MACINTOSH=23]="MACINTOSH",i[i.BIG5=24]="BIG5",i[i.CP949=25]="CP949",i[i.JOHAB=26]="JOHAB",i[i.CP866=27]="CP866",i[i.ANSI_1250=28]="ANSI_1250",i[i.ANSI_1251=29]="ANSI_1251",i[i.ANSI_1252=30]="ANSI_1252",i[i.GB2312=31]="GB2312",i[i.ANSI_1253=32]="ANSI_1253",i[i.ANSI_1254=33]="ANSI_1254",i[i.ANSI_1255=34]="ANSI_1255",i[i.ANSI_1256=35]="ANSI_1256",i[i.ANSI_1257=36]="ANSI_1257",i[i.ANSI_874=37]="ANSI_874",i[i.ANSI_932=38]="ANSI_932",i[i.ANSI_936=39]="ANSI_936",i[i.ANSI_949=40]="ANSI_949",i[i.ANSI_950=41]="ANSI_950",i[i.ANSI_1361=42]="ANSI_1361",i[i.UTF16=43]="UTF16",i[i.ANSI_1258=44]="ANSI_1258",i[i.UNDEFINED=255]="UNDEFINED",i))(va||{});const ic=["utf-8","utf-8","iso-8859-1","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-9","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","shift-jis","macintosh","big5","utf-8","utf-8","ibm866","windows-1250","windows-1251","windows-1252","gbk","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-874","shift-jis","gbk","euc-kr","big5","utf-8","utf-16le","windows-1258"],ul=i=>ic[i],ei="Continuous",Xs="ByLayer",cl="ByBlock";var cn=(i=>(i[i.EndPoint=1]="EndPoint",i[i.MidPoint=2]="MidPoint",i[i.Center=3]="Center",i[i.Node=4]="Node",i[i.Quadrant=5]="Quadrant",i[i.Insertion=7]="Insertion",i[i.Perpendicular=8]="Perpendicular",i[i.Tangent=9]="Tangent",i[i.Nearest=10]="Nearest",i[i.Centroid=11]="Centroid",i))(cn||{}),ya=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(ya||{});function ac(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function oc(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}var dl=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(dl||{});class Ti{constructor(e){this.i=0,this._records=e,this._keys=Array.from(e.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const e=this._records.get(this._keys[this.i]);return this.i+=1,{value:e,done:!1}}return{value:null,done:!0}}}const ml="Load Database";class It extends al{constructor(e,t){super(e.stage),this.data=e,this.progress=t}async run(e){const t=fa.getInstance().getEntry(ml),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const o=await this.data.task(e);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",o?o.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),t&&(t.data[this.name]=Date.now()-s),o}}class ba{constructor(e={}){this.config=e}async read(e,t,s,o){const h={name:ml,data:{total:0},format(){let g="";return Object.keys(this.data).forEach(A=>{A!=="total"&&(g+=`- ${A}: ${this.data[A]} ms
|
|
2
|
-
`)}),g+=`- total: ${this.data.total} ms`,g}};fa.getInstance().collect(h),this.progress=o;const c={value:0},f=new ol;f.setCompleteCallback(()=>this.onFinished()),f.setErrorCallback(g=>this.onError(g)),f.addTask(new It({stage:"START",step:1,progress:c,task:async g=>g},o)),f.addTask(new It({stage:"PARSE",step:5,progress:c,task:async g=>await this.parse(g)},o)),f.addTask(new It({stage:"FONT",step:5,progress:c,task:async g=>{const A=this.getFonts(g.model);return{model:g.model,data:A}}},o)),f.addTask(new It({stage:"LTYPE",step:1,progress:c,task:async g=>(this.processLineTypes(g.model,t),g)},o)),f.addTask(new It({stage:"STYLE",step:1,progress:c,task:async g=>(this.processTextStyles(g.model,t),g)},o)),f.addTask(new It({stage:"DIMSTYLE",step:1,progress:c,task:async g=>(this.processDimStyles(g.model,t),g)},o)),f.addTask(new It({stage:"LAYER",step:1,progress:c,task:async g=>(this.processLayers(g.model,t),t.tables.layerTable.numEntries===0&&t.createDefaultData({layer:!0}),g)},o)),f.addTask(new It({stage:"VPORT",step:1,progress:c,task:async g=>(this.processViewports(g.model,t),g)},o)),f.addTask(new It({stage:"HEADER",step:1,progress:c,task:async g=>(this.processHeader(g.model,t),g)},o)),f.addTask(new It({stage:"BLOCK_RECORD",step:5,progress:c,task:async g=>(this.processBlockTables(g.model,t),g)},o)),f.addTask(new It({stage:"OBJECT",step:5,progress:c,task:async g=>(this.processObjects(g.model,t),t.dictionaries.layouts.numEntries===0&&t.createDefaultData({layout:!0}),g)},o)),f.addTask(new It({stage:"BLOCK",step:5,progress:c,task:async g=>(await this.processBlocks(g.model,t),g)},o)),f.addTask(new It({stage:"ENTITY",step:100,progress:c,task:async g=>(await this.processEntities(g.model,t,s,c,o),g)},o)),f.addTask(new It({stage:"END",step:0,progress:c,task:async g=>g},o));const b=Date.now();await f.run(e),h.data.total=Date.now()-b}onError(e){if(this.progress){const t=e.task;this.progress(t.data.progress.value,t.data.stage,"ERROR",void 0,e)}return console.error(`Error occurred in conversion stage '${e.task.name}': `,e.error),e.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),Gr.instance.clear())}async parse(e,t){throw new Error("Not impelemented yet!")}getFonts(e){throw new Error("Not impelemented yet!")}processLineTypes(e,t){throw new Error("Not impelemented yet!")}processTextStyles(e,t){throw new Error("Not impelemented yet!")}processDimStyles(e,t){throw new Error("Not impelemented yet!")}processLayers(e,t){throw new Error("Not impelemented yet!")}processViewports(e,t){throw new Error("Not impelemented yet!")}processHeader(e,t){throw new Error("Not impelemented yet!")}processBlockTables(e,t){throw new Error("Not impelemented yet!")}processObjects(e,t){throw new Error("Not impelemented yet!")}processBlocks(e,t){throw new Error("Not impelemented yet!")}processEntities(e,t,s,o,h){throw new Error("Not impelemented yet!")}}var ht,us,Qe,st,cs,Jt,yt,pr,er,en,ds,ms,tn,rn,ps,fs,gs,Nt,fr,qe,nn,_s,_e,bt,vs,xt,ys,gr,_r,tr,bs,sn,Ct,vr,an,Ki,$i,yr,br,xs,ws,xr,As,Zi,Qi,ut,wr,ct,Lt,Ji,ea,ta,ra,Ar,Ot,on,Ss,ln,zt,Sr,Rt,Ir;(ht={})[ht.None=0]="None",ht[ht.Anonymous=1]="Anonymous",ht[ht.NonConstant=2]="NonConstant",ht[ht.Xref=4]="Xref",ht[ht.XrefOverlay=8]="XrefOverlay",ht[ht.ExternallyDependent=16]="ExternallyDependent",ht[ht.ResolvedOrDependent=32]="ResolvedOrDependent",ht[ht.ReferencedXref=64]="ReferencedXref";(us={})[us.BYBLOCK=0]="BYBLOCK",us[us.BYLAYER=256]="BYLAYER";(Qe={})[Qe.Rotated=0]="Rotated",Qe[Qe.Aligned=1]="Aligned",Qe[Qe.Angular=2]="Angular",Qe[Qe.Diameter=3]="Diameter",Qe[Qe.Radius=4]="Radius",Qe[Qe.Angular3Point=5]="Angular3Point",Qe[Qe.Ordinate=6]="Ordinate",Qe[Qe.ReferenceIsExclusive=32]="ReferenceIsExclusive",Qe[Qe.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Qe[Qe.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(st={})[st.TopLeft=1]="TopLeft",st[st.TopCenter=2]="TopCenter",st[st.TopRight=3]="TopRight",st[st.MiddleLeft=4]="MiddleLeft",st[st.MiddleCenter=5]="MiddleCenter",st[st.MiddleRight=6]="MiddleRight",st[st.BottomLeft=7]="BottomLeft",st[st.BottomCenter=8]="BottomCenter",st[st.BottomRight=9]="BottomRight";(cs={})[cs.AtLeast=1]="AtLeast",cs[cs.Exact=2]="Exact";var zo=((Jt={})[Jt.Center=0]="Center",Jt[Jt.Above=1]="Above",Jt[Jt.Outside=2]="Outside",Jt[Jt.JIS=3]="JIS",Jt[Jt.Below=4]="Below",Jt),Cn=((yt={})[yt.Feet=0]="Feet",yt[yt.None=1]="None",yt[yt.Inch=2]="Inch",yt[yt.FeetAndInch=3]="FeetAndInch",yt[yt.Leading=4]="Leading",yt[yt.Trailing=8]="Trailing",yt[yt.LeadingAndTrailing=12]="LeadingAndTrailing",yt),lc=((pr={})[pr.None=0]="None",pr[pr.Leading=1]="Leading",pr[pr.Trailing=2]="Trailing",pr[pr.LeadingAndTrailing=3]="LeadingAndTrailing",pr),hc=((er={})[er.Center=0]="Center",er[er.Left=1]="Left",er[er.Right=2]="Right",er[er.OverFirst=3]="OverFirst",er[er.OverSecond=4]="OverSecond",er),uc=((en={})[en.Bottom=0]="Bottom",en[en.Center=1]="Center",en[en.Top=2]="Top",en);(ds={})[ds.PatternFill=0]="PatternFill",ds[ds.SolidFill=1]="SolidFill";(ms={})[ms.NonAssociative=0]="NonAssociative",ms[ms.Associative=1]="Associative";(tn={})[tn.Normal=0]="Normal",tn[tn.Outer=1]="Outer",tn[tn.Ignore=2]="Ignore";(rn={})[rn.UserDefined=0]="UserDefined",rn[rn.Predefined=1]="Predefined",rn[rn.Custom=2]="Custom";(ps={})[ps.NotAnnotated=0]="NotAnnotated",ps[ps.Annotated=1]="Annotated";(fs={})[fs.Solid=0]="Solid",fs[fs.Gradient=1]="Gradient";(gs={})[gs.TwoColor=0]="TwoColor",gs[gs.OneColor=1]="OneColor";var cc=((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),js=((fr={})[fr.Line=1]="Line",fr[fr.Circular=2]="Circular",fr[fr.Elliptic=3]="Elliptic",fr[fr.Spline=4]="Spline",fr),dc=((qe={})[qe.Off=0]="Off",qe[qe.Solid=1]="Solid",qe[qe.Dashed=2]="Dashed",qe[qe.Dotted=3]="Dotted",qe[qe.ShotDash=4]="ShotDash",qe[qe.MediumDash=5]="MediumDash",qe[qe.LongDash=6]="LongDash",qe[qe.DoubleShortDash=7]="DoubleShortDash",qe[qe.DoubleMediumDash=8]="DoubleMediumDash",qe[qe.DoubleLongDash=9]="DoubleLongDash",qe[qe.DoubleMediumLongDash=10]="DoubleMediumLongDash",qe[qe.SparseDot=11]="SparseDot",qe);dc.Off;(nn={})[nn.Standard=-3]="Standard",nn[nn.ByLayer=-2]="ByLayer",nn[nn.ByBlock=-1]="ByBlock";(_s={})[_s.English=0]="English",_s[_s.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";(bt={})[bt.OPTIMIZED_2D=0]="OPTIMIZED_2D",bt[bt.WIREFRAME=1]="WIREFRAME",bt[bt.HIDDEN_LINE=2]="HIDDEN_LINE",bt[bt.FLAT_SHADED=3]="FLAT_SHADED",bt[bt.GOURAUD_SHADED=4]="GOURAUD_SHADED",bt[bt.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",bt[bt.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(vs={})[vs.UCS_UNCHANGED=0]="UCS_UNCHANGED",vs[vs.HAS_OWN_UCS=1]="HAS_OWN_UCS";(xt={})[xt.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",xt[xt.TOP=1]="TOP",xt[xt.BOTTOM=2]="BOTTOM",xt[xt.FRONT=3]="FRONT",xt[xt.BACK=4]="BACK",xt[xt.LEFT=5]="LEFT",xt[xt.RIGHT=6]="RIGHT";(ys={})[ys.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ys[ys.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(gr={})[gr.ByLayer=0]="ByLayer",gr[gr.ByBlock=1]="ByBlock",gr[gr.ByDictionaryDefault=2]="ByDictionaryDefault",gr[gr.ByObject=3]="ByObject";function Ae(i,e,t){return i.code===e&&(t==null||i.value===t)}function ze(i){let e={};i.rewind();let t=i.next(),s=t.code;if(e.x=t.value,(t=i.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+t.code+".");return e.y=t.value,(t=i.next()).code!==s+20?i.rewind():e.z=t.value,e}let xa=Symbol();function be(i,e){return(t,s,o)=>{let h=function(b,g=!1){return b.reduce((A,x)=>{x.pushContext&&A.push({});let E=A[A.length-1];for(let T of typeof x.code=="number"?[x.code]:x.code){let O=E[T]??(E[T]=[]);x.isMultiple&&O.length&&g&&console.warn(`Snippet ${O[O.length-1].name} for code(${T}) is shadowed by ${x.name}`),O.push(x)}return A},[{}])}(i,s.debug),c=!1,f=h.length-1;for(;!Ae(t,0,"EOF");){let b=function(U,D,de){return U.find((ve,oe)=>{var W;return oe>=de&&((W=ve[D])==null?void 0:W.length)})}(h,t.code,f),g=b==null?void 0:b[t.code],A=g==null?void 0:g[g.length-1];if(!b||!A){s.rewind();break}A.isMultiple||b[t.code].pop();let{name:x,parser:E,isMultiple:T,isReducible:O}=A,z=E==null?void 0:E(t,s,o);if(z===xa){s.rewind();break}if(x){let[U,D]=function(de,ve){let oe=ve.split(".");if(!oe.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let W=de;for(let ue=0;ue<oe.length-1;++ue){let se=na(oe[ue]),Ve=na(oe[ue+1]);Object.prototype.hasOwnProperty.call(W,se)||(typeof Ve=="number"?W[se]=[]:W[se]={}),W=W[se]}return[W,na(oe[oe.length-1])]}(o,x);T&&!O?(Object.prototype.hasOwnProperty.call(U,D)||(U[D]=[]),U[D].push(z)):U[D]=z}A.pushContext&&(f-=1),c=!0,t=s.next()}return e&&Object.setPrototypeOf(o,e),c}}function na(i){let e=Number.parseInt(i);return Number.isNaN(e)?i:e}function y({value:i}){return i}function G(i,e){return ze(e)}function De({value:i}){return!!i}let mc=[{code:1001,name:"xdata",parser:pl}];function pl(i,e){var o;if(!Ae(i,1001))throw Error("XData must starts with code 1001");let t={appName:i.value,value:[]};i=e.next();let s=[t.value];for(;!Ae(i,0,"EOF")&&i.code>=1e3;){let h=s[s.length-1];switch(i.code){case 1002:i.value==="{"?s.push([]):(s.pop(),(o=s[s.length-1])==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Pr(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Pr(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Pr(i.code),value:i.value});break;case 1010:h.push({type:Pr(i.code),value:ze(e)});break;case 1011:h.push({name:"worldSpacePosition",type:Pr(i.code),value:ze(e)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Pr(i.code),value:ze(e)});break;case 1013:h.push({name:"worldSpaceDirection",type:Pr(i.code),value:ze(e)});break;case 1041:h.push({name:"distance",type:Pr(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Pr(i.code),value:i.value})}i=e.next()}return e.rewind(),t}function Pr(i){switch(i){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 mn(i,e,t){for(;Ae(i,102);){var s;let o=i.value;if(i=e.next(),!o.startsWith("{")){e.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${o}`),function(c,f){for(;!Ae(c,102)&&!Ae(c,0,"EOF");)c=f.next()}(i,e),i=e.next();continue}let h=o.slice(1).trim();t.extensions??(t.extensions={}),(s=t.extensions)[h]??(s[h]=[]),function(c,f,b){for(;!Ae(c,102,"}")&&!Ae(c,0,"EOF");)b.push(c),c=f.next()}(i,e,t.extensions[h]),i=e.next()}e.rewind()}let pc=0;function fl(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=pc++)}var fc=[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 gl(i){return fc[i]}(_r={})[_r.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",_r[_r.CAST=1]="CAST",_r[_r.RECEIVE=2]="RECEIVE",_r[_r.IGNORE=3]="IGNORE";let Ue=[...mc,{code:284,name:"shadowMode",parser:y},{code:390,name:"plotStyleHardId",parser:y},{code:380,name:"plotStyleType",parser:y},{code:440,name:"transparency",parser:y},{code:430,name:"colorName",parser:y},{code:420,name:"color",parser:y},{code:310,name:"proxyEntity",isMultiple:!0,parser:y},{code:92,name:"proxyByte",parser:y},{code:60,name:"isVisible",parser:De},{code:48,name:"lineTypeScale",parser:y},{code:370,name:"lineweight",parser:y},{code:62,name:"colorIndex",parser(i,e,t){let s=i.value;return s>0&&s<256&&(t.color=gl(Math.abs(s))),s}},{code:347,name:"materialObjectHardId",parser:y},{code:6,name:"lineType",parser:y},{code:8,name:"layer",parser:y},{code:410,name:"layoutTabName",parser:y},{code:67,name:"isInPaperSpace",parser:De},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:y},{code:102,parser:mn},{code:102,parser:mn},{code:102,parser:mn},{code:5,name:"handle",parser:y}];function Mi(i){return[{code:3,name:i,parser:(e,t,s)=>(s._code3text=(s._code3text??"")+e.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(e,t,s)=>(s._code1text=e.value,(s._code3text??"")+s._code1text)}]}function _l(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let gc={extrusionDirection:{x:0,y:0,z:1}},_c=[{code:210,name:"extrusionDirection",parser:G},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:100,name:"subclassMarker",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G},{code:39,name:"thickness",parser:y},{code:100},...Ue];class vl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){_l(this,"parser",be(_c,gc))}}_l(vl,"ForEntityName","ARC");(tr={})[tr.NONE=0]="NONE",tr[tr.INVISIBLE=1]="INVISIBLE",tr[tr.CONSTANT=2]="CONSTANT",tr[tr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",tr[tr.PRESET=8]="PRESET";(bs={})[bs.MULTILINE=2]="MULTILINE",bs[bs.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(sn={})[sn.NONE=0]="NONE",sn[sn.MIRRORED_X=2]="MIRRORED_X",sn[sn.MIRRORED_Y=4]="MIRRORED_Y";var vc=((Ct={})[Ct.LEFT=0]="LEFT",Ct[Ct.CENTER=1]="CENTER",Ct[Ct.RIGHT=2]="RIGHT",Ct[Ct.ALIGNED=3]="ALIGNED",Ct[Ct.MIDDLE=4]="MIDDLE",Ct[Ct.FIT=5]="FIT",Ct),yc=((vr={})[vr.BASELINE=0]="BASELINE",vr[vr.BOTTOM=1]="BOTTOM",vr[vr.MIDDLE=2]="MIDDLE",vr[vr.TOP=3]="TOP",vr);function yl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let bl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:vc.LEFT,valign:yc.BASELINE,extrusionDirection:{x:0,y:0,z:1}},xl=[{code:73,name:"valign",parser:y},{code:100},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{code:72,name:"valign",parser:y},{code:72,name:"halign",parser:y},{code:71,name:"generationFlag",parser:y},{code:7,name:"styleName",parser:y},{code:51,name:"obliqueAngle",parser:y},{code:41,name:"xScale",parser:y},{code:50,name:"rotation",parser:y},{code:1,name:"text",parser:y},{code:40,name:"textHeight",parser:y},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class wl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){yl(this,"parser",be(xl,bl))}}function Al(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}yl(wl,"ForEntityName","TEXT");let bc={...bl},xc=[{code:2},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:De},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedRecord",parser:De},{code:100},{code:280,name:"isLocked",parser:De},{code:74,name:"valign",parser:y},{code:73},{code:70,name:"attributeFlag",parser:y},{code:2,name:"tag",parser:y},{code:3,name:"prompt",parser:y},{code:280},{code:100,name:"subclassMarker",parser:y},...xl.slice(2)];class Sl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Al(this,"parser",be(xc,bc))}}Al(Sl,"ForEntityName","ATTDEF");(an={})[an.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",an[an.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",an[an.BY_STYLE=5]="BY_STYLE";function wc(i,e){let t={};for(let s of i){let o=e(s);o!=null&&(t[o]??(t[o]=[]),t[o].push(s))}return t}function*ti(i,e=1/0,t=1){for(let s=i;s!==e;s+=t)yield s}function Vr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function wa(i,e,t){if(Ae(e,102))return mn(e,t,i),!0;switch(e.code){case 0:i.type=e.value;break;case 5:i.handle=e.value;break;case 330:i.ownerBlockRecordSoftId=e.value;break;case 67:i.isInPaperSpace=!!e.value;break;case 8:i.layer=e.value;break;case 6:i.lineType=e.value;break;case 347:i.materialObjectHardId=e.value;break;case 62:i.colorIndex=e.value,i.color=gl(Math.abs(e.value));break;case 370:i.lineweight=e.value;break;case 48:i.lineTypeScale=e.value;break;case 60:i.isVisible=!!e.value;break;case 92:i.proxyByte=e.value;break;case 310:i.proxyEntity=e.value;break;case 100:break;case 420:i.color=e.value;break;case 430:i.transparency=e.value;break;case 390:i.plotStyleHardId=e.value;break;case 284:i.shadowMode=e.value;break;case 1001:i.xdata=pl(e,t);break;default:return!1}return!0}function Il(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Ac={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Ks=[{code:46,name:"annotationHeight",parser:y},{code:101,parser(i,e){(function(t){t.rewind();let s=t.next();if(s.code!==101)throw Error("Bad call for skipEmbeddedObject()");do s=t.next();while(s.code!==0);t.rewind()})(e)}},{code:50,name:"columnHeight",parser:y},{code:49,name:"columnGutter",parser:y},{code:48,name:"columnWidth",parser:y},{code:79,name:"columnAutoHeight",parser:y},{code:78,name:"columnFlowReversed",parser:y},{code:76,name:"columnCount",parser:y},{code:75,name:"columnType",parser:y},{code:441,name:"backgroundFillTransparency",parser:y},{code:63,name:"backgroundFillColor",parser:y},{code:45,name:"fillBoxScale",parser:y},{code:[...ti(430,440)],name:"backgroundColor",parser:y},{code:[...ti(420,430)],name:"backgroundColor",parser:y},{code:90,name:"backgroundFill",parser:y},{code:44,name:"lineSpacing",parser:y},{code:73,name:"lineSpacingStyle",parser:y},{code:50,name:"rotation",parser:y},{code:43},{code:42},{code:11,name:"direction",parser:G},{code:210,name:"extrusionDirection",parser:G},{code:7,name:"styleName",parser:y},...Mi("text"),{code:72,name:"drawingDirection",parser:y},{code:71,name:"attachmentPoint",parser:y},{code:41,name:"width",parser:y},{code:40,name:"height",parser:y},{code:10,name:"insertionPoint",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Pl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Il(this,"parser",be(Ks,Ac))}}function El(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Il(Pl,"ForEntityName","MTEXT");let Sc={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Ic=[...Ks.slice(Ks.findIndex(({name:i})=>i==="columnType"),Ks.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!Ae(i,0,"MTEXT"))return xa}},{code:2,name:"definitionTag",parser:y},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardId",parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:De},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedEntriesKeep",parser:De},{code:100},{code:280,name:"lockPositionFlag",parser:De},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"alignmentPoint",parser:G},{code:74,name:"verticalJustification",parser:y},{code:72,name:"horizontalJustification",parser:y},{code:71,name:"textGenerationFlag",parser:y},{code:7,name:"textStyle",parser:y},{code:51,name:"obliqueAngle",parser:y},{code:41,name:"scale",parser:y},{code:50,name:"rotation",parser:y},{code:73},{code:70,name:"attributeFlag",parser:y},{code:2,name:"tag",parser:y},{code:280},{code:100,name:"subclassMarker",parser:y},{code:1,name:"text",parser:y},{code:40,name:"textHeight",parser:y},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100},...Ue];class kl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){El(this,"parser",be(Ic,Sc))}}function Tl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}El(kl,"ForEntityName","ATTRIB");let Pc=[...Mi("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Ml{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Tl(this,"parser",be(Pc))}}function Nl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Tl(Ml,"ForEntityName","BODY");let Ec={thickness:0,extrusionDirection:{x:0,y:0,z:1}},kc=[{code:210,name:"extrusionDirection",parser:G},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Cl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Nl(this,"parser",be(kc,Ec))}}Nl(Cl,"ForEntityName","CIRCLE");class $s{parseEntity(e,t){let s={};for(;!Ae(t,0,"EOF");){if(t.code===0){e.rewind();break}(function(o,h,c){switch(h.code){case 100:o.subclassMarker=h.value;break;case 280:o.version=h.value;break;case 2:o.name=h.value;break;case 10:o.definitionPoint=ze(c);break;case 11:o.textPoint=ze(c);break;case 12:o.insertionPoint=ze(c);break;case 13:o.subDefinitionPoint1=ze(c);break;case 14:o.subDefinitionPoint2=ze(c);break;case 15:o.centerPoint=ze(c);break;case 16:o.arcPoint=ze(c);break;case 70:o.dimensionType=h.value;break;case 71:o.attachmentPoint=h.value;break;case 72:o.textLineSpacingStyle=h.value;break;case 40:o.leaderLength=h.value;break;case 41:o.textLineSpacingFactor=h.value;break;case 42:o.measurement=h.value;break;case 1:o.text=h.value;break;case 50:o.rotationAngle=h.value;break;case 52:o.obliqueAngle=h.value;break;case 53:o.textRotation=h.value;break;case 51:o.ocsRotation=h.value;break;case 210:o.extrusionDirection=ze(c);break;case 3:o.styleName=h.value;break;default:wa(o,h,c)}})(s,t,e),t=e.next()}return s}}function Ll(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}$i="DIMENSION",(Ki="ForEntityName")in $s?Object.defineProperty($s,Ki,{value:$i,enumerable:!0,configurable:!0,writable:!0}):$s[Ki]=$i;let Tc={extrusionDirection:{x:0,y:0,z:1}},Mc=[{code:42,name:"endAngle",parser:y},{code:41,name:"startAngle",parser:y},{code:40,name:"axisRatio",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"majorAxisEndPoint",parser:G},{code:10,name:"center",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Ol{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Ll(this,"parser",be(Mc,Tc))}}Ll(Ol,"ForEntityName","ELLIPSE");(yr={})[yr.First=1]="First",yr[yr.Second=2]="Second",yr[yr.Third=4]="Third",yr[yr.Fourth=8]="Fourth";function zl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Nc=[{code:13,name:"vertices.3",parser:G},{code:12,name:"vertices.2",parser:G},{code:11,name:"vertices.1",parser:G},{code:10,name:"vertices.0",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Rl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){zl(this,"parser",be(Nc))}}zl(Rl,"ForEntityName","3DFACE");let Bl=[{code:330,name:"sourceBoundaryObjects",parser:y,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:y}],Cc=[{code:11,name:"end",parser:G},{code:10,name:"start",parser:G}],Lc=[{code:73,name:"isCCW",parser:De},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G}],Oc=[{code:73,name:"isCCW",parser:De},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"lengthOfMinorAxis",parser:y},{code:11,name:"end",parser:G},{code:10,name:"center",parser:G}],zc=[{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{code:11,name:"fitDatum",isMultiple:!0,parser:G},{code:97,name:"numberOfFitData",parser:y},{code:10,name:"controlPoints",isMultiple:!0,parser(i,e){let t={...ze(e),weight:1};return(i=e.next()).code===42?t.weight=i.value:e.rewind(),t}},{code:40,name:"knots",isMultiple:!0,parser:y},{code:96,name:"numberOfControlPoints",parser:y},{code:95,name:"numberOfKnots",parser:y},{code:74,name:"isPeriodic",parser:De},{code:73,name:"splineFlag",parser:y},{code:94,name:"degree",parser:y}],Rc={[js.Line]:Cc,[js.Circular]:Lc,[js.Elliptic]:Oc,[js.Spline]:zc},Bc=[...Bl,{code:72,name:"edges",parser(i,e){let t={type:i.value},s=be(Rc[t.type]);if(!s)throw Error(`Invalid edge type ${t.type}`);return s(i=e.next(),e,t),t},isMultiple:!0},{code:93,name:"numberOfEdges",parser:y}],Dc=[...Bl,{code:10,name:"vertices",parser(i,e){let t={...ze(e),bulge:0};return(i=e.next()).code===42?t.bulge=i.value:e.rewind(),t},isMultiple:!0},{code:93,name:"numberOfVertices",parser:y},{code:73,name:"isClosed",parser:De},{code:72,name:"hasBulge",parser:De}],Fc=[{code:49,name:"dashLengths",parser:y,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:y},{code:45,name:"offset",parser:Ro},{code:43,name:"base",parser:Ro},{code:53,name:"angle",parser:y}];function Ro(i,e){let t=i.code+1,s={x:i.value,y:1};return(i=e.next()).code===t?s.y=i.value:e.rewind(),s}function Dl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Uc={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Vc=[{code:470},{code:463},{code:462,name:"colorTint",parser:y},{code:461,name:"gradientDefinition",parser:y},{code:460,name:"gradientRotation",parser:y},{code:453,name:"numberOfColors",parser:y},{code:452,name:"gradientColorFlag",parser:y},{code:451},{code:450,name:"gradientFlag",parser:y},{code:10,name:"seedPoints",parser:G,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:G},{code:98,name:"numberOfSeedPoints",parser:y},{code:47,name:"pixelSize",parser:y},{code:53,name:"definitionLines",parser:function(i,e){let t={};return be(Fc)(i,e,t),t},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:y},{code:77,name:"isDouble",parser:De},{code:73,name:"isAnnotated",parser:De},{code:41,name:"patternScale",parser:y},{code:52,name:"patternAngle",parser:y},{code:76,name:"patternType",parser:y},{code:75,name:"hatchStyle",parser:y},{code:92,name:"boundaryPaths",parser:function(i,e){let t={boundaryPathTypeFlag:i.value},s=t.boundaryPathTypeFlag&cc.Polyline;return i=e.next(),s?be(Dc)(i,e,t):be(Bc)(i,e,t),t},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:y},{code:71,name:"associativity",parser:y},{code:63,name:"patternFillColor",parser:y},{code:70,name:"solidFill",parser:y},{code:2,name:"patternName",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:10,name:"elevationPoint",parser:G},{code:100,name:"subclassMarker",parser:y,pushContext:!0},...Ue];class Fl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Dl(this,"parser",be(Vc,Uc))}}Dl(Fl,"ForEntityName","HATCH");(br={})[br.ShowImage=1]="ShowImage",br[br.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",br[br.UseClippingBoundary=4]="UseClippingBoundary",br[br.TransparencyIsOn=8]="TransparencyIsOn";(xs={})[xs.Rectangular=1]="Rectangular",xs[xs.Polygonal=2]="Polygonal";(ws={})[ws.Outside=0]="Outside",ws[ws.Inside=1]="Inside";function Ul(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let jc={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Gc=[{code:290,name:"clipMode",parser:y},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:G},{code:91,name:"countBoundaryPoints",parser:y},{code:71,name:"clippingBoundaryType",parser:y},{code:360,name:"imageDefReactorHandle",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipped",parser:De},{code:70,name:"flags",parser:y},{code:340,name:"imageDefHandle",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vPixel",parser:G},{code:11,name:"uPixel",parser:G},{code:10,name:"position",parser:G},{code:90,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Vl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Ul(this,"parser",be(Gc,jc))}}function jl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Ul(Vl,"ForEntityName","IMAGE");let Wc={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Hc=[{code:210,name:"extrusionDirection",parser:G},{code:45,name:"rowSpacing",parser:y},{code:44,name:"columnSpacing",parser:y},{code:71,name:"rowCount",parser:y},{code:70,name:"columnCount",parser:y},{code:50,name:"rotation",parser:y},{code:43,name:"zScale",parser:y},{code:42,name:"yScale",parser:y},{code:41,name:"xScale",parser:y},{code:10,name:"insertionPoint",parser:G},{code:2,name:"name",parser:y},{code:66,name:"isVariableAttributes",parser:De},{code:100,name:"subclassMarker",parser:y},...Ue];class Gl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){jl(this,"parser",be(Hc,Wc))}}function Wl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}jl(Gl,"ForEntityName","INSERT");let qc={isArrowheadEnabled:!0},Yc=[{code:213,name:"offsetFromAnnotation",parser:G},{code:212,name:"offsetFromBlock",parser:G},{code:211,name:"horizontalDirection",parser:G},{code:210,name:"normal",parser:G},{code:340,name:"associatedAnnotation",parser:y},{code:77,name:"byBlockColor",parser:y},{code:10,name:"vertices",parser:G,isMultiple:!0},{code:76,name:"numberOfVertices",parser:y},{code:41,name:"textWidth",parser:y},{code:40,name:"textHeight",parser:y},{code:75,name:"isHooklineExists",parser:De},{code:74,name:"isHooklineSameDirection",parser:De},{code:73,name:"leaderCreationFlag",parser:y},{code:72,name:"isSpline",parser:De},{code:71,name:"isArrowheadEnabled",parser:De},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue],Hl=class{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Wl(this,"parser",be(Yc,qc))}};Wl(Hl,"ForEntityName","LEADER");(xr={})[xr.TextAnnotation=0]="TextAnnotation",xr[xr.ToleranceAnnotation=1]="ToleranceAnnotation",xr[xr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",xr[xr.NoAnnotation=3]="NoAnnotation";function ql(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let Xc={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Kc=[{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Yl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ql(this,"parser",be(Kc,Xc))}}ql(Yl,"ForEntityName","LINE");(As={})[As.IS_CLOSED=1]="IS_CLOSED",As[As.PLINE_GEN=128]="PLINE_GEN";let $c={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Zc={bulge:0},Qc=[{code:42,name:"bulge",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:91,name:"id",parser:y},{code:20,name:"y",parser:y},{code:10,name:"x",parser:y}],Jc=[{code:210,name:"extrusionDirection",parser:G},{code:10,name:"vertices",isMultiple:!0,parser(i,e){let t={};return be(Qc,Zc)(i,e,t),t}},{code:39,name:"thickness",parser:y},{code:38,name:"elevation",parser:y},{code:43,name:"constantWidth",parser:y},{code:70,name:"flag",parser:y},{code:90,name:"numberOfVertices",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class Zs{parseEntity(e,t){let s={};return be(Jc,$c)(t,e,s),s}}function Xl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Qi="LWPOLYLINE",(Zi="ForEntityName")in Zs?Object.defineProperty(Zs,Zi,{value:Qi,enumerable:!0,configurable:!0,writable:!0}):Zs[Zi]=Qi;let ed=[{code:90,name:"overridenSubEntityCount",parser:y},{code:140,name:"edgeCreaseWeights",parser:y,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:y},{code:94,parser(i,e,t){t.edgeCount=i.value,t.edgeIndices=[];for(let s=0;s<t.edgeCount;++s){let o=[];i=e.next(),o[0]=i.value,i=e.next(),o[1]=i.value,t.edgeIndices.push(o)}}},{code:93,parser(i,e,t){t.totalFaceIndices=i.value,t.faceIndices=[];let s=[];for(let h=0;h<t.totalFaceIndices&&!Ae(i,0);++h)i=e.next(),s.push(i.value);let o=0;for(;o<s.length;){let h=s[o++],c=[];for(let f=0;f<h;++f)c.push(s[o++]);t.faceIndices.push(c)}}},{code:10,name:"vertices",parser:G,isMultiple:!0},{code:92,name:"verticesCount",parser:y},{code:91,name:"subdivisionLevel",parser:y},{code:40,name:"blendCrease",parser:y},{code:72,name:"isBlendCreased",parser:De},{code:71,name:"version",parser:y},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Ue];class Kl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Xl(this,"parser",be(ed))}}function $l(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Xl(Kl,"ForEntityName","MESH");let td={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},rd=[{code:50,name:"angle",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class Zl{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){$l(this,"parser",be(rd,td))}}$l(Zl,"ForEntityName","POINT");(ut={})[ut.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ut[ut.CURVE_FIT=2]="CURVE_FIT",ut[ut.SPLINE_FIT=4]="SPLINE_FIT",ut[ut.POLYLINE_3D=8]="POLYLINE_3D",ut[ut.POLYGON_3D=16]="POLYGON_3D",ut[ut.CLOSED_POLYGON=32]="CLOSED_POLYGON",ut[ut.POLYFACE=64]="POLYFACE",ut[ut.CONTINUOUS=128]="CONTINUOUS";(wr={})[wr.NONE=0]="NONE",wr[wr.QUADRATIC=5]="QUADRATIC",wr[wr.CUBIC=6]="CUBIC",wr[wr.BEZIER=8]="BEZIER";(ct={})[ct.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ct[ct.TANGENT_DEFINED=2]="TANGENT_DEFINED",ct[ct.NOT_USED=4]="NOT_USED",ct[ct.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ct[ct.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ct[ct.FOR_POLYLINE=32]="FOR_POLYLINE",ct[ct.FOR_POLYGON=64]="FOR_POLYGON",ct[ct.POLYFACE=128]="POLYFACE";function Ql(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let nd={startWidth:0,endWidth:0,bulge:0},sd=[{code:91,name:"id",parser:y},{code:[...ti(71,75)],name:"faces",isMultiple:!0,parser:y},{code:50,name:"tangentDirection",parser:y},{code:70,name:"flag",parser:y},{code:42,name:"bulge",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:30,name:"z",parser:y},{code:20,name:"y",parser:y},{code:10,name:"x",parser:y},{code:100,name:"subclassMarker",parser:y},{code:100},...Ue];class Aa{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Ql(this,"parser",be(sd,nd))}}function Jl(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Ql(Aa,"ForEntityName","VERTEX");let id={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:[]},ad=[{code:0,name:"vertices",isMultiple:!0,parser:(i,e)=>Ae(i,0,"VERTEX")?(i=e.next(),new Aa().parseEntity(e,i)):xa},{code:210,name:"extrusionDirection",parser:G},{code:75,name:"smoothType",parser:y},{code:74,name:"surfaceNDensity",parser:y},{code:73,name:"surfaceMDensity",parser:y},{code:72,name:"meshNVertexCount",parser:y},{code:71,name:"meshMVertexCount",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:70,name:"flag",parser:y},{code:39,name:"thickness",parser:y},{code:30,name:"elevation",parser:y},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:y},...Ue];class eh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){Jl(this,"parser",be(ad,id))}}function th(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}Jl(eh,"ForEntityName","POLYLINE");let od=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class rh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){th(this,"parser",be(od))}}function nh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}th(rh,"ForEntityName","RAY");let ld=[...Mi("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class sh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){nh(this,"parser",be(ld))}}function ih(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}nh(sh,"ForEntityName","REGION");let hd={vertices:[],backLineVertices:[]},ud=[{code:360,name:"geometrySettingHardId",parser:y},{code:12,name:"backLineVertices",isMultiple:!0,parser:G},{code:93,name:"numberOfBackLineVertices",parser:y},{code:11,name:"vertices",isMultiple:!0,parser:G},{code:92,name:"verticesCount",parser:y},{code:[63,411],name:"indicatorColor",parser:y},{code:70,name:"indicatorTransparency",parser:y},{code:41,name:"bottomHeight",parser:y},{code:40,name:"topHeight",parser:y},{code:10,name:"verticalDirection",parser:G},{code:1,name:"name",parser:y},{code:91,name:"flag",parser:y},{code:90,name:"state",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class ah{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ih(this,"parser",be(ud,hd))}}function oh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}ih(ah,"ForEntityName","SECTION");let cd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},dd=[{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:[...ti(10,14)],name:"points",isMultiple:!0,parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class lh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){oh(this,"parser",be(dd,cd))}}function hh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}oh(lh,"ForEntityName","SOLID");let md=[{code:350,name:"historyObjectSoftId",parser:y},{code:100,name:"subclassMarker",parser:y},...Mi("data"),{code:70,name:"version",parser:y},{code:100},...Ue];class uh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){hh(this,"parser",be(md))}}hh(uh,"ForEntityName","3DSOLID");(Lt={})[Lt.NONE=0]="NONE",Lt[Lt.CLOSED=1]="CLOSED",Lt[Lt.PERIODIC=2]="PERIODIC",Lt[Lt.RATIONAL=4]="RATIONAL",Lt[Lt.PLANAR=8]="PLANAR",Lt[Lt.LINEAR=16]="LINEAR";function ch(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let pd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},fd=[{code:11,name:"fitPoints",isMultiple:!0,parser:G},{code:10,name:"controlPoints",isMultiple:!0,parser:G},{code:41,name:"weights",isMultiple:!0,parser:y},{code:40,name:"knots",isMultiple:!0,parser:y},{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{code:44,name:"fitTolerance",parser:y},{code:43,name:"controlTolerance",parser:y},{code:42,name:"knotTolerance",parser:y},{code:74,name:"numberOfFitPoints",parser:y},{code:73,name:"numberOfControlPoints",parser:y},{code:72,name:"numberOfKnots",parser:y},{code:71,name:"degree",parser:y},{code:70,name:"flag",parser:y},{code:210,name:"normal",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue];class dh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){ch(this,"parser",be(fd,pd))}}ch(dh,"ForEntityName","SPLINE");class Qs{parseEntity(e,t){let s={};for(;!e.isEOF();){if(t.code===0){e.rewind();break}switch(t.code){case 100:s.subclassMarker=t.value,t=e.next();break;case 2:s.name=t.value,t=e.next();break;case 5:s.handle=t.value,t=e.next();break;case 10:s.startPoint=Vr(ze(e)),t=e.lastReadGroup;break;case 11:s.directionVector=Vr(ze(e)),t=e.lastReadGroup;break;case 90:s.tableValue=t.value,t=e.next();break;case 91:s.rowCount=t.value,t=e.next();break;case 92:s.columnCount=t.value,t=e.next();break;case 93:s.overrideFlag=t.value,t=e.next();break;case 94:s.borderColorOverrideFlag=t.value,t=e.next();break;case 95:s.borderLineWeightOverrideFlag=t.value,t=e.next();break;case 96:s.borderVisibilityOverrideFlag=t.value,t=e.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(t.value),t=e.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(t.value),t=e.next();break;case 280:s.version=t.value,t=e.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=t.value,t=e.next();break;case 330:s.ownerDictionaryId=t.value,t=e.next();break;case 342:s.tableStyleId=t.value,t=e.next();break;case 343:s.blockRecordHandle=t.value,t=e.next();break;case 170:s.attachmentPoint=t.value,t=e.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(o,h){let c=!1,f=!1,b={};for(;!o.isEOF()&&h.code!==0&&!f;)switch(h.code){case 171:if(c){f=!0;continue}b.cellType=h.value,c=!0,h=o.next();break;case 172:b.flagValue=h.value,h=o.next();break;case 173:b.mergedValue=h.value,h=o.next();break;case 174:b.autoFit=h.value,h=o.next();break;case 175:b.borderWidth=h.value,h=o.next();break;case 176:b.borderHeight=h.value,h=o.next();break;case 91:b.overrideFlag=h.value,h=o.next();break;case 178:b.virtualEdgeFlag=h.value,h=o.next();break;case 145:b.rotation=h.value,h=o.next();break;case 345:b.fieldObjetId=h.value,h=o.next();break;case 340:b.blockTableRecordId=h.value,h=o.next();break;case 146:b.blockScale=h.value,h=o.next();break;case 177:b.blockAttrNum=h.value,h=o.next();break;case 7:b.textStyle=h.value,h=o.next();break;case 140:b.textHeight=h.value,h=o.next();break;case 170:b.attachmentPoint=h.value,h=o.next();break;case 92:b.extendedCellFlags=h.value,h=o.next();break;case 285:b.rightBorderVisibility=!!(h.value??!0),h=o.next();break;case 286:b.bottomBorderVisibility=!!(h.value??!0),h=o.next();break;case 288:b.leftBorderVisibility=!!(h.value??!0),h=o.next();break;case 289:b.topBorderVisibility=!!(h.value??!0),h=o.next();break;case 301:(function(g,A,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=A.next();break;case 1:g.text=x.value,x=A.next();break;case 300:g.attrText=x.value,x=A.next();break;case 302:g.text=x.value?x.value:g.text,x=A.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=A.next()}})(b,o,h),h=o.next();break;default:return b}return c=!1,f=!1,b}(e,t)),t=e.lastReadGroup;break;default:wa(s,t,e),t=e.next()}}return s}}function mh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}ea="ACAD_TABLE",(Ji="ForEntityName")in Qs?Object.defineProperty(Qs,Ji,{value:ea,enumerable:!0,configurable:!0,writable:!0}):Qs[Ji]=ea;let gd=[{code:11,name:"xAxisDirection",parser:G},{code:210,name:"extrusionDirection",parser:G},{code:1,name:"text",parser:y},{code:10,name:"position",parser:G},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class ph{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){mh(this,"parser",be(gd))}}mh(ph,"ForEntityName","TOLERANCE");let Js=class{parseEntity(e,t){let s={};for(;t!=="EOF";){if(t.code===0){e.rewind();break}!function(o,h,c){if(c==="EOF")return!1;switch(c.code){case 0:return!1;case 8:o.layer=c.value;break;case 100:o.subclassMarker=c.value;break;case 10:o.viewportCenter=Vr(ze(h));break;case 40:o.width=c.value;break;case 41:o.height=c.value;break;case 68:o.status=c.value;break;case 69:o.viewportId=c.value;break;case 12:o.displayCenter=ze(h);break;case 13:o.snapBase=ze(h);break;case 14:o.snapSpacing=ze(h);break;case 15:o.gridSpacing=ze(h);break;case 16:o.viewDirection=Vr(ze(h));break;case 17:o.targetPoint=Vr(ze(h));break;case 42:o.perspectiveLensLength=c.value;break;case 43:o.frontClipZ=c.value;break;case 44:o.backClipZ=c.value;break;case 45:o.viewHeight=c.value;break;case 50:o.snapAngle=c.value;break;case 51:o.viewTwistAngle=c.value;break;case 72:o.circleZoomPercent=c.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(c.value);break;case 90:o.statusBitFlags=c.value;break;case 340:o.clippingBoundaryId=c.value;break;case 1:o.sheetName=c.value;break;case 281:o.renderMode=c.value;break;case 71:o.ucsPerViewport=c.value;break;case 110:o.ucsOrigin=Vr(ze(h));break;case 111:o.ucsXAxis=Vr(ze(h));break;case 112:o.ucsYAxis=Vr(ze(h));break;case 345:o.ucsId=c.value;break;case 346:o.ucsBaseId=c.value;break;case 79:o.orthographicType=c.value;break;case 146:o.elevation=c.value;break;case 170:o.shadePlotMode=c.value;break;case 61:o.majorGridFrequency=c.value;break;case 332:o.backgroundId=c.value;break;case 333:o.shadePlotId=c.value;break;case 348:o.visualStyleId=c.value;break;case 292:o.isDefaultLighting=!!c.value;break;case 282:o.defaultLightingType=c.value;break;case 141:o.brightness=c.value;break;case 142:o.contrast=c.value;break;case 63:case 421:case 431:o.ambientLightColor=c.value;break;case 361:o.sunId=c.value;break;case 335:case 343:case 344:case 91:o.softPointer=c.value}return!0}(s,e,t)&&wa(s,t,e),t=e.next()}return s}};ra="VIEWPORT",(ta="ForEntityName")in Js?Object.defineProperty(Js,ta,{value:ra,enumerable:!0,configurable:!0,writable:!0}):Js[ta]=ra;(Ar={})[Ar.ShowImage=1]="ShowImage",Ar[Ar.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Ar[Ar.UseClippingBoundary=4]="UseClippingBoundary",Ar[Ar.Transparency=8]="Transparency";function fh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}let _d={brightness:50,constrast:50,fade:0},vd=[{code:14,name:"boundary",isMultiple:!0,parser:G},{code:91,name:"numberOfVertices",parser:y},{code:71,name:"boundaryType",parser:y},{code:360,name:"imageDefReactorHardId",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipping",parser:De},{code:70,name:"displayFlag",parser:y},{code:340,name:"imageDefHardId",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vDirection",parser:G},{code:11,name:"uDirection",parser:G},{code:10,name:"position",parser:G},{code:90,name:"classVersion",parser:y},{code:100,name:"subclassMarker",parser:y},...Ue];class gh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){fh(this,"parser",be(vd,_d))}}function _h(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}fh(gh,"ForEntityName","WIPEOUT");let yd=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ue],vh=class{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){_h(this,"parser",be(yd))}};function yh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}_h(vh,"ForEntityName","XLINE");let bd={},xd=[{code:170,name:"multileaderType",parser:y},{code:291,name:"doglegEnabled",parser:De},{code:40,name:"doglegLength",parser:y},{code:172,name:"contentType",parser:y},{code:3,name:"textContent",parser:y},{code:12,name:"textAnchor",parser:G},{code:344,name:"blockHandle",parser:y},{code:15,name:"blockPosition",parser:G},{code:302,name:"leaderSections",parser:function(i,e,t){let s,o={leaderLines:[]};for(;e.hasNext()&&(s=e.next()).code!==303;)switch(s.code){case 10:o.landingPoint=(s.value,ze(e));break;case 11:o.doglegVector=(s.value,ze(e));break;case 40:o.doglegLength=s.value;break;case 304:o.leaderLines.push(function(h,c,f){let b,g={vertices:[]};for(;c.hasNext()&&(b=c.next()).code!==305;)b.code===10&&g.vertices.push((b.value,ze(c)));return g}(0,e))}return o},isMultiple:!0},...Ue];class bh{parseEntity(e,t){let s={};return this.parser(t,e,s),s}constructor(){yh(this,"parser",be(xd,bd))}}yh(bh,"ForEntityName","MULTILEADER");let wd=Object.fromEntries([vl,Sl,kl,Ml,Cl,$s,Ol,Rl,Vl,Gl,Hl,Yl,Zs,Kl,Pl,bh,Zl,eh,rh,sh,ah,lh,uh,dh,Qs,wl,ph,Fl,Aa,Js,gh,vh].map(i=>[i.ForEntityName,new i]));function xh(i,e){let t=[];for(;!Ae(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){e.rewind();break}let s=wd[i.value];if(s){let o=i.value;i=e.next();let h=s.parseEntity(e,i);h.type=o,fl(h),t.push(h)}else e.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=e.next()}return t}function Ad(i,e){let t={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");){if(Ae(i,0,"BLOCK")){let s=Sd(i=e.next(),e);fl(s),s.name&&(t[s.name]=s)}i=e.next()}return t}function Sd(i,e){let t={};for(;!Ae(i,0,"EOF");){if(Ae(i,0,"ENDBLK")){for(i=e.next();!Ae(i,0,"EOF");){if(Ae(i,100,"AcDbBlockEnd"))return t;i=e.next()}break}switch(i.code){case 1:t.xrefPath=i.value;break;case 2:t.name=i.value;break;case 3:t.name2=i.value;break;case 5:t.handle=i.value;break;case 8:t.layer=i.value;break;case 10:t.position=ze(e);break;case 67:t.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(t.type=i.value);break;case 100:break;case 330:t.ownerHandle=i.value;break;case 0:t.entities=xh(i,e)}i=e.next()}return t}function Id(i,e){let t=null,s={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");)i.code===9?t=i.value:i.code===10?s[t]=ze(e):s[t]=i.value,i=e.next();return s}(Ot={})[Ot.NOT_APPLICABLE=0]="NOT_APPLICABLE",Ot[Ot.KEEP_EXISTING=1]="KEEP_EXISTING",Ot[Ot.USE_CLONE=2]="USE_CLONE",Ot[Ot.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Ot[Ot.VALUE_NAME=4]="VALUE_NAME",Ot[Ot.UNMANGLE_NAME=5]="UNMANGLE_NAME";let Sa=[{code:330,name:"ownerObjectId",parser:y},{code:102,parser:mn},{code:102,parser:mn},{code:102,parser:mn},{code:5,name:"handle",parser:y}],Pd=[{code:3,name:"entries",parser:(i,e)=>{let t={name:i.value};return(i=e.next()).code===350?t.objectSoftId=i.value:i.code===360?t.objectHardId=i.value:e.rewind(),t},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:y},{code:280,name:"isHardOwned",parser:De},{code:100,name:"subclassMarker",parser:y},...Sa],Ed=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:y},{code:90,name:"version",parser:y},{code:1,name:"fileName",parser:y},{code:10,name:"size",parser:G},{code:11,name:"sizeOfOnePixel",parser:G},{code:280,name:"isLoaded",parser:y},{code:281,name:"resolutionUnits",parser:y},{code:100,name:"subclassMarker",parser:y}];(on={})[on.NOUNIT=0]="NOUNIT",on[on.CENTIMETERS=2]="CENTIMETERS",on[on.INCH=5]="INCH";(Ss={})[Ss.PSLTSCALE=1]="PSLTSCALE",Ss[Ss.LIMCHECK=2]="LIMCHECK";(ln={})[ln.INCHES=0]="INCHES",ln[ln.MILLIMETERS=1]="MILLIMETERS",ln[ln.PIXELS=2]="PIXELS";(zt={})[zt.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",zt[zt.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",zt[zt.DRAWING_LIMITS=2]="DRAWING_LIMITS",zt[zt.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",zt[zt.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",zt[zt.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Sr={})[Sr.AS_DISPLAYED=0]="AS_DISPLAYED",Sr[Sr.WIREFRAME=1]="WIREFRAME",Sr[Sr.HIDDEN=2]="HIDDEN",Sr[Sr.RENDERED=3]="RENDERED";(Rt={})[Rt.DRAFT=0]="DRAFT",Rt[Rt.PREVIEW=1]="PREVIEW",Rt[Rt.NORMAL=2]="NORMAL",Rt[Rt.PRESENTATION=3]="PRESENTATION",Rt[Rt.MAXIMUM=4]="MAXIMUM",Rt[Rt.CUSTOM=5]="CUSTOM";let wh=[{code:333,name:"shadePlotId",parser:y},{code:149,name:"imageOriginY",parser:y},{code:148,name:"imageOriginX",parser:y},{code:147,name:"scaleFactor",parser:y},{code:78,name:"shadePlotCustomDPI",parser:y},{code:77,name:"shadePlotResolution",parser:y},{code:76,name:"shadePlotMode",parser:y},{code:75,name:"standardScaleType",parser:y},{code:7,name:"currentStyleSheet",parser:y},{code:74,name:"plotType",parser:y},{code:73,name:"plotRotation",parser:y},{code:72,name:"plotPaperUnit",parser:y},{code:70,name:"layoutFlag",parser:y},{code:143,name:"printScaleDenominator",parser:y},{code:142,name:"printScaleNumerator",parser:y},{code:141,name:"windowAreaYMax",parser:y},{code:140,name:"windowAreaXMax",parser:y},{code:49,name:"windowAreaYMin",parser:y},{code:48,name:"windowAreaXMin",parser:y},{code:47,name:"plotOriginY",parser:y},{code:46,name:"plotOriginX",parser:y},{code:45,name:"paperHeight",parser:y},{code:44,name:"paperWidth",parser:y},{code:43,name:"marginTop",parser:y},{code:42,name:"marginRight",parser:y},{code:41,name:"marginBottom",parser:y},{code:40,name:"marginLeft",parser:y},{code:6,name:"plotViewName",parser:y},{code:4,name:"paperSize",parser:y},{code:2,name:"configName",parser:y},{code:1,name:"pageSetupName",parser:y},{code:100,name:"subclassMarker",parser:y},...Sa],kd=[{code:346,name:"orthographicUcsId",parser:y},{code:345,name:"namedUcsId",parser:y},{code:331,name:"viewportId",parser:y},{code:330,name:"paperSpaceTableId",parser:y},{code:76,name:"orthographicType",parser:y},{code:17,name:"ucsYAxis",parser:G},{code:16,name:"ucsXAxis",parser:G},{code:13,name:"ucsOrigin",parser:G},{code:146,name:"elevation",parser:y},{code:15,name:"maxExtent",parser:G},{code:14,name:"minExtent",parser:G},{code:12,name:"insertionPoint",parser:G},{code:11,name:"maxLimit",parser:G},{code:10,name:"minLimit",parser:G},{code:71,name:"tabOrder",parser:y},{code:70,name:"controlFlag",parser:y},{code:1,name:"layoutName",parser:y},{code:100,name:"subclassMarker",parser:y},...wh],Td=[{code:40,name:"wcsToOCSTransform",parser:Bo},{code:40,name:"ocsToWCSTransform",parser:Bo},{code:41,name:"backClippingDistance",parser:y},{code:73,name:"isBackClipping",parser:De,pushContext:!0},{code:40,name:"frontClippingDistance",parser:y},{code:72,name:"isFrontClipping",parser:De,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:De},{code:11,name:"position",parser:G},{code:210,name:"normal",parser:G},{code:10,name:"boundaryVertices",parser:G,isMultiple:!0},{code:70,name:"boundaryCount",parser:y},{code:100,name:"subclassMarker",parser:y},{code:100},...Sa];function Bo(i,e){let t=[];for(let s=0;s<3&&Ae(i,40);++s){let o=[];for(let h=0;h<4&&Ae(i,40);++h)o.push(i.value),i=e.next();t.push(o)}return e.rewind(),t}let Md={LAYOUT:kd,PLOTSETTINGS:wh,DICTIONARY:Pd,SPATIAL_FILTER:Td,IMAGEDEF:Ed};function Nd(i,e){let t=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,o=Md[s];if(i.code===0&&(o!=null&&o.length)){let h=be(o),c={name:s};h(i=e.next(),e,c)?(t.push(c),i=e.peek()):i=e.next()}else i=e.next()}return{byName:wc(t,({name:s})=>s)}}let Un=[{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102,parser(i,e){for(;!Ae(i,0,"EOF")&&!Ae(i,102,"}");)i=e.next()}},{code:5,name:"handle",parser:y}],Cd=be([{code:310,name:"bmpPreview",parser:y},{code:281,name:"scalability",parser:y},{code:280,name:"explodability",parser:y},{code:70,name:"insertionUnits",parser:y},{code:340,name:"layoutObjects",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...Un]),Ld=[{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:zo.Above,defaultValueImperial:zo.Center},{name:"DIMZIN",code:78,defaultValue:Cn.Trailing,defaultValueImperial:Cn.Feet},{name:"DIMAZIN",code:79,defaultValue:lc.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:hc.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:uc.Center},{name:"DIMTZIN",code:284,defaultValue:Cn.Trailing,defaultValueImperial:Cn.Feet},{name:"DIMALTZ",code:285,defaultValue:Cn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Cn.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}],Od=be([...Ld.map(i=>({...i,parser:y})),{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},{code:105,name:"handle",parser:y},...Un.filter(i=>i.code!==5)]),zd=be([{code:347,name:"materialObjectId",parser:y},{code:390,name:"plotStyleNameObjectId",parser:y},{code:370,name:"lineweight",parser:y},{code:290,name:"isPlotting",parser:De},{code:6,name:"lineType",parser:y},{code:62,name:"colorIndex",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...Un]);(Ir={})[Ir.NONE=0]="NONE",Ir[Ir.AbsoluteRotation=1]="AbsoluteRotation",Ir[Ir.TextEmbedded=2]="TextEmbedded",Ir[Ir.ShapeEmbedded=4]="ShapeEmbedded";let Rd=be([{code:9,name:"text",parser:y},{code:45,name:"offsetY",parser:y},{code:44,name:"offsetX",parser:y},{code:50,name:"rotation",parser:y},{code:46,name:"scale",parser:y},{code:340,name:"styleObjectId",parser:y},{code:75,name:"shapeNumber",parser:y},{code:74,name:"elementTypeFlag",parser:y},{code:49,name:"elementLength",parser:y}],{elementTypeFlag:0,elementLength:0}),Bd=be([{code:49,name:"pattern",parser(i,e){let t={};return Rd(i,e,t),t},isMultiple:!0},{code:40,name:"totalPatternLength",parser:y},{code:73,name:"numberOfLineTypes",parser:y},{code:72,parser:y},{code:3,name:"description",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...Un]),Dd=be([{code:1e3,name:"extendedFont",parser:y},{code:1001},{code:4,name:"bigFont",parser:y},{code:3,name:"font",parser:y},{code:42,name:"lastHeight",parser:y},{code:71,name:"textGenerationFlag",parser:y},{code:50,name:"obliqueAngle",parser:y},{code:41,name:"widthFactor",parser:y},{code:40,name:"fixedTextHeight",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...Un]),Fd=be([{code:[63,421,431],name:"ambientColor",parser:y},{code:142,name:"contrast",parser:y},{code:141,name:"brightness",parser:y},{code:282,name:"defaultLightingType",parser:y},{code:292,name:"isDefaultLightingOn",parser:De},{code:348,name:"visualStyleObjectId",parser:y},{code:333,name:"shadePlotObjectId",parser:y},{code:332,name:"backgroundObjectId",parser:y},{code:61,name:"majorGridLines",parser:y},{code:170,name:"shadePlotSetting",parser:y},{code:146,name:"elevation",parser:y},{code:79,name:"orthographicType",parser:y},{code:112,name:"ucsYAxis",parser:G},{code:111,name:"ucsXAxis",parser:G},{code:110,name:"ucsOrigin",parser:G},{code:74,name:"ucsIconSetting",parser:y},{code:71,name:"viewMode",parser:y},{code:281,name:"renderMode",parser:y},{code:1,name:"styleSheet",parser:y},{code:[331,441],name:"frozenLayers",parser:y,isMultiple:!0},{code:72,name:"circleSides",parser:y},{code:51,name:"viewTwistAngle",parser:y},{code:50,name:"snapRotationAngle",parser:y},{code:45,name:"viewHeight",parser:y},{code:44,name:"backClippingPlane",parser:y},{code:43,name:"frontClippingPlane",parser:y},{code:42,name:"lensLength",parser:y},{code:17,name:"viewTarget",parser:G},{code:16,name:"viewDirectionFromTarget",parser:G},{code:15,name:"gridSpacing",parser:G},{code:14,name:"snapSpacing",parser:G},{code:13,name:"snapBasePoint",parser:G},{code:12,name:"center",parser:G},{code:11,name:"upperRightCorner",parser:G},{code:10,name:"lowerLeftCorner",parser:G},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...Un]),Ud={BLOCK_RECORD:Cd,DIMSTYLE:Od,LAYER:zd,LTYPE:Bd,STYLE:Dd,VPORT:Fd},Vd=be([{code:70,name:"maxNumberOfEntries",parser:y},{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:y},{code:2,name:"name",parser:y}]);function jd(i,e){var s;let t={};for(;!Ae(i,0,"EOF")&&!Ae(i,0,"ENDSEC");){if(Ae(i,0,"TABLE")){i=e.next();let o={entries:[]};Vd(i,e,o),t[o.name]=o}if(Ae(i,0)&&!Ae(i,0,"ENDTAB")){let o=i.value;i=e.next();let h=Ud[o];if(!h){e.debug&&console.warn(`parseTable: Invalid table name '${o}'`),i=e.next();continue}let c={};h(i,e,c),(s=t[o])==null||s.entries.push(c)}i=e.next()}return t}function Is(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}class Do{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let e=parseInt(this._data[this._pointer++],10),t=Fo(e,this._data[this._pointer++],this.debug),s={code:e,value:t};return Ae(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 e={code:parseInt(this._data[this._pointer]),value:0};return e.value=Fo(e.code,this._data[this._pointer+1],this.debug),e}rewind(e){e=e||1,this._pointer=this._pointer-2*e}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(e,t=!1){Is(this,"_data",void 0),Is(this,"debug",void 0),Is(this,"_pointer",void 0),Is(this,"_eof",void 0),Is(this,"lastReadGroup",void 0),this._data=e,this.debug=t,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Fo(i,e,t=!1){return i<=9?e:i>=10&&i<=59?parseFloat(e.trim()):i>=60&&i<=99?parseInt(e.trim()):i>=100&&i<=109?e:i>=110&&i<=149?parseFloat(e.trim()):i>=160&&i<=179?parseInt(e.trim()):i>=210&&i<=239?parseFloat(e.trim()):i>=270&&i<=289?parseInt(e.trim()):i>=290&&i<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(e.trim()):i>=300&&i<=369?e:i>=370&&i<=389?parseInt(e.trim()):i>=390&&i<=399?e:i>=400&&i<=409?parseInt(e.trim()):i>=410&&i<=419?e:i>=420&&i<=429?parseInt(e.trim()):i>=430&&i<=439?e:i>=440&&i<=459?parseInt(e.trim()):i>=460&&i<=469?parseFloat(e.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?e:i>=1010&&i<=1059?parseFloat(e.trim()):i>=1060&&i<=1071?parseInt(e.trim()):(t&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:e}),e)}function ha(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}class Gd{constructor(){ha(this,"encoding","utf-8"),ha(this,"encodingFailureFatal",!1)}}class Wd extends EventTarget{parseSync(e,t=!1){let s=new Do(e.split(/\r\n|\r|\n/g),t);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(e){let t="",s=this;return new Promise((o,h)=>{e.on("data",c=>{t+=c}),e.on("end",()=>{try{let c=t.split(/\r\n|\r|\n/g),f=new Do(c);if(!f.hasNext())throw Error("Empty file");o(s.parseAll(f))}catch(c){h(c)}}),e.on("error",c=>{h(c)})})}async parseFromUrl(e,t){let s=await fetch(e,t);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:c,value:f}=await o.read();if(c){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(f,{stream:!0})}return this.parseSync(h)}parseAll(e){let t={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=e.next();for(;!Ae(s,0,"EOF");)Ae(s,0,"SECTION")&&(Ae(s=e.next(),2,"HEADER")?(s=e.next(),t.header=Id(s,e)):Ae(s,2,"BLOCKS")?(s=e.next(),t.blocks=Ad(s,e)):Ae(s,2,"ENTITIES")?(s=e.next(),t.entities=xh(s,e)):Ae(s,2,"TABLES")?(s=e.next(),t.tables=jd(s,e)):Ae(s,2,"OBJECTS")&&(s=e.next(),t.objects=Nd(s,e))),s=e.next();return t}constructor(e=new Gd){super(),ha(this,"_decoder",void 0),this._decoder=new TextDecoder(e.encoding,{fatal:e.encodingFailureFatal})}}const Uo=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class ri{constructor(e){if(typeof e=="string"){const t=Uo.find(s=>s.name===e);if(!t)throw new Error(`Unknown DWG version name: ${e}`);this.name=t.name,this.value=t.value;return}if(typeof e=="number"){const t=Uo.find(s=>s.value===e);if(!t)throw new Error(`Unknown DWG version value: ${e}`);this.name=t.name,this.value=t.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class Hd{parse(e){const t=new Wd,s=this.getDxfInfoFromBuffer(e);let o="";return s.version&&s.version.value<=23&&s.encoding?o=new TextDecoder(s.encoding).decode(e):o=new TextDecoder().decode(e),t.parseSync(o)}getDxfInfoFromBuffer(e){var g,A,x;const s=new TextDecoder("utf-8");let o=0,h="",c=null,f=null,b=!1;for(;o<e.byteLength;){const E=Math.min(o+65536,e.byteLength),T=e.slice(o,E);o=E;const z=(h+s.decode(T,{stream:!0})).split(/\r?\n/);h=z.pop()??"";for(let U=0;U<z.length;U++){const D=z[U].trim();if(D==="SECTION"&&((g=z[U+2])==null?void 0:g.trim())==="HEADER")b=!0;else if(D==="ENDSEC"&&b)return{version:c,encoding:f};if(b&&D==="$ACADVER"){const de=(A=z[U+2])==null?void 0:A.trim();de&&(c=new ri(de))}else if(b&&D==="$DWGCODEPAGE"){const de=(x=z[U+2])==null?void 0:x.trim();if(de){const ve=va[de];f=ul(ve)}}if(c&&f)return{version:c,encoding:f}}}return{version:c,encoding:f}}}const gt=["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 Vo=1234567;const Ia=Math.PI/180,Pa=180/Math.PI;function Ah(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(gt[i&255]+gt[i>>8&255]+gt[i>>16&255]+gt[i>>24&255]+"-"+gt[e&255]+gt[e>>8&255]+"-"+gt[e>>16&15|64]+gt[e>>24&255]+"-"+gt[t&63|128]+gt[t>>8&255]+"-"+gt[t>>16&255]+gt[t>>24&255]+gt[s&255]+gt[s>>8&255]+gt[s>>16&255]+gt[s>>24&255]).toLowerCase()}function kr(i,e,t){return Math.max(e,Math.min(t,i))}function Ea(i,e){return(i%e+e)%e}function Sh(i,e,t,s,o){return s+(i-e)*(o-s)/(t-e)}function Ih(i,e,t){return i!==e?(t-i)/(e-i):0}function ka(i,e,t){return(1-t)*i+t*e}function Ph(i,e,t,s){return ka(i,e,1-Math.exp(-t*s))}function Eh(i,e=1){return e-Math.abs(Ea(i,e*2)-e)}function kh(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Th(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Mh(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Nh(i,e){return i+Math.random()*(e-i)}function Ch(i){return i*(.5-Math.random())}function Lh(i){i!==void 0&&(Vo=i);let e=Vo+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Oh(i){return i*Ia}function zh(i){return i*Pa}function Rh(i){return(i&i-1)===0&&i!==0}function Bh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Dh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ts(i){const e=Math.PI*2;return(i%e+e)%e}function Fh(i,e,t){return i>e&&i<t||i>t&&i<e}function Uh(i,e,t,s=!1){return i=Ts(i),e=Ts(e),t=Ts(t),s?e>t?i<=e&&i>=t:i<=e||i>=t:e<t?i>=e&&i<=t:i>=e||i<=t}function Ta(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Vh(i,e=1e-7){const t=Ta(i);return Math.max(Math.pow(10,t)*e,e)}const Ee={DEG2RAD:Ia,RAD2DEG:Pa,generateUUID:Ah,clamp:kr,euclideanModulo:Ea,mapLinear:Sh,inverseLerp:Ih,lerp:ka,damp:Ph,pingpong:Eh,smoothstep:kh,smootherstep:Th,randInt:Mh,randFloat:Nh,randFloatSpread:Ch,seededRandom:Lh,degToRad:Oh,radToDeg:zh,isPowerOfTwo:Rh,ceilPowerOfTwo:Bh,floorPowerOfTwo:Dh,normalizeAngle:Ts,isBetween:Fh,isBetweenAngle:Uh,intPartLength:Ta,relativeEps:Vh},ua=class jh{constructor(e,t){this.x=0,this.y=0;const s=+(e!==void 0)+ +(t!==void 0);if(s!==0){if(s===1&&e instanceof Array){this.x=e[0],this.y=e[1];return}if(s===1){const{x:o,y:h}=e;this.x=o,this.y=h;return}if(s===2){this.x=e,this.y=t;return}throw Ut.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new jh(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix2d(e){const t=this.x,s=this.y,o=e.elements;return this.x=o[0]*t+o[3]*s+o[6],this.y=o[1]*t+o[4]*s+o[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const s=Math.cos(t),o=Math.sin(t),h=this.x-e.x,c=this.y-e.y;return this.x=h*s-c*o+e.x,this.y=h*o+c*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(e=1e-7){return Math.min(Ee.relativeEps(this.x,e),Ee.relativeEps(this.y,e))}*[Symbol.iterator](){yield this.x,yield this.y}};ua.EMPTY=Object.freeze(new ua(0,0));let $e=ua;const ca=class Gh{constructor(e,t,s,o,h,c,f,b,g){this.elements=[1,0,0,0,1,0,0,0,1],e!=null&&t!=null&&s!=null&&o!=null&&h!=null&&c!=null&&f!=null&&b!=null&&g!=null&&this.set(e,t,s,o,h,c,f,b,g)}set(e,t,s,o,h,c,f,b,g){const A=this.elements;return A[0]=e,A[1]=o,A[2]=f,A[3]=t,A[4]=h,A[5]=b,A[6]=s,A[7]=c,A[8]=g,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,o=t.elements,h=this.elements,c=s[0],f=s[3],b=s[6],g=s[1],A=s[4],x=s[7],E=s[2],T=s[5],O=s[8],z=o[0],U=o[3],D=o[6],de=o[1],ve=o[4],oe=o[7],W=o[2],ue=o[5],se=o[8];return h[0]=c*z+f*de+b*W,h[3]=c*U+f*ve+b*ue,h[6]=c*D+f*oe+b*se,h[1]=g*z+A*de+x*W,h[4]=g*U+A*ve+x*ue,h[7]=g*D+A*oe+x*se,h[2]=E*z+T*de+O*W,h[5]=E*U+T*ve+O*ue,h[8]=E*D+T*oe+O*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],c=e[4],f=e[5],b=e[6],g=e[7],A=e[8];return t*c*A-t*f*g-s*h*A+s*f*b+o*h*g-o*c*b}invert(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],c=e[4],f=e[5],b=e[6],g=e[7],A=e[8],x=A*c-f*g,E=f*b-A*h,T=g*h-c*b,O=t*x+s*E+o*T;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);const z=1/O;return e[0]=x*z,e[1]=(o*g-A*s)*z,e[2]=(f*s-o*c)*z,e[3]=E*z,e[4]=(A*t-o*b)*z,e[5]=(o*h-f*t)*z,e[6]=T*z,e[7]=(s*b-g*t)*z,e[8]=(c*t-s*h)*z,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e.elements[0]=t[0],e.elements[1]=t[3],e.elements[2]=t[6],e.elements[3]=t[1],e.elements[4]=t[4],e.elements[5]=t[7],e.elements[6]=t[2],e.elements[7]=t[5],e.elements[8]=t[8],this}setUvTransform(e,t,s,o,h,c,f){const b=Math.cos(h),g=Math.sin(h);return this.set(s*b,s*g,-s*(b*c+g*f)+c+e,-o*g,o*b,-o*(-g*c+b*f)+f+t,0,0,1),this}scale(e,t){return this.premultiply(sa.makeScale(e,t)),this}rotate(e){return this.premultiply(sa.makeRotation(-e)),this}translate(e,t){return this.premultiply(sa.makeTranslation(e,t)),this}makeTranslation(e,t){return e instanceof $e?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let o=0;o<9;o++)if(t[o]!==s[o])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new Gh().fromArray(this.elements)}};ca.IDENTITY=Object.freeze(new ca);let Ni=ca;const sa=new Ni,un=1e-6,nt=2*Math.PI,qd={x:0,y:0},Ma={x:0,y:0,z:0};class Na{constructor(){this.equalPointTol=un,this.equalVectorTol=un}equalPoint2d(e,t){return new $e(e).sub(t).length()<this.equalPointTol}equalPoint3d(e,t){return new Z(e).sub(t).length()<this.equalPointTol}static equalToZero(e,t=un){return e<t&&e>-t}static equal(e,t,s=un){return Math.abs(e-t)<s}static great(e,t,s=un){return e-t>s}static less(e,t,s=un){return e-t<s}}const Ca=new Na;function La(i,e,t=!1){const s=i.x,o=i.y;let h=!1;const c=e.length;for(let f=0,b=c-1;f<c;b=f++){const g=e[f].x,A=e[f].y,x=e[b].x,E=e[b].y;let T=A>o!=E>o;t&&(T=A>=o!=E>=o),T&&s<(x-g)*(o-A)/(E-A)+g&&(h=!h)}return h}function Wh(i,e){if(i.length===0||e.length===0)return!1;const t=new _t().setFromPoints(i),s=new _t().setFromPoints(e);if(!t.intersectsBox(s))return!1;for(let o=0;o<i.length;){if(La(i[o],e,!0))return!0;o<i.length-1&&Ca.equalPoint2d(i[o+1],i[o])&&++o,++o}return!1}const Hh={isPointInPolygon:La,isPolygonIntersect:Wh};function qh(i,e){const t=[],s=e-1,o=i;for(let h=0;h<=o;h++)t.push(0);for(let h=1;h<=s-o;h++)t.push(h);for(let h=0;h<=o;h++)t.push(s-o+1);return t}function Yh(i,e){const t=e.length-1,s=i,o=[0];let h=0;for(let f=1;f<=t;f++){const b=e[f][0]-e[f-1][0],g=e[f][1]-e[f-1][1],A=e[f][2]-e[f-1][2],x=Math.sqrt(b*b+g*g+A*A);h+=x,o.push(h)}const c=[];for(let f=0;f<=s;f++)c.push(0);for(let f=1;f<=t-s;f++){const b=o[f]/h;c.push(b*(t-s+1))}for(let f=0;f<=s;f++)c.push(t-s+1);return c}function Xh(i,e){const t=e.length-1,s=i,o=[0];let h=0;for(let f=1;f<=t;f++){const b=e[f][0]-e[f-1][0],g=e[f][1]-e[f-1][1],A=e[f][2]-e[f-1][2],x=Math.sqrt(b*b+g*g+A*A),E=Math.sqrt(x);h+=E,o.push(h)}const c=[];for(let f=0;f<=s;f++)c.push(0);for(let f=1;f<=t-s;f++){const b=o[f]/h;c.push(b*(t-s+1))}for(let f=0;f<=s;f++)c.push(t-s+1);return c}function ni(i,e,t,s){if(e===0)return t>=s[i]&&t<s[i+1]?1:0;const o=s[i+e]-s[i],h=s[i+e+1]-s[i+1],c=o>1e-10?(t-s[i])/o:0,f=h>1e-10?(s[i+e+1]-t)/h:0;return c*ni(i,e-1,t,s)+f*ni(i+1,e-1,t,s)}function Ms(i,e,t,s,o){const h=s.length-1,c=e;if(i=Math.max(t[c],Math.min(t[h+1],i)),Math.abs(i-t[h+1])<1e-8)return[...s[h]];if(Math.abs(i-t[c])<1e-8)return[...s[0]];const f=[0,0,0];let b=0;for(let g=0;g<=h;g++){const A=ni(g,c,i,t),x=o[g]*A;f[0]+=s[g][0]*x,f[1]+=s[g][1]*x,f[2]+=s[g][2]*x,b+=x}if(b<1e-10){const g=t[t.length-c-1];if(Math.abs(i-g)<1e-8)return[...s[h]];if(Math.abs(i-t[c])<1e-8)return[...s[0]]}return b>1e-10&&(f[0]/=b,f[1]/=b,f[2]/=b),f}function Kh(i,e,t,s){const o=i,h=e[o],c=e[e.length-o-1];let f=0;const b=1e3,g=(c-h)/b;let A=Ms(h,i,e,t,s);for(let z=1;z<=b;z++){const U=h+z*g,D=Ms(U,i,e,t,s),de=D[0]-A[0],ve=D[1]-A[1],oe=D[2]-A[2];f+=Math.sqrt(de*de+ve*ve+oe*oe),A=D}const x=Ms(c,i,e,t,s),E=x[0]-A[0],T=x[1]-A[1],O=x[2]-A[2];return f+=Math.sqrt(E*E+T*T+O*O),f}function Yd(i){return i.map(e=>[...e])}class Hr{constructor(e=0,t=0,s=0,o=1){this._x=e,this._y=t,this._z=s,this._w=o}static slerpFlat(e,t,s,o,h,c,f){let b=s[o+0],g=s[o+1],A=s[o+2],x=s[o+3];const E=h[c+0],T=h[c+1],O=h[c+2],z=h[c+3];if(f===0){e[t+0]=b,e[t+1]=g,e[t+2]=A,e[t+3]=x;return}if(f===1){e[t+0]=E,e[t+1]=T,e[t+2]=O,e[t+3]=z;return}if(x!==z||b!==E||g!==T||A!==O){let U=1-f;const D=b*E+g*T+A*O+x*z,de=D>=0?1:-1,ve=1-D*D;if(ve>Number.EPSILON){const W=Math.sqrt(ve),ue=Math.atan2(W,D*de);U=Math.sin(U*ue)/W,f=Math.sin(f*ue)/W}const oe=f*de;if(b=b*U+E*oe,g=g*U+T*oe,A=A*U+O*oe,x=x*U+z*oe,U===1-f){const W=1/Math.sqrt(b*b+g*g+A*A+x*x);b*=W,g*=W,A*=W,x*=W}}e[t]=b,e[t+1]=g,e[t+2]=A,e[t+3]=x}static multiplyQuaternionsFlat(e,t,s,o,h,c){const f=s[o],b=s[o+1],g=s[o+2],A=s[o+3],x=h[c],E=h[c+1],T=h[c+2],O=h[c+3];return e[t]=f*O+A*x+b*T-g*E,e[t+1]=b*O+A*E+g*x-f*T,e[t+2]=g*O+A*T+f*E-b*x,e[t+3]=A*O-f*x-b*E-g*T,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,o){return this._x=e,this._y=t,this._z=s,this._w=o,this._onChangeCallback(),this}clone(){return new Hr(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e.x,o=e.y,h=e.z,c=e.order,f=Math.cos,b=Math.sin,g=f(s/2),A=f(o/2),x=f(h/2),E=b(s/2),T=b(o/2),O=b(h/2);switch(c){case"XYZ":this._x=E*A*x+g*T*O,this._y=g*T*x-E*A*O,this._z=g*A*O+E*T*x,this._w=g*A*x-E*T*O;break;case"YXZ":this._x=E*A*x+g*T*O,this._y=g*T*x-E*A*O,this._z=g*A*O-E*T*x,this._w=g*A*x+E*T*O;break;case"ZXY":this._x=E*A*x-g*T*O,this._y=g*T*x+E*A*O,this._z=g*A*O+E*T*x,this._w=g*A*x-E*T*O;break;case"ZYX":this._x=E*A*x-g*T*O,this._y=g*T*x+E*A*O,this._z=g*A*O-E*T*x,this._w=g*A*x+E*T*O;break;case"YZX":this._x=E*A*x+g*T*O,this._y=g*T*x+E*A*O,this._z=g*A*O-E*T*x,this._w=g*A*x-E*T*O;break;case"XZY":this._x=E*A*x-g*T*O,this._y=g*T*x-E*A*O,this._z=g*A*O+E*T*x,this._w=g*A*x+E*T*O;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,o=Math.sin(s);return this._x=e.x*o,this._y=e.y*o,this._z=e.z*o,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],o=t[4],h=t[8],c=t[1],f=t[5],b=t[9],g=t[2],A=t[6],x=t[10],E=s+f+x;if(E>0){const T=.5/Math.sqrt(E+1);this._w=.25/T,this._x=(A-b)*T,this._y=(h-g)*T,this._z=(c-o)*T}else if(s>f&&s>x){const T=2*Math.sqrt(1+s-f-x);this._w=(A-b)/T,this._x=.25*T,this._y=(o+c)/T,this._z=(h+g)/T}else if(f>x){const T=2*Math.sqrt(1+f-s-x);this._w=(h-g)/T,this._x=(o+c)/T,this._y=.25*T,this._z=(b+A)/T}else{const T=2*Math.sqrt(1+x-s-f);this._w=(c-o)/T,this._x=(h+g)/T,this._y=(b+A)/T,this._z=.25*T}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return s<Number.EPSILON?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(kr(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(s===0)return this;const o=Math.min(1,t/s);return this.slerp(e,o),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,o=e._y,h=e._z,c=e._w,f=t._x,b=t._y,g=t._z,A=t._w;return this._x=s*A+c*f+o*g-h*b,this._y=o*A+c*b+h*f-s*g,this._z=h*A+c*g+s*b-o*f,this._w=c*A-s*f-o*b-h*g,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const s=this._x,o=this._y,h=this._z,c=this._w;let f=c*e._w+s*e._x+o*e._y+h*e._z;if(f<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,f=-f):this.copy(e),f>=1)return this._w=c,this._x=s,this._y=o,this._z=h,this;const b=1-f*f;if(b<=Number.EPSILON){const T=1-t;return this._w=T*c+t*this._w,this._x=T*s+t*this._x,this._y=T*o+t*this._y,this._z=T*h+t*this._z,this.normalize(),this}const g=Math.sqrt(b),A=Math.atan2(g,f),x=Math.sin((1-t)*A)/g,E=Math.sin(t*A)/g;return this._w=c*x+this._w*E,this._x=s*x+this._x*E,this._y=o*x+this._y*E,this._z=h*x+this._z*E,this._onChangeCallback(),this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),o=Math.sqrt(1-s),h=Math.sqrt(s);return this.set(o*Math.sin(e),o*Math.cos(e),h*Math.sin(t),h*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Dt=class $h{constructor(e,t,s){this.x=0,this.y=0,this.z=0;const o=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0);if(o!==0){if(o===1&&e instanceof Array){this.x=e[0],this.y=e[1],this.z=e[2];return}if(o===1){const{x:h,y:c,z:f}=e;this.x=h,this.y=c,this.z=f||0;return}if(o===3){this.x=e,this.y=t,this.z=s;return}throw Ut.ILLEGAL_PARAMETERS}}set(e,t,s){return s===void 0&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new $h(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z||0,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z||0,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(jo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,o=this.z,h=e.elements;return this.x=h[0]*t+h[3]*s+h[6]*o,this.y=h[1]*t+h[4]*s+h[7]*o,this.z=h[2]*t+h[5]*s+h[8]*o,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix3d(e){const t=this.x,s=this.y,o=this.z,h=e.elements,c=1/(h[3]*t+h[7]*s+h[11]*o+h[15]);return this.x=(h[0]*t+h[4]*s+h[8]*o+h[12])*c,this.y=(h[1]*t+h[5]*s+h[9]*o+h[13])*c,this.z=(h[2]*t+h[6]*s+h[10]*o+h[14])*c,this}applyQuaternion(e){const t=this.x,s=this.y,o=this.z,h=e.x,c=e.y,f=e.z,b=e.w,g=2*(c*o-f*s),A=2*(f*t-h*o),x=2*(h*s-c*t);return this.x=t+b*g+c*x-f*A,this.y=s+b*A+f*g-h*x,this.z=o+b*x+h*A-c*g,this}transformDirection(e){const t=this.x,s=this.y,o=this.z,h=e.elements;return this.x=h[0]*t+h[4]*s+h[8]*o,this.y=h[1]*t+h[5]*s+h[9]*o,this.z=h[2]*t+h[6]*s+h[10]*o,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,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(e){return this.x*e.x+this.y*e.y+this.z*e.z}isParallelTo(e){const t=this.dot(e),s=this.length(),o=e.length();return Math.abs(t)===s*o}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,o=e.y,h=e.z,c=t.x,f=t.y,b=t.z;return this.x=o*b-h*f,this.y=h*c-s*b,this.z=s*f-o*c,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return ia.copy(this).projectOnVector(e),this.sub(ia)}reflect(e){return this.sub(ia.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,o=this.z-e.z;return t*t+s*s+o*o}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),o=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=o,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Dt.X_AXIS=Object.freeze(new Dt(1,0,0)),Dt.NEGATIVE_X_AXIS=Object.freeze(new Dt(-1,0,0)),Dt.Y_AXIS=Object.freeze(new Dt(0,1,0)),Dt.NEGATIVE_Y_AXIS=Object.freeze(new Dt(0,-1,0)),Dt.Z_AXIS=Object.freeze(new Dt(0,0,1)),Dt.NEGATIVE_Z_AXIS=Object.freeze(new Dt(0,0,-1));let Z=Dt;const ia=new Z,jo=new Hr,da=class Zh{constructor(e,t,s,o,h,c,f,b,g,A,x,E,T,O,z,U){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!=null&&t!=null&&s!=null&&o!=null&&h!=null&&c!=null&&f!=null&&b!=null&&g!=null&&A!=null&&x!=null&&E!=null&&T!=null&&O!=null&&z!=null&&U!=null&&this.set(e,t,s,o,h,c,f,b,g,A,x,E,T,O,z,U)}set(e,t,s,o,h,c,f,b,g,A,x,E,T,O,z,U){const D=this.elements;return D[0]=e,D[4]=t,D[8]=s,D[12]=o,D[1]=h,D[5]=c,D[9]=f,D[13]=b,D[2]=g,D[6]=A,D[10]=x,D[14]=E,D[3]=T,D[7]=O,D[11]=z,D[15]=U,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 Zh().fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}setFromExtrusionDirection(e){if(Ca.equalPoint3d(e,Z.Z_AXIS))this.identity();else{const t=new Z(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?t.crossVectors(Z.Y_AXIS,e).normalize():t.crossVectors(Z.Z_AXIS,e).normalize();const s=e.clone().cross(t).normalize();this.set(t.x,t.y,t.z,0,s.x,s.y,s.z,0,e.x,e.y,e.z,0,0,0,0,1)}return this}extractBasis(e,t,s){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,s=e.elements,o=1/Ln.setFromMatrixColumn(e,0).length(),h=1/Ln.setFromMatrixColumn(e,1).length(),c=1/Ln.setFromMatrixColumn(e,2).length();return t[0]=s[0]*o,t[1]=s[1]*o,t[2]=s[2]*o,t[3]=0,t[4]=s[4]*h,t[5]=s[5]*h,t[6]=s[6]*h,t[7]=0,t[8]=s[8]*c,t[9]=s[9]*c,t[10]=s[10]*c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Xd,e,Kd)}lookAt(e,t,s){const o=this.elements;return Bt.subVectors(e,t),Bt.lengthSq()===0&&(Bt.z=1),Bt.normalize(),Ur.crossVectors(s,Bt),Ur.lengthSq()===0&&(Math.abs(s.z)===1?Bt.x+=1e-4:Bt.z+=1e-4,Bt.normalize(),Ur.crossVectors(s,Bt)),Ur.normalize(),Gs.crossVectors(Bt,Ur),o[0]=Ur.x,o[4]=Gs.x,o[8]=Bt.x,o[1]=Ur.y,o[5]=Gs.y,o[9]=Bt.y,o[2]=Ur.z,o[6]=Gs.z,o[10]=Bt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,o=t.elements,h=this.elements,c=s[0],f=s[4],b=s[8],g=s[12],A=s[1],x=s[5],E=s[9],T=s[13],O=s[2],z=s[6],U=s[10],D=s[14],de=s[3],ve=s[7],oe=s[11],W=s[15],ue=o[0],se=o[4],Ve=o[8],Ye=o[12],We=o[1],xe=o[5],Le=o[9],dt=o[13],mt=o[2],Pt=o[6],Je=o[10],at=o[14],Q=o[3],Me=o[7],ot=o[11],hr=o[15];return h[0]=c*ue+f*We+b*mt+g*Q,h[4]=c*se+f*xe+b*Pt+g*Me,h[8]=c*Ve+f*Le+b*Je+g*ot,h[12]=c*Ye+f*dt+b*at+g*hr,h[1]=A*ue+x*We+E*mt+T*Q,h[5]=A*se+x*xe+E*Pt+T*Me,h[9]=A*Ve+x*Le+E*Je+T*ot,h[13]=A*Ye+x*dt+E*at+T*hr,h[2]=O*ue+z*We+U*mt+D*Q,h[6]=O*se+z*xe+U*Pt+D*Me,h[10]=O*Ve+z*Le+U*Je+D*ot,h[14]=O*Ye+z*dt+U*at+D*hr,h[3]=de*ue+ve*We+oe*mt+W*Q,h[7]=de*se+ve*xe+oe*Pt+W*Me,h[11]=de*Ve+ve*Le+oe*Je+W*ot,h[15]=de*Ye+ve*dt+oe*at+W*hr,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],o=e[8],h=e[12],c=e[1],f=e[5],b=e[9],g=e[13],A=e[2],x=e[6],E=e[10],T=e[14],O=e[3],z=e[7],U=e[11],D=e[15];return O*(+h*b*x-o*g*x-h*f*E+s*g*E+o*f*T-s*b*T)+z*(+t*b*T-t*g*E+h*c*E-o*c*T+o*g*A-h*b*A)+U*(+t*g*x-t*f*T-h*c*x+s*c*T+h*f*A-s*g*A)+D*(-o*f*A-t*b*x+t*f*E+o*c*x-s*c*E+s*b*A)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const o=this.elements;return e instanceof Z?(o[12]=e.x,o[13]=e.y,o[14]=e.z):(o[12]=e,o[13]=t,o[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],o=e[2],h=e[3],c=e[4],f=e[5],b=e[6],g=e[7],A=e[8],x=e[9],E=e[10],T=e[11],O=e[12],z=e[13],U=e[14],D=e[15],de=x*U*g-z*E*g+z*b*T-f*U*T-x*b*D+f*E*D,ve=O*E*g-A*U*g-O*b*T+c*U*T+A*b*D-c*E*D,oe=A*z*g-O*x*g+O*f*T-c*z*T-A*f*D+c*x*D,W=O*x*b-A*z*b-O*f*E+c*z*E+A*f*U-c*x*U,ue=t*de+s*ve+o*oe+h*W;if(ue===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const se=1/ue;return e[0]=de*se,e[1]=(z*E*h-x*U*h-z*o*T+s*U*T+x*o*D-s*E*D)*se,e[2]=(f*U*h-z*b*h+z*o*g-s*U*g-f*o*D+s*b*D)*se,e[3]=(x*b*h-f*E*h-x*o*g+s*E*g+f*o*T-s*b*T)*se,e[4]=ve*se,e[5]=(A*U*h-O*E*h+O*o*T-t*U*T-A*o*D+t*E*D)*se,e[6]=(O*b*h-c*U*h-O*o*g+t*U*g+c*o*D-t*b*D)*se,e[7]=(c*E*h-A*b*h+A*o*g-t*E*g-c*o*T+t*b*T)*se,e[8]=oe*se,e[9]=(O*x*h-A*z*h-O*s*T+t*z*T+A*s*D-t*x*D)*se,e[10]=(c*z*h-O*f*h+O*s*g-t*z*g-c*s*D+t*f*D)*se,e[11]=(A*f*h-c*x*h-A*s*g+t*x*g+c*s*T-t*f*T)*se,e[12]=W*se,e[13]=(A*z*o-O*x*o+O*s*E-t*z*E-A*s*U+t*x*U)*se,e[14]=(O*f*o-c*z*o-O*s*b+t*z*b+c*s*U-t*f*U)*se,e[15]=(c*x*o-A*f*o+A*s*b-t*x*b-c*s*E+t*f*E)*se,this}scale(e){const t=this.elements,s=e.x,o=e.y,h=e.z;return t[0]*=s,t[4]*=o,t[8]*=h,t[1]*=s,t[5]*=o,t[9]*=h,t[2]*=s,t[6]*=o,t[10]*=h,t[3]*=s,t[7]*=o,t[11]*=h,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],o=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,o))}makeTranslation(e,t,s){return e instanceof Z?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),o=Math.sin(t),h=1-s,c=e.x,f=e.y,b=e.z,g=h*c,A=h*f;return this.set(g*c+s,g*f-o*b,g*b+o*f,0,g*f+o*b,A*f+s,A*b-o*c,0,g*b-o*f,A*b+o*c,h*b*b+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,o,h,c){return this.set(1,s,h,0,e,1,c,0,t,o,1,0,0,0,0,1),this}compose(e,t,s){const o=this.elements,h=t.x,c=t.y,f=t.z,b=t.w,g=h+h,A=c+c,x=f+f,E=h*g,T=h*A,O=h*x,z=c*A,U=c*x,D=f*x,de=b*g,ve=b*A,oe=b*x,W=s.x,ue=s.y,se=s.z;return o[0]=(1-(z+D))*W,o[1]=(T+oe)*W,o[2]=(O-ve)*W,o[3]=0,o[4]=(T-oe)*ue,o[5]=(1-(E+D))*ue,o[6]=(U+de)*ue,o[7]=0,o[8]=(O+ve)*se,o[9]=(U-de)*se,o[10]=(1-(E+z))*se,o[11]=0,o[12]=e.x,o[13]=e.y,o[14]=e.z,o[15]=1,this}decompose(e,t,s){const o=this.elements;let h=Ln.set(o[0],o[1],o[2]).length();const c=Ln.set(o[4],o[5],o[6]).length(),f=Ln.set(o[8],o[9],o[10]).length();this.determinant()<0&&(h=-h),e.x=o[12],e.y=o[13],e.z=o[14],rr.copy(this);const b=1/h,g=1/c,A=1/f;return rr.elements[0]*=b,rr.elements[1]*=b,rr.elements[2]*=b,rr.elements[4]*=g,rr.elements[5]*=g,rr.elements[6]*=g,rr.elements[8]*=A,rr.elements[9]*=A,rr.elements[10]*=A,t.setFromRotationMatrix(rr),s.x=h,s.y=c,s.z=f,this}equals(e){const t=this.elements,s=e.elements;for(let o=0;o<16;o++)if(t[o]!==s[o])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}};da.IDENTITY=Object.freeze(new da);let gn=da;const Ln=new Z,rr=new gn,Xd=new Z(0,0,0),Kd=new Z(1,1,1),Ur=new Z,Gs=new Z,Bt=new Z;class Re{constructor(e=void 0,t=void 0){this.min=e==null?new Z(1/0,1/0,1/0):new Z(e.x,e.y,e.z),this.max=t==null?new Z(-1/0,-1/0,-1/0):new Z(t.x,t.y,t.z)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t+=3)this.expandByPoint(aa.fromArray(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=aa.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}clone(){return new Re().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new Z(0,0,0):new Z(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Z(0,0,0):new Z(0,0,0).subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,aa).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Er[0].set(this.min.x,this.min.y,this.min.z).applyMatrix3d(e),Er[1].set(this.min.x,this.min.y,this.max.z).applyMatrix3d(e),Er[2].set(this.min.x,this.max.y,this.min.z).applyMatrix3d(e),Er[3].set(this.min.x,this.max.y,this.max.z).applyMatrix3d(e),Er[4].set(this.max.x,this.min.y,this.min.z).applyMatrix3d(e),Er[5].set(this.max.x,this.min.y,this.max.z).applyMatrix3d(e),Er[6].set(this.max.x,this.max.y,this.min.z).applyMatrix3d(e),Er[7].set(this.max.x,this.max.y,this.max.z).applyMatrix3d(e),this.setFromPoints(Er),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Er=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],aa=new Z,Go=new $e;class _t{constructor(e=void 0,t=void 0){this.min=e==null?new $e(1/0,1/0):new $e(e.x,e.y),this.max=t==null?new $e(-1/0,-1/0):new $e(t.x,t.y)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,s=e.length;t<s;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const s=Go.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}clone(){return new _t().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $e(0,0):new $e(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $e(0,0):new $e(0,0).subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Go).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Wo=new Z,$d=new Z,Zd=new Ni;class Rs{constructor(e=new Z(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,s,o){return this.normal.set(e,t,s),this.constant=o,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,s){const o=Wo.subVectors(s,t).cross($d.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(o,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectsBox(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const s=t||Zd.getNormalMatrix(e),o=this.coplanarPoint(Wo).applyMatrix3d(e),h=this.normal.applyMatrix3(s).normalize();return this.constant=-o.dot(h),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new Rs().copy(this)}}class Te extends $e{static pointArrayToNumberArray(e){const t=new Array(e.length*2);return e.forEach((s,o)=>{s.toArray(t,o*2)}),t}}class Y extends Z{static pointArrayToNumberArray(e,t=!0){const s=t?3:2,o=new Array(e.length*s);return e.forEach((h,c)=>{h.toArray(o,c*s)}),o}}const Ho=new gn,qo=new Hr,Qh=class ma{constructor(e=0,t=0,s=0,o=ma.DEFAULT_ORDER){this._x=e,this._y=t,this._z=s,this._order=o}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,o=this._order){return this._x=e,this._y=t,this._z=s,this._order=o,this._onChangeCallback(),this}clone(){return new ma(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const o=e.elements,h=o[0],c=o[4],f=o[8],b=o[1],g=o[5],A=o[9],x=o[2],E=o[6],T=o[10];switch(t){case"XYZ":this._y=Math.asin(kr(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(-A,T),this._z=Math.atan2(-c,h)):(this._x=Math.atan2(E,g),this._z=0);break;case"YXZ":this._x=Math.asin(-kr(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(f,T),this._z=Math.atan2(b,g)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(kr(E,-1,1)),Math.abs(E)<.9999999?(this._y=Math.atan2(-x,T),this._z=Math.atan2(-c,g)):(this._y=0,this._z=Math.atan2(b,h));break;case"ZYX":this._y=Math.asin(-kr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(E,T),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-c,g));break;case"YZX":this._z=Math.asin(kr(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-A,g),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(f,T));break;case"XZY":this._z=Math.asin(-kr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(E,g),this._y=Math.atan2(f,h)):(this._x=Math.atan2(-A,T),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,s=!0){return Ho.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ho,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return qo.setFromEuler(this),this.setFromQuaternion(qo,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Qh.DEFAULT_ORDER="XYZ";let Jh=Qh;class eu{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Oa extends eu{translate(e){return this.transform(new Ni().makeTranslation(e.x,e.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Ci extends Oa{constructor(){super(),this._loops=[]}add(e){this._loops.push(e),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const e=this.outter;return e?e.box:new _t}transform(e){return this._boundingBoxNeedsUpdate=!0,this}getPoints(e){const t=[];for(let s=0;s<this.loops.length;++s){const o=this.loops[s].getPoints(e);t.push(o)}return t}buildHierarchy(){var e;const t=this.getPoints(100),s=this.calculateBoundaryBoxes(t),o=this.sortBoundaryBoxesByAreas(s),h=new Map,c=o.length;for(let b=0;b<c;b++)h.set(o[b],{index:o[b],children:[]});const f={index:-1,children:[]};for(let b=0;b<c;b++){const g=o[b],A=t[g],x=s[g];let E=b+1;for(;E<c;E++){const T=o[E],O=t[T];if(s[T].containsBox(x)&&Hh.isPointInPolygon(A[Ee.randInt(0,A.length-1)],O)){(e=h.get(T))==null||e.children.push(h.get(g));break}}E===c&&f.children.push(h.get(g))}return f}calculateBoundaryBoxes(e){const t=[];return e.forEach(s=>{t.push(new _t().setFromPoints(s))}),t}sortBoundaryBoxesByAreas(e){const t=[];e.forEach((o,h)=>{const c=o.size,f=c.width*c.height;t.push({area:f,index:h})}),t.sort((o,h)=>o.area-h.area);const s=[];return t.forEach(o=>{s.push(o.index)}),s}}class Vn extends Oa{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(e){const t=this.getUtoTmapping(e);return this.getPoint(t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){const t=[];let s,o=this.getPoint(0),h=0;t.push(0);for(let c=1;c<=e;c++)s=this.getPoint(c/e),h+=s.distanceTo(o),t.push(h),o=s;return t}getUtoTmapping(e,t){const s=this.getLengths();let o=0;const h=s.length;let c;t?c=t:c=e*s[h-1];let f=0,b=h-1,g;for(;f<=b;)if(o=Math.floor(f+(b-f)/2),g=s[o]-c,g<0)f=o+1;else if(g>0)b=o-1;else{b=o;break}if(o=b,s[o]===c)return o/(h-1);const A=s[o],x=s[o+1]-A,E=(c-A)/x;return(o+E)/(h-1)}getTangent(e){let t=e-1e-4,s=e+1e-4;t<0&&(t=0),s>1&&(s=1);const o=this.getPoint(t),h=this.getPoint(s),c=new Te;return c.copy(h).sub(o).normalize(),c}getTangentAt(e){const t=this.getUtoTmapping(e);return this.getTangent(t)}}class Rn extends Vn{constructor(e,t,s,o,h){super();const c=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c==3)typeof e=="object"&&typeof t=="object"&&typeof s=="object"?this.createByThreePoints(e,t,s):this.createByStartEndPointsAndBulge(e,t,s);else if(c==5){const f=e;this.center=new Te(f.x,f.y),this.radius=t,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(s)):Ee.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(o)):Ee.normalizeAngle(o)}else throw Ut.ILLEGAL_PARAMETERS}createByThreePoints(e,t,s){const o=(se,Ve)=>({x:(se.x+Ve.x)/2,y:(se.y+Ve.y)/2}),h=(se,Ve)=>(Ve.y-se.y)/(Ve.x-se.x),c=se=>-1/se,f=o(e,t),b=o(t,s),g=h(e,t),A=h(t,s),x=c(g),E=c(A),T=(se,Ve,Ye,We)=>{const xe=(We-Ve)/(se-Ye),Le=se*xe+Ve;return{x:xe,y:Le}},O=f.y-x*f.x,z=b.y-E*b.x,U=T(x,O,E,z),D=Math.sqrt(Math.pow(e.x-U.x,2)+Math.pow(e.y-U.y,2)),de=(se,Ve)=>Math.atan2(se.y-Ve.y,se.x-Ve.x),ve=de(e,U),oe=de(t,U),W=de(s,U),ue=W>ve&&W<oe||ve>W&&ve<oe||oe>W&&oe<ve;this.center=U,this.radius=D,this._clockwise=!ue,this._startAngle=ve,this._endAngle=W}createByStartEndPointsAndBulge(e,t,s){let o,h,c;s<0?(o=Math.atan(-s)*4,h=new $e(e),c=new $e(t)):(o=Math.atan(s)*4,h=new $e(t),c=new $e(e));const f=new $e().subVectors(c,h),b=f.length(),g=new $e().addVectors(h,f.multiplyScalar(.5)),A=Math.abs(b/2/Math.tan(o/2)),x=f.normalize();let E;if(o<Math.PI){const T=new $e(x.x*Math.cos(Math.PI/2)-x.y*Math.sin(Math.PI/2),x.y*Math.cos(Math.PI/2)+x.x*Math.sin(Math.PI/2));E=g.add(T.multiplyScalar(-A))}else{const T=new $e(x.x*Math.cos(Math.PI/2)-x.y*Math.sin(Math.PI/2),x.y*Math.cos(Math.PI/2)+x.x*Math.sin(Math.PI/2));E=g.add(T.multiplyScalar(A))}s<0?(this._startAngle=Math.atan2(h.y-E.y,h.x-E.x),this._endAngle=Math.atan2(c.y-E.y,c.x-E.x)):(this._startAngle=Math.atan2(c.y-E.y,c.x-E.x),this._endAngle=Math.atan2(h.y-E.y,h.x-E.x)),this._clockwise=s<0,this.center=E,this.radius=c.sub(E).length()}get center(){return this._center}set center(e){this._center=new Te(e.x,e.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(e){this._startAngle=this._clockwise?this._mirrorAngle(Ee.normalizeAngle(e)):Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(e){const t=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(t):t,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(e){return(360-e*180/Math.PI)%360*Math.PI/180}_getInternalAngle(e){return this._clockwise?this._mirrorAngle(e):e}get deltaAngle(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return this.clockwise?Ee.normalizeAngle(e-t):Ee.normalizeAngle(t-e)}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle),s=Ee.normalizeAngle((e+t)/2),o=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(o)}get closed(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return Math.abs(t-e)/Math.PI%2==0}calculateBoundingBox(){const e=[this.startPoint,this.endPoint],t=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of t){const c=this._getInternalAngle(h);Ee.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&e.push(this.getPointAtAngle(h))}const s=e.map(h=>h.x),o=e.map(h=>h.y);return new _t(new Te(Math.min(...s),Math.min(...o)),new Te(Math.max(...s),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Rn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(e){const t=this._getInternalAngle(e),s=this.center.x+this.radius*Math.cos(t),o=this.center.y+this.radius*Math.sin(t);return new Te(s,o)}getPoints(e=100){const t=[];let s=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(s=nt,o=0),this.clockwise)for(let h=0;h<=e;h++){const c=o-s*(h/e),f=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(f);t.push(new Te(b.x,b.y))}else for(let h=0;h<=e;h++){const c=o+s*(h/e),f=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(f);t.push(new Te(b.x,b.y))}return t}}class Qd extends eu{translate(e){return this.transform(new gn().makeTranslation(e.x,e.y,e.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Bs extends Qd{}class qr extends Bs{constructor(e,t){super(),this._start=new Y(e),this._end=new Y(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}get direction(){return new Z().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new Y((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(e){return this.project(e).distanceTo(e)<1e-6}at(e,t){return this.delta(t).multiplyScalar(e).add(this._start)}atLength(e,t=!1){if(t){const s=this.delta(hn).normalize();return new Y(this._start).addScaledVector(s,e)}else{const s=this.delta(hn).normalize();return new Y(this._end).addScaledVector(s,e)}}extend(e,t=!1){if(t){const s=hn.subVectors(this._start,this._end).normalize();this._start=new Y(this._start).addScaledVector(s,e)}else{const s=this.delta(hn).normalize();this._end=new Y(this._end).addScaledVector(s,e)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(e,t){Yo.subVectors(e,this._start),Ws.subVectors(this.endPoint,this.startPoint);const s=Ws.dot(Ws);let o=Ws.dot(Yo)/s;return t&&(o=Ee.clamp(o,0,1)),o}closestPointToPoint(e,t,s){const o=this.closestPointToPointParameter(e,t);return this.delta(s).multiplyScalar(o).add(this._start)}delta(e){return e.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(e){const t=this.direction,s=hn.subVectors(e,this.startPoint).dot(t);return new Y().copy(t).multiplyScalar(s).add(this.startPoint)}perpPoint(e){const t=this.direction,s=this.startPoint,o=hn.subVectors(e,s).dot(t),h=hn.copy(t).multiplyScalar(o);return new Y().addVectors(s,h)}calculateBoundingBox(){const e=new Y(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),t=new Y(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new Re(e,t)}transform(e){return this._start.applyMatrix3d(e),this._end.applyMatrix3d(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new qr(this._start.clone(),this._end.clone())}}const hn=new Z,Yo=new Z,Ws=new Z;class pn extends Bs{static computeCenterPoint(e,t,s){const o=new Z().addVectors(e,t).multiplyScalar(.5),h=new Z().addVectors(e,s).multiplyScalar(.5),c=new Z().subVectors(t,e),f=new Z().subVectors(s,e),b=new Z().crossVectors(c,f).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const g=new Z().crossVectors(c,b).normalize(),A=new Z().crossVectors(f,b).normalize(),x=g.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=A.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),T=new qr(o,o.clone().add(x)),O=new qr(h,h.clone().add(E)),z=new Z;return T.closestPointToPoint(O.startPoint,!0,z)?z:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(e,t,s){const o=pn.computeCenterPoint(e,t,s);if(o){const h=o.distanceTo(e),c=new Z().subVectors(e,o),f=new Z().subVectors(t,o),b=Math.atan2(c.y,c.x),g=Math.atan2(f.y,f.x);return new pn(o,h,b,g,Z.Z_AXIS)}}constructor(e,t,s,o,h,c=Z.X_AXIS){super(),this.center=e,this.radius=t,this.startAngle=s,this.endAngle=o,this.normal=h,this.refVec=c,(o-s)%nt==0?(this.startAngle=0,this.endAngle=nt):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(e){this._center=new Y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Ee.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(e){this._normal=new Z(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(e){this._refVec=new Z(e.x,e.y,e.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 e=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Ee.isBetweenAngle(b,this.startAngle,this.endAngle)&&e.push(b);let t=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,f=-1/0;for(const b of e){const g=this.getPointAtAngle(b);g.x<t&&(t=g.x),g.y<s&&(s=g.y),g.z<o&&(o=g.z),g.x>h&&(h=g.x),g.y>c&&(c=g.y),g.z>f&&(f=g.z)}return new Re({x:t,y:s,z:o},{x:h,y:c,z:f})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(e){const t=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=nt,o=0);for(let h=0;h<=e;h++){const c=o+s*(h/e),f=this.getPointAtAngle(c);t.push(f)}return t}transform(e){const t=oa.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=oa.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix3d(e),t.applyMatrix3d(e),s.applyMatrix3d(e),this.normal.applyMatrix3d(e).normalize(),this.refVec.applyMatrix3d(e).normalize(),this.startAngle=this.getAngle(t),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new pn(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(e){return e.sub(this.center),Math.atan2(e.dot(oa.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))}getPointAtAngle(e){const t=this.normal,s=this.refVec,o={x:t.y*s.z-t.z*s.y,y:t.z*s.x-t.x*s.z,z:t.x*s.y-t.y*s.x},h=this.center,c=this.radius;return new Y(h.x+c*(s.x*Math.cos(e)+o.x*Math.sin(e)),h.y+c*(s.y*Math.cos(e)+o.y*Math.sin(e)),h.z+c*(s.z*Math.cos(e)+o.z*Math.sin(e)))}get plane(){const e=new Z(this.center).distanceTo(Ma);return new Rs(this.normal,e)}}const oa=new Z;class Li extends Vn{constructor(e,t,s,o=0,h=nt,c=!1,f=0){super(),this.center=e,this.majorAxisRadius=t,this.minorAxisRadius=s,(h-o)%nt==0?(this.startAngle=0,this.endAngle=nt):(this.startAngle=o,this.endAngle=h),this.clockwise=c,this.rotation=f}get center(){return this._center}set center(e){this._center=new Y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Ee.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let e=1/0,t=1/0,s=-1/0,o=-1/0;for(let h=0;h<=100;h++){const c=this.getPoint(h/100);e=Math.min(e,c.x),t=Math.min(t,c.y),s=Math.max(s,c.x),o=Math.max(o,c.y)}return new _t({x:e,y:t},{x:s,y:o})}get closed(){return this.deltaAngle==0}getPoint(e){const t=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=t;for(;s>t;)s-=t;s<Number.EPSILON&&(o?s=0:s=t),this.clockwise===!0&&!o&&(s===t?s=-t:s=s-t);const h=this.startAngle+e*s;let c=this.center.x+this.majorAxisRadius*Math.cos(h),f=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const b=Math.cos(this.rotation),g=Math.sin(this.rotation),A=c-this.center.x,x=f-this.center.y;c=A*b-x*g+this.center.x,f=A*g+x*b+this.center.y}return new Te(c,f)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}clone(){return new Li(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Oi extends Bs{constructor(e,t,s,o,h,c=0,f=nt){super(),this.center=e,this.normal=t,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(f-c);Math.abs(b-nt)<1e-10||Math.abs(b-2*nt)<1e-10?(this.startAngle=0,this.endAngle=nt):(this.startAngle=c,this.endAngle=f)}get center(){return this._center}set center(e){this._center=new Y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw Ut.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==nt?e:Ee.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const e=this.endAngle-this.startAngle;return Math.abs(e-nt)<1e-10?nt:Ee.normalizeAngle(e)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(e){this._normal=new Z(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(e){this._majorAxis=new Z(e.x,e.y,e.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new Z().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get isCircular(){return Na.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const e=1e3,t=this.deltaAngle/e;let s=0,o=this.getPointAtAngle(this.startAngle);for(let h=1;h<=e;h++){const c=this.startAngle+h*t,f=this.getPointAtAngle(c),b=f.x-o.x,g=f.y-o.y,A=f.z-o.z;s+=Math.sqrt(b*b+g*g+A*A),o=f}return s}calculateBoundingBox(){if(this.majorAxis.equals(Z.X_AXIS)||this.majorAxis.equals(Z.Y_AXIS)||this.majorAxis.isParallelTo(Z.X_AXIS)||this.majorAxis.isParallelTo(Z.Y_AXIS)){const e=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Ee.isBetweenAngle(b,this.startAngle,this.endAngle)&&e.push(b);let t=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,f=-1/0;for(const b of e){const g=this.getPointAtAngle(b);g.x<t&&(t=g.x),g.y<s&&(s=g.y),g.z<o&&(o=g.z),g.x>h&&(h=g.x),g.y>c&&(c=g.y),g.z>f&&(f=g.z)}return new Re({x:t,y:s,z:o},{x:h,y:c,z:f})}else{let e=1/0,t=1/0,s=1/0,o=-1/0,h=-1/0,c=-1/0;for(let f=0;f<=100;f++){const b=this.startAngle+this.deltaAngle*(f/100),g=this.getPointAtAngle(b);e=Math.min(e,g.x),t=Math.min(t,g.y),s=Math.min(s,g.z),o=Math.max(o,g.x),h=Math.max(h,g.y),c=Math.max(c,g.z)}return new Re({x:e,y:t,z:s},{x:o,y:h,z:c})}}get closed(){return this.deltaAngle==0}getPoints(e=100){const t=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=nt,o=0);for(let h=0;h<=e;h++){const c=o+s*(h/e),f=this.getPointAtAngle(c);t.push(f)}return t}getPointAtAngle(e){const t=Math.cos(e),s=Math.sin(e),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),h=this.majorAxis.clone().multiplyScalar(t*this.majorAxisRadius).add(o);return new Y(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(e){const t=new Z(e).sub(this.center),s=t.dot(this.majorAxis),o=t.dot(this.minorAxis),h=s/this.majorAxisRadius,c=o/this.minorAxisRadius;return h*h+c*c<=1}transform(e){return this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Oi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const e=new Z(this.center).distanceTo(Ma);return new Rs(this.normal,e)}}class Ds extends Vn{constructor(e=null,t=!1){super(),this._vertices=e||new Array,this._closed=t}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const e=this._vertices[0];return new Te(e.x,e.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const e=this.numberOfVertices;if(e>0)if(this.closed){const t=this._vertices[0];return new Te(t.x,t.y)}else{const t=this._vertices[e-1];return new Te(t.x,t.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let e=0;const t=this._vertices.length;for(let s=0;s<t;++s){const o=this._vertices[s];let h=null;if(s<t-1?h=this._vertices[s+1]:s==t-1&&this.closed&&(h=this._vertices[0]),h)if(o.bulge){const c=new Rn(o,h,o.bulge);e+=c.length}else e+=new Te(o.x,o.y).distanceTo(h)}return e}set closed(e){this._closed=e,this._boundingBoxNeedsUpdate=!0}addVertexAt(e,t){e<=0?this._vertices.unshift(t):this._vertices.splice(e,0,t),this._boundingBoxNeedsUpdate=!0}getPointAt(e){const t=this._vertices[e];return new Te(t.x,t.y)}calculateBoundingBox(){const e=this.getPoints(100);return new _t().setFromPoints(e)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(e,t){const s=[];return this.getPoints(e).forEach(o=>s.push(new Y().set(o.x,o.y,t))),s}getPoints(e){const t=[],s=this._vertices.length;for(let o=0;o<s;++o){const h=this._vertices[o];if(h.bulge){let c=null;if(o<s-1?c=this._vertices[o+1]:o==s-1&&this.closed&&(c=this._vertices[0]),c){const f=new Rn(h,c,h.bulge).getPoints(e),b=f.length;for(let g=0;g<b;++g){const A=f[g];t.push(new Te(A.x,A.y))}}}else t.push(new Te(h.x,h.y)),o==s-1&&this.closed&&t.push(t[0])}return t}}class zi extends Vn{constructor(e,t){super(),this._start=new Te(e),this._end=new Te(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const e=new Te(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),t=new Te(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new _t(e,t)}transform(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new zi(this._start.clone(),this._end.clone())}}class tu extends Vn{constructor(e=[]){super(),this._curves=e}get curves(){return this._curves}add(e){this._curves.push(e),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const e=this._curves[0].startPoint;return new Te(e.x,e.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let e=0;return this._curves.forEach(t=>{e+=t.length}),e}calculateBoundingBox(){const e=this.getPoints(100),t=new _t;return t.setFromPoints(e),t}transform(e){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(e){const t=[];return this.curves.forEach(s=>{s.getPoints(e).forEach(o=>{t.push(new Te(o.x,o.y))})}),t}}function Jd(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ru={exports:{}};(function(i,e){(function(t){i.exports=t()})(function(){var t={},s=this;new Function("try {return this===window;}catch(e){ return false;}");var o=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(o()&&h(),o()||h()){var c=s;if(h()){var f=function(b,g){var A=s;return b.split(".").forEach(function(x){A&&(A=A[x])}),A?A[g]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var g=f(b.data.className,b.data.methodName);if(!g)return console.error("could not find "+b.data.className+"."+b.data.methodName);postMessage({result:g.apply(null,b.data.args),id:b.data.id})}}}}return function(b,g,A){g.geom=g.geom||{},g.exe=g.exe||{},g.eval=g.eval||{},g.core=g.core||{},g.promhx=g.promhx||{};var x={},E=function(){return Me.__string_rec(this,"")};function T(r,n){function a(){}a.prototype=r;var l=new a;for(var u in n)l[u]=n[u];return n.toString!==Object.prototype.toString&&(l.toString=n.toString),l}var O=function(){};x.HxOverrides=O,O.__name__=["HxOverrides"],O.strDate=function(r){var n=r.length;switch(n){case 8:var a=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(a[0]),l.setUTCMinutes(a[1]),l.setUTCSeconds(a[2]),l;case 10:var u=r.split("-");return new Date(u[0],u[1]-1,u[2],0,0,0);case 19:var d=r.split(" "),p=d[0].split("-"),_=d[1].split(":");return new Date(p[0],p[1]-1,p[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},O.cca=function(r,n){var a=r.charCodeAt(n);if(a==a)return a},O.substr=function(r,n,a){return n!=null&&n!=0&&a!=null&&a<0?"":(a==null&&(a=r.length),n<0?(n=r.length+n,n<0&&(n=0)):a<0&&(a=r.length+a-n),r.substr(n,a))},O.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var z=function(){};x.Lambda=z,z.__name__=["Lambda"],z.fold=function(r,n,a){for(var l=Xt(r)();l.hasNext();){var u=l.next();a=n(u,a)}return a};var U=function(){this.length=0};x.List=U,U.__name__=["List"],U.prototype={add:function(r){var n=[r];this.h==null?this.h=n:this.q[1]=n,this.q=n,this.length++},pop:function(){if(this.h==null)return null;var r=this.h[0];return this.h=this.h[1],this.h==null&&(this.q=null),this.length--,r},isEmpty:function(){return this.h==null},__class__:U},Math.__name__=["Math"];var D=function(){};x.Reflect=D,D.__name__=["Reflect"],D.field=function(r,n){try{return r[n]}catch(a){return a instanceof Q&&(a=a.val),null}},D.callMethod=function(r,n,a){return n.apply(r,a)},D.fields=function(r){var n=[];if(r!=null){var a=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&a.call(r,l)&&n.push(l)}return n},D.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},D.deleteField=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)?(delete r[n],!0):!1};var de=function(){};x.Std=de,de.__name__=["Std"],de.string=function(r){return Me.__string_rec(r,"")},de.parseFloat=function(r){return parseFloat(r)};var ve=function(){this.b=""};x.StringBuf=ve,ve.__name__=["StringBuf"],ve.prototype={add:function(r){this.b+=de.string(r)},__class__:ve};var oe=function(){};x.StringTools=oe,oe.__name__=["StringTools"],oe.fastCodeAt=function(r,n){return r.charCodeAt(n)};var W=x.ValueType={__ename__:["ValueType"],__constructs__:["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]};W.TNull=["TNull",0],W.TNull.toString=E,W.TNull.__enum__=W,W.TInt=["TInt",1],W.TInt.toString=E,W.TInt.__enum__=W,W.TFloat=["TFloat",2],W.TFloat.toString=E,W.TFloat.__enum__=W,W.TBool=["TBool",3],W.TBool.toString=E,W.TBool.__enum__=W,W.TObject=["TObject",4],W.TObject.toString=E,W.TObject.__enum__=W,W.TFunction=["TFunction",5],W.TFunction.toString=E,W.TFunction.__enum__=W,W.TClass=function(r){var n=["TClass",6,r];return n.__enum__=W,n.toString=E,n},W.TEnum=function(r){var n=["TEnum",7,r];return n.__enum__=W,n.toString=E,n},W.TUnknown=["TUnknown",8],W.TUnknown.toString=E,W.TUnknown.__enum__=W;var ue=function(){};x.Type=ue,ue.__name__=["Type"],ue.getClassName=function(r){var n=r.__name__;return n==null?null:n.join(".")},ue.getEnumName=function(r){var n=r.__ename__;return n.join(".")},ue.resolveClass=function(r){var n=x[r];return n==null||!n.__name__?null:n},ue.resolveEnum=function(r){var n=x[r];return n==null||!n.__ename__?null:n},ue.createEmptyInstance=function(r){function n(){}return n.prototype=r.prototype,new n},ue.createEnum=function(r,n,a){var l=D.field(r,n);if(l==null)throw new Q("No such constructor "+n);if(D.isFunction(l)){if(a==null)throw new Q("Constructor "+n+" need parameters");return D.callMethod(r,l,a)}if(a!=null&&a.length!=0)throw new Q("Constructor "+n+" does not need parameters");return l},ue.getEnumConstructs=function(r){var n=r.__constructs__;return n.slice()},ue.typeof=function(r){var n=typeof r;switch(n){case"boolean":return W.TBool;case"string":return W.TClass(String);case"number":return Math.ceil(r)==r%2147483648?W.TInt:W.TFloat;case"object":if(r==null)return W.TNull;var a=r.__enum__;if(a!=null)return W.TEnum(a);var l=Me.getClass(r);return l!=null?W.TClass(l):W.TObject;case"function":return r.__name__||r.__ename__?W.TObject:W.TFunction;case"undefined":return W.TNull;default:return W.TUnknown}};var se=function(){};x["haxe.IMap"]=se,se.__name__=["haxe","IMap"];var Ve=function(r,n){this.high=r,this.low=n};x["haxe._Int64.___Int64"]=Ve,Ve.__name__=["haxe","_Int64","___Int64"],Ve.prototype={__class__:Ve};var Ye=function(){this.buf=new ve,this.cache=[],this.useCache=Ye.USE_CACHE,this.useEnumIndex=Ye.USE_ENUM_INDEX,this.shash=new mt,this.scount=0};x["haxe.Serializer"]=Ye,Ye.__name__=["haxe","Serializer"],Ye.prototype={toString:function(){return this.buf.b},serializeString:function(r){var n=this.shash.get(r);if(n!=null){this.buf.b+="R",n==null?this.buf.b+="null":this.buf.b+=""+n;return}this.shash.set(r,this.scount++),this.buf.b+="y",r=encodeURIComponent(r),r.length==null?this.buf.b+="null":this.buf.b+=""+r.length,this.buf.b+=":",r==null?this.buf.b+="null":this.buf.b+=""+r},serializeRef:function(r){for(var n=typeof r,a=0,l=this.cache.length;a<l;){var u=a++,d=this.cache[u];if(typeof d==n&&d==r)return this.buf.b+="r",u==null?this.buf.b+="null":this.buf.b+=""+u,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var n=0,a=D.fields(r);n<a.length;){var l=a[n];++n,this.serializeString(l),this.serialize(D.field(r,l))}this.buf.b+="g"},serialize:function(r){{var n=ue.typeof(r);switch(n[1]){case 0:this.buf.b+="n";break;case 1:var a=r;if(a==0){this.buf.b+="z";return}this.buf.b+="i",a==null?this.buf.b+="null":this.buf.b+=""+a;break;case 2:var l=r;isNaN(l)?this.buf.b+="k":isFinite(l)?(this.buf.b+="d",l==null?this.buf.b+="null":this.buf.b+=""+l):l<0?this.buf.b+="m":this.buf.b+="p";break;case 3:r?this.buf.b+="t":this.buf.b+="f";break;case 6:var u=n[2];if(u==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(u){case Array:var d=0;this.buf.b+="a";for(var p=r.length,_=0;_<p;){var v=_++;r[v]==null?d++:(d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d),d=0),this.serialize(r[v]))}d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d)),this.buf.b+="h";break;case U:this.buf.b+="l";for(var w=r,I=w.h,S=null;I!=null;){var P;S=I[0],I=I[1],P=S,this.serialize(P)}this.buf.b+="h";break;case Date:var k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case mt:this.buf.b+="b";for(var M=r,L=M.keys();L.hasNext();){var C=L.next();this.serializeString(C),this.serialize(ji[C]!=null?M.getReserved(C):M.h[C])}this.buf.b+="h";break;case xe:this.buf.b+="q";for(var B=r,R=B.keys();R.hasNext();){var F=R.next();this.buf.b+=":",F==null?this.buf.b+="null":this.buf.b+=""+F,this.serialize(B.h[F])}this.buf.b+="h";break;case Le:this.buf.b+="M";for(var V=r,q=V.keys();q.hasNext();){var J=q.next(),H=D.field(J,"__id__");D.deleteField(J,"__id__"),this.serialize(J),J.__id__=H,this.serialize(V.h[J.__id__])}this.buf.b+="h";break;case Pt:for(var j=r,K=0,ee=j.length-2,te=new ve,ie=Ye.BASE64;K<ee;){var he=j.get(K++),ae=j.get(K++),ce=j.get(K++);te.add(ie.charAt(he>>2)),te.add(ie.charAt((he<<4|ae>>4)&63)),te.add(ie.charAt((ae<<2|ce>>6)&63)),te.add(ie.charAt(ce&63))}if(K==ee){var ne=j.get(K++),me=j.get(K++);te.add(ie.charAt(ne>>2)),te.add(ie.charAt((ne<<4|me>>4)&63)),te.add(ie.charAt(me<<2&63))}else if(K==ee+1){var X=j.get(K++);te.add(ie.charAt(X>>2)),te.add(ie.charAt(X<<4&63))}var fe=te.b;this.buf.b+="s",fe.length==null?this.buf.b+="null":this.buf.b+=""+fe.length,this.buf.b+=":",fe==null?this.buf.b+="null":this.buf.b+=""+fe;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ue.getClassName(u)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ue.getClassName(u)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Me.__instanceof(r,bo)){var Ie=ue.getClassName(r);this.buf.b+="A",this.serializeString(Ie)}else if(Me.__instanceof(r,xo))this.buf.b+="B",this.serializeString(ue.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Ge=n[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(ue.getEnumName(Ge)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=de.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Xe=r.length;this.buf.b+=de.string(Xe-2);for(var Fe=2;Fe<Xe;){var Ke=Fe++;this.serialize(r[Ke])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+de.string(r))}}},__class__:Ye};var We=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=We.DEFAULT_RESOLVER;n==null&&(n=ue,We.DEFAULT_RESOLVER=n),this.setResolver(n)};x["haxe.Unserializer"]=We,We.__name__=["haxe","Unserializer"],We.initCodes=function(){for(var r=[],n=0,a=We.BASE64.length;n<a;){var l=n++;r[We.BASE64.charCodeAt(l)]=l}return r},We.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(n){return null},resolveEnum:function(n){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,n=!1,a=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=a)break;n=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return n&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var n=this.buf.charCodeAt(this.pos);if(n>=43&&n<58||n==101||n==69)this.pos++;else break}return de.parseFloat(O.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var n=this.unserialize();if(typeof n!="string")throw new Q("Invalid object key");var a=this.unserialize();r[n]=a}this.pos++},unserializeEnum:function(r,n){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var a=this.readDigits();if(a==0)return ue.createEnum(r,n);for(var l=[];a-- >0;)l.push(this.unserialize());return ue.createEnum(r,n,l)},unserialize:function(){var r=this.get(this.pos++);switch(r){case 110:return null;case 116:return!0;case 102:return!1;case 122:return 0;case 105:return this.readDigits();case 100:return this.readFloat();case 121:var n=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<n)throw new Q("Invalid string length");var a=O.substr(this.buf,this.pos,n);return this.pos+=n,a=decodeURIComponent(a.split("+").join(" ")),this.scache.push(a),a;case 107:return NaN;case 109:return-1/0;case 112:return 1/0;case 97:this.buf;var l=[];for(this.cache.push(l);;){var u=this.buf.charCodeAt(this.pos);if(u==104){this.pos++;break}if(u==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var p={};return this.cache.push(p),this.unserializeObject(p),p;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var v=this.readDigits();if(v<0||v>=this.scache.length)throw new Q("Invalid string reference");return this.scache[v];case 120:throw new Q(this.unserialize());case 99:var w=this.unserialize(),I=this.resolver.resolveClass(w);if(I==null)throw new Q("Class not found "+w);var S=ue.createEmptyInstance(I);return this.cache.push(S),this.unserializeObject(S),S;case 119:var P=this.unserialize(),k=this.resolver.resolveEnum(P);if(k==null)throw new Q("Enum not found "+P);var M=this.unserializeEnum(k,this.unserialize());return this.cache.push(M),M;case 106:var L=this.unserialize(),C=this.resolver.resolveEnum(L);if(C==null)throw new Q("Enum not found "+L);this.pos++;var B=this.readDigits(),R=ue.getEnumConstructs(C)[B];if(R==null)throw new Q("Unknown enum index "+L+"@"+B);var F=this.unserializeEnum(C,R);return this.cache.push(F),F;case 108:var V=new U;for(this.cache.push(V),this.buf;this.buf.charCodeAt(this.pos)!=104;)V.add(this.unserialize());return this.pos++,V;case 98:var q=new mt;for(this.cache.push(q),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();q.set(J,this.unserialize())}return this.pos++,q;case 113:var H=new xe;this.cache.push(H),this.buf;for(var j=this.get(this.pos++);j==58;){var K=this.readDigits();H.set(K,this.unserialize()),j=this.get(this.pos++)}if(j!=104)throw new Q("Invalid IntMap format");return H;case 77:var ee=new Le;for(this.cache.push(ee),this.buf;this.buf.charCodeAt(this.pos)!=104;){var te=this.unserialize();ee.set(te,this.unserialize())}return this.pos++,ee;case 118:var ie;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var he=O.substr(this.buf,this.pos,19);ie=O.strDate(he),this.pos+=19}else{var ae=this.readFloat(),ce=new Date;ce.setTime(ae),ie=ce}return this.cache.push(ie),ie;case 115:var ne=this.readDigits(),me=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<ne)throw new Q("Invalid bytes length");var X=We.CODES;X==null&&(X=We.initCodes(),We.CODES=X);var fe=this.pos,Ie=ne&3,Ge;Ge=(ne>>2)*3+(Ie>=2?Ie-1:0);for(var Xe=fe+(ne-Ie),Fe=Pt.alloc(Ge),Ke=0;fe<Xe;){var At=X[oe.fastCodeAt(me,fe++)],Ht=X[oe.fastCodeAt(me,fe++)];Fe.set(Ke++,At<<2|Ht>>4);var vt=X[oe.fastCodeAt(me,fe++)];Fe.set(Ke++,Ht<<4|vt>>2);var ft=X[oe.fastCodeAt(me,fe++)];Fe.set(Ke++,vt<<6|ft)}if(Ie>=2){var St=X[oe.fastCodeAt(me,fe++)],Mt=X[oe.fastCodeAt(me,fe++)];if(Fe.set(Ke++,St<<2|Mt>>4),Ie==3){var Kt=X[oe.fastCodeAt(me,fe++)];Fe.set(Ke++,Mt<<4|Kt>>2)}}return this.pos+=ne,this.cache.push(Fe),Fe;case 67:var or=this.unserialize(),$t=this.resolver.resolveClass(or);if($t==null)throw new Q("Class not found "+or);var Zt=ue.createEmptyInstance($t);if(this.cache.push(Zt),Zt.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Zt;case 65:var Qt=this.unserialize(),dr=this.resolver.resolveClass(Qt);if(dr==null)throw new Q("Class not found "+Qt);return dr;case 66:var Mn=this.unserialize(),Zr=this.resolver.resolveEnum(Mn);if(Zr==null)throw new Q("Enum not found "+Mn);return Zr}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:We};var xe=function(){this.h={}};x["haxe.ds.IntMap"]=xe,xe.__name__=["haxe","ds","IntMap"],xe.__interfaces__=[se],xe.prototype={set:function(r,n){this.h[r]=n},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n|0);return O.iter(r)},__class__:xe};var Le=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Le,Le.__name__=["haxe","ds","ObjectMap"],Le.__interfaces__=[se],Le.prototype={set:function(r,n){var a=r.__id__||(r.__id__=++Le.count);this.h[a]=n,this.h.__keys__[a]=r},keys:function(){var r=[];for(var n in this.h.__keys__)this.h.hasOwnProperty(n)&&r.push(this.h.__keys__[n]);return O.iter(r)},__class__:Le};var dt=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};dt.Some=function(r){var n=["Some",0,r];return n.__enum__=dt,n.toString=E,n},dt.None=["None",1],dt.None.toString=E,dt.None.__enum__=dt;var mt=function(){this.h={}};x["haxe.ds.StringMap"]=mt,mt.__name__=["haxe","ds","StringMap"],mt.__interfaces__=[se],mt.prototype={set:function(r,n){ji[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return ji[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,n){this.rh==null&&(this.rh={}),this.rh["$"+r]=n},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return O.iter(r)},arrayKeys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n);if(this.rh!=null)for(var n in this.rh)n.charCodeAt(0)==36&&r.push(n.substr(1));return r},__class__:mt};var Pt=function(r){this.length=r.byteLength,this.b=new Gi(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Pt,Pt.__name__=["haxe","io","Bytes"],Pt.alloc=function(r){return new Pt(new Vs(r))},Pt.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:Pt};var Je=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};Je.Blocked=["Blocked",0],Je.Blocked.toString=E,Je.Blocked.__enum__=Je,Je.Overflow=["Overflow",1],Je.Overflow.toString=E,Je.Overflow.__enum__=Je,Je.OutsideBounds=["OutsideBounds",2],Je.OutsideBounds.toString=E,Je.OutsideBounds.__enum__=Je,Je.Custom=function(r){var n=["Custom",3,r];return n.__enum__=Je,n.toString=E,n};var at=function(){};x["haxe.io.FPHelper"]=at,at.__name__=["haxe","io","FPHelper"],at.i32ToFloat=function(r){var n=1-(r>>>31<<1),a=r>>>23&255,l=r&8388607;return l==0&&a==0?0:n*(1+Math.pow(2,-23)*l)*Math.pow(2,a-127)},at.floatToI32=function(r){if(r==0)return 0;var n;r<0?n=-r:n=r;var a=Math.floor(Math.log(n)/.6931471805599453);a<-127?a=-127:a>128&&(a=128);var l=Math.round((n/Math.pow(2,a)-1)*8388608)&8388607;return(r<0?-2147483648:0)|a+127<<23|l},at.i64ToDouble=function(r,n){var a=1-(n>>>31<<1),l=(n>>20&2047)-1023,u=(n&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return u==0&&l==-1023?0:a*(1+Math.pow(2,-52)*u)*Math.pow(2,l)},at.doubleToI64=function(r){var n=at.i64tmp;if(r==0)n.low=0,n.high=0;else{var a;r<0?a=-r:a=r;var l=Math.floor(Math.log(a)/.6931471805599453),u,d=(a/Math.pow(2,l)-1)*4503599627370496;u=Math.round(d);var p=u|0,_=u/4294967296|0;n.low=p,n.high=(r<0?-2147483648:0)|l+1023<<20|_}return n};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};x["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=T(Error.prototype,{__class__:Q});var Me=function(){};x["js.Boot"]=Me,Me.__name__=["js","Boot"],Me.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var a=Me.__nativeClassName(r);return a!=null?Me.__resolveNativeClass(a):null},Me.__string_rec=function(r,n){if(r==null)return"null";if(n.length>=5)return"<...>";var a=typeof r;switch(a=="function"&&(r.__name__||r.__ename__)&&(a="object"),a){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";n+=" ";for(var u=2,d=r.length;u<d;){var p=u++;p!=2?l+=","+Me.__string_rec(r[p],n):l+=Me.__string_rec(r[p],n)}return l+")"}var _=r.length,v="[";n+=" ";for(var w=0;w<_;){var I=w++;v+=(I>0?",":"")+Me.__string_rec(r[I],n)}return v+="]",v}var S;try{S=r.toString}catch(C){return C instanceof Q&&(C=C.val),"???"}if(S!=null&&S!=Object.toString&&typeof S=="function"){var P=r.toString();if(P!="[object Object]")return P}var k=null,M=`{
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function lc(i,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const o in s)if(o!=="default"&&!(o in i)){const h=Object.getOwnPropertyDescriptor(s,o);h&&Object.defineProperty(i,o,h.get?h:{enumerable:!0,get:()=>s[o]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}const $s={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},Ji=[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 cs(i,t,e){return Math.max(t,Math.min(e,i))}const hl=class ul{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(cs(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=cs(t,0,256),this._colorIndex>0&&this._colorIndex<256?(this._color=Ji[t],this._colorName=this.getColorNameByValue(this._color)):(this._color=null,this._colorName=null))}get colorName(){return this._colorName}set colorName(t){if(t){const e=$s[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 o=Math.round(cs(t,0,255)),h=Math.round(cs(e,0,255)),c=Math.round(cs(s,0,255));return this.color=(o<<16)+(h<<8)+c,this}setColorName(t){const e=$s[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new ul;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($s))if(s===t)return e;return null}getColorIndexByValue(t){const e=Ji.length-1;for(let s=1;s<e;++s)if(Ji[s]===t)return s;return null}};hl.NAMES=$s;let Wr=hl;const je={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")}};let hc=class{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 o=s.indexOf(e);o!==-1&&s.splice(o,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 o=0,h=s.length;o<h;o++)s[o].call(this,t)}}},ie=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 uc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var cl={exports:{}};(function(i){(function(t,e){i.exports?i.exports=e():t.log=e()})(uc,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],h={},c=null;function g(z,U){var F=z[U];if(typeof F.bind=="function")return F.bind(z);try{return Function.prototype.bind.call(F,z)}catch{return function(){return Function.prototype.apply.apply(F,[z,arguments])}}}function x(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function f(z){return z==="debug"&&(z="log"),typeof console===e?!1:z==="trace"&&s?x:console[z]!==void 0?g(console,z):console.log!==void 0?g(console,"log"):t}function A(){for(var z=this.getLevel(),U=0;U<o.length;U++){var F=o[U];this[F]=U<z?t:this.methodFactory(F,z,this.name)}if(this.log=this.debug,typeof console===e&&z<this.levels.SILENT)return"No console available for logging"}function b(z){return function(){typeof console!==e&&(A.call(this),this[z].apply(this,arguments))}}function E(z,U,F){return f(z)||b.apply(this,arguments)}function T(z,U){var F=this,dt,vt,ot,W="loglevel";typeof z=="string"?W+=":"+z:typeof z=="symbol"&&(W=void 0);function ut(bt){var Ot=(o[bt]||"silent").toUpperCase();if(!(typeof window===e||!W)){try{window.localStorage[W]=Ot;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Ot+";"}catch{}}}function st(){var bt;if(!(typeof window===e||!W)){try{bt=window.localStorage[W]}catch{}if(typeof bt===e)try{var Ot=window.document.cookie,de=encodeURIComponent(W),me=Ot.indexOf(de+"=");me!==-1&&(bt=/^([^;]+)/.exec(Ot.slice(me+de.length+1))[1])}catch{}return F.levels[bt]===void 0&&(bt=void 0),bt}}function Vt(){if(!(typeof window===e||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Yt(bt){var Ot=bt;if(typeof Ot=="string"&&F.levels[Ot.toUpperCase()]!==void 0&&(Ot=F.levels[Ot.toUpperCase()]),typeof Ot=="number"&&Ot>=0&&Ot<=F.levels.SILENT)return Ot;throw new TypeError("log.setLevel() called with invalid level: "+bt)}F.name=z,F.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},F.methodFactory=U||E,F.getLevel=function(){return ot??vt??dt},F.setLevel=function(bt,Ot){return ot=Yt(bt),Ot!==!1&&ut(ot),A.call(F)},F.setDefaultLevel=function(bt){vt=Yt(bt),st()||F.setLevel(bt,!1)},F.resetLevel=function(){ot=null,Vt(),A.call(F)},F.enableAll=function(bt){F.setLevel(F.levels.TRACE,bt)},F.disableAll=function(bt){F.setLevel(F.levels.SILENT,bt)},F.rebuild=function(){if(c!==F&&(dt=Yt(c.getLevel())),A.call(F),c===F)for(var bt in h)h[bt].rebuild()},dt=Yt(c?c.getLevel():"WARN");var Wt=st();Wt!=null&&(ot=Yt(Wt)),A.call(F)}c=new T,c.getLogger=function(z){if(typeof z!="symbol"&&typeof z!="string"||z==="")throw new TypeError("You must supply a name when creating a logger.");var U=h[z];return U||(U=h[z]=new T(z,c.methodFactory)),U};var O=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=O),c},c.getLoggers=function(){return h},c.default=c,c})})(cl);var dl=cl.exports;const dc=cc(dl),mc=lc({__proto__:null,default:dc},[dl]),pc=!0,Ms=mc;Ms.setLevel("debug");const gc=i=>{try{Ms.setLevel(i)}catch(t){Ms.setLevel("error"),Ms.error(t)}};function ks(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function Vn(i,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i[s]===void 0&&(i[s]=e[s]);return i}function ml(i,t){return i!=null&&Object.prototype.hasOwnProperty.call(i,t)}function pl(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function Bn(i,t){if(i===t)return!0;if(i==null||t==null)return i===t;if(typeof i!=typeof t)return!1;if(typeof i!="object")return i===t;if(Array.isArray(i)!==Array.isArray(t))return!1;if(Array.isArray(i)){if(i.length!==t.length)return!1;for(let o=0;o<i.length;o++)if(!Bn(i[o],t[o]))return!1;return!0}const e=Object.keys(i),s=Object.keys(t);if(e.length!==s.length)return!1;for(const o of e)if(!Object.prototype.hasOwnProperty.call(t,o)||!Bn(i[o],t[o]))return!1;return!0}let gl=class fl{constructor(t,e){this.events={attrChanged:new ie,modelChanged:new ie},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&Vn(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let o;typeof t=="object"?(o=t,s=e):(o={},o[t]=e),s||(s={});const h=s.unset,c=s.silent,g=[],x=this._changing;this._changing=!0,x||(this._previousAttributes=ks(this.attributes),this.changed={});const f=this.attributes,A=this.changed,b=this._previousAttributes;for(const E in o)e=o[E],Bn(f[E],e)||g.push(E),Bn(b[E],e)?delete A[E]:A[E]=e,h?delete f[E]:f[E]=e;if(!c){g.length&&(this._pending=s);for(let E=0;E<g.length;E++)this.events.attrChanged.dispatch({object:this,attrName:g[E],attrValue:f[g[E]],options:s})}if(x)return this;if(!c)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?!pl(this.changed):ml(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?ks(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const o in t){const h=t[o];Bn(e[o],h)||(s[o]=h)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return ks(this._previousAttributes)}clone(){const t=ks(this.attributes);return new fl(t)}},wa=class Ts{constructor(){this.entries=new Map}static getInstance(){return Ts.instance||(Ts.instance=new Ts),Ts.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 fc{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,o=Math.max(0,e),h=["B","KB","MB","GB","TB"],c=Math.floor(Math.log(t)/Math.log(s)),g=t/Math.pow(s,c);return`${parseFloat(g.toFixed(o))} ${h[c]}`}}class _l{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class vl{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,s)=>{const o=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,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 o=0;o<e;o++){const h=this.tasks[o];try{s=await this.scheduleTask(async()=>{const c=await h.run(s);return this.onProgress((o+1)/e,h),c})}catch(c){if(this.onError({error:c,taskIndex:o,task:h}))break}}this.onComplete(s)}}let yl=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 o=this.handlers[e],h=this.handlers[e+1];if(o.global&&(o.lastIndex=0),o.test(t))return h}return null}};const xl=new yl;let _c=class{constructor(t){this.manager=t!==void 0?t:xl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,o)=>{this.load(t,s,e,o)})}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 Aa{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 o=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(t){let e=0;const s=async()=>{const o=e,h=Math.min(e+this._chunkSize,this._count);await t(o,h),e=h,e<this._count&&await this.scheduleTask(s)};await s()}}var Sa=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(Sa||{});class Gr{static get instance(){return this._instance||(this._instance=new Gr),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,o=!0,h,c){const g=[];if(e!=null){const x=this.createKey(e.name,s);let f;if(this.has(x))f=this.get(x);else{const A=e.newIterator();for(const b of A)b.color.isByBlock&&s?(Ho.copy(b.color),b.color.color=s,this.addEntity(b,g,t),b.color.copy(Ho)):this.addEntity(b,g,t);f=t.group(g),f&&o&&this.set(x,f)}return f&&h&&(f.applyMatrix(h),c&&(c.x!=0||c.y!=0||c.z!=1)&&(h.setFromExtrusionDirection(c),f.applyMatrix(h))),f}else return t.group(g)}addEntity(t,e,s){const o=t.draw(s);o&&(this.attachEntityInfo(o,t),e.push(o))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const Ho=new Wr;var Ia=(i=>(i[i.UTF8=0]="UTF8",i[i.US_ASCII=1]="US_ASCII",i[i.ISO_8859_1=2]="ISO_8859_1",i[i.ISO_8859_2=3]="ISO_8859_2",i[i.ISO_8859_3=4]="ISO_8859_3",i[i.ISO_8859_4=5]="ISO_8859_4",i[i.ISO_8859_5=6]="ISO_8859_5",i[i.ISO_8859_6=7]="ISO_8859_6",i[i.ISO_8859_7=8]="ISO_8859_7",i[i.ISO_8859_8=9]="ISO_8859_8",i[i.ISO_8859_9=10]="ISO_8859_9",i[i.CP437=11]="CP437",i[i.CP850=12]="CP850",i[i.CP852=13]="CP852",i[i.CP855=14]="CP855",i[i.CP857=15]="CP857",i[i.CP860=16]="CP860",i[i.CP861=17]="CP861",i[i.CP863=18]="CP863",i[i.CP864=19]="CP864",i[i.CP865=20]="CP865",i[i.CP869=21]="CP869",i[i.CP932=22]="CP932",i[i.MACINTOSH=23]="MACINTOSH",i[i.BIG5=24]="BIG5",i[i.CP949=25]="CP949",i[i.JOHAB=26]="JOHAB",i[i.CP866=27]="CP866",i[i.ANSI_1250=28]="ANSI_1250",i[i.ANSI_1251=29]="ANSI_1251",i[i.ANSI_1252=30]="ANSI_1252",i[i.GB2312=31]="GB2312",i[i.ANSI_1253=32]="ANSI_1253",i[i.ANSI_1254=33]="ANSI_1254",i[i.ANSI_1255=34]="ANSI_1255",i[i.ANSI_1256=35]="ANSI_1256",i[i.ANSI_1257=36]="ANSI_1257",i[i.ANSI_874=37]="ANSI_874",i[i.ANSI_932=38]="ANSI_932",i[i.ANSI_936=39]="ANSI_936",i[i.ANSI_949=40]="ANSI_949",i[i.ANSI_950=41]="ANSI_950",i[i.ANSI_1361=42]="ANSI_1361",i[i.UTF16=43]="UTF16",i[i.ANSI_1258=44]="ANSI_1258",i[i.UNDEFINED=255]="UNDEFINED",i))(Ia||{});const vc=["utf-8","utf-8","iso-8859-1","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-9","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","shift-jis","macintosh","big5","utf-8","utf-8","ibm866","windows-1250","windows-1251","windows-1252","gbk","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-874","shift-jis","gbk","euc-kr","big5","utf-8","utf-16le","windows-1258"],bl=i=>vc[i],ni="Continuous",Zs="ByLayer",wl="ByBlock";var dn=(i=>(i[i.EndPoint=1]="EndPoint",i[i.MidPoint=2]="MidPoint",i[i.Center=3]="Center",i[i.Node=4]="Node",i[i.Quadrant=5]="Quadrant",i[i.Insertion=7]="Insertion",i[i.Perpendicular=8]="Perpendicular",i[i.Tangent=9]="Tangent",i[i.Nearest=10]="Nearest",i[i.Centroid=11]="Centroid",i))(dn||{}),Pa=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(Pa||{});function yc(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function xc(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}var Al=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(Al||{});class Oi{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const Sl="Load Database";class Ee extends _l{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=wa.getInstance().getEntry(Sl),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const o=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",o?o.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-s),o}}class Ea{constructor(t={}){this.config=t}async read(t,e,s,o){const h={name:Sl,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(A=>{A!=="total"&&(f+=`- ${A}: ${this.data[A]} ms
|
|
2
|
+
`)}),f+=`- total: ${this.data.total} ms`,f}};wa.getInstance().collect(h),this.progress=o;const c={value:0},g=new vl;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new Ee({stage:"START",step:1,progress:c,task:async f=>f},o)),g.addTask(new Ee({stage:"PARSE",step:5,progress:c,task:async f=>await this.parse(f)},o)),g.addTask(new Ee({stage:"FONT",step:5,progress:c,task:async f=>{const A=this.getFonts(f.model);return{model:f.model,data:A}}},o)),g.addTask(new Ee({stage:"LTYPE",step:1,progress:c,task:async f=>(this.processLineTypes(f.model,e),f)},o)),g.addTask(new Ee({stage:"STYLE",step:1,progress:c,task:async f=>(this.processTextStyles(f.model,e),f)},o)),g.addTask(new Ee({stage:"DIMSTYLE",step:1,progress:c,task:async f=>(this.processDimStyles(f.model,e),f)},o)),g.addTask(new Ee({stage:"LAYER",step:1,progress:c,task:async f=>(this.processLayers(f.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),f)},o)),g.addTask(new Ee({stage:"VPORT",step:1,progress:c,task:async f=>(this.processViewports(f.model,e),f)},o)),g.addTask(new Ee({stage:"HEADER",step:1,progress:c,task:async f=>(this.processHeader(f.model,e),f)},o)),g.addTask(new Ee({stage:"BLOCK_RECORD",step:5,progress:c,task:async f=>(this.processBlockTables(f.model,e),f)},o)),g.addTask(new Ee({stage:"OBJECT",step:5,progress:c,task:async f=>(this.processObjects(f.model,e),e.dictionaries.layouts.numEntries===0&&e.createDefaultData({layout:!0}),f)},o)),g.addTask(new Ee({stage:"BLOCK",step:5,progress:c,task:async f=>(await this.processBlocks(f.model,e),f)},o)),g.addTask(new Ee({stage:"ENTITY",step:100,progress:c,task:async f=>(await this.processEntities(f.model,e,s,c,o),f)},o)),g.addTask(new Ee({stage:"END",step:0,progress:c,task:async f=>f},o));const x=Date.now();await g.run(t),h.data.total=Date.now()-x}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return console.error(`Error occurred in conversion stage '${t.task.name}': `,t.error),t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),Gr.instance.clear())}async parse(t,e){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,o,h){throw new Error("Not impelemented yet!")}}var he,ds,Qt,se,ms,Je,ye,pr,tr,en,ps,gs,rn,nn,fs,_s,vs,Le,gr,qt,sn,ys,_t,xe,xs,be,bs,fr,_r,er,ws,an,Oe,vr,on,ta,ea,yr,xr,As,Ss,br,Is,ra,na,ue,wr,ce,ze,sa,ia,aa,oa,Ar,Re,ln,Ps,hn,Be,Sr,Fe,Ir;(he={})[he.None=0]="None",he[he.Anonymous=1]="Anonymous",he[he.NonConstant=2]="NonConstant",he[he.Xref=4]="Xref",he[he.XrefOverlay=8]="XrefOverlay",he[he.ExternallyDependent=16]="ExternallyDependent",he[he.ResolvedOrDependent=32]="ResolvedOrDependent",he[he.ReferencedXref=64]="ReferencedXref";(ds={})[ds.BYBLOCK=0]="BYBLOCK",ds[ds.BYLAYER=256]="BYLAYER";(Qt={})[Qt.Rotated=0]="Rotated",Qt[Qt.Aligned=1]="Aligned",Qt[Qt.Angular=2]="Angular",Qt[Qt.Diameter=3]="Diameter",Qt[Qt.Radius=4]="Radius",Qt[Qt.Angular3Point=5]="Angular3Point",Qt[Qt.Ordinate=6]="Ordinate",Qt[Qt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Qt[Qt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Qt[Qt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(se={})[se.TopLeft=1]="TopLeft",se[se.TopCenter=2]="TopCenter",se[se.TopRight=3]="TopRight",se[se.MiddleLeft=4]="MiddleLeft",se[se.MiddleCenter=5]="MiddleCenter",se[se.MiddleRight=6]="MiddleRight",se[se.BottomLeft=7]="BottomLeft",se[se.BottomCenter=8]="BottomCenter",se[se.BottomRight=9]="BottomRight";(ms={})[ms.AtLeast=1]="AtLeast",ms[ms.Exact=2]="Exact";var qo=((Je={})[Je.Center=0]="Center",Je[Je.Above=1]="Above",Je[Je.Outside=2]="Outside",Je[Je.JIS=3]="JIS",Je[Je.Below=4]="Below",Je),Ln=((ye={})[ye.Feet=0]="Feet",ye[ye.None=1]="None",ye[ye.Inch=2]="Inch",ye[ye.FeetAndInch=3]="FeetAndInch",ye[ye.Leading=4]="Leading",ye[ye.Trailing=8]="Trailing",ye[ye.LeadingAndTrailing=12]="LeadingAndTrailing",ye),bc=((pr={})[pr.None=0]="None",pr[pr.Leading=1]="Leading",pr[pr.Trailing=2]="Trailing",pr[pr.LeadingAndTrailing=3]="LeadingAndTrailing",pr),wc=((tr={})[tr.Center=0]="Center",tr[tr.Left=1]="Left",tr[tr.Right=2]="Right",tr[tr.OverFirst=3]="OverFirst",tr[tr.OverSecond=4]="OverSecond",tr),Ac=((en={})[en.Bottom=0]="Bottom",en[en.Center=1]="Center",en[en.Top=2]="Top",en);(ps={})[ps.PatternFill=0]="PatternFill",ps[ps.SolidFill=1]="SolidFill";(gs={})[gs.NonAssociative=0]="NonAssociative",gs[gs.Associative=1]="Associative";(rn={})[rn.Normal=0]="Normal",rn[rn.Outer=1]="Outer",rn[rn.Ignore=2]="Ignore";(nn={})[nn.UserDefined=0]="UserDefined",nn[nn.Predefined=1]="Predefined",nn[nn.Custom=2]="Custom";(fs={})[fs.NotAnnotated=0]="NotAnnotated",fs[fs.Annotated=1]="Annotated";(_s={})[_s.Solid=0]="Solid",_s[_s.Gradient=1]="Gradient";(vs={})[vs.TwoColor=0]="TwoColor",vs[vs.OneColor=1]="OneColor";var Sc=((Le={})[Le.Default=0]="Default",Le[Le.External=1]="External",Le[Le.Polyline=2]="Polyline",Le[Le.Derived=4]="Derived",Le[Le.Textbox=8]="Textbox",Le[Le.Outermost=16]="Outermost",Le),Ws=((gr={})[gr.Line=1]="Line",gr[gr.Circular=2]="Circular",gr[gr.Elliptic=3]="Elliptic",gr[gr.Spline=4]="Spline",gr),Ic=((qt={})[qt.Off=0]="Off",qt[qt.Solid=1]="Solid",qt[qt.Dashed=2]="Dashed",qt[qt.Dotted=3]="Dotted",qt[qt.ShotDash=4]="ShotDash",qt[qt.MediumDash=5]="MediumDash",qt[qt.LongDash=6]="LongDash",qt[qt.DoubleShortDash=7]="DoubleShortDash",qt[qt.DoubleMediumDash=8]="DoubleMediumDash",qt[qt.DoubleLongDash=9]="DoubleLongDash",qt[qt.DoubleMediumLongDash=10]="DoubleMediumLongDash",qt[qt.SparseDot=11]="SparseDot",qt);Ic.Off;(sn={})[sn.Standard=-3]="Standard",sn[sn.ByLayer=-2]="ByLayer",sn[sn.ByBlock=-1]="ByBlock";(ys={})[ys.English=0]="English",ys[ys.Metric=1]="Metric";(_t={})[_t.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",_t[_t.FRONT_CLIPPING=2]="FRONT_CLIPPING",_t[_t.BACK_CLIPPING=4]="BACK_CLIPPING",_t[_t.UCS_FOLLOW=8]="UCS_FOLLOW",_t[_t.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",_t[_t.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",_t[_t.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",_t[_t.FAST_ZOOM=128]="FAST_ZOOM",_t[_t.SNAP_MODE=256]="SNAP_MODE",_t[_t.GRID_MODE=512]="GRID_MODE",_t[_t.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",_t[_t.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",_t[_t.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",_t[_t.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",_t[_t.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",_t[_t.UNUSED=32768]="UNUSED",_t[_t.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",_t[_t.VIEWPORT_OFF=131072]="VIEWPORT_OFF",_t[_t.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",_t[_t.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",_t[_t.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",_t[_t.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(xe={})[xe.OPTIMIZED_2D=0]="OPTIMIZED_2D",xe[xe.WIREFRAME=1]="WIREFRAME",xe[xe.HIDDEN_LINE=2]="HIDDEN_LINE",xe[xe.FLAT_SHADED=3]="FLAT_SHADED",xe[xe.GOURAUD_SHADED=4]="GOURAUD_SHADED",xe[xe.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",xe[xe.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(xs={})[xs.UCS_UNCHANGED=0]="UCS_UNCHANGED",xs[xs.HAS_OWN_UCS=1]="HAS_OWN_UCS";(be={})[be.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",be[be.TOP=1]="TOP",be[be.BOTTOM=2]="BOTTOM",be[be.FRONT=3]="FRONT",be[be.BACK=4]="BACK",be[be.LEFT=5]="LEFT",be[be.RIGHT=6]="RIGHT";(bs={})[bs.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",bs[bs.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(fr={})[fr.ByLayer=0]="ByLayer",fr[fr.ByBlock=1]="ByBlock",fr[fr.ByDictionaryDefault=2]="ByDictionaryDefault",fr[fr.ByObject=3]="ByObject";function At(i,t,e){return i.code===t&&(e==null||i.value===e)}function Rt(i){let t={};i.rewind();let e=i.next(),s=e.code;if(t.x=e.value,(e=i.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=i.next()).code!==s+20?i.rewind():t.z=e.value,t}let ka=Symbol();function xt(i,t){return(e,s,o)=>{let h=function(x,f=!1){return x.reduce((A,b)=>{b.pushContext&&A.push({});let E=A[A.length-1];for(let T of typeof b.code=="number"?[b.code]:b.code){let O=E[T]??(E[T]=[]);b.isMultiple&&O.length&&f&&console.warn(`Snippet ${O[O.length-1].name} for code(${T}) is shadowed by ${b.name}`),O.push(b)}return A},[{}])}(i,s.debug),c=!1,g=h.length-1;for(;!At(e,0,"EOF");){let x=function(U,F,dt){return U.find((vt,ot)=>{var W;return ot>=dt&&((W=vt[F])==null?void 0:W.length)})}(h,e.code,g),f=x==null?void 0:x[e.code],A=f==null?void 0:f[f.length-1];if(!x||!A){s.rewind();break}A.isMultiple||x[e.code].pop();let{name:b,parser:E,isMultiple:T,isReducible:O}=A,z=E==null?void 0:E(e,s,o);if(z===ka){s.rewind();break}if(b){let[U,F]=function(dt,vt){let ot=vt.split(".");if(!ot.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let W=dt;for(let ut=0;ut<ot.length-1;++ut){let st=la(ot[ut]),Vt=la(ot[ut+1]);Object.prototype.hasOwnProperty.call(W,st)||(typeof Vt=="number"?W[st]=[]:W[st]={}),W=W[st]}return[W,la(ot[ot.length-1])]}(o,b);T&&!O?(Object.prototype.hasOwnProperty.call(U,F)||(U[F]=[]),U[F].push(z)):U[F]=z}A.pushContext&&(g-=1),c=!0,e=s.next()}return t&&Object.setPrototypeOf(o,t),c}}function la(i){let t=Number.parseInt(i);return Number.isNaN(t)?i:t}function y({value:i}){return i}function G(i,t){return Rt(t)}function Ft({value:i}){return!!i}let Pc=[{code:1001,name:"xdata",parser:Il}];function Il(i,t){var o;if(!At(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let s=[e.value];for(;!At(i,0,"EOF")&&i.code>=1e3;){let h=s[s.length-1];switch(i.code){case 1002:i.value==="{"?s.push([]):(s.pop(),(o=s[s.length-1])==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Pr(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Pr(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Pr(i.code),value:i.value});break;case 1010:h.push({type:Pr(i.code),value:Rt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Pr(i.code),value:Rt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Pr(i.code),value:Rt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Pr(i.code),value:Rt(t)});break;case 1041:h.push({name:"distance",type:Pr(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Pr(i.code),value:i.value})}i=t.next()}return t.rewind(),e}function Pr(i){switch(i){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 pn(i,t,e){for(;At(i,102);){var s;let o=i.value;if(i=t.next(),!o.startsWith("{")){t.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${o}`),function(c,g){for(;!At(c,102)&&!At(c,0,"EOF");)c=g.next()}(i,t),i=t.next();continue}let h=o.slice(1).trim();e.extensions??(e.extensions={}),(s=e.extensions)[h]??(s[h]=[]),function(c,g,x){for(;!At(c,102,"}")&&!At(c,0,"EOF");)x.push(c),c=g.next()}(i,t,e.extensions[h]),i=t.next()}t.rewind()}let Ec=0;function Pl(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=Ec++)}var kc=[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 El(i){return kc[i]}(_r={})[_r.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",_r[_r.CAST=1]="CAST",_r[_r.RECEIVE=2]="RECEIVE",_r[_r.IGNORE=3]="IGNORE";let Ut=[...Pc,{code:284,name:"shadowMode",parser:y},{code:390,name:"plotStyleHardId",parser:y},{code:380,name:"plotStyleType",parser:y},{code:440,name:"transparency",parser:y},{code:430,name:"colorName",parser:y},{code:420,name:"color",parser:y},{code:310,name:"proxyEntity",isMultiple:!0,parser:y},{code:92,name:"proxyByte",parser:y},{code:60,name:"isVisible",parser:Ft},{code:48,name:"lineTypeScale",parser:y},{code:370,name:"lineweight",parser:y},{code:62,name:"colorIndex",parser(i,t,e){let s=i.value;return s>0&&s<256&&(e.color=El(Math.abs(s))),s}},{code:347,name:"materialObjectHardId",parser:y},{code:6,name:"lineType",parser:y},{code:8,name:"layer",parser:y},{code:410,name:"layoutTabName",parser:y},{code:67,name:"isInPaperSpace",parser:Ft},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:y},{code:102,parser:pn},{code:102,parser:pn},{code:102,parser:pn},{code:5,name:"handle",parser:y}];function zi(i){return[{code:3,name:i,parser:(t,e,s)=>(s._code3text=(s._code3text??"")+t.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(t,e,s)=>(s._code1text=t.value,(s._code3text??"")+s._code1text)}]}function kl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Tc={extrusionDirection:{x:0,y:0,z:1}},Mc=[{code:210,name:"extrusionDirection",parser:G},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:100,name:"subclassMarker",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G},{code:39,name:"thickness",parser:y},{code:100},...Ut];class Tl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kl(this,"parser",xt(Mc,Tc))}}kl(Tl,"ForEntityName","ARC");(er={})[er.NONE=0]="NONE",er[er.INVISIBLE=1]="INVISIBLE",er[er.CONSTANT=2]="CONSTANT",er[er.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",er[er.PRESET=8]="PRESET";(ws={})[ws.MULTILINE=2]="MULTILINE",ws[ws.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(an={})[an.NONE=0]="NONE",an[an.MIRRORED_X=2]="MIRRORED_X",an[an.MIRRORED_Y=4]="MIRRORED_Y";var Nc=((Oe={})[Oe.LEFT=0]="LEFT",Oe[Oe.CENTER=1]="CENTER",Oe[Oe.RIGHT=2]="RIGHT",Oe[Oe.ALIGNED=3]="ALIGNED",Oe[Oe.MIDDLE=4]="MIDDLE",Oe[Oe.FIT=5]="FIT",Oe),Cc=((vr={})[vr.BASELINE=0]="BASELINE",vr[vr.BOTTOM=1]="BOTTOM",vr[vr.MIDDLE=2]="MIDDLE",vr[vr.TOP=3]="TOP",vr);function Ml(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Nl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Nc.LEFT,valign:Cc.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Cl=[{code:73,name:"valign",parser:y},{code:100},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{code:72,name:"valign",parser:y},{code:72,name:"halign",parser:y},{code:71,name:"generationFlag",parser:y},{code:7,name:"styleName",parser:y},{code:51,name:"obliqueAngle",parser:y},{code:41,name:"xScale",parser:y},{code:50,name:"rotation",parser:y},{code:1,name:"text",parser:y},{code:40,name:"textHeight",parser:y},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class Ll{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ml(this,"parser",xt(Cl,Nl))}}function Ol(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ml(Ll,"ForEntityName","TEXT");let Lc={...Nl},Oc=[{code:2},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Ft},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedRecord",parser:Ft},{code:100},{code:280,name:"isLocked",parser:Ft},{code:74,name:"valign",parser:y},{code:73},{code:70,name:"attributeFlag",parser:y},{code:2,name:"tag",parser:y},{code:3,name:"prompt",parser:y},{code:280},{code:100,name:"subclassMarker",parser:y},...Cl.slice(2)];class zl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ol(this,"parser",xt(Oc,Lc))}}Ol(zl,"ForEntityName","ATTDEF");(on={})[on.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",on[on.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",on[on.BY_STYLE=5]="BY_STYLE";function zc(i,t){let e={};for(let s of i){let o=t(s);o!=null&&(e[o]??(e[o]=[]),e[o].push(s))}return e}function*si(i,t=1/0,e=1){for(let s=i;s!==t;s+=e)yield s}function Vr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function Ta(i,t,e){if(At(t,102))return pn(t,e,i),!0;switch(t.code){case 0:i.type=t.value;break;case 5:i.handle=t.value;break;case 330:i.ownerBlockRecordSoftId=t.value;break;case 67:i.isInPaperSpace=!!t.value;break;case 8:i.layer=t.value;break;case 6:i.lineType=t.value;break;case 347:i.materialObjectHardId=t.value;break;case 62:i.colorIndex=t.value,i.color=El(Math.abs(t.value));break;case 370:i.lineweight=t.value;break;case 48:i.lineTypeScale=t.value;break;case 60:i.isVisible=!!t.value;break;case 92:i.proxyByte=t.value;break;case 310:i.proxyEntity=t.value;break;case 100:break;case 420:i.color=t.value;break;case 430:i.transparency=t.value;break;case 390:i.plotStyleHardId=t.value;break;case 284:i.shadowMode=t.value;break;case 1001:i.xdata=Il(t,e);break;default:return!1}return!0}function Rl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Rc={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Qs=[{code:46,name:"annotationHeight",parser:y},{code:101,parser(i,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:y},{code:49,name:"columnGutter",parser:y},{code:48,name:"columnWidth",parser:y},{code:79,name:"columnAutoHeight",parser:y},{code:78,name:"columnFlowReversed",parser:y},{code:76,name:"columnCount",parser:y},{code:75,name:"columnType",parser:y},{code:441,name:"backgroundFillTransparency",parser:y},{code:63,name:"backgroundFillColor",parser:y},{code:45,name:"fillBoxScale",parser:y},{code:[...si(430,440)],name:"backgroundColor",parser:y},{code:[...si(420,430)],name:"backgroundColor",parser:y},{code:90,name:"backgroundFill",parser:y},{code:44,name:"lineSpacing",parser:y},{code:73,name:"lineSpacingStyle",parser:y},{code:50,name:"rotation",parser:y},{code:43},{code:42},{code:11,name:"direction",parser:G},{code:210,name:"extrusionDirection",parser:G},{code:7,name:"styleName",parser:y},...zi("text"),{code:72,name:"drawingDirection",parser:y},{code:71,name:"attachmentPoint",parser:y},{code:41,name:"width",parser:y},{code:40,name:"height",parser:y},{code:10,name:"insertionPoint",parser:G},{code:100,name:"subclassMarker",parser:y},...Ut];class Bl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Rl(this,"parser",xt(Qs,Rc))}}function Fl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Rl(Bl,"ForEntityName","MTEXT");let Bc={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Fc=[...Qs.slice(Qs.findIndex(({name:i})=>i==="columnType"),Qs.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!At(i,0,"MTEXT"))return ka}},{code:2,name:"definitionTag",parser:y},{code:40,name:"annotationScale",parser:y},{code:10,name:"alignmentPoint",parser:G},{code:340,name:"secondaryAttributesHardId",parser:y},{code:70,name:"numberOfSecondaryAttributes",parser:y},{code:70,name:"isReallyLocked",parser:Ft},{code:70,name:"mtextFlag",parser:y},{code:280,name:"isDuplicatedEntriesKeep",parser:Ft},{code:100},{code:280,name:"lockPositionFlag",parser:Ft},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"alignmentPoint",parser:G},{code:74,name:"verticalJustification",parser:y},{code:72,name:"horizontalJustification",parser:y},{code:71,name:"textGenerationFlag",parser:y},{code:7,name:"textStyle",parser:y},{code:51,name:"obliqueAngle",parser:y},{code:41,name:"scale",parser:y},{code:50,name:"rotation",parser:y},{code:73},{code:70,name:"attributeFlag",parser:y},{code:2,name:"tag",parser:y},{code:280},{code:100,name:"subclassMarker",parser:y},{code:1,name:"text",parser:y},{code:40,name:"textHeight",parser:y},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100},...Ut];class Dl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Fl(this,"parser",xt(Fc,Bc))}}function Ul(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Fl(Dl,"ForEntityName","ATTRIB");let Dc=[...zi("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class Vl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ul(this,"parser",xt(Dc))}}function jl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ul(Vl,"ForEntityName","BODY");let Uc={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Vc=[{code:210,name:"extrusionDirection",parser:G},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class Gl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){jl(this,"parser",xt(Vc,Uc))}}jl(Gl,"ForEntityName","CIRCLE");class Js{parseEntity(t,e){let s={};for(;!At(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(o,h,c){switch(h.code){case 100:o.subclassMarker=h.value;break;case 280:o.version=h.value;break;case 2:o.name=h.value;break;case 10:o.definitionPoint=Rt(c);break;case 11:o.textPoint=Rt(c);break;case 12:o.insertionPoint=Rt(c);break;case 13:o.subDefinitionPoint1=Rt(c);break;case 14:o.subDefinitionPoint2=Rt(c);break;case 15:o.centerPoint=Rt(c);break;case 16:o.arcPoint=Rt(c);break;case 70:o.dimensionType=h.value;break;case 71:o.attachmentPoint=h.value;break;case 72:o.textLineSpacingStyle=h.value;break;case 40:o.leaderLength=h.value;break;case 41:o.textLineSpacingFactor=h.value;break;case 42:o.measurement=h.value;break;case 1:o.text=h.value;break;case 50:o.rotationAngle=h.value;break;case 52:o.obliqueAngle=h.value;break;case 53:o.textRotation=h.value;break;case 51:o.ocsRotation=h.value;break;case 210:o.extrusionDirection=Rt(c);break;case 3:o.styleName=h.value;break;default:Ta(o,h,c)}})(s,e,t),e=t.next()}return s}}function Wl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ea="DIMENSION",(ta="ForEntityName")in Js?Object.defineProperty(Js,ta,{value:ea,enumerable:!0,configurable:!0,writable:!0}):Js[ta]=ea;let jc={extrusionDirection:{x:0,y:0,z:1}},Gc=[{code:42,name:"endAngle",parser:y},{code:41,name:"startAngle",parser:y},{code:40,name:"axisRatio",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:11,name:"majorAxisEndPoint",parser:G},{code:10,name:"center",parser:G},{code:100,name:"subclassMarker",parser:y},...Ut];class Hl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wl(this,"parser",xt(Gc,jc))}}Wl(Hl,"ForEntityName","ELLIPSE");(yr={})[yr.First=1]="First",yr[yr.Second=2]="Second",yr[yr.Third=4]="Third",yr[yr.Fourth=8]="Fourth";function ql(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Wc=[{code:13,name:"vertices.3",parser:G},{code:12,name:"vertices.2",parser:G},{code:11,name:"vertices.1",parser:G},{code:10,name:"vertices.0",parser:G},{code:100,name:"subclassMarker",parser:y},...Ut];class Yl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ql(this,"parser",xt(Wc))}}ql(Yl,"ForEntityName","3DFACE");let Xl=[{code:330,name:"sourceBoundaryObjects",parser:y,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:y}],Hc=[{code:11,name:"end",parser:G},{code:10,name:"start",parser:G}],qc=[{code:73,name:"isCCW",parser:Ft},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"radius",parser:y},{code:10,name:"center",parser:G}],Yc=[{code:73,name:"isCCW",parser:Ft},{code:51,name:"endAngle",parser:y},{code:50,name:"startAngle",parser:y},{code:40,name:"lengthOfMinorAxis",parser:y},{code:11,name:"end",parser:G},{code:10,name:"center",parser:G}],Xc=[{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{code:11,name:"fitDatum",isMultiple:!0,parser:G},{code:97,name:"numberOfFitData",parser:y},{code:10,name:"controlPoints",isMultiple:!0,parser(i,t){let e={...Rt(t),weight:1};return(i=t.next()).code===42?e.weight=i.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:y},{code:96,name:"numberOfControlPoints",parser:y},{code:95,name:"numberOfKnots",parser:y},{code:74,name:"isPeriodic",parser:Ft},{code:73,name:"splineFlag",parser:y},{code:94,name:"degree",parser:y}],Kc={[Ws.Line]:Hc,[Ws.Circular]:qc,[Ws.Elliptic]:Yc,[Ws.Spline]:Xc},$c=[...Xl,{code:72,name:"edges",parser(i,t){let e={type:i.value},s=xt(Kc[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(i=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:y}],Zc=[...Xl,{code:10,name:"vertices",parser(i,t){let e={...Rt(t),bulge:0};return(i=t.next()).code===42?e.bulge=i.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:y},{code:73,name:"isClosed",parser:Ft},{code:72,name:"hasBulge",parser:Ft}],Qc=[{code:49,name:"dashLengths",parser:y,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:y},{code:45,name:"offset",parser:Yo},{code:43,name:"base",parser:Yo},{code:53,name:"angle",parser:y}];function Yo(i,t){let e=i.code+1,s={x:i.value,y:1};return(i=t.next()).code===e?s.y=i.value:t.rewind(),s}function Kl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Jc={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},td=[{code:470},{code:463},{code:462,name:"colorTint",parser:y},{code:461,name:"gradientDefinition",parser:y},{code:460,name:"gradientRotation",parser:y},{code:453,name:"numberOfColors",parser:y},{code:452,name:"gradientColorFlag",parser:y},{code:451},{code:450,name:"gradientFlag",parser:y},{code:10,name:"seedPoints",parser:G,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:G},{code:98,name:"numberOfSeedPoints",parser:y},{code:47,name:"pixelSize",parser:y},{code:53,name:"definitionLines",parser:function(i,t){let e={};return xt(Qc)(i,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:y},{code:77,name:"isDouble",parser:Ft},{code:73,name:"isAnnotated",parser:Ft},{code:41,name:"patternScale",parser:y},{code:52,name:"patternAngle",parser:y},{code:76,name:"patternType",parser:y},{code:75,name:"hatchStyle",parser:y},{code:92,name:"boundaryPaths",parser:function(i,t){let e={boundaryPathTypeFlag:i.value},s=e.boundaryPathTypeFlag&Sc.Polyline;return i=t.next(),s?xt(Zc)(i,t,e):xt($c)(i,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:y},{code:71,name:"associativity",parser:y},{code:63,name:"patternFillColor",parser:y},{code:70,name:"solidFill",parser:y},{code:2,name:"patternName",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:10,name:"elevationPoint",parser:G},{code:100,name:"subclassMarker",parser:y,pushContext:!0},...Ut];class $l{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Kl(this,"parser",xt(td,Jc))}}Kl($l,"ForEntityName","HATCH");(xr={})[xr.ShowImage=1]="ShowImage",xr[xr.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",xr[xr.UseClippingBoundary=4]="UseClippingBoundary",xr[xr.TransparencyIsOn=8]="TransparencyIsOn";(As={})[As.Rectangular=1]="Rectangular",As[As.Polygonal=2]="Polygonal";(Ss={})[Ss.Outside=0]="Outside",Ss[Ss.Inside=1]="Inside";function Zl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let ed={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},rd=[{code:290,name:"clipMode",parser:y},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:G},{code:91,name:"countBoundaryPoints",parser:y},{code:71,name:"clippingBoundaryType",parser:y},{code:360,name:"imageDefReactorHandle",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipped",parser:Ft},{code:70,name:"flags",parser:y},{code:340,name:"imageDefHandle",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vPixel",parser:G},{code:11,name:"uPixel",parser:G},{code:10,name:"position",parser:G},{code:90,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class Ql{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zl(this,"parser",xt(rd,ed))}}function Jl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Zl(Ql,"ForEntityName","IMAGE");let nd={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},sd=[{code:210,name:"extrusionDirection",parser:G},{code:45,name:"rowSpacing",parser:y},{code:44,name:"columnSpacing",parser:y},{code:71,name:"rowCount",parser:y},{code:70,name:"columnCount",parser:y},{code:50,name:"rotation",parser:y},{code:43,name:"zScale",parser:y},{code:42,name:"yScale",parser:y},{code:41,name:"xScale",parser:y},{code:10,name:"insertionPoint",parser:G},{code:2,name:"name",parser:y},{code:66,name:"isVariableAttributes",parser:Ft},{code:100,name:"subclassMarker",parser:y},...Ut];class th{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Jl(this,"parser",xt(sd,nd))}}function eh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Jl(th,"ForEntityName","INSERT");let id={isArrowheadEnabled:!0},ad=[{code:213,name:"offsetFromAnnotation",parser:G},{code:212,name:"offsetFromBlock",parser:G},{code:211,name:"horizontalDirection",parser:G},{code:210,name:"normal",parser:G},{code:340,name:"associatedAnnotation",parser:y},{code:77,name:"byBlockColor",parser:y},{code:10,name:"vertices",parser:G,isMultiple:!0},{code:76,name:"numberOfVertices",parser:y},{code:41,name:"textWidth",parser:y},{code:40,name:"textHeight",parser:y},{code:75,name:"isHooklineExists",parser:Ft},{code:74,name:"isHooklineSameDirection",parser:Ft},{code:73,name:"leaderCreationFlag",parser:y},{code:72,name:"isSpline",parser:Ft},{code:71,name:"isArrowheadEnabled",parser:Ft},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut],rh=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){eh(this,"parser",xt(ad,id))}};eh(rh,"ForEntityName","LEADER");(br={})[br.TextAnnotation=0]="TextAnnotation",br[br.ToleranceAnnotation=1]="ToleranceAnnotation",br[br.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",br[br.NoAnnotation=3]="NoAnnotation";function nh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let od={thickness:0,extrusionDirection:{x:0,y:0,z:1}},ld=[{code:210,name:"extrusionDirection",parser:G},{code:11,name:"endPoint",parser:G},{code:10,name:"startPoint",parser:G},{code:39,name:"thickness",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class sh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nh(this,"parser",xt(ld,od))}}nh(sh,"ForEntityName","LINE");(Is={})[Is.IS_CLOSED=1]="IS_CLOSED",Is[Is.PLINE_GEN=128]="PLINE_GEN";let hd={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},ud={bulge:0},cd=[{code:42,name:"bulge",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:91,name:"id",parser:y},{code:20,name:"y",parser:y},{code:10,name:"x",parser:y}],dd=[{code:210,name:"extrusionDirection",parser:G},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return xt(cd,ud)(i,t,e),e}},{code:39,name:"thickness",parser:y},{code:38,name:"elevation",parser:y},{code:43,name:"constantWidth",parser:y},{code:70,name:"flag",parser:y},{code:90,name:"numberOfVertices",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class ti{parseEntity(t,e){let s={};return xt(dd,hd)(e,t,s),s}}function ih(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}na="LWPOLYLINE",(ra="ForEntityName")in ti?Object.defineProperty(ti,ra,{value:na,enumerable:!0,configurable:!0,writable:!0}):ti[ra]=na;let md=[{code:90,name:"overridenSubEntityCount",parser:y},{code:140,name:"edgeCreaseWeights",parser:y,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:y},{code:94,parser(i,t,e){e.edgeCount=i.value,e.edgeIndices=[];for(let s=0;s<e.edgeCount;++s){let o=[];i=t.next(),o[0]=i.value,i=t.next(),o[1]=i.value,e.edgeIndices.push(o)}}},{code:93,parser(i,t,e){e.totalFaceIndices=i.value,e.faceIndices=[];let s=[];for(let h=0;h<e.totalFaceIndices&&!At(i,0);++h)i=t.next(),s.push(i.value);let o=0;for(;o<s.length;){let h=s[o++],c=[];for(let g=0;g<h;++g)c.push(s[o++]);e.faceIndices.push(c)}}},{code:10,name:"vertices",parser:G,isMultiple:!0},{code:92,name:"verticesCount",parser:y},{code:91,name:"subdivisionLevel",parser:y},{code:40,name:"blendCrease",parser:y},{code:72,name:"isBlendCreased",parser:Ft},{code:71,name:"version",parser:y},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Ut];class ah{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ih(this,"parser",xt(md))}}function oh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ih(ah,"ForEntityName","MESH");let pd={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},gd=[{code:50,name:"angle",parser:y},{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ut];class lh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){oh(this,"parser",xt(gd,pd))}}oh(lh,"ForEntityName","POINT");(ue={})[ue.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ue[ue.CURVE_FIT=2]="CURVE_FIT",ue[ue.SPLINE_FIT=4]="SPLINE_FIT",ue[ue.POLYLINE_3D=8]="POLYLINE_3D",ue[ue.POLYGON_3D=16]="POLYGON_3D",ue[ue.CLOSED_POLYGON=32]="CLOSED_POLYGON",ue[ue.POLYFACE=64]="POLYFACE",ue[ue.CONTINUOUS=128]="CONTINUOUS";var Hs=((wr={})[wr.NONE=0]="NONE",wr[wr.QUADRATIC=5]="QUADRATIC",wr[wr.CUBIC=6]="CUBIC",wr[wr.BEZIER=8]="BEZIER",wr),fd=((ce={})[ce.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ce[ce.TANGENT_DEFINED=2]="TANGENT_DEFINED",ce[ce.NOT_USED=4]="NOT_USED",ce[ce.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ce[ce.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ce[ce.FOR_POLYLINE=32]="FOR_POLYLINE",ce[ce.FOR_POLYGON=64]="FOR_POLYGON",ce[ce.POLYFACE=128]="POLYFACE",ce);function hh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let _d={startWidth:0,endWidth:0,bulge:0},vd=[{code:91,name:"id",parser:y},{code:[...si(71,75)],name:"faces",isMultiple:!0,parser:y},{code:50,name:"tangentDirection",parser:y},{code:70,name:"flag",parser:y},{code:42,name:"bulge",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:30,name:"z",parser:y},{code:20,name:"y",parser:y},{code:10,name:"x",parser:y},{code:100,name:"subclassMarker",parser:y},{code:100},...Ut];class Ma{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){hh(this,"parser",xt(vd,_d))}}function uh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}hh(Ma,"ForEntityName","VERTEX");let yd={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:[]},xd=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>At(i,0,"VERTEX")?(i=t.next(),new Ma().parseEntity(t,i)):ka},{code:210,name:"extrusionDirection",parser:G},{code:75,name:"smoothType",parser:y},{code:74,name:"surfaceNDensity",parser:y},{code:73,name:"surfaceMDensity",parser:y},{code:72,name:"meshNVertexCount",parser:y},{code:71,name:"meshMVertexCount",parser:y},{code:41,name:"endWidth",parser:y},{code:40,name:"startWidth",parser:y},{code:70,name:"flag",parser:y},{code:39,name:"thickness",parser:y},{code:30,name:"elevation",parser:y},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:y},...Ut];class ch{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){uh(this,"parser",xt(xd,yd))}}function dh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}uh(ch,"ForEntityName","POLYLINE");let bd=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ut];class mh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dh(this,"parser",xt(bd))}}function ph(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}dh(mh,"ForEntityName","RAY");let wd=[...zi("data"),{code:70,name:"version",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class gh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ph(this,"parser",xt(wd))}}function fh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ph(gh,"ForEntityName","REGION");let Ad={vertices:[],backLineVertices:[]},Sd=[{code:360,name:"geometrySettingHardId",parser:y},{code:12,name:"backLineVertices",isMultiple:!0,parser:G},{code:93,name:"numberOfBackLineVertices",parser:y},{code:11,name:"vertices",isMultiple:!0,parser:G},{code:92,name:"verticesCount",parser:y},{code:[63,411],name:"indicatorColor",parser:y},{code:70,name:"indicatorTransparency",parser:y},{code:41,name:"bottomHeight",parser:y},{code:40,name:"topHeight",parser:y},{code:10,name:"verticalDirection",parser:G},{code:1,name:"name",parser:y},{code:91,name:"flag",parser:y},{code:90,name:"state",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class _h{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){fh(this,"parser",xt(Sd,Ad))}}function vh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}fh(_h,"ForEntityName","SECTION");let Id={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Pd=[{code:210,name:"extrusionDirection",parser:G},{code:39,name:"thickness",parser:y},{code:[...si(10,14)],name:"points",isMultiple:!0,parser:G},{code:100,name:"subclassMarker",parser:y},...Ut];class yh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){vh(this,"parser",xt(Pd,Id))}}function xh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}vh(yh,"ForEntityName","SOLID");let Ed=[{code:350,name:"historyObjectSoftId",parser:y},{code:100,name:"subclassMarker",parser:y},...zi("data"),{code:70,name:"version",parser:y},{code:100},...Ut];class bh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){xh(this,"parser",xt(Ed))}}xh(bh,"ForEntityName","3DSOLID");(ze={})[ze.NONE=0]="NONE",ze[ze.CLOSED=1]="CLOSED",ze[ze.PERIODIC=2]="PERIODIC",ze[ze.RATIONAL=4]="RATIONAL",ze[ze.PLANAR=8]="PLANAR",ze[ze.LINEAR=16]="LINEAR";function wh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let kd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Td=[{code:11,name:"fitPoints",isMultiple:!0,parser:G},{code:10,name:"controlPoints",isMultiple:!0,parser:G},{code:41,name:"weights",isMultiple:!0,parser:y},{code:40,name:"knots",isMultiple:!0,parser:y},{code:13,name:"endTangent",parser:G},{code:12,name:"startTangent",parser:G},{code:44,name:"fitTolerance",parser:y},{code:43,name:"controlTolerance",parser:y},{code:42,name:"knotTolerance",parser:y},{code:74,name:"numberOfFitPoints",parser:y},{code:73,name:"numberOfControlPoints",parser:y},{code:72,name:"numberOfKnots",parser:y},{code:71,name:"degree",parser:y},{code:70,name:"flag",parser:y},{code:210,name:"normal",parser:G},{code:100,name:"subclassMarker",parser:y},...Ut];class Ah{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){wh(this,"parser",xt(Td,kd))}}wh(Ah,"ForEntityName","SPLINE");class ei{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=Vr(Rt(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Vr(Rt(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(o,h){let c=!1,g=!1,x={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(c){g=!0;continue}x.cellType=h.value,c=!0,h=o.next();break;case 172:x.flagValue=h.value,h=o.next();break;case 173:x.mergedValue=h.value,h=o.next();break;case 174:x.autoFit=h.value,h=o.next();break;case 175:x.borderWidth=h.value,h=o.next();break;case 176:x.borderHeight=h.value,h=o.next();break;case 91:x.overrideFlag=h.value,h=o.next();break;case 178:x.virtualEdgeFlag=h.value,h=o.next();break;case 145:x.rotation=h.value,h=o.next();break;case 345:x.fieldObjetId=h.value,h=o.next();break;case 340:x.blockTableRecordId=h.value,h=o.next();break;case 146:x.blockScale=h.value,h=o.next();break;case 177:x.blockAttrNum=h.value,h=o.next();break;case 7:x.textStyle=h.value,h=o.next();break;case 140:x.textHeight=h.value,h=o.next();break;case 170:x.attachmentPoint=h.value,h=o.next();break;case 92:x.extendedCellFlags=h.value,h=o.next();break;case 285:x.rightBorderVisibility=!!(h.value??!0),h=o.next();break;case 286:x.bottomBorderVisibility=!!(h.value??!0),h=o.next();break;case 288:x.leftBorderVisibility=!!(h.value??!0),h=o.next();break;case 289:x.topBorderVisibility=!!(h.value??!0),h=o.next();break;case 301:(function(f,A,b){for(;b.code!==304;)switch(b.code){case 301:case 93:case 90:case 94:b=A.next();break;case 1:f.text=b.value,b=A.next();break;case 300:f.attrText=b.value,b=A.next();break;case 302:f.text=b.value?b.value:f.text,b=A.next();break;default:console.log(`Ignore code: ${b.code}, value: ${b.value}`),b=A.next()}})(x,o,h),h=o.next();break;default:return x}return c=!1,g=!1,x}(t,e)),e=t.lastReadGroup;break;default:Ta(s,e,t),e=t.next()}}return s}}function Sh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ia="ACAD_TABLE",(sa="ForEntityName")in ei?Object.defineProperty(ei,sa,{value:ia,enumerable:!0,configurable:!0,writable:!0}):ei[sa]=ia;let Md=[{code:11,name:"xAxisDirection",parser:G},{code:210,name:"extrusionDirection",parser:G},{code:1,name:"text",parser:y},{code:10,name:"position",parser:G},{code:3,name:"styleName",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class Ih{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sh(this,"parser",xt(Md))}}Sh(Ih,"ForEntityName","TOLERANCE");let ri=class{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(o,h,c){if(c==="EOF")return!1;switch(c.code){case 0:return!1;case 8:o.layer=c.value;break;case 100:o.subclassMarker=c.value;break;case 10:o.viewportCenter=Vr(Rt(h));break;case 40:o.width=c.value;break;case 41:o.height=c.value;break;case 68:o.status=c.value;break;case 69:o.viewportId=c.value;break;case 12:o.displayCenter=Rt(h);break;case 13:o.snapBase=Rt(h);break;case 14:o.snapSpacing=Rt(h);break;case 15:o.gridSpacing=Rt(h);break;case 16:o.viewDirection=Vr(Rt(h));break;case 17:o.targetPoint=Vr(Rt(h));break;case 42:o.perspectiveLensLength=c.value;break;case 43:o.frontClipZ=c.value;break;case 44:o.backClipZ=c.value;break;case 45:o.viewHeight=c.value;break;case 50:o.snapAngle=c.value;break;case 51:o.viewTwistAngle=c.value;break;case 72:o.circleZoomPercent=c.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(c.value);break;case 90:o.statusBitFlags=c.value;break;case 340:o.clippingBoundaryId=c.value;break;case 1:o.sheetName=c.value;break;case 281:o.renderMode=c.value;break;case 71:o.ucsPerViewport=c.value;break;case 110:o.ucsOrigin=Vr(Rt(h));break;case 111:o.ucsXAxis=Vr(Rt(h));break;case 112:o.ucsYAxis=Vr(Rt(h));break;case 345:o.ucsId=c.value;break;case 346:o.ucsBaseId=c.value;break;case 79:o.orthographicType=c.value;break;case 146:o.elevation=c.value;break;case 170:o.shadePlotMode=c.value;break;case 61:o.majorGridFrequency=c.value;break;case 332:o.backgroundId=c.value;break;case 333:o.shadePlotId=c.value;break;case 348:o.visualStyleId=c.value;break;case 292:o.isDefaultLighting=!!c.value;break;case 282:o.defaultLightingType=c.value;break;case 141:o.brightness=c.value;break;case 142:o.contrast=c.value;break;case 63:case 421:case 431:o.ambientLightColor=c.value;break;case 361:o.sunId=c.value;break;case 335:case 343:case 344:case 91:o.softPointer=c.value}return!0}(s,t,e)&&Ta(s,e,t),e=t.next()}return s}};oa="VIEWPORT",(aa="ForEntityName")in ri?Object.defineProperty(ri,aa,{value:oa,enumerable:!0,configurable:!0,writable:!0}):ri[aa]=oa;(Ar={})[Ar.ShowImage=1]="ShowImage",Ar[Ar.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Ar[Ar.UseClippingBoundary=4]="UseClippingBoundary",Ar[Ar.Transparency=8]="Transparency";function Ph(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Nd={brightness:50,constrast:50,fade:0},Cd=[{code:14,name:"boundary",isMultiple:!0,parser:G},{code:91,name:"numberOfVertices",parser:y},{code:71,name:"boundaryType",parser:y},{code:360,name:"imageDefReactorHardId",parser:y},{code:283,name:"fade",parser:y},{code:282,name:"contrast",parser:y},{code:281,name:"brightness",parser:y},{code:280,name:"isClipping",parser:Ft},{code:70,name:"displayFlag",parser:y},{code:340,name:"imageDefHardId",parser:y},{code:13,name:"imageSize",parser:G},{code:12,name:"vDirection",parser:G},{code:11,name:"uDirection",parser:G},{code:10,name:"position",parser:G},{code:90,name:"classVersion",parser:y},{code:100,name:"subclassMarker",parser:y},...Ut];class Eh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ph(this,"parser",xt(Cd,Nd))}}function kh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ph(Eh,"ForEntityName","WIPEOUT");let Ld=[{code:11,name:"direction",parser:G},{code:10,name:"position",parser:G},{code:100,name:"subclassMarker",parser:y},...Ut],Th=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kh(this,"parser",xt(Ld))}};function Mh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}kh(Th,"ForEntityName","XLINE");let Od={},zd=[{code:170,name:"multileaderType",parser:y},{code:291,name:"doglegEnabled",parser:Ft},{code:40,name:"doglegLength",parser:y},{code:172,name:"contentType",parser:y},{code:3,name:"textContent",parser:y},{code:12,name:"textAnchor",parser:G},{code:344,name:"blockHandle",parser:y},{code:15,name:"blockPosition",parser:G},{code:302,name:"leaderSections",parser:function(i,t,e){let s,o={leaderLines:[]};for(;t.hasNext()&&(s=t.next()).code!==303;)switch(s.code){case 10:o.landingPoint=(s.value,Rt(t));break;case 11:o.doglegVector=(s.value,Rt(t));break;case 40:o.doglegLength=s.value;break;case 304:o.leaderLines.push(function(h,c,g){let x,f={vertices:[]};for(;c.hasNext()&&(x=c.next()).code!==305;)x.code===10&&f.vertices.push((x.value,Rt(c)));return f}(0,t))}return o},isMultiple:!0},...Ut];class Nh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Mh(this,"parser",xt(zd,Od))}}Mh(Nh,"ForEntityName","MULTILEADER");let Rd=Object.fromEntries([Tl,zl,Dl,Vl,Gl,Js,Hl,Yl,Ql,th,rh,sh,ti,ah,Bl,Nh,lh,ch,mh,gh,_h,yh,bh,Ah,ei,Ll,Ih,$l,Ma,ri,Eh,Th].map(i=>[i.ForEntityName,new i]));function Ch(i,t){let e=[];for(;!At(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let s=Rd[i.value];if(s){let o=i.value;i=t.next();let h=s.parseEntity(t,i);h.type=o,Pl(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=t.next()}return e}function Bd(i,t){let e={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");){if(At(i,0,"BLOCK")){let s=Fd(i=t.next(),t);Pl(s),s.name&&(e[s.name]=s)}i=t.next()}return e}function Fd(i,t){let e={};for(;!At(i,0,"EOF");){if(At(i,0,"ENDBLK")){for(i=t.next();!At(i,0,"EOF");){if(At(i,100,"AcDbBlockEnd"))return e;i=t.next()}break}switch(i.code){case 1:e.xrefPath=i.value;break;case 2:e.name=i.value;break;case 3:e.name2=i.value;break;case 5:e.handle=i.value;break;case 8:e.layer=i.value;break;case 10:e.position=Rt(t);break;case 67:e.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(e.type=i.value);break;case 100:break;case 330:e.ownerHandle=i.value;break;case 0:e.entities=Ch(i,t)}i=t.next()}return e}function Dd(i,t){let e=null,s={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");)i.code===9?e=i.value:i.code===10?s[e]=Rt(t):s[e]=i.value,i=t.next();return s}(Re={})[Re.NOT_APPLICABLE=0]="NOT_APPLICABLE",Re[Re.KEEP_EXISTING=1]="KEEP_EXISTING",Re[Re.USE_CLONE=2]="USE_CLONE",Re[Re.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Re[Re.VALUE_NAME=4]="VALUE_NAME",Re[Re.UNMANGLE_NAME=5]="UNMANGLE_NAME";let Na=[{code:330,name:"ownerObjectId",parser:y},{code:102,parser:pn},{code:102,parser:pn},{code:102,parser:pn},{code:5,name:"handle",parser:y}],Ud=[{code:3,name:"entries",parser:(i,t)=>{let e={name:i.value};return(i=t.next()).code===350?e.objectSoftId=i.value:i.code===360?e.objectHardId=i.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:y},{code:280,name:"isHardOwned",parser:Ft},{code:100,name:"subclassMarker",parser:y},...Na],Vd=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:y},{code:90,name:"version",parser:y},{code:1,name:"fileName",parser:y},{code:10,name:"size",parser:G},{code:11,name:"sizeOfOnePixel",parser:G},{code:280,name:"isLoaded",parser:y},{code:281,name:"resolutionUnits",parser:y},{code:100,name:"subclassMarker",parser:y}];(ln={})[ln.NOUNIT=0]="NOUNIT",ln[ln.CENTIMETERS=2]="CENTIMETERS",ln[ln.INCH=5]="INCH";(Ps={})[Ps.PSLTSCALE=1]="PSLTSCALE",Ps[Ps.LIMCHECK=2]="LIMCHECK";(hn={})[hn.INCHES=0]="INCHES",hn[hn.MILLIMETERS=1]="MILLIMETERS",hn[hn.PIXELS=2]="PIXELS";(Be={})[Be.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",Be[Be.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",Be[Be.DRAWING_LIMITS=2]="DRAWING_LIMITS",Be[Be.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",Be[Be.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",Be[Be.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Sr={})[Sr.AS_DISPLAYED=0]="AS_DISPLAYED",Sr[Sr.WIREFRAME=1]="WIREFRAME",Sr[Sr.HIDDEN=2]="HIDDEN",Sr[Sr.RENDERED=3]="RENDERED";(Fe={})[Fe.DRAFT=0]="DRAFT",Fe[Fe.PREVIEW=1]="PREVIEW",Fe[Fe.NORMAL=2]="NORMAL",Fe[Fe.PRESENTATION=3]="PRESENTATION",Fe[Fe.MAXIMUM=4]="MAXIMUM",Fe[Fe.CUSTOM=5]="CUSTOM";let Lh=[{code:333,name:"shadePlotId",parser:y},{code:149,name:"imageOriginY",parser:y},{code:148,name:"imageOriginX",parser:y},{code:147,name:"scaleFactor",parser:y},{code:78,name:"shadePlotCustomDPI",parser:y},{code:77,name:"shadePlotResolution",parser:y},{code:76,name:"shadePlotMode",parser:y},{code:75,name:"standardScaleType",parser:y},{code:7,name:"currentStyleSheet",parser:y},{code:74,name:"plotType",parser:y},{code:73,name:"plotRotation",parser:y},{code:72,name:"plotPaperUnit",parser:y},{code:70,name:"layoutFlag",parser:y},{code:143,name:"printScaleDenominator",parser:y},{code:142,name:"printScaleNumerator",parser:y},{code:141,name:"windowAreaYMax",parser:y},{code:140,name:"windowAreaXMax",parser:y},{code:49,name:"windowAreaYMin",parser:y},{code:48,name:"windowAreaXMin",parser:y},{code:47,name:"plotOriginY",parser:y},{code:46,name:"plotOriginX",parser:y},{code:45,name:"paperHeight",parser:y},{code:44,name:"paperWidth",parser:y},{code:43,name:"marginTop",parser:y},{code:42,name:"marginRight",parser:y},{code:41,name:"marginBottom",parser:y},{code:40,name:"marginLeft",parser:y},{code:6,name:"plotViewName",parser:y},{code:4,name:"paperSize",parser:y},{code:2,name:"configName",parser:y},{code:1,name:"pageSetupName",parser:y},{code:100,name:"subclassMarker",parser:y},...Na],jd=[{code:346,name:"orthographicUcsId",parser:y},{code:345,name:"namedUcsId",parser:y},{code:331,name:"viewportId",parser:y},{code:330,name:"paperSpaceTableId",parser:y},{code:76,name:"orthographicType",parser:y},{code:17,name:"ucsYAxis",parser:G},{code:16,name:"ucsXAxis",parser:G},{code:13,name:"ucsOrigin",parser:G},{code:146,name:"elevation",parser:y},{code:15,name:"maxExtent",parser:G},{code:14,name:"minExtent",parser:G},{code:12,name:"insertionPoint",parser:G},{code:11,name:"maxLimit",parser:G},{code:10,name:"minLimit",parser:G},{code:71,name:"tabOrder",parser:y},{code:70,name:"controlFlag",parser:y},{code:1,name:"layoutName",parser:y},{code:100,name:"subclassMarker",parser:y},...Lh],Gd=[{code:40,name:"wcsToOCSTransform",parser:Xo},{code:40,name:"ocsToWCSTransform",parser:Xo},{code:41,name:"backClippingDistance",parser:y},{code:73,name:"isBackClipping",parser:Ft,pushContext:!0},{code:40,name:"frontClippingDistance",parser:y},{code:72,name:"isFrontClipping",parser:Ft,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Ft},{code:11,name:"position",parser:G},{code:210,name:"normal",parser:G},{code:10,name:"boundaryVertices",parser:G,isMultiple:!0},{code:70,name:"boundaryCount",parser:y},{code:100,name:"subclassMarker",parser:y},{code:100},...Na];function Xo(i,t){let e=[];for(let s=0;s<3&&At(i,40);++s){let o=[];for(let h=0;h<4&&At(i,40);++h)o.push(i.value),i=t.next();e.push(o)}return t.rewind(),e}let Wd={LAYOUT:jd,PLOTSETTINGS:Lh,DICTIONARY:Ud,SPATIAL_FILTER:Gd,IMAGEDEF:Vd};function Hd(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,o=Wd[s];if(i.code===0&&(o!=null&&o.length)){let h=xt(o),c={name:s};h(i=t.next(),t,c)?(e.push(c),i=t.peek()):i=t.next()}else i=t.next()}return{byName:zc(e,({name:s})=>s)}}let jn=[{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102,parser(i,t){for(;!At(i,0,"EOF")&&!At(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:y}],qd=xt([{code:310,name:"bmpPreview",parser:y},{code:281,name:"scalability",parser:y},{code:280,name:"explodability",parser:y},{code:70,name:"insertionUnits",parser:y},{code:340,name:"layoutObjects",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...jn]),Yd=[{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:qo.Above,defaultValueImperial:qo.Center},{name:"DIMZIN",code:78,defaultValue:Ln.Trailing,defaultValueImperial:Ln.Feet},{name:"DIMAZIN",code:79,defaultValue:bc.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:wc.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Ac.Center},{name:"DIMTZIN",code:284,defaultValue:Ln.Trailing,defaultValueImperial:Ln.Feet},{name:"DIMALTZ",code:285,defaultValue:Ln.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Ln.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}],Xd=xt([...Yd.map(i=>({...i,parser:y})),{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},{code:105,name:"handle",parser:y},...jn.filter(i=>i.code!==5)]),Kd=xt([{code:347,name:"materialObjectId",parser:y},{code:390,name:"plotStyleNameObjectId",parser:y},{code:370,name:"lineweight",parser:y},{code:290,name:"isPlotting",parser:Ft},{code:6,name:"lineType",parser:y},{code:62,name:"colorIndex",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...jn]);(Ir={})[Ir.NONE=0]="NONE",Ir[Ir.AbsoluteRotation=1]="AbsoluteRotation",Ir[Ir.TextEmbedded=2]="TextEmbedded",Ir[Ir.ShapeEmbedded=4]="ShapeEmbedded";let $d=xt([{code:9,name:"text",parser:y},{code:45,name:"offsetY",parser:y},{code:44,name:"offsetX",parser:y},{code:50,name:"rotation",parser:y},{code:46,name:"scale",parser:y},{code:340,name:"styleObjectId",parser:y},{code:75,name:"shapeNumber",parser:y},{code:74,name:"elementTypeFlag",parser:y},{code:49,name:"elementLength",parser:y}],{elementTypeFlag:0,elementLength:0}),Zd=xt([{code:49,name:"pattern",parser(i,t){let e={};return $d(i,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:y},{code:73,name:"numberOfLineTypes",parser:y},{code:72,parser:y},{code:3,name:"description",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...jn]),Qd=xt([{code:1e3,name:"extendedFont",parser:y},{code:1001},{code:4,name:"bigFont",parser:y},{code:3,name:"font",parser:y},{code:42,name:"lastHeight",parser:y},{code:71,name:"textGenerationFlag",parser:y},{code:50,name:"obliqueAngle",parser:y},{code:41,name:"widthFactor",parser:y},{code:40,name:"fixedTextHeight",parser:y},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...jn]),Jd=xt([{code:[63,421,431],name:"ambientColor",parser:y},{code:142,name:"contrast",parser:y},{code:141,name:"brightness",parser:y},{code:282,name:"defaultLightingType",parser:y},{code:292,name:"isDefaultLightingOn",parser:Ft},{code:348,name:"visualStyleObjectId",parser:y},{code:333,name:"shadePlotObjectId",parser:y},{code:332,name:"backgroundObjectId",parser:y},{code:61,name:"majorGridLines",parser:y},{code:170,name:"shadePlotSetting",parser:y},{code:146,name:"elevation",parser:y},{code:79,name:"orthographicType",parser:y},{code:112,name:"ucsYAxis",parser:G},{code:111,name:"ucsXAxis",parser:G},{code:110,name:"ucsOrigin",parser:G},{code:74,name:"ucsIconSetting",parser:y},{code:71,name:"viewMode",parser:y},{code:281,name:"renderMode",parser:y},{code:1,name:"styleSheet",parser:y},{code:[331,441],name:"frozenLayers",parser:y,isMultiple:!0},{code:72,name:"circleSides",parser:y},{code:51,name:"viewTwistAngle",parser:y},{code:50,name:"snapRotationAngle",parser:y},{code:45,name:"viewHeight",parser:y},{code:44,name:"backClippingPlane",parser:y},{code:43,name:"frontClippingPlane",parser:y},{code:42,name:"lensLength",parser:y},{code:17,name:"viewTarget",parser:G},{code:16,name:"viewDirectionFromTarget",parser:G},{code:15,name:"gridSpacing",parser:G},{code:14,name:"snapSpacing",parser:G},{code:13,name:"snapBasePoint",parser:G},{code:12,name:"center",parser:G},{code:11,name:"upperRightCorner",parser:G},{code:10,name:"lowerLeftCorner",parser:G},{code:70,name:"standardFlag",parser:y},{code:2,name:"name",parser:y},{code:100,name:"subclassMarker",parser:y},...jn]),t0={BLOCK_RECORD:qd,DIMSTYLE:Xd,LAYER:Kd,LTYPE:Zd,STYLE:Qd,VPORT:Jd},e0=xt([{code:70,name:"maxNumberOfEntries",parser:y},{code:100,name:"subclassMarker",parser:y},{code:330,name:"ownerObjectId",parser:y},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:y},{code:2,name:"name",parser:y}]);function r0(i,t){var s;let e={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");){if(At(i,0,"TABLE")){i=t.next();let o={entries:[]};e0(i,t,o),e[o.name]=o}if(At(i,0)&&!At(i,0,"ENDTAB")){let o=i.value;i=t.next();let h=t0[o];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${o}'`),i=t.next();continue}let c={};h(i,t,c),(s=e[o])==null||s.entries.push(c)}i=t.next()}return e}function Es(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class Ko{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=$o(t,this._data[this._pointer++],this.debug),s={code:t,value:e};return At(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=$o(t.code,this._data[this._pointer+1],this.debug),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t,e=!1){Es(this,"_data",void 0),Es(this,"debug",void 0),Es(this,"_pointer",void 0),Es(this,"_eof",void 0),Es(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function $o(i,t,e=!1){return i<=9?t:i>=10&&i<=59?parseFloat(t.trim()):i>=60&&i<=99?parseInt(t.trim()):i>=100&&i<=109?t:i>=110&&i<=149?parseFloat(t.trim()):i>=160&&i<=179?parseInt(t.trim()):i>=210&&i<=239?parseFloat(t.trim()):i>=270&&i<=289?parseInt(t.trim()):i>=290&&i<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(t.trim()):i>=300&&i<=369?t:i>=370&&i<=389?parseInt(t.trim()):i>=390&&i<=399?t:i>=400&&i<=409?parseInt(t.trim()):i>=410&&i<=419?t:i>=420&&i<=429?parseInt(t.trim()):i>=430&&i<=439?t:i>=440&&i<=459?parseInt(t.trim()):i>=460&&i<=469?parseFloat(t.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?t:i>=1010&&i<=1059?parseFloat(t.trim()):i>=1060&&i<=1071?parseInt(t.trim()):(e&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:t}),t)}function pa(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class n0{constructor(){pa(this,"encoding","utf-8"),pa(this,"encodingFailureFatal",!1)}}class s0 extends EventTarget{parseSync(t,e=!1){let s=new Ko(t.split(/\r\n|\r|\n/g),e);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(t){let e="",s=this;return new Promise((o,h)=>{t.on("data",c=>{e+=c}),t.on("end",()=>{try{let c=e.split(/\r\n|\r|\n/g),g=new Ko(c);if(!g.hasNext())throw Error("Empty file");o(s.parseAll(g))}catch(c){h(c)}}),t.on("error",c=>{h(c)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:c,value:g}=await o.read();if(c){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(g,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!At(s,0,"EOF");)At(s,0,"SECTION")&&(At(s=t.next(),2,"HEADER")?(s=t.next(),e.header=Dd(s,t)):At(s,2,"BLOCKS")?(s=t.next(),e.blocks=Bd(s,t)):At(s,2,"ENTITIES")?(s=t.next(),e.entities=Ch(s,t)):At(s,2,"TABLES")?(s=t.next(),e.tables=r0(s,t)):At(s,2,"OBJECTS")&&(s=t.next(),e.objects=Hd(s,t))),s=t.next();return e}constructor(t=new n0){super(),pa(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}const Zo=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class ii{constructor(t){if(typeof t=="string"){const e=Zo.find(s=>s.name===t);if(!e)throw new Error(`Unknown DWG version name: ${t}`);this.name=e.name,this.value=e.value;return}if(typeof t=="number"){const e=Zo.find(s=>s.value===t);if(!e)throw new Error(`Unknown DWG version value: ${t}`);this.name=e.name,this.value=e.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class i0{parse(t){const e=new s0,s=this.getDxfInfoFromBuffer(t);let o="";return s.version&&s.version.value<=23&&s.encoding?o=new TextDecoder(s.encoding).decode(t):o=new TextDecoder().decode(t),e.parseSync(o)}getDxfInfoFromBuffer(t){var f,A,b;const s=new TextDecoder("utf-8");let o=0,h="",c=null,g=null,x=!1;for(;o<t.byteLength;){const E=Math.min(o+65536,t.byteLength),T=t.slice(o,E);o=E;const z=(h+s.decode(T,{stream:!0})).split(/\r?\n/);h=z.pop()??"";for(let U=0;U<z.length;U++){const F=z[U].trim();if(F==="SECTION"&&((f=z[U+2])==null?void 0:f.trim())==="HEADER")x=!0;else if(F==="ENDSEC"&&x)return{version:c,encoding:g};if(x&&F==="$ACADVER"){const dt=(A=z[U+2])==null?void 0:A.trim();dt&&(c=new ii(dt))}else if(x&&F==="$DWGCODEPAGE"){const dt=(b=z[U+2])==null?void 0:b.trim();if(dt){const vt=Ia[dt];g=bl(vt)}}if(c&&g)return{version:c,encoding:g}}}return{version:c,encoding:g}}}const fe=["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 Qo=1234567;const Ca=Math.PI/180,La=180/Math.PI;function Oh(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(fe[i&255]+fe[i>>8&255]+fe[i>>16&255]+fe[i>>24&255]+"-"+fe[t&255]+fe[t>>8&255]+"-"+fe[t>>16&15|64]+fe[t>>24&255]+"-"+fe[e&63|128]+fe[e>>8&255]+"-"+fe[e>>16&255]+fe[e>>24&255]+fe[s&255]+fe[s>>8&255]+fe[s>>16&255]+fe[s>>24&255]).toLowerCase()}function kr(i,t,e){return Math.max(t,Math.min(e,i))}function Oa(i,t){return(i%t+t)%t}function zh(i,t,e,s,o){return s+(i-t)*(o-s)/(e-t)}function Rh(i,t,e){return i!==t?(e-i)/(t-i):0}function za(i,t,e){return(1-e)*i+e*t}function Bh(i,t,e,s){return za(i,t,1-Math.exp(-e*s))}function Fh(i,t=1){return t-Math.abs(Oa(i,t*2)-t)}function Dh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Uh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Vh(i,t){return i+Math.floor(Math.random()*(t-i+1))}function jh(i,t){return i+Math.random()*(t-i)}function Gh(i){return i*(.5-Math.random())}function Wh(i){i!==void 0&&(Qo=i);let t=Qo+=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 Hh(i){return i*Ca}function qh(i){return i*La}function Yh(i){return(i&i-1)===0&&i!==0}function Xh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Kh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ns(i){const t=Math.PI*2;return(i%t+t)%t}function $h(i,t,e){return i>t&&i<e||i>e&&i<t}function Zh(i,t,e,s=!1){return i=Ns(i),t=Ns(t),e=Ns(e),s?t>e?i<=t&&i>=e:i<=t||i>=e:t<e?i>=t&&i<=e:i>=t||i<=e}function Ra(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Qh(i,t=1e-7){const e=Ra(i);return Math.max(Math.pow(10,e)*t,t)}const Et={DEG2RAD:Ca,RAD2DEG:La,generateUUID:Oh,clamp:kr,euclideanModulo:Oa,mapLinear:zh,inverseLerp:Rh,lerp:za,damp:Bh,pingpong:Fh,smoothstep:Dh,smootherstep:Uh,randInt:Vh,randFloat:jh,randFloatSpread:Gh,seededRandom:Wh,degToRad:Hh,radToDeg:qh,isPowerOfTwo:Yh,ceilPowerOfTwo:Xh,floorPowerOfTwo:Kh,normalizeAngle:Ns,isBetween:$h,isBetweenAngle:Zh,intPartLength:Ra,relativeEps:Qh},ga=class Jh{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:o,y:h}=t;this.x=o,this.y=h;return}if(s===2){this.x=t,this.y=e;return}throw je.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 Jh(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,o=t.elements;return this.x=o[0]*e+o[3]*s+o[6],this.y=o[1]*e+o[4]*s+o[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),o=Math.sin(e),h=this.x-t.x,c=this.y-t.y;return this.x=h*s-c*o+t.x,this.y=h*o+c*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(Et.relativeEps(this.x,t),Et.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};ga.EMPTY=Object.freeze(new ga(0,0));let $t=ga;const fa=class tu{constructor(t,e,s,o,h,c,g,x,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&o!=null&&h!=null&&c!=null&&g!=null&&x!=null&&f!=null&&this.set(t,e,s,o,h,c,g,x,f)}set(t,e,s,o,h,c,g,x,f){const A=this.elements;return A[0]=t,A[1]=o,A[2]=g,A[3]=e,A[4]=h,A[5]=x,A[6]=s,A[7]=c,A[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,o=e.elements,h=this.elements,c=s[0],g=s[3],x=s[6],f=s[1],A=s[4],b=s[7],E=s[2],T=s[5],O=s[8],z=o[0],U=o[3],F=o[6],dt=o[1],vt=o[4],ot=o[7],W=o[2],ut=o[5],st=o[8];return h[0]=c*z+g*dt+x*W,h[3]=c*U+g*vt+x*ut,h[6]=c*F+g*ot+x*st,h[1]=f*z+A*dt+b*W,h[4]=f*U+A*vt+b*ut,h[7]=f*F+A*ot+b*st,h[2]=E*z+T*dt+O*W,h[5]=E*U+T*vt+O*ut,h[8]=E*F+T*ot+O*st,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],o=t[2],h=t[3],c=t[4],g=t[5],x=t[6],f=t[7],A=t[8];return e*c*A-e*g*f-s*h*A+s*g*x+o*h*f-o*c*x}invert(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],c=t[4],g=t[5],x=t[6],f=t[7],A=t[8],b=A*c-g*f,E=g*x-A*h,T=f*h-c*x,O=e*b+s*E+o*T;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);const z=1/O;return t[0]=b*z,t[1]=(o*f-A*s)*z,t[2]=(g*s-o*c)*z,t[3]=E*z,t[4]=(A*e-o*x)*z,t[5]=(o*h-g*e)*z,t[6]=T*z,t[7]=(s*x-f*e)*z,t[8]=(c*e-s*h)*z,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,o,h,c,g){const x=Math.cos(h),f=Math.sin(h);return this.set(s*x,s*f,-s*(x*c+f*g)+c+t,-o*f,o*x,-o*(-f*c+x*g)+g+e,0,0,1),this}scale(t,e){return this.premultiply(ha.makeScale(t,e)),this}rotate(t){return this.premultiply(ha.makeRotation(-t)),this}translate(t,e){return this.premultiply(ha.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof $t?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 o=0;o<9;o++)if(e[o]!==s[o])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 tu().fromArray(this.elements)}};fa.IDENTITY=Object.freeze(new fa);let Ri=fa;const ha=new Ri,cn=1e-6,ne=2*Math.PI,a0={x:0,y:0},Ba={x:0,y:0,z:0};class Fa{constructor(){this.equalPointTol=cn,this.equalVectorTol=cn}equalPoint2d(t,e){return new $t(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new Z(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=cn){return t<e&&t>-e}static equal(t,e,s=cn){return Math.abs(t-e)<s}static great(t,e,s=cn){return t-e>s}static less(t,e,s=cn){return t-e<s}}const Da=new Fa;function Ua(i,t,e=!1){const s=i.x,o=i.y;let h=!1;const c=t.length;for(let g=0,x=c-1;g<c;x=g++){const f=t[g].x,A=t[g].y,b=t[x].x,E=t[x].y;let T=A>o!=E>o;e&&(T=A>=o!=E>=o),T&&s<(b-f)*(o-A)/(E-A)+f&&(h=!h)}return h}function eu(i,t){if(i.length===0||t.length===0)return!1;const e=new _e().setFromPoints(i),s=new _e().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let o=0;o<i.length;){if(Ua(i[o],t,!0))return!0;o<i.length-1&&Da.equalPoint2d(i[o+1],i[o])&&++o,++o}return!1}const ru={isPointInPolygon:Ua,isPolygonIntersect:eu};function nu(i,t){const e=[],s=t-1,o=i;for(let h=0;h<=o;h++)e.push(0);for(let h=1;h<=s-o;h++)e.push(h);for(let h=0;h<=o;h++)e.push(s-o+1);return e}function su(i,t){const e=t.length-1,s=i,o=[0];let h=0;for(let g=1;g<=e;g++){const x=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],A=t[g][2]-t[g-1][2],b=Math.sqrt(x*x+f*f+A*A);h+=b,o.push(h)}const c=[];for(let g=0;g<=s;g++)c.push(0);for(let g=1;g<=e-s;g++){const x=o[g]/h;c.push(x*(e-s+1))}for(let g=0;g<=s;g++)c.push(e-s+1);return c}function iu(i,t){const e=t.length-1,s=i,o=[0];let h=0;for(let g=1;g<=e;g++){const x=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],A=t[g][2]-t[g-1][2],b=Math.sqrt(x*x+f*f+A*A),E=Math.sqrt(b);h+=E,o.push(h)}const c=[];for(let g=0;g<=s;g++)c.push(0);for(let g=1;g<=e-s;g++){const x=o[g]/h;c.push(x*(e-s+1))}for(let g=0;g<=s;g++)c.push(e-s+1);return c}function ai(i,t,e,s){if(t===0)return e>=s[i]&&e<s[i+1]?1:0;const o=s[i+t]-s[i],h=s[i+t+1]-s[i+1],c=o>1e-10?(e-s[i])/o:0,g=h>1e-10?(s[i+t+1]-e)/h:0;return c*ai(i,t-1,e,s)+g*ai(i+1,t-1,e,s)}function Cs(i,t,e,s,o){const h=s.length-1,c=t;if(i=Math.max(e[c],Math.min(e[h+1],i)),Math.abs(i-e[h+1])<1e-8)return[...s[h]];if(Math.abs(i-e[c])<1e-8)return[...s[0]];const g=[0,0,0];let x=0;for(let f=0;f<=h;f++){const A=ai(f,c,i,e),b=o[f]*A;g[0]+=s[f][0]*b,g[1]+=s[f][1]*b,g[2]+=s[f][2]*b,x+=b}if(x<1e-10){const f=e[e.length-c-1];if(Math.abs(i-f)<1e-8)return[...s[h]];if(Math.abs(i-e[c])<1e-8)return[...s[0]]}return x>1e-10&&(g[0]/=x,g[1]/=x,g[2]/=x),g}function au(i,t,e,s){const o=i,h=t[o],c=t[t.length-o-1];let g=0;const x=1e3,f=(c-h)/x;let A=Cs(h,i,t,e,s);for(let z=1;z<=x;z++){const U=h+z*f,F=Cs(U,i,t,e,s),dt=F[0]-A[0],vt=F[1]-A[1],ot=F[2]-A[2];g+=Math.sqrt(dt*dt+vt*vt+ot*ot),A=F}const b=Cs(c,i,t,e,s),E=b[0]-A[0],T=b[1]-A[1],O=b[2]-A[2];return g+=Math.sqrt(E*E+T*T+O*O),g}function o0(i){return i.map(t=>[...t])}class Hr{constructor(t=0,e=0,s=0,o=1){this._x=t,this._y=e,this._z=s,this._w=o}static slerpFlat(t,e,s,o,h,c,g){let x=s[o+0],f=s[o+1],A=s[o+2],b=s[o+3];const E=h[c+0],T=h[c+1],O=h[c+2],z=h[c+3];if(g===0){t[e+0]=x,t[e+1]=f,t[e+2]=A,t[e+3]=b;return}if(g===1){t[e+0]=E,t[e+1]=T,t[e+2]=O,t[e+3]=z;return}if(b!==z||x!==E||f!==T||A!==O){let U=1-g;const F=x*E+f*T+A*O+b*z,dt=F>=0?1:-1,vt=1-F*F;if(vt>Number.EPSILON){const W=Math.sqrt(vt),ut=Math.atan2(W,F*dt);U=Math.sin(U*ut)/W,g=Math.sin(g*ut)/W}const ot=g*dt;if(x=x*U+E*ot,f=f*U+T*ot,A=A*U+O*ot,b=b*U+z*ot,U===1-g){const W=1/Math.sqrt(x*x+f*f+A*A+b*b);x*=W,f*=W,A*=W,b*=W}}t[e]=x,t[e+1]=f,t[e+2]=A,t[e+3]=b}static multiplyQuaternionsFlat(t,e,s,o,h,c){const g=s[o],x=s[o+1],f=s[o+2],A=s[o+3],b=h[c],E=h[c+1],T=h[c+2],O=h[c+3];return t[e]=g*O+A*b+x*T-f*E,t[e+1]=x*O+A*E+f*b-g*T,t[e+2]=f*O+A*T+g*E-x*b,t[e+3]=A*O-g*b-x*E-f*T,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,o){return this._x=t,this._y=e,this._z=s,this._w=o,this._onChangeCallback(),this}clone(){return new Hr(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,o=t.y,h=t.z,c=t.order,g=Math.cos,x=Math.sin,f=g(s/2),A=g(o/2),b=g(h/2),E=x(s/2),T=x(o/2),O=x(h/2);switch(c){case"XYZ":this._x=E*A*b+f*T*O,this._y=f*T*b-E*A*O,this._z=f*A*O+E*T*b,this._w=f*A*b-E*T*O;break;case"YXZ":this._x=E*A*b+f*T*O,this._y=f*T*b-E*A*O,this._z=f*A*O-E*T*b,this._w=f*A*b+E*T*O;break;case"ZXY":this._x=E*A*b-f*T*O,this._y=f*T*b+E*A*O,this._z=f*A*O+E*T*b,this._w=f*A*b-E*T*O;break;case"ZYX":this._x=E*A*b-f*T*O,this._y=f*T*b+E*A*O,this._z=f*A*O-E*T*b,this._w=f*A*b+E*T*O;break;case"YZX":this._x=E*A*b+f*T*O,this._y=f*T*b+E*A*O,this._z=f*A*O-E*T*b,this._w=f*A*b-E*T*O;break;case"XZY":this._x=E*A*b-f*T*O,this._y=f*T*b-E*A*O,this._z=f*A*O+E*T*b,this._w=f*A*b+E*T*O;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,o=Math.sin(s);return this._x=t.x*o,this._y=t.y*o,this._z=t.z*o,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],o=e[4],h=e[8],c=e[1],g=e[5],x=e[9],f=e[2],A=e[6],b=e[10],E=s+g+b;if(E>0){const T=.5/Math.sqrt(E+1);this._w=.25/T,this._x=(A-x)*T,this._y=(h-f)*T,this._z=(c-o)*T}else if(s>g&&s>b){const T=2*Math.sqrt(1+s-g-b);this._w=(A-x)/T,this._x=.25*T,this._y=(o+c)/T,this._z=(h+f)/T}else if(g>b){const T=2*Math.sqrt(1+g-s-b);this._w=(h-f)/T,this._x=(o+c)/T,this._y=.25*T,this._z=(x+A)/T}else{const T=2*Math.sqrt(1+b-s-g);this._w=(c-o)/T,this._x=(h+f)/T,this._y=(x+A)/T,this._z=.25*T}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(kr(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const o=Math.min(1,e/s);return this.slerp(t,o),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,o=t._y,h=t._z,c=t._w,g=e._x,x=e._y,f=e._z,A=e._w;return this._x=s*A+c*g+o*f-h*x,this._y=o*A+c*x+h*g-s*f,this._z=h*A+c*f+s*x-o*g,this._w=c*A-s*g-o*x-h*f,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,o=this._y,h=this._z,c=this._w;let g=c*t._w+s*t._x+o*t._y+h*t._z;if(g<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,g=-g):this.copy(t),g>=1)return this._w=c,this._x=s,this._y=o,this._z=h,this;const x=1-g*g;if(x<=Number.EPSILON){const T=1-e;return this._w=T*c+e*this._w,this._x=T*s+e*this._x,this._y=T*o+e*this._y,this._z=T*h+e*this._z,this.normalize(),this}const f=Math.sqrt(x),A=Math.atan2(f,g),b=Math.sin((1-e)*A)/f,E=Math.sin(e*A)/f;return this._w=c*b+this._w*E,this._x=s*b+this._x*E,this._y=o*b+this._y*E,this._z=h*b+this._z*E,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(),o=Math.sqrt(1-s),h=Math.sqrt(s);return this.set(o*Math.sin(t),o*Math.cos(t),h*Math.sin(e),h*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Ue=class ou{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const o=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0);if(o!==0){if(o===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(o===1){const{x:h,y:c,z:g}=t;this.x=h,this.y=c,this.z=g||0;return}if(o===3){this.x=t,this.y=e,this.z=s;return}throw je.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 ou(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(Jo.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Jo.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,o=this.z,h=t.elements;return this.x=h[0]*e+h[3]*s+h[6]*o,this.y=h[1]*e+h[4]*s+h[7]*o,this.z=h[2]*e+h[5]*s+h[8]*o,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,o=this.z,h=t.elements,c=1/(h[3]*e+h[7]*s+h[11]*o+h[15]);return this.x=(h[0]*e+h[4]*s+h[8]*o+h[12])*c,this.y=(h[1]*e+h[5]*s+h[9]*o+h[13])*c,this.z=(h[2]*e+h[6]*s+h[10]*o+h[14])*c,this}applyQuaternion(t){const e=this.x,s=this.y,o=this.z,h=t.x,c=t.y,g=t.z,x=t.w,f=2*(c*o-g*s),A=2*(g*e-h*o),b=2*(h*s-c*e);return this.x=e+x*f+c*b-g*A,this.y=s+x*A+g*f-h*b,this.z=o+x*b+h*A-c*f,this}transformDirection(t){const e=this.x,s=this.y,o=this.z,h=t.elements;return this.x=h[0]*e+h[4]*s+h[8]*o,this.y=h[1]*e+h[5]*s+h[9]*o,this.z=h[2]*e+h[6]*s+h[10]*o,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(),o=t.length();return Math.abs(e)===s*o}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,o=t.y,h=t.z,c=e.x,g=e.y,x=e.z;return this.x=o*x-h*g,this.y=h*c-s*x,this.z=s*g-o*c,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 ua.copy(this).projectOnVector(t),this.sub(ua)}reflect(t){return this.sub(ua.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,o=this.z-t.z;return e*e+s*s+o*o}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(),o=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=o,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}};Ue.X_AXIS=Object.freeze(new Ue(1,0,0)),Ue.NEGATIVE_X_AXIS=Object.freeze(new Ue(-1,0,0)),Ue.Y_AXIS=Object.freeze(new Ue(0,1,0)),Ue.NEGATIVE_Y_AXIS=Object.freeze(new Ue(0,-1,0)),Ue.Z_AXIS=Object.freeze(new Ue(0,0,1)),Ue.NEGATIVE_Z_AXIS=Object.freeze(new Ue(0,0,-1));let Z=Ue;const ua=new Z,Jo=new Hr,_a=class lu{constructor(t,e,s,o,h,c,g,x,f,A,b,E,T,O,z,U){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&o!=null&&h!=null&&c!=null&&g!=null&&x!=null&&f!=null&&A!=null&&b!=null&&E!=null&&T!=null&&O!=null&&z!=null&&U!=null&&this.set(t,e,s,o,h,c,g,x,f,A,b,E,T,O,z,U)}set(t,e,s,o,h,c,g,x,f,A,b,E,T,O,z,U){const F=this.elements;return F[0]=t,F[4]=e,F[8]=s,F[12]=o,F[1]=h,F[5]=c,F[9]=g,F[13]=x,F[2]=f,F[6]=A,F[10]=b,F[14]=E,F[3]=T,F[7]=O,F[11]=z,F[15]=U,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 lu().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(Da.equalPoint3d(t,Z.Z_AXIS))this.identity();else{const e=new Z(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(Z.Y_AXIS,t).normalize():e.crossVectors(Z.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,o=1/On.setFromMatrixColumn(t,0).length(),h=1/On.setFromMatrixColumn(t,1).length(),c=1/On.setFromMatrixColumn(t,2).length();return e[0]=s[0]*o,e[1]=s[1]*o,e[2]=s[2]*o,e[3]=0,e[4]=s[4]*h,e[5]=s[5]*h,e[6]=s[6]*h,e[7]=0,e[8]=s[8]*c,e[9]=s[9]*c,e[10]=s[10]*c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(l0,t,h0)}lookAt(t,e,s){const o=this.elements;return De.subVectors(t,e),De.lengthSq()===0&&(De.z=1),De.normalize(),Ur.crossVectors(s,De),Ur.lengthSq()===0&&(Math.abs(s.z)===1?De.x+=1e-4:De.z+=1e-4,De.normalize(),Ur.crossVectors(s,De)),Ur.normalize(),qs.crossVectors(De,Ur),o[0]=Ur.x,o[4]=qs.x,o[8]=De.x,o[1]=Ur.y,o[5]=qs.y,o[9]=De.y,o[2]=Ur.z,o[6]=qs.z,o[10]=De.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,o=e.elements,h=this.elements,c=s[0],g=s[4],x=s[8],f=s[12],A=s[1],b=s[5],E=s[9],T=s[13],O=s[2],z=s[6],U=s[10],F=s[14],dt=s[3],vt=s[7],ot=s[11],W=s[15],ut=o[0],st=o[4],Vt=o[8],Yt=o[12],Wt=o[1],bt=o[5],Ot=o[9],de=o[13],me=o[2],ke=o[6],Jt=o[10],ae=o[14],Q=o[3],Nt=o[7],oe=o[11],hr=o[15];return h[0]=c*ut+g*Wt+x*me+f*Q,h[4]=c*st+g*bt+x*ke+f*Nt,h[8]=c*Vt+g*Ot+x*Jt+f*oe,h[12]=c*Yt+g*de+x*ae+f*hr,h[1]=A*ut+b*Wt+E*me+T*Q,h[5]=A*st+b*bt+E*ke+T*Nt,h[9]=A*Vt+b*Ot+E*Jt+T*oe,h[13]=A*Yt+b*de+E*ae+T*hr,h[2]=O*ut+z*Wt+U*me+F*Q,h[6]=O*st+z*bt+U*ke+F*Nt,h[10]=O*Vt+z*Ot+U*Jt+F*oe,h[14]=O*Yt+z*de+U*ae+F*hr,h[3]=dt*ut+vt*Wt+ot*me+W*Q,h[7]=dt*st+vt*bt+ot*ke+W*Nt,h[11]=dt*Vt+vt*Ot+ot*Jt+W*oe,h[15]=dt*Yt+vt*de+ot*ae+W*hr,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],o=t[8],h=t[12],c=t[1],g=t[5],x=t[9],f=t[13],A=t[2],b=t[6],E=t[10],T=t[14],O=t[3],z=t[7],U=t[11],F=t[15];return O*(+h*x*b-o*f*b-h*g*E+s*f*E+o*g*T-s*x*T)+z*(+e*x*T-e*f*E+h*c*E-o*c*T+o*f*A-h*x*A)+U*(+e*f*b-e*g*T-h*c*b+s*c*T+h*g*A-s*f*A)+F*(-o*g*A-e*x*b+e*g*E+o*c*b-s*c*E+s*x*A)}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 o=this.elements;return t instanceof Z?(o[12]=t.x,o[13]=t.y,o[14]=t.z):(o[12]=t,o[13]=e,o[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],c=t[4],g=t[5],x=t[6],f=t[7],A=t[8],b=t[9],E=t[10],T=t[11],O=t[12],z=t[13],U=t[14],F=t[15],dt=b*U*f-z*E*f+z*x*T-g*U*T-b*x*F+g*E*F,vt=O*E*f-A*U*f-O*x*T+c*U*T+A*x*F-c*E*F,ot=A*z*f-O*b*f+O*g*T-c*z*T-A*g*F+c*b*F,W=O*b*x-A*z*x-O*g*E+c*z*E+A*g*U-c*b*U,ut=e*dt+s*vt+o*ot+h*W;if(ut===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const st=1/ut;return t[0]=dt*st,t[1]=(z*E*h-b*U*h-z*o*T+s*U*T+b*o*F-s*E*F)*st,t[2]=(g*U*h-z*x*h+z*o*f-s*U*f-g*o*F+s*x*F)*st,t[3]=(b*x*h-g*E*h-b*o*f+s*E*f+g*o*T-s*x*T)*st,t[4]=vt*st,t[5]=(A*U*h-O*E*h+O*o*T-e*U*T-A*o*F+e*E*F)*st,t[6]=(O*x*h-c*U*h-O*o*f+e*U*f+c*o*F-e*x*F)*st,t[7]=(c*E*h-A*x*h+A*o*f-e*E*f-c*o*T+e*x*T)*st,t[8]=ot*st,t[9]=(O*b*h-A*z*h-O*s*T+e*z*T+A*s*F-e*b*F)*st,t[10]=(c*z*h-O*g*h+O*s*f-e*z*f-c*s*F+e*g*F)*st,t[11]=(A*g*h-c*b*h-A*s*f+e*b*f+c*s*T-e*g*T)*st,t[12]=W*st,t[13]=(A*z*o-O*b*o+O*s*E-e*z*E-A*s*U+e*b*U)*st,t[14]=(O*g*o-c*z*o-O*s*x+e*z*x+c*s*U-e*g*U)*st,t[15]=(c*b*o-A*g*o+A*s*x-e*b*x-c*s*E+e*g*E)*st,this}scale(t){const e=this.elements,s=t.x,o=t.y,h=t.z;return e[0]*=s,e[4]*=o,e[8]*=h,e[1]*=s,e[5]*=o,e[9]*=h,e[2]*=s,e[6]*=o,e[10]*=h,e[3]*=s,e[7]*=o,e[11]*=h,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],o=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,o))}makeTranslation(t,e,s){return t instanceof Z?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),o=Math.sin(e),h=1-s,c=t.x,g=t.y,x=t.z,f=h*c,A=h*g;return this.set(f*c+s,f*g-o*x,f*x+o*g,0,f*g+o*x,A*g+s,A*x-o*c,0,f*x-o*g,A*x+o*c,h*x*x+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,o,h,c){return this.set(1,s,h,0,t,1,c,0,e,o,1,0,0,0,0,1),this}compose(t,e,s){const o=this.elements,h=e.x,c=e.y,g=e.z,x=e.w,f=h+h,A=c+c,b=g+g,E=h*f,T=h*A,O=h*b,z=c*A,U=c*b,F=g*b,dt=x*f,vt=x*A,ot=x*b,W=s.x,ut=s.y,st=s.z;return o[0]=(1-(z+F))*W,o[1]=(T+ot)*W,o[2]=(O-vt)*W,o[3]=0,o[4]=(T-ot)*ut,o[5]=(1-(E+F))*ut,o[6]=(U+dt)*ut,o[7]=0,o[8]=(O+vt)*st,o[9]=(U-dt)*st,o[10]=(1-(E+z))*st,o[11]=0,o[12]=t.x,o[13]=t.y,o[14]=t.z,o[15]=1,this}decompose(t,e,s){const o=this.elements;let h=On.set(o[0],o[1],o[2]).length();const c=On.set(o[4],o[5],o[6]).length(),g=On.set(o[8],o[9],o[10]).length();this.determinant()<0&&(h=-h),t.x=o[12],t.y=o[13],t.z=o[14],rr.copy(this);const x=1/h,f=1/c,A=1/g;return rr.elements[0]*=x,rr.elements[1]*=x,rr.elements[2]*=x,rr.elements[4]*=f,rr.elements[5]*=f,rr.elements[6]*=f,rr.elements[8]*=A,rr.elements[9]*=A,rr.elements[10]*=A,e.setFromRotationMatrix(rr),s.x=h,s.y=c,s.z=g,this}equals(t){const e=this.elements,s=t.elements;for(let o=0;o<16;o++)if(e[o]!==s[o])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}};_a.IDENTITY=Object.freeze(new _a);let qr=_a;const On=new Z,rr=new qr,l0=new Z(0,0,0),h0=new Z(1,1,1),Ur=new Z,qs=new Z,De=new Z;class Mt{constructor(t=void 0,e=void 0){this.min=t==null?new Z(1/0,1/0,1/0):new Z(t.x,t.y,t.z),this.max=e==null?new Z(-1/0,-1/0,-1/0):new Z(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(ca.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=ca.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Mt().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 Z(0,0,0):new Z(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Z(0,0,0):new Z(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,ca).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:(Er[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Er[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Er[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Er[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Er[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Er[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Er[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Er[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Er),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 Er=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],ca=new Z,tl=new $t;class _e{constructor(t=void 0,e=void 0){this.min=t==null?new $t(1/0,1/0):new $t(t.x,t.y),this.max=e==null?new $t(-1/0,-1/0):new $t(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=tl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new _e().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 $t(0,0):new $t(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $t(0,0):new $t(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,tl).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 el=new Z,u0=new Z,c0=new Ri;class Ds{constructor(t=new Z(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,o){return this.normal.set(t,e,s),this.constant=o,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const o=el.subVectors(s,e).cross(u0.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(o,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||c0.getNormalMatrix(t),o=this.coplanarPoint(el).applyMatrix4(t),h=this.normal.applyMatrix3(s).normalize();return this.constant=-o.dot(h),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new Ds().copy(this)}}class Tt extends $t{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,o)=>{s.toArray(e,o*2)}),e}}class q extends Z{static pointArrayToNumberArray(t,e=!0){const s=e?3:2,o=new Array(t.length*s);return t.forEach((h,c)=>{h.toArray(o,c*s)}),o}}const rl=new qr,nl=new Hr,hu=class va{constructor(t=0,e=0,s=0,o=va.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=o}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,o=this._order){return this._x=t,this._y=e,this._z=s,this._order=o,this._onChangeCallback(),this}clone(){return new va(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const o=t.elements,h=o[0],c=o[4],g=o[8],x=o[1],f=o[5],A=o[9],b=o[2],E=o[6],T=o[10];switch(e){case"XYZ":this._y=Math.asin(kr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-A,T),this._z=Math.atan2(-c,h)):(this._x=Math.atan2(E,f),this._z=0);break;case"YXZ":this._x=Math.asin(-kr(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(g,T),this._z=Math.atan2(x,f)):(this._y=Math.atan2(-b,h),this._z=0);break;case"ZXY":this._x=Math.asin(kr(E,-1,1)),Math.abs(E)<.9999999?(this._y=Math.atan2(-b,T),this._z=Math.atan2(-c,f)):(this._y=0,this._z=Math.atan2(x,h));break;case"ZYX":this._y=Math.asin(-kr(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(E,T),this._z=Math.atan2(x,h)):(this._x=0,this._z=Math.atan2(-c,f));break;case"YZX":this._z=Math.asin(kr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(-A,f),this._y=Math.atan2(-b,h)):(this._x=0,this._y=Math.atan2(g,T));break;case"XZY":this._z=Math.asin(-kr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(E,f),this._y=Math.atan2(g,h)):(this._x=Math.atan2(-A,T),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 rl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(rl,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return nl.setFromEuler(this),this.setFromQuaternion(nl,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}};hu.DEFAULT_ORDER="XYZ";let uu=hu;class cu{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Va extends cu{translate(t){return this.transform(new Ri().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Bi extends Va{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 _e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const o=this.loops[s].getPoints(t);e.push(o)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),o=this.sortBoundaryBoxesByAreas(s),h=new Map,c=o.length;for(let x=0;x<c;x++)h.set(o[x],{index:o[x],children:[]});const g={index:-1,children:[]};for(let x=0;x<c;x++){const f=o[x],A=e[f],b=s[f];let E=x+1;for(;E<c;E++){const T=o[E],O=e[T];if(s[T].containsBox(b)&&ru.isPointInPolygon(A[Et.randInt(0,A.length-1)],O)){(t=h.get(T))==null||t.children.push(h.get(f));break}}E===c&&g.children.push(h.get(f))}return g}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new _e().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((o,h)=>{const c=o.size,g=c.width*c.height;e.push({area:g,index:h})}),e.sort((o,h)=>o.area-h.area);const s=[];return e.forEach(o=>{s.push(o.index)}),s}}class Gn extends Va{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,o=this.getPoint(0),h=0;e.push(0);for(let c=1;c<=t;c++)s=this.getPoint(c/t),h+=s.distanceTo(o),e.push(h),o=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let o=0;const h=s.length;let c;e?c=e:c=t*s[h-1];let g=0,x=h-1,f;for(;g<=x;)if(o=Math.floor(g+(x-g)/2),f=s[o]-c,f<0)g=o+1;else if(f>0)x=o-1;else{x=o;break}if(o=x,s[o]===c)return o/(h-1);const A=s[o],b=s[o+1]-A,E=(c-A)/b;return(o+E)/(h-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const o=this.getPoint(e),h=this.getPoint(s),c=new Tt;return c.copy(h).sub(o).normalize(),c}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class Fn extends Gn{constructor(t,e,s,o,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(c==5){const g=t;this.center=new Tt(g.x,g.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(s)):Et.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(o)):Et.normalizeAngle(o)}else throw je.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const o=(st,Vt)=>({x:(st.x+Vt.x)/2,y:(st.y+Vt.y)/2}),h=(st,Vt)=>(Vt.y-st.y)/(Vt.x-st.x),c=st=>-1/st,g=o(t,e),x=o(e,s),f=h(t,e),A=h(e,s),b=c(f),E=c(A),T=(st,Vt,Yt,Wt)=>{const bt=(Wt-Vt)/(st-Yt),Ot=st*bt+Vt;return{x:bt,y:Ot}},O=g.y-b*g.x,z=x.y-E*x.x,U=T(b,O,E,z),F=Math.sqrt(Math.pow(t.x-U.x,2)+Math.pow(t.y-U.y,2)),dt=(st,Vt)=>Math.atan2(st.y-Vt.y,st.x-Vt.x),vt=dt(t,U),ot=dt(e,U),W=dt(s,U),ut=W>vt&&W<ot||vt>W&&vt<ot||ot>W&&ot<vt;this.center=U,this.radius=F,this._clockwise=!ut,this._startAngle=vt,this._endAngle=W}createByStartEndPointsAndBulge(t,e,s){let o,h,c;s<0?(o=Math.atan(-s)*4,h=new $t(t),c=new $t(e)):(o=Math.atan(s)*4,h=new $t(e),c=new $t(t));const g=new $t().subVectors(c,h),x=g.length(),f=new $t().addVectors(h,g.multiplyScalar(.5)),A=Math.abs(x/2/Math.tan(o/2)),b=g.normalize();let E;if(o<Math.PI){const T=new $t(b.x*Math.cos(Math.PI/2)-b.y*Math.sin(Math.PI/2),b.y*Math.cos(Math.PI/2)+b.x*Math.sin(Math.PI/2));E=f.add(T.multiplyScalar(-A))}else{const T=new $t(b.x*Math.cos(Math.PI/2)-b.y*Math.sin(Math.PI/2),b.y*Math.cos(Math.PI/2)+b.x*Math.sin(Math.PI/2));E=f.add(T.multiplyScalar(A))}s<0?(this._startAngle=Math.atan2(h.y-E.y,h.x-E.x),this._endAngle=Math.atan2(c.y-E.y,c.x-E.x)):(this._startAngle=Math.atan2(c.y-E.y,c.x-E.x),this._endAngle=Math.atan2(h.y-E.y,h.x-E.x)),this._clockwise=s<0,this.center=E,this.radius=c.sub(E).length()}get center(){return this._center}set center(t){this._center=new Tt(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(t)):Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const e=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(e):e,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return this.clockwise?Et.normalizeAngle(t-e):Et.normalizeAngle(e-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=Et.normalizeAngle((t+e)/2),o=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(o)}get closed(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return Math.abs(e-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of e){const c=this._getInternalAngle(h);Et.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const s=t.map(h=>h.x),o=t.map(h=>h.y);return new _e(new Tt(Math.min(...s),Math.min(...o)),new Tt(Math.max(...s),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Fn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),s=this.center.x+this.radius*Math.cos(e),o=this.center.y+this.radius*Math.sin(e);return new Tt(s,o)}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(s=ne,o=0),this.clockwise)for(let h=0;h<=t;h++){const c=o-s*(h/t),g=this._clockwise?this._mirrorAngle(c):c,x=this.getPointAtAngle(g);e.push(new Tt(x.x,x.y))}else for(let h=0;h<=t;h++){const c=o+s*(h/t),g=this._clockwise?this._mirrorAngle(c):c,x=this.getPointAtAngle(g);e.push(new Tt(x.x,x.y))}return e}}class d0 extends cu{translate(t){return this.transform(new qr().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 Us extends d0{}class Yr extends Us{constructor(t,e){super(),this._start=new q(t),this._end=new q(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 Z().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new q((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(un).normalize();return new q(this._start).addScaledVector(s,t)}else{const s=this.delta(un).normalize();return new q(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=un.subVectors(this._start,this._end).normalize();this._start=new q(this._start).addScaledVector(s,t)}else{const s=this.delta(un).normalize();this._end=new q(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){sl.subVectors(t,this._start),Ys.subVectors(this.endPoint,this.startPoint);const s=Ys.dot(Ys);let o=Ys.dot(sl)/s;return e&&(o=Et.clamp(o,0,1)),o}closestPointToPoint(t,e,s){const o=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(o).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=un.subVectors(t,this.startPoint).dot(e);return new q().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,o=un.subVectors(t,s).dot(e),h=un.copy(e).multiplyScalar(o);return new q().addVectors(s,h)}calculateBoundingBox(){const t=new q(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 q(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 Mt(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Yr(this._start.clone(),this._end.clone())}}const un=new Z,sl=new Z,Ys=new Z;class gn extends Us{static computeCenterPoint(t,e,s){const o=new Z().addVectors(t,e).multiplyScalar(.5),h=new Z().addVectors(t,s).multiplyScalar(.5),c=new Z().subVectors(e,t),g=new Z().subVectors(s,t),x=new Z().crossVectors(c,g).normalize();if(x.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new Z().crossVectors(c,x).normalize(),A=new Z().crossVectors(g,x).normalize(),b=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=A.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),T=new Yr(o,o.clone().add(b)),O=new Yr(h,h.clone().add(E)),z=new Z;return T.closestPointToPoint(O.startPoint,!0,z)?z:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const o=gn.computeCenterPoint(t,e,s);if(o){const h=o.distanceTo(t),c=new Z().subVectors(t,o),g=new Z().subVectors(e,o),x=Math.atan2(c.y,c.x),f=Math.atan2(g.y,g.x);return new gn(o,h,x,f,Z.Z_AXIS)}}constructor(t,e,s,o,h,c=Z.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=o,this.normal=h,this.refVec=c,(o-s)%ne==0?(this.startAngle=0,this.endAngle=ne):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new q(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Et.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 Z(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new Z(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 x=0;x<2*Math.PI;x+=Math.PI/2)Et.isBetweenAngle(x,this.startAngle,this.endAngle)&&t.push(x);let e=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const x of t){const f=this.getPointAtAngle(x);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>g&&(g=f.z)}return new Mt({x:e,y:s,z:o},{x:h,y:c,z:g})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=ne,o=0);for(let h=0;h<=t;h++){const c=o+s*(h/t),g=this.getPointAtAngle(c);e.push(g)}return e}transform(t){const e=da.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=da.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),s.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new gn(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(da.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,o={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},h=this.center,c=this.radius;return new q(h.x+c*(s.x*Math.cos(t)+o.x*Math.sin(t)),h.y+c*(s.y*Math.cos(t)+o.y*Math.sin(t)),h.z+c*(s.z*Math.cos(t)+o.z*Math.sin(t)))}get plane(){const t=new Z(this.center).distanceTo(Ba);return new Ds(this.normal,t)}}const da=new Z;class Fi extends Gn{constructor(t,e,s,o=0,h=ne,c=!1,g=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(h-o)%ne==0?(this.startAngle=0,this.endAngle=ne):(this.startAngle=o,this.endAngle=h),this.clockwise=c,this.rotation=g}get center(){return this._center}set center(t){this._center=new q(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.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 Et.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,o=-1/0;for(let h=0;h<=100;h++){const c=this.getPoint(h/100);t=Math.min(t,c.x),e=Math.min(e,c.y),s=Math.max(s,c.x),o=Math.max(o,c.y)}return new _e({x:t,y:e},{x:s,y:o})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(o?s=0:s=e),this.clockwise===!0&&!o&&(s===e?s=-e:s=s-e);const h=this.startAngle+t*s;let c=this.center.x+this.majorAxisRadius*Math.cos(h),g=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const x=Math.cos(this.rotation),f=Math.sin(this.rotation),A=c-this.center.x,b=g-this.center.y;c=A*x-b*f+this.center.x,g=A*f+b*x+this.center.y}return new Tt(c,g)}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 Fi(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Di extends Us{constructor(t,e,s,o,h,c=0,g=ne){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const x=Math.abs(g-c);Math.abs(x-ne)<1e-10||Math.abs(x-2*ne)<1e-10?(this.startAngle=0,this.endAngle=ne):(this.startAngle=c,this.endAngle=g)}get center(){return this._center}set center(t){this._center=new q(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-ne)<1e-10?ne:Et.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 Z(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new Z(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new Z().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get isCircular(){return Fa.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,o=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const c=this.startAngle+h*e,g=this.getPointAtAngle(c),x=g.x-o.x,f=g.y-o.y,A=g.z-o.z;s+=Math.sqrt(x*x+f*f+A*A),o=g}return s}calculateBoundingBox(){if(this.majorAxis.equals(Z.X_AXIS)||this.majorAxis.equals(Z.Y_AXIS)||this.majorAxis.isParallelTo(Z.X_AXIS)||this.majorAxis.isParallelTo(Z.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let x=0;x<2*Math.PI;x+=Math.PI/2)Et.isBetweenAngle(x,this.startAngle,this.endAngle)&&t.push(x);let e=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const x of t){const f=this.getPointAtAngle(x);f.x<e&&(e=f.x),f.y<s&&(s=f.y),f.z<o&&(o=f.z),f.x>h&&(h=f.x),f.y>c&&(c=f.y),f.z>g&&(g=f.z)}return new Mt({x:e,y:s,z:o},{x:h,y:c,z:g})}else{let t=1/0,e=1/0,s=1/0,o=-1/0,h=-1/0,c=-1/0;for(let g=0;g<=100;g++){const x=this.startAngle+this.deltaAngle*(g/100),f=this.getPointAtAngle(x);t=Math.min(t,f.x),e=Math.min(e,f.y),s=Math.min(s,f.z),o=Math.max(o,f.x),h=Math.max(h,f.y),c=Math.max(c,f.z)}return new Mt({x:t,y:e,z:s},{x:o,y:h,z:c})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=ne,o=0);for(let h=0;h<=t;h++){const c=o+s*(h/t),g=this.getPointAtAngle(c);e.push(g)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(o);return new q(this.center.x+h.x,this.center.y+h.y,this.center.z+h.z)}contains(t){const e=new Z(t).sub(this.center),s=e.dot(this.majorAxis),o=e.dot(this.minorAxis),h=s/this.majorAxisRadius,c=o/this.minorAxisRadius;return h*h+c*c<=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 Di(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new Z(this.center).distanceTo(Ba);return new Ds(this.normal,t)}}class _n extends Gn{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 Tt(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 Tt(e.x,e.y)}else{const e=this._vertices[t-1];return new Tt(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 o=this._vertices[s];let h=null;if(s<e-1?h=this._vertices[s+1]:s==e-1&&this.closed&&(h=this._vertices[0]),h)if(o.bulge){const c=new Fn(o,h,o.bulge);t+=c.length}else t+=new Tt(o.x,o.y).distanceTo(h)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new Tt(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new _e().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(o=>s.push(new q().set(o.x,o.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let o=0;o<s;++o){const h=this._vertices[o];if(h.bulge){let c=null;if(o<s-1?c=this._vertices[o+1]:o==s-1&&this.closed&&(c=this._vertices[0]),c){const g=new Fn(h,c,h.bulge).getPoints(t),x=g.length;for(let f=0;f<x;++f){const A=g[f];e.push(new Tt(A.x,A.y))}}}else e.push(new Tt(h.x,h.y)),o==s-1&&this.closed&&e.push(e[0])}return e}}class Ui extends Gn{constructor(t,e){super(),this._start=new Tt(t),this._end=new Tt(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 Tt(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new Tt(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new _e(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 Ui(this._start.clone(),this._end.clone())}}class du extends Gn{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 Tt(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 _e;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(o=>{e.push(new Tt(o.x,o.y))})}),e}}function m0(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var mu={exports:{}};(function(i,t){(function(e){i.exports=e()})(function(){var e={},s=this;new Function("try {return this===window;}catch(e){ return false;}");var o=new Function("try {return this===global;}catch(e){return false;}"),h=new Function("try {return typeof importScripts === 'function';}catch(e){return false;}");if(o()&&h(),o()||h()){var c=s;if(h()){var g=function(x,f){var A=s;return x.split(".").forEach(function(b){A&&(A=A[b])}),A?A[f]:null};onmessage=function(x){if(!(!x.data.className||!x.data.methodName)){var f=g(x.data.className,x.data.methodName);if(!f)return console.error("could not find "+x.data.className+"."+x.data.methodName);postMessage({result:f.apply(null,x.data.args),id:x.data.id})}}}}return function(x,f,A){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var b={},E=function(){return Nt.__string_rec(this,"")};function T(r,n){function a(){}a.prototype=r;var l=new a;for(var u in n)l[u]=n[u];return n.toString!==Object.prototype.toString&&(l.toString=n.toString),l}var O=function(){};b.HxOverrides=O,O.__name__=["HxOverrides"],O.strDate=function(r){var n=r.length;switch(n){case 8:var a=r.split(":"),l=new Date;return l.setTime(0),l.setUTCHours(a[0]),l.setUTCMinutes(a[1]),l.setUTCSeconds(a[2]),l;case 10:var u=r.split("-");return new Date(u[0],u[1]-1,u[2],0,0,0);case 19:var d=r.split(" "),p=d[0].split("-"),_=d[1].split(":");return new Date(p[0],p[1]-1,p[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},O.cca=function(r,n){var a=r.charCodeAt(n);if(a==a)return a},O.substr=function(r,n,a){return n!=null&&n!=0&&a!=null&&a<0?"":(a==null&&(a=r.length),n<0?(n=r.length+n,n<0&&(n=0)):a<0&&(a=r.length+a-n),r.substr(n,a))},O.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var z=function(){};b.Lambda=z,z.__name__=["Lambda"],z.fold=function(r,n,a){for(var l=Xe(r)();l.hasNext();){var u=l.next();a=n(u,a)}return a};var U=function(){this.length=0};b.List=U,U.__name__=["List"],U.prototype={add:function(r){var n=[r];this.h==null?this.h=n:this.q[1]=n,this.q=n,this.length++},pop:function(){if(this.h==null)return null;var r=this.h[0];return this.h=this.h[1],this.h==null&&(this.q=null),this.length--,r},isEmpty:function(){return this.h==null},__class__:U},Math.__name__=["Math"];var F=function(){};b.Reflect=F,F.__name__=["Reflect"],F.field=function(r,n){try{return r[n]}catch(a){return a instanceof Q&&(a=a.val),null}},F.callMethod=function(r,n,a){return n.apply(r,a)},F.fields=function(r){var n=[];if(r!=null){var a=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&a.call(r,l)&&n.push(l)}return n},F.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},F.deleteField=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)?(delete r[n],!0):!1};var dt=function(){};b.Std=dt,dt.__name__=["Std"],dt.string=function(r){return Nt.__string_rec(r,"")},dt.parseFloat=function(r){return parseFloat(r)};var vt=function(){this.b=""};b.StringBuf=vt,vt.__name__=["StringBuf"],vt.prototype={add:function(r){this.b+=dt.string(r)},__class__:vt};var ot=function(){};b.StringTools=ot,ot.__name__=["StringTools"],ot.fastCodeAt=function(r,n){return r.charCodeAt(n)};var W=b.ValueType={__ename__:["ValueType"],__constructs__:["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]};W.TNull=["TNull",0],W.TNull.toString=E,W.TNull.__enum__=W,W.TInt=["TInt",1],W.TInt.toString=E,W.TInt.__enum__=W,W.TFloat=["TFloat",2],W.TFloat.toString=E,W.TFloat.__enum__=W,W.TBool=["TBool",3],W.TBool.toString=E,W.TBool.__enum__=W,W.TObject=["TObject",4],W.TObject.toString=E,W.TObject.__enum__=W,W.TFunction=["TFunction",5],W.TFunction.toString=E,W.TFunction.__enum__=W,W.TClass=function(r){var n=["TClass",6,r];return n.__enum__=W,n.toString=E,n},W.TEnum=function(r){var n=["TEnum",7,r];return n.__enum__=W,n.toString=E,n},W.TUnknown=["TUnknown",8],W.TUnknown.toString=E,W.TUnknown.__enum__=W;var ut=function(){};b.Type=ut,ut.__name__=["Type"],ut.getClassName=function(r){var n=r.__name__;return n==null?null:n.join(".")},ut.getEnumName=function(r){var n=r.__ename__;return n.join(".")},ut.resolveClass=function(r){var n=b[r];return n==null||!n.__name__?null:n},ut.resolveEnum=function(r){var n=b[r];return n==null||!n.__ename__?null:n},ut.createEmptyInstance=function(r){function n(){}return n.prototype=r.prototype,new n},ut.createEnum=function(r,n,a){var l=F.field(r,n);if(l==null)throw new Q("No such constructor "+n);if(F.isFunction(l)){if(a==null)throw new Q("Constructor "+n+" need parameters");return F.callMethod(r,l,a)}if(a!=null&&a.length!=0)throw new Q("Constructor "+n+" does not need parameters");return l},ut.getEnumConstructs=function(r){var n=r.__constructs__;return n.slice()},ut.typeof=function(r){var n=typeof r;switch(n){case"boolean":return W.TBool;case"string":return W.TClass(String);case"number":return Math.ceil(r)==r%2147483648?W.TInt:W.TFloat;case"object":if(r==null)return W.TNull;var a=r.__enum__;if(a!=null)return W.TEnum(a);var l=Nt.getClass(r);return l!=null?W.TClass(l):W.TObject;case"function":return r.__name__||r.__ename__?W.TObject:W.TFunction;case"undefined":return W.TNull;default:return W.TUnknown}};var st=function(){};b["haxe.IMap"]=st,st.__name__=["haxe","IMap"];var Vt=function(r,n){this.high=r,this.low=n};b["haxe._Int64.___Int64"]=Vt,Vt.__name__=["haxe","_Int64","___Int64"],Vt.prototype={__class__:Vt};var Yt=function(){this.buf=new vt,this.cache=[],this.useCache=Yt.USE_CACHE,this.useEnumIndex=Yt.USE_ENUM_INDEX,this.shash=new me,this.scount=0};b["haxe.Serializer"]=Yt,Yt.__name__=["haxe","Serializer"],Yt.prototype={toString:function(){return this.buf.b},serializeString:function(r){var n=this.shash.get(r);if(n!=null){this.buf.b+="R",n==null?this.buf.b+="null":this.buf.b+=""+n;return}this.shash.set(r,this.scount++),this.buf.b+="y",r=encodeURIComponent(r),r.length==null?this.buf.b+="null":this.buf.b+=""+r.length,this.buf.b+=":",r==null?this.buf.b+="null":this.buf.b+=""+r},serializeRef:function(r){for(var n=typeof r,a=0,l=this.cache.length;a<l;){var u=a++,d=this.cache[u];if(typeof d==n&&d==r)return this.buf.b+="r",u==null?this.buf.b+="null":this.buf.b+=""+u,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var n=0,a=F.fields(r);n<a.length;){var l=a[n];++n,this.serializeString(l),this.serialize(F.field(r,l))}this.buf.b+="g"},serialize:function(r){{var n=ut.typeof(r);switch(n[1]){case 0:this.buf.b+="n";break;case 1:var a=r;if(a==0){this.buf.b+="z";return}this.buf.b+="i",a==null?this.buf.b+="null":this.buf.b+=""+a;break;case 2:var l=r;isNaN(l)?this.buf.b+="k":isFinite(l)?(this.buf.b+="d",l==null?this.buf.b+="null":this.buf.b+=""+l):l<0?this.buf.b+="m":this.buf.b+="p";break;case 3:r?this.buf.b+="t":this.buf.b+="f";break;case 6:var u=n[2];if(u==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(u){case Array:var d=0;this.buf.b+="a";for(var p=r.length,_=0;_<p;){var v=_++;r[v]==null?d++:(d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d),d=0),this.serialize(r[v]))}d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d)),this.buf.b+="h";break;case U:this.buf.b+="l";for(var w=r,I=w.h,S=null;I!=null;){var P;S=I[0],I=I[1],P=S,this.serialize(P)}this.buf.b+="h";break;case Date:var k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case me:this.buf.b+="b";for(var M=r,L=M.keys();L.hasNext();){var C=L.next();this.serializeString(C),this.serialize(Yi[C]!=null?M.getReserved(C):M.h[C])}this.buf.b+="h";break;case bt:this.buf.b+="q";for(var B=r,R=B.keys();R.hasNext();){var D=R.next();this.buf.b+=":",D==null?this.buf.b+="null":this.buf.b+=""+D,this.serialize(B.h[D])}this.buf.b+="h";break;case Ot:this.buf.b+="M";for(var V=r,Y=V.keys();Y.hasNext();){var J=Y.next(),H=F.field(J,"__id__");F.deleteField(J,"__id__"),this.serialize(J),J.__id__=H,this.serialize(V.h[J.__id__])}this.buf.b+="h";break;case ke:for(var j=r,K=0,tt=j.length-2,et=new vt,it=Yt.BASE64;K<tt;){var ht=j.get(K++),at=j.get(K++),ct=j.get(K++);et.add(it.charAt(ht>>2)),et.add(it.charAt((ht<<4|at>>4)&63)),et.add(it.charAt((at<<2|ct>>6)&63)),et.add(it.charAt(ct&63))}if(K==tt){var nt=j.get(K++),mt=j.get(K++);et.add(it.charAt(nt>>2)),et.add(it.charAt((nt<<4|mt>>4)&63)),et.add(it.charAt(mt<<2&63))}else if(K==tt+1){var X=j.get(K++);et.add(it.charAt(X>>2)),et.add(it.charAt(X<<4&63))}var gt=et.b;this.buf.b+="s",gt.length==null?this.buf.b+="null":this.buf.b+=""+gt.length,this.buf.b+=":",gt==null?this.buf.b+="null":this.buf.b+=""+gt;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ut.getClassName(u)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ut.getClassName(u)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Nt.__instanceof(r,No)){var It=ut.getClassName(r);this.buf.b+="A",this.serializeString(It)}else if(Nt.__instanceof(r,Co))this.buf.b+="B",this.serializeString(ut.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var Gt=n[2];if(this.useCache){if(this.serializeRef(r))return;this.cache.pop()}this.useEnumIndex?this.buf.b+="j":this.buf.b+="w",this.serializeString(ut.getEnumName(Gt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=dt.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Xt=r.length;this.buf.b+=dt.string(Xt-2);for(var Dt=2;Dt<Xt;){var Kt=Dt++;this.serialize(r[Kt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+dt.string(r))}}},__class__:Yt};var Wt=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=Wt.DEFAULT_RESOLVER;n==null&&(n=ut,Wt.DEFAULT_RESOLVER=n),this.setResolver(n)};b["haxe.Unserializer"]=Wt,Wt.__name__=["haxe","Unserializer"],Wt.initCodes=function(){for(var r=[],n=0,a=Wt.BASE64.length;n<a;){var l=n++;r[Wt.BASE64.charCodeAt(l)]=l}return r},Wt.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(n){return null},resolveEnum:function(n){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,n=!1,a=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=a)break;n=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return n&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var n=this.buf.charCodeAt(this.pos);if(n>=43&&n<58||n==101||n==69)this.pos++;else break}return dt.parseFloat(O.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var n=this.unserialize();if(typeof n!="string")throw new Q("Invalid object key");var a=this.unserialize();r[n]=a}this.pos++},unserializeEnum:function(r,n){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var a=this.readDigits();if(a==0)return ut.createEnum(r,n);for(var l=[];a-- >0;)l.push(this.unserialize());return ut.createEnum(r,n,l)},unserialize:function(){var r=this.get(this.pos++);switch(r){case 110:return null;case 116:return!0;case 102:return!1;case 122:return 0;case 105:return this.readDigits();case 100:return this.readFloat();case 121:var n=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<n)throw new Q("Invalid string length");var a=O.substr(this.buf,this.pos,n);return this.pos+=n,a=decodeURIComponent(a.split("+").join(" ")),this.scache.push(a),a;case 107:return NaN;case 109:return-1/0;case 112:return 1/0;case 97:this.buf;var l=[];for(this.cache.push(l);;){var u=this.buf.charCodeAt(this.pos);if(u==104){this.pos++;break}if(u==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var p={};return this.cache.push(p),this.unserializeObject(p),p;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var v=this.readDigits();if(v<0||v>=this.scache.length)throw new Q("Invalid string reference");return this.scache[v];case 120:throw new Q(this.unserialize());case 99:var w=this.unserialize(),I=this.resolver.resolveClass(w);if(I==null)throw new Q("Class not found "+w);var S=ut.createEmptyInstance(I);return this.cache.push(S),this.unserializeObject(S),S;case 119:var P=this.unserialize(),k=this.resolver.resolveEnum(P);if(k==null)throw new Q("Enum not found "+P);var M=this.unserializeEnum(k,this.unserialize());return this.cache.push(M),M;case 106:var L=this.unserialize(),C=this.resolver.resolveEnum(L);if(C==null)throw new Q("Enum not found "+L);this.pos++;var B=this.readDigits(),R=ut.getEnumConstructs(C)[B];if(R==null)throw new Q("Unknown enum index "+L+"@"+B);var D=this.unserializeEnum(C,R);return this.cache.push(D),D;case 108:var V=new U;for(this.cache.push(V),this.buf;this.buf.charCodeAt(this.pos)!=104;)V.add(this.unserialize());return this.pos++,V;case 98:var Y=new me;for(this.cache.push(Y),this.buf;this.buf.charCodeAt(this.pos)!=104;){var J=this.unserialize();Y.set(J,this.unserialize())}return this.pos++,Y;case 113:var H=new bt;this.cache.push(H),this.buf;for(var j=this.get(this.pos++);j==58;){var K=this.readDigits();H.set(K,this.unserialize()),j=this.get(this.pos++)}if(j!=104)throw new Q("Invalid IntMap format");return H;case 77:var tt=new Ot;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var it;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var ht=O.substr(this.buf,this.pos,19);it=O.strDate(ht),this.pos+=19}else{var at=this.readFloat(),ct=new Date;ct.setTime(at),it=ct}return this.cache.push(it),it;case 115:var nt=this.readDigits(),mt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var X=Wt.CODES;X==null&&(X=Wt.initCodes(),Wt.CODES=X);var gt=this.pos,It=nt&3,Gt;Gt=(nt>>2)*3+(It>=2?It-1:0);for(var Xt=gt+(nt-It),Dt=ke.alloc(Gt),Kt=0;gt<Xt;){var Ie=X[ot.fastCodeAt(mt,gt++)],He=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Ie<<2|He>>4);var ve=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,He<<4|ve>>2);var ge=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,ve<<6|ge)}if(It>=2){var Pe=X[ot.fastCodeAt(mt,gt++)],Ce=X[ot.fastCodeAt(mt,gt++)];if(Dt.set(Kt++,Pe<<2|Ce>>4),It==3){var Ke=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Ce<<4|Ke>>2)}}return this.pos+=nt,this.cache.push(Dt),Dt;case 67:var or=this.unserialize(),$e=this.resolver.resolveClass(or);if($e==null)throw new Q("Class not found "+or);var Ze=ut.createEmptyInstance($e);if(this.cache.push(Ze),Ze.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Ze;case 65:var Qe=this.unserialize(),dr=this.resolver.resolveClass(Qe);if(dr==null)throw new Q("Class not found "+Qe);return dr;case 66:var Nn=this.unserialize(),Qr=this.resolver.resolveEnum(Nn);if(Qr==null)throw new Q("Enum not found "+Nn);return Qr}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Wt};var bt=function(){this.h={}};b["haxe.ds.IntMap"]=bt,bt.__name__=["haxe","ds","IntMap"],bt.__interfaces__=[st],bt.prototype={set:function(r,n){this.h[r]=n},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n|0);return O.iter(r)},__class__:bt};var Ot=function(){this.h={},this.h.__keys__={}};b["haxe.ds.ObjectMap"]=Ot,Ot.__name__=["haxe","ds","ObjectMap"],Ot.__interfaces__=[st],Ot.prototype={set:function(r,n){var a=r.__id__||(r.__id__=++Ot.count);this.h[a]=n,this.h.__keys__[a]=r},keys:function(){var r=[];for(var n in this.h.__keys__)this.h.hasOwnProperty(n)&&r.push(this.h.__keys__[n]);return O.iter(r)},__class__:Ot};var de=b["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};de.Some=function(r){var n=["Some",0,r];return n.__enum__=de,n.toString=E,n},de.None=["None",1],de.None.toString=E,de.None.__enum__=de;var me=function(){this.h={}};b["haxe.ds.StringMap"]=me,me.__name__=["haxe","ds","StringMap"],me.__interfaces__=[st],me.prototype={set:function(r,n){Yi[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return Yi[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,n){this.rh==null&&(this.rh={}),this.rh["$"+r]=n},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return O.iter(r)},arrayKeys:function(){var r=[];for(var n in this.h)this.h.hasOwnProperty(n)&&r.push(n);if(this.rh!=null)for(var n in this.rh)n.charCodeAt(0)==36&&r.push(n.substr(1));return r},__class__:me};var ke=function(r){this.length=r.byteLength,this.b=new Xi(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};b["haxe.io.Bytes"]=ke,ke.__name__=["haxe","io","Bytes"],ke.alloc=function(r){return new ke(new Gs(r))},ke.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:ke};var Jt=b["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};Jt.Blocked=["Blocked",0],Jt.Blocked.toString=E,Jt.Blocked.__enum__=Jt,Jt.Overflow=["Overflow",1],Jt.Overflow.toString=E,Jt.Overflow.__enum__=Jt,Jt.OutsideBounds=["OutsideBounds",2],Jt.OutsideBounds.toString=E,Jt.OutsideBounds.__enum__=Jt,Jt.Custom=function(r){var n=["Custom",3,r];return n.__enum__=Jt,n.toString=E,n};var ae=function(){};b["haxe.io.FPHelper"]=ae,ae.__name__=["haxe","io","FPHelper"],ae.i32ToFloat=function(r){var n=1-(r>>>31<<1),a=r>>>23&255,l=r&8388607;return l==0&&a==0?0:n*(1+Math.pow(2,-23)*l)*Math.pow(2,a-127)},ae.floatToI32=function(r){if(r==0)return 0;var n;r<0?n=-r:n=r;var a=Math.floor(Math.log(n)/.6931471805599453);a<-127?a=-127:a>128&&(a=128);var l=Math.round((n/Math.pow(2,a)-1)*8388608)&8388607;return(r<0?-2147483648:0)|a+127<<23|l},ae.i64ToDouble=function(r,n){var a=1-(n>>>31<<1),l=(n>>20&2047)-1023,u=(n&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return u==0&&l==-1023?0:a*(1+Math.pow(2,-52)*u)*Math.pow(2,l)},ae.doubleToI64=function(r){var n=ae.i64tmp;if(r==0)n.low=0,n.high=0;else{var a;r<0?a=-r:a=r;var l=Math.floor(Math.log(a)/.6931471805599453),u,d=(a/Math.pow(2,l)-1)*4503599627370496;u=Math.round(d);var p=u|0,_=u/4294967296|0;n.low=p,n.high=(r<0?-2147483648:0)|l+1023<<20|_}return n};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};b["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=T(Error.prototype,{__class__:Q});var Nt=function(){};b["js.Boot"]=Nt,Nt.__name__=["js","Boot"],Nt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var a=Nt.__nativeClassName(r);return a!=null?Nt.__resolveNativeClass(a):null},Nt.__string_rec=function(r,n){if(r==null)return"null";if(n.length>=5)return"<...>";var a=typeof r;switch(a=="function"&&(r.__name__||r.__ename__)&&(a="object"),a){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";n+=" ";for(var u=2,d=r.length;u<d;){var p=u++;p!=2?l+=","+Nt.__string_rec(r[p],n):l+=Nt.__string_rec(r[p],n)}return l+")"}var _=r.length,v="[";n+=" ";for(var w=0;w<_;){var I=w++;v+=(I>0?",":"")+Nt.__string_rec(r[I],n)}return v+="]",v}var S;try{S=r.toString}catch(C){return C instanceof Q&&(C=C.val),"???"}if(S!=null&&S!=Object.toString&&typeof S=="function"){var P=r.toString();if(P!="[object Object]")return P}var k=null,M=`{
|
|
3
3
|
`;n+=" ";var L=r.hasOwnProperty!=null;for(var k in r)L&&!r.hasOwnProperty(k)||k=="prototype"||k=="__class__"||k=="__super__"||k=="__interfaces__"||k=="__properties__"||(M.length!=2&&(M+=`,
|
|
4
|
-
`),M+=n+k+" : "+
|
|
5
|
-
`+n+"}",M;case"function":return"<function>";case"string":return r;default:return String(r)}},Me.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var a=r.__interfaces__;if(a!=null)for(var l=0,u=a.length;l<u;){var d=l++,p=a[d];if(p==n||Me.__interfLoop(p,n))return!0}return Me.__interfLoop(r.__super__,n)},Me.__instanceof=function(r,n){if(n==null)return!1;switch(n){case Ou:return(r|0)===r;case vo:return typeof r=="number";case yo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case zu:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||Me.__interfLoop(Me.getClass(r),n))return!0}else if(typeof n=="object"&&Me.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==bo&&r.__name__!=null||n==xo&&r.__ename__!=null?!0:r.__enum__==n}},Me.__nativeClassName=function(r){var n=Me.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},Me.__isNativeObj=function(r){return Me.__nativeClassName(r)!=null},Me.__resolveNativeClass=function(r){return A[r]};var ot=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var a=0;a<n;){var l=a++;this.a[l]=0}this.byteLength=n}};x["js.html.compat.ArrayBuffer"]=ot,ot.__name__=["js","html","compat","ArrayBuffer"],ot.sliceImpl=function(r,n){var a=new Gi(this,r,n==null?null:n-r),l=new Vs(a.byteLength),u=new Gi(l);return u.set(a),l},ot.prototype={slice:function(r,n){return new ot(this.a.slice(r,n))},__class__:ot};var hr=function(r,n,a){if(this.buf=r,n==null?this.offset=0:this.offset=n,a==null?this.length=r.byteLength-this.offset:this.length=a,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(Je.OutsideBounds)};x["js.html.compat.DataView"]=hr,hr.__name__=["js","html","compat","DataView"],hr.prototype={getInt8:function(r){var n=this.buf.a[this.offset+r];return n>=128?n-256:n},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,n){var a=this.getUint16(r,n);return a>=32768?a-65536:a},getUint16:function(r,n){return n?this.buf.a[this.offset+r]|this.buf.a[this.offset+r+1]<<8:this.buf.a[this.offset+r]<<8|this.buf.a[this.offset+r+1]},getInt32:function(r,n){var a=this.offset+r,l=this.buf.a[a++],u=this.buf.a[a++],d=this.buf.a[a++],p=this.buf.a[a++];return n?l|u<<8|d<<16|p<<24:p|d<<8|u<<16|l<<24},getUint32:function(r,n){var a=this.getInt32(r,n);return a<0?a+4294967296:a},getFloat32:function(r,n){return at.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var a=this.getInt32(r,n),l=this.getInt32(r+4,n);return at.i64ToDouble(n?a:l,n?l:a)},setInt8:function(r,n){n<0?this.buf.a[r+this.offset]=n+128&255:this.buf.a[r+this.offset]=n&255},setUint8:function(r,n){this.buf.a[r+this.offset]=n&255},setInt16:function(r,n,a){this.setUint16(r,n<0?n+65536:n,a)},setUint16:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l]=n&255,this.buf.a[l++]=n>>8&255):(this.buf.a[l++]=n>>8&255,this.buf.a[l]=n&255)},setInt32:function(r,n,a){this.setUint32(r,n,a)},setUint32:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l++]=n&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>>24):(this.buf.a[l++]=n>>>24,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n&255)},setFloat32:function(r,n,a){this.setUint32(r,at.floatToI32(n),a)},setFloat64:function(r,n,a){var l=at.doubleToI64(n);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:hr};var nr=function(){};x["js.html.compat.Uint8Array"]=nr,nr.__name__=["js","html","compat","Uint8Array"],nr._new=function(r,n,a){var l;if(typeof r=="number"){l=[];for(var u=0;u<r;){var d=u++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new ot(l)}else if(Me.__instanceof(r,ot)){var p=r;n==null&&(n=0),a==null&&(a=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+a),l.byteLength=l.length,l.byteOffset=n,l.buffer=p}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new ot(l);else throw new Q("TODO "+de.string(r));return l.subarray=nr._subarray,l.set=nr._set,l},nr._set=function(r,n){var a=this;if(Me.__instanceof(r.buffer,ot)){var l=r;if(r.byteLength+n>a.byteLength)throw new Q("set() outside of range");for(var u=0,d=r.byteLength;u<d;){var p=u++;a[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>a.byteLength)throw new Q("set() outside of range");for(var v=0,w=_.length;v<w;){var I=v++;a[I+n]=_[I]}}else throw new Q("TODO")},nr._subarray=function(r,n){var a=this,l=nr._new(a.slice(r,n));return l.byteOffset=r,l};var ke=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&ke.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=ke,ke.__name__=["promhx","base","AsyncBase"],ke.link=function(r,n,a){r._update.push({async:n,linkf:function(l){n.handleResolve(a(l))}}),ke.immediateLinkUpdate(r,n,a)},ke.immediateLinkUpdate=function(r,n,a){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(a(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},ke.linkAll=function(r,n){for(var a=function(d,p,_){if(d.length==0||ke.allFulfilled(d)){for(var v,w=[],I=Xt(r)();I.hasNext();){var S=I.next();w.push(S==p?_:S._val)}v=w,n.handleResolve(v)}},l=Xt(r)();l.hasNext();){var u=l.next();u._update.push({async:n,linkf:function(d,p,_){return function(v){d(p,_,v)}}(a,function(d){for(var p,_=[],v=Xt(r)();v.hasNext();){var w=v.next();w!=u&&_.push(w)}return p=_,p}(),u)})}ke.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],v=Xt(r)();v.hasNext();){var w=v.next();_.push(w._val)}return p=_,p}())},ke.pipeLink=function(r,n,a){var l=!1,u=function(d){if(!l){l=!0;var p=a(d);p._update.push({async:n,linkf:Tt(n,n.handleResolve)}),ke.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:u}),r._resolved&&!r._pending)try{u(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},ke.allResolved=function(r){for(var n=Xt(r)();n.hasNext();){var a=n.next();if(!a._resolved)return!1}return!0},ke.allFulfilled=function(r){for(var n=Xt(r)();n.hasNext();){var a=n.next();if(!a._fulfilled)return!1}return!0},ke.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,this},isResolved:function(){return this._resolved},isErrored:function(){return this._errored},isErrorHandled:function(){return this._error.length>0},isErrorPending:function(){return this._errorPending},isFulfilled:function(){return this._fulfilled},isPending:function(){return this._pending},handleResolve:function(r){this._resolve(r)},_resolve:function(r){var n=this;this._pending?Se.enqueue(function(a,l){return function(){a(l)}}(Tt(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,Se.queue.add(function(){n._val=r;for(var a=0,l=n._update;a<l.length;){var u=l[a];++a;try{u.linkf(r)}catch(d){d instanceof Q&&(d=d.val),u.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),Se.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,a=function(l){if(n._error.length>0)for(var u=0,d=n._error;u<d.length;){var p=d[u];++u,p(l)}else if(n._update.length>0)for(var _=0,v=n._update;_<v.length;){var w=v[_];++_,w.async.handleError(l)}else throw new Q(l);n._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,Se.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),a(l)}else a(r)}),Se.continueOnNextLoop())},then:function(r){var n=new ke(null);return ke.link(this,n,r),n},unlink:function(r){var n=this;Se.queue.add(function(){n._update=n._update.filter(function(a){return a.async!=r})}),Se.continueOnNextLoop()},isLinked:function(r){for(var n=!1,a=0,l=this._update;a<l.length;){var u=l[a];if(++a,u.async==r)return!0}return n},__class__:ke};var yn=g.promhx.Deferred=function(){ke.call(this)};x["promhx.Deferred"]=yn,yn.__name__=["promhx","Deferred"],yn.__super__=ke,yn.prototype=T(ke.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pt(this)},stream:function(){return new He(this)},publicStream:function(){return new Mr(this)},__class__:yn});var pt=g.promhx.Promise=function(r){ke.call(this,r),this._rejected=!1};x["promhx.Promise"]=pt,pt.__name__=["promhx","Promise"],pt.whenAll=function(r){var n=new pt(null);return ke.linkAll(r,n),n},pt.promise=function(r){var n=new pt;return n.handleResolve(r),n},pt.__super__=ke,pt.prototype=T(ke.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var n="Promise has already been resolved";throw new Q(bn.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pt(null);return ke.link(this,n,r),n},unlink:function(r){var n=this;Se.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var a="Downstream Promise is not fullfilled";n.handleError(bn.DownstreamNotFullfilled(a))}}),Se.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pt(null);return ke.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pt;return this.catchError(function(a){var l=r(a);l.then(Tt(n,n._resolve))}),this.then(Tt(n,n._resolve)),n},__class__:pt});var He=g.promhx.Stream=function(r){ke.call(this,r),this._end_promise=new pt};x["promhx.Stream"]=He,He.__name__=["promhx","Stream"],He.foreach=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.handleResolve(l)}return n.end(),n},He.wheneverAll=function(r){var n=new He(null);return ke.linkAll(r,n),n},He.concatAll=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.concat(l)}return n},He.mergeAll=function(r){for(var n=new He(null),a=Xt(r)();a.hasNext();){var l=a.next();n.merge(l)}return n},He.stream=function(r){var n=new He(null);return n.handleResolve(r),n},He.__super__=ke,He.prototype=T(ke.prototype,{then:function(r){var n=new He(null);return ke.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(a){n.end()}}),n},detachStream:function(r){for(var n=[],a=!1,l=0,u=this._update;l<u.length;){var d=u[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),a=!0):n.push(d)}return this._update=n,a},first:function(){var r=new pt(null);return this.then(function(n){r._resolved||r.handleResolve(n)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var n=new He(null);return ke.pipeLink(this,n,r),this._end_promise.then(function(a){n.end()}),n},errorPipe:function(r){var n=new He(null);return this.catchError(function(a){var l=r(a);l.then(Tt(n,n._resolve)),l._end_promise.then((Vi=n._end_promise,Tt(Vi,Vi._resolve)))}),this.then(Tt(n,n._resolve)),this._end_promise.then(function(a){n.end()}),n},handleEnd:function(){if(this._pending)Se.queue.add(Tt(this,this.handleEnd)),Se.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=dt.Some(this._val):r=dt.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return Se.queue.add(Tt(this,this.handleEnd)),Se.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new He(null);return this._update.push({async:n,linkf:function(a){r(a)&&n.handleResolve(a)}}),ke.immediateLinkUpdate(this,n,function(a){return a}),n},concat:function(r){var n=new He(null);return this._update.push({async:n,linkf:Tt(n,n.handleResolve)}),ke.immediateLinkUpdate(this,n,function(a){return a}),this._end_promise.then(function(a){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new He(null);return this._update.push({async:n,linkf:Tt(n,n.handleResolve)}),r._update.push({async:n,linkf:Tt(n,n.handleResolve)}),ke.immediateLinkUpdate(this,n,function(a){return a}),ke.immediateLinkUpdate(r,n,function(a){return a}),n},__class__:He});var Mr=g.promhx.PublicStream=function(r){He.call(this,r)};x["promhx.PublicStream"]=Mr,Mr.__name__=["promhx","PublicStream"],Mr.publicstream=function(r){var n=new Mr(null);return n.handleResolve(r),n},Mr.__super__=He,Mr.prototype=T(He.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Mr});var Se=function(){};x["promhx.base.EventLoop"]=Se,Se.__name__=["promhx","base","EventLoop"],Se.enqueue=function(r){Se.queue.add(r),Se.continueOnNextLoop()},Se.set_nextLoop=function(r){if(Se.nextLoop!=null)throw new Q("nextLoop has already been set");return Se.nextLoop=r,Se.nextLoop},Se.queueEmpty=function(){return Se.queue.isEmpty()},Se.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=Se.queue.pop())!=null;)n();return Se.queue.isEmpty()},Se.clear=function(){Se.queue=new U},Se.f=function(){var r=Se.queue.pop();r!=null&&r(),Se.queue.isEmpty()||Se.continueOnNextLoop()},Se.continueOnNextLoop=function(){Se.nextLoop!=null?Se.nextLoop(Se.f):setImmediate(Se.f)};var bn=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};bn.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=bn,n.toString=E,n},bn.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=bn,n.toString=E,n};var Fs=function(){};x["verb.Verb"]=Fs,Fs.__name__=["verb","Verb"],Fs.main=function(){b.log("verb 2.1.0")};var $=function(){};x["verb.core.ArrayExtensions"]=$,$.__name__=["verb","core","ArrayExtensions"],$.alloc=function(r,n){if(!(n<0))for(;r.length<n;)r.push(null)},$.reversed=function(r){var n=r.slice();return n.reverse(),n},$.last=function(r){return r[r.length-1]},$.first=function(r){return r[0]},$.spliceAndInsert=function(r,n,a,l){r.splice(n,a),r.splice(n,0,l)},$.left=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(0,n)},$.right=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n)},$.rightWithPivot=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n-1)},$.unique=function(r,n){if(r.length==0)return[];for(var a=[r.pop()];r.length>0;){for(var l=r.pop(),u=!0,d=0;d<a.length;){var p=a[d];if(++d,n(l,p)){u=!1;break}}u&&a.push(l)}return a};var Be=function(){};x["verb.core.Binomial"]=Be,Be.__name__=["verb","core","Binomial"],Be.get=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;if(n>r-n&&(n=r-n),Be.memo_exists(r,n))return Be.get_memo(r,n);for(var a=1,l=r,u=1,d=n+1;u<d;){var p=u++;if(Be.memo_exists(l,p)){r--,a=Be.get_memo(l,p);continue}a*=r--,a/=p,Be.memoize(l,p,a)}return a},Be.get_no_memo=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;n>r-n&&(n=r-n);for(var a=1,l=1,u=n+1;l<u;){var d=l++;a*=r--,a/=d}return a},Be.memo_exists=function(r,n){return Be.memo.h.hasOwnProperty(r)&&Be.memo.h[r].h.hasOwnProperty(n)},Be.get_memo=function(r,n){return Be.memo.h[r].h[n]},Be.memoize=function(r,n,a){Be.memo.h.hasOwnProperty(r)||Be.memo.set(r,new xe),Be.memo.h[r].h[n]=a};var Et=g.core.BoundingBox=function(r){this.max=null,this.min=null,this.dim=3,this.initialized=!1,r!=null&&this.addRange(r)};x["verb.core.BoundingBox"]=Et,Et.__name__=["verb","core","BoundingBox"],Et.intervalsOverlap=function(r,n,a,l,u){u==null&&(u=-1);var d;u<-.5?d=re.TOLERANCE:d=u;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,v=Math.min(a,l)-d,w=Math.max(a,l)+d;return p>=v&&p<=w||_>=v&&_<=w||v>=p&&v<=_||w>=p&&w<=_},Et.prototype={fromPoint:function(r){return new Et([r])},add:function(r){if(!this.initialized)return this.dim=r.length,this.min=r.slice(0),this.max=r.slice(0),this.initialized=!0,this;for(var n=0,a=this.dim;n<a;){var l=n++;r[l]>this.max[l]&&(this.max[l]=r[l]),r[l]<this.min[l]&&(this.min[l]=r[l])}return this},addRange:function(r){for(var n=r.length,a=0;a<n;){var l=a++;this.add(r[l])}return this},contains:function(r,n){return n==null&&(n=-1),this.initialized?this.intersects(new Et([r]),n):!1},intersects:function(r,n){if(n==null&&(n=-1),!this.initialized||!r.initialized)return!1;for(var a=this.min,l=this.max,u=r.min,d=r.max,p=0,_=this.dim;p<_;){var v=p++;if(!Et.intervalsOverlap(a[v],l[v],u[v],d[v],n))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,n=0,a=0,l=this.dim;a<l;){var u=a++,d=this.getAxisLength(u);d>r&&(r=d,n=u)}return n},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,n){if(!this.initialized)return null;var a=this.min,l=this.max,u=r.min,d=r.max;if(!this.intersects(r,n))return null;for(var p=[],_=[],v=0,w=this.dim;v<w;){var I=v++;p.push(Math.min(l[I],d[I])),_.push(Math.max(a[I],u[I]))}return new Et([_,p])},__class__:Et};var re=g.core.Constants=function(){};x["verb.core.Constants"]=re,re.__name__=["verb","core","Constants"];var Ze=g.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Ze,Ze.__name__=["verb","core","SerializableBase"],Ze.prototype={serialize:function(){var r=new Ye;return r.serialize(this),r.toString()},__class__:Ze};var jn=g.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=jn,jn.__name__=["verb","core","Plane"],jn.__super__=Ze,jn.prototype=T(Ze.prototype,{__class__:jn});var xn=g.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=xn,xn.__name__=["verb","core","Ray"],xn.__super__=Ze,xn.prototype=T(Ze.prototype,{__class__:xn});var je=g.core.NurbsCurveData=function(r,n,a){this.degree=r,this.controlPoints=a,this.knots=n};x["verb.core.NurbsCurveData"]=je,je.__name__=["verb","core","NurbsCurveData"],je.__super__=Ze,je.prototype=T(Ze.prototype,{__class__:je});var et=g.core.NurbsSurfaceData=function(r,n,a,l,u){this.degreeU=r,this.degreeV=n,this.knotsU=a,this.knotsV=l,this.controlPoints=u};x["verb.core.NurbsSurfaceData"]=et,et.__name__=["verb","core","NurbsSurfaceData"],et.__super__=Ze,et.prototype=T(Ze.prototype,{__class__:et});var qt=g.core.MeshData=function(r,n,a,l){this.faces=r,this.points=n,this.normals=a,this.uvs=l};x["verb.core.MeshData"]=qt,qt.__name__=["verb","core","MeshData"],qt.empty=function(){return new qt([],[],[],[])},qt.__super__=Ze,qt.prototype=T(Ze.prototype,{__class__:qt});var Gn=g.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=Gn,Gn.__name__=["verb","core","PolylineData"],Gn.__super__=Ze,Gn.prototype=T(Ze.prototype,{__class__:Gn});var Wn=g.core.VolumeData=function(r,n,a,l,u,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=a,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=p};x["verb.core.VolumeData"]=Wn,Wn.__name__=["verb","core","VolumeData"],Wn.__super__=Ze,Wn.prototype=T(Ze.prototype,{__class__:Wn});var tt=g.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=tt,tt.__name__=["verb","core","Pair"],tt.prototype={__class__:tt};var wt=g.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=wt,wt.__name__=["verb","core","Interval"],wt.prototype={__class__:wt};var Kr=g.core.CurveCurveIntersection=function(r,n,a,l){this.point0=r,this.point1=n,this.u0=a,this.u1=l};x["verb.core.CurveCurveIntersection"]=Kr,Kr.__name__=["verb","core","CurveCurveIntersection"],Kr.prototype={__class__:Kr};var Hn=g.core.CurveSurfaceIntersection=function(r,n,a,l){this.u=r,this.uv=n,this.curvePoint=a,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=Hn,Hn.__name__=["verb","core","CurveSurfaceIntersection"],Hn.prototype={__class__:Hn};var Nr=g.core.MeshIntersectionPoint=function(r,n,a,l,u){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=n,this.point=a,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=Nr,Nr.__name__=["verb","core","MeshIntersectionPoint"],Nr.prototype={__class__:Nr};var qn=g.core.PolylineMeshIntersection=function(r,n,a,l,u){this.point=r,this.u=n,this.uv=a,this.polylineIndex=l,this.faceIndex=u};x["verb.core.PolylineMeshIntersection"]=qn,qn.__name__=["verb","core","PolylineMeshIntersection"],qn.prototype={__class__:qn};var Yn=g.core.SurfaceSurfaceIntersectionPoint=function(r,n,a,l){this.uv0=r,this.uv1=n,this.point=a,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=Yn,Yn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Yn.prototype={__class__:Yn};var Xn=g.core.TriSegmentIntersection=function(r,n,a,l){this.point=r,this.s=n,this.t=a,this.p=l};x["verb.core.TriSegmentIntersection"]=Xn,Xn.__name__=["verb","core","TriSegmentIntersection"],Xn.prototype={__class__:Xn};var wn=g.core.CurveTriPoint=function(r,n,a){this.u=r,this.point=n,this.uv=a};x["verb.core.CurveTriPoint"]=wn,wn.__name__=["verb","core","CurveTriPoint"],wn.prototype={__class__:wn};var Gt=function(r,n,a,l,u){u==null&&(u=!1),l==null&&(l=-1),this.uv=a,this.point=r,this.normal=n,this.id=l,this.degen=u};x["verb.core.SurfacePoint"]=Gt,Gt.__name__=["verb","core","SurfacePoint"],Gt.fromUv=function(r,n){return new Gt(null,null,[r,n])},Gt.prototype={__class__:Gt};var Us=g.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=Us,Us.__name__=["verb","core","CurvePoint"],Us.prototype={__class__:Us};var Kn=g.core.KdTree=function(r,n){this.dim=3,this.points=r,this.distanceFunction=n,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};x["verb.core.KdTree"]=Kn,Kn.__name__=["verb","core","KdTree"],Kn.prototype={buildTree:function(r,n,a){var l=n%this.dim,u,d;return r.length==0?null:r.length==1?new Sn(r[0],l,a):(r.sort(function(p,_){var v=p.point[l]-_.point[l];return v==0?0:v>0?1:-1}),u=Math.floor(r.length/2),d=new Sn(r[u],l,a),d.left=this.buildTree(r.slice(0,u),n+1,d),d.right=this.buildTree(r.slice(u+1),n+1,d),d)},nearest:function(r,n,a){var l=this,u=new $n(function(S){return-S.item1}),d,p=null;p=function(S){for(var P,k=S.dimension,M=l.distanceFunction(r,S.kdPoint.point),L,C=[],B=0,R=l.dim;B<R;)B++,C.push(0);L=C;for(var F,V,q=function(K,ee){u.push(new tt(K,ee)),u.size()>n&&u.pop()},J=0,H=l.dim;J<H;){var j=J++;j==S.dimension?L[j]=r[j]:L[j]=S.kdPoint.point[j]}if(F=l.distanceFunction(L,S.kdPoint.point),S.right==null&&S.left==null){(u.size()<n||M<u.peek().item1)&&q(S,M);return}S.right==null?P=S.left:S.left==null?P=S.right:r[k]<S.kdPoint.point[k]?P=S.left:P=S.right,p(P),(u.size()<n||M<u.peek().item1)&&q(S,M),(u.size()<n||Math.abs(F)<u.peek().item1)&&(P==S.left?V=S.right:V=S.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,u.push(new tt(null,a));d(this.root);for(var v=[],w=0;w<n;){var I=w++;u.content[I].item0!=null&&v.push(new tt(u.content[I].item0.kdPoint,u.content[I].item1))}return v},__class__:Kn};var $n=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=$n,$n.__name__=["verb","core","BinaryHeap"],$n.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],n=this.content.pop();return this.content.length>0&&(this.content[0]=n,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var n=this.content.length,a=0;a<n;){var l=a++;if(this.content[l]==r){var u=this.content.pop();l!=n-1&&(this.content[l]=u,this.scoreFunction(u)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var n=this.content[r];r>0;){var a=Math.floor((r+1)/2)-1,l=this.content[a];if(this.scoreFunction(n)<this.scoreFunction(l))this.content[a]=n,this.content[r]=l,r=a;else break}},sinkDown:function(r){for(var n=this.content.length,a=this.content[r],l=this.scoreFunction(a);;){var u=(r+1)*2,d=u-1,p=-1,_=0;if(d<n){var v=this.content[d];_=this.scoreFunction(v),_<l&&(p=d)}if(u<n){var w=this.content[u],I=this.scoreFunction(w);I<(p==-1?l:_)&&(p=u)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=a,r=p;else break}},__class__:$n};var An=g.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=An,An.__name__=["verb","core","KdPoint"],An.prototype={__class__:An};var Sn=g.core.KdNode=function(r,n,a){this.kdPoint=r,this.left=null,this.right=null,this.parent=a,this.dimension=n};x["verb.core.KdNode"]=Sn,Sn.__name__=["verb","core","KdNode"],Sn.prototype={__class__:Sn};var ur=function(){};x["verb.eval.IBoundingBoxTree"]=ur,ur.__name__=["verb","eval","IBoundingBoxTree"],ur.prototype={__class__:ur};var sr=function(r,n){this._boundingBox=null,this._curve=r,n==null&&(n=m.domain(this._curve.knots)/64),this._knotTol=n};x["verb.core.LazyCurveBoundingBoxTree"]=sr,sr.__name__=["verb","core","LazyCurveBoundingBoxTree"],sr.__interfaces__=[ur],sr.prototype={split:function(){var r=$.first(this._curve.knots),n=$.last(this._curve.knots),a=n-r,l=lt.curveSplit(this._curve,(n+r)/2+a*.1*Math.random());return new tt(new sr(l[0],this._knotTol),new sr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Et(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:sr};var ir=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var a=[],l=0,u=r.faces.length;l<u;){var d=l++;a.push(d)}n=a}this._faceIndices=n};x["verb.core.LazyMeshBoundingBoxTree"]=ir,ir.__name__=["verb","core","LazyMeshBoundingBoxTree"],ir.__interfaces__=[ur],ir.prototype={split:function(){var r=rt.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=$.left(r),a=$.right(r);return new tt(new ir(this._mesh,n),new ir(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=rt.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:ir};var ar=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new wt(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=ar,ar.__name__=["verb","core","LazyPolylineBoundingBoxTree"],ar.__interfaces__=[ur],ar.prototype={split:function(){var r=this._interval.min,n=this._interval.max,a=r+Math.ceil((n-r)/2),l=new wt(r,a),u=new wt(a,n);return new tt(new ar(this._polyline,l),new ar(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Et(this._polyline.points)),this._boundingBox},yield:function(){return this._interval.min},indivisible:function(r){return this._interval.max-this._interval.min==1},empty:function(){return this._interval.max-this._interval.min==0},__class__:ar};var Cr=function(r,n,a,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,a==null&&(a=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Cr,Cr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Cr.__interfaces__=[ur],Cr.prototype={split:function(){var r,n;this._splitV?(r=$.first(this._surface.knotsV),n=$.last(this._surface.knotsV)):(r=$.first(this._surface.knotsU),n=$.last(this._surface.knotsU));var a=(r+n)/2,l=lt.surfaceSplit(this._surface,a,this._splitV);return new tt(new Cr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Cr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Et;for(var r=0,n=this._surface.controlPoints;r<n.length;){var a=n[r];++r,this._boundingBox.addRange(N.dehomogenize1d(a))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Cr};var Ce=g.core.Mat=function(){};x["verb.core.Mat"]=Ce,Ce.__name__=["verb","core","Mat"],Ce.mul=function(r,n){for(var a=[],l=0,u=n.length;l<u;){var d=l++;a.push(m.mul(r,n[d]))}return a},Ce.mult=function(r,n){var a,l,u,d,p,_,v,w;a=r.length,l=n.length,u=n[0].length,d=[];for(var I=a-1,S=0,P=0;I>=0;){for(p=[],_=r[I],P=u-1;P>=0;){for(v=_[l-1]*n[l-1][P],S=l-2;S>=1;)w=S-1,v+=_[S]*n[S][P]+_[w]*n[w][P],S-=2;S==0&&(v+=_[0]*n[0][P]),p[P]=v,P--}d[I]=p,I--}return d},Ce.add=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.add(r[d],n[d]))}return a},Ce.div=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.div(r[d],n))}return a},Ce.sub=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.sub(r[d],n[d]))}return a},Ce.dot=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.dot(r[d],n))}return a},Ce.identity=function(r){for(var n=m.zeros2d(r,r),a=0;a<r;){var l=a++;n[l][l]=1}return n},Ce.transpose=function(r){if(r.length==0)return[];for(var n=[],a=0,l=r[0].length;a<l;){var u=a++;n.push(function(d){for(var p,_=[],v=0,w=r.length;v<w;){var I=v++;_.push(r[I][u])}return p=_,p}())}return n},Ce.solve=function(r,n){return Ce.LUsolve(Ce.LU(r),n)},Ce.LUsolve=function(r,n){var a,l,u=r.LU,d=u.length,p=n.slice(),_=r.P,v,w,I;for(a=d-1;a!=-1;)p[a]=n[a],--a;for(a=0;a<d;){for(v=_[a],_[a]!=a&&(I=p[a],p[a]=p[v],p[v]=I),w=u[a],l=0;l<a;)p[a]-=p[l]*w[l],++l;++a}for(a=d-1;a>=0;){for(w=u[a],l=a+1;l<d;)p[a]-=p[l]*w[l],++l;p[a]/=w[a],--a}return p},Ce.LU=function(r){for(var n,a,l,u,d,p,_,v,w,I=[],S=0,P=r.length;S<P;){var k=S++;I.push(r[k].slice())}r=I;var M=r.length,L=M-1,C=[];for(l=0;l<M;){for(_=l,p=r[l],w=Math.abs(p[l]),a=l+1;a<M;)u=Math.abs(r[a][l]),w<u&&(w=u,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=p,p=r[l]),d=p[l],n=l+1;n<M;)r[n][l]/=d,++n;for(n=l+1;n<M;){for(v=r[n],a=l+1;a<L;)v[a]-=v[l]*p[a],++a,v[a]-=v[l]*p[a],++a;a==L&&(v[a]-=v[l]*p[a]),++n}++l}return new Zn(r,C)};var Zn=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=Zn,Zn.__name__=["verb","core","_Mat","LUDecomp"],Zn.prototype={__class__:Zn};var rt=g.core.Mesh=function(){};x["verb.core.Mesh"]=rt,rt.__name__=["verb","core","Mesh"],rt.getTriangleNorm=function(r,n){var a=r[n[0]],l=r[n[1]],u=r[n[2]],d=m.sub(l,a),p=m.sub(u,a),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},rt.makeMeshAabb=function(r,n){for(var a=new Et,l=0;l<n.length;){var u=n[l];++l,a.add(r.points[r.faces[u][0]]),a.add(r.points[r.faces[u][1]]),a.add(r.points[r.faces[u][2]])}return a},rt.sortTrianglesOnLongestAxis=function(r,n,a){for(var l=r.getLongestAxis(),u=[],d=0;d<a.length;){var p=a[d];++d;var _=rt.getMinCoordOnAxis(n.points,n.faces[p],l);u.push(new tt(_,p))}u.sort(function(P,k){var M=P.item0,L=k.item0;return M==L?0:M>L?1:-1});for(var v=[],w=0,I=u.length;w<I;){var S=w++;v.push(u[S].item1)}return v},rt.getMinCoordOnAxis=function(r,n,a){for(var l=1/0,u=0;u<3;){var d=u++,p=r[n[d]][a];p<l&&(l=p)}return l},rt.getTriangleCentroid=function(r,n){for(var a=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var p=d++;a[p]+=r[n[u]][p]}for(var _=0;_<3;){var v=_++;a[v]/=3}return a},rt.triangleUVFromPoint=function(r,n,a){var l=r.faces[n],u=r.points[l[0]],d=r.points[l[1]],p=r.points[l[2]],_=r.uvs[l[0]],v=r.uvs[l[1]],w=r.uvs[l[2]],I=m.sub(u,a),S=m.sub(d,a),P=m.sub(p,a),k=m.norm(m.cross(m.sub(u,d),m.sub(u,p))),M=m.norm(m.cross(S,P))/k,L=m.norm(m.cross(P,I))/k,C=m.norm(m.cross(I,S))/k;return m.add(m.mul(M,_),m.add(m.mul(L,v),m.mul(C,w)))};var Lr=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var a=[],l=0,u=r.faces.length;l<u;){var d=l++;a.push(d)}n=a}if(this._boundingBox=rt.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=rt.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=$.left(p),v=$.right(p);this._children=new tt(new Lr(r,_),new Lr(r,v))};x["verb.core.MeshBoundingBoxTree"]=Lr,Lr.__name__=["verb","core","MeshBoundingBoxTree"],Lr.__interfaces__=[ur],Lr.prototype={split:function(){return this._children},boundingBox:function(){return this._boundingBox},yield:function(){return this._face},indivisible:function(r){return this._children==null},empty:function(){return this._empty},__class__:Lr};var Yt=g.core.Minimizer=function(){};x["verb.core.Minimizer"]=Yt,Yt.__name__=["verb","core","Minimizer"],Yt.uncmin=function(r,n,a,l,u){a==null&&(a=1e-8),l==null&&(l=function(J){return Yt.numericalGradient(r,J)}),u==null&&(u=1e3),n=n.slice(0);var d=n.length,p=r(n),_=p,v;if(isNaN(p))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,re.EPSILON);var w,I,S,P=Ce.identity(d),k=0,M=[],L,C,B,R,F,V,q="";for(I=l(n);k<u;){if(!m.all(m.finite(I))){q="Gradient has Infinity or NaN";break}if(w=m.neg(Ce.dot(P,I)),!m.all(m.finite(w))){q="Search direction has Infinity or NaN";break}if(V=m.norm(w),V<a){q="Newton step smaller than tol";break}for(F=1,v=m.dot(I,w),L=n;k<u&&!(F*V<a);){if(M=m.mul(F,w),L=m.add(n,M),_=r(L),_-p>=.1*F*v||isNaN(_)){F*=.5,++k;continue}break}if(F*V<a){q="Line search step size smaller than tol";break}if(k==u){q="maxit reached during line search";break}S=l(L),C=m.sub(S,I),R=m.dot(C,M),B=Ce.dot(P,C),P=Ce.sub(Ce.add(P,Ce.mul((R+m.dot(C,B))/(R*R),Yt.tensor(M,M))),Ce.div(Ce.add(Yt.tensor(B,M),Yt.tensor(M,B)),R)),n=L,p=_,I=S,++k}return new Qn(n,p,I,P,k,q)},Yt.numericalGradient=function(r,n){var a=n.length,l=r(n);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var u=n.slice(0),d,p,_=[],v,w=.001,I,S,P,k=0,M,L,C,B=0;B<a;)for(var R=B++,F=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(u[R]=n[R]+F,d=r(u),u[R]=n[R]-F,p=r(u),u[R]=n[R],isNaN(d)||isNaN(p)){F/=16;continue}if(_[R]=(d-p)/(2*F),I=n[R]-F,S=n[R],P=n[R]+F,M=(d-l)/F,L=(l-p)/F,C=m.max([Math.abs(_[R]),Math.abs(l),Math.abs(d),Math.abs(p),Math.abs(I),Math.abs(S),Math.abs(P),1e-8]),v=Math.min(m.max([Math.abs(M-_[R]),Math.abs(L-_[R]),Math.abs(M-L)])/C,F/C),v>w)F/=16;else break}return _},Yt.tensor=function(r,n){for(var a=r.length,l=n.length,u=[],d,p,_=a-1;_>=0;){d=[],p=r[_];for(var v=l-1;v>=3;)d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v;for(;v>=0;)d[v]=p*n[v],--v;u[_]=d,_--}return u};var Qn=function(r,n,a,l,u,d){this.solution=r,this.value=n,this.gradient=a,this.invHessian=l,this.iterations=u,this.message=d};x["verb.core.MinimizationResult"]=Qn,Qn.__name__=["verb","core","MinimizationResult"],Qn.prototype={__class__:Qn};var In=function(){};x["verb.core.ISerializable"]=In,In.__name__=["verb","core","ISerializable"],In.prototype={__class__:In};var Ui=g.core.Deserializer=function(){};x["verb.core.Deserializer"]=Ui,Ui.__name__=["verb","core","Deserializer"],Ui.deserialize=function(r){var n=new We(r),a=n.unserialize();return a};var kt=g.core.Trig=function(){};x["verb.core.Trig"]=kt,kt.__name__=["verb","core","Trig"],kt.isPointInPlane=function(r,n,a){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<a},kt.distToSegment=function(r,n,a){var l=kt.segmentClosestPoint(n,r,a,0,1);return m.dist(n,l.pt)},kt.rayClosestPoint=function(r,n,a){var l=m.sub(r,n),u=m.dot(l,a),d=m.add(n,m.mul(u,a));return d},kt.distToRay=function(r,n,a){var l=kt.rayClosestPoint(r,n,a),u=m.sub(l,r);return m.norm(u)},kt.threePointsAreFlat=function(r,n,a,l){var u=m.sub(n,r),d=m.sub(a,r),p=m.cross(u,d),_=m.dot(p,p);return _<l},kt.segmentClosestPoint=function(r,n,a,l,u){var d=m.sub(a,n),p=m.norm(d);if(p<re.EPSILON)return{u:l,pt:n};var _=n,v=m.mul(1/p,d),w=m.sub(r,_),I=m.dot(w,v);return I<0?{u:l,pt:n}:I>p?{u,pt:a}:{u:l+(u-l)*I/p,pt:m.add(_,m.mul(I,v))}};var m=g.core.Vec=function(){};x["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,n){return Math.acos(m.dot(r,n)/(m.norm(r)*m.norm(n)))},m.positiveAngleBetween=function(r,n,a){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,I=Math.atan2(v,w),S=m.dot(a,l);return Math.abs(S)<re.EPSILON||S>0?I:-I},m.signedAngleBetween=function(r,n,a){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,I=Math.atan2(v,w),S=m.dot(a,l);return S>0?I:2*Math.PI-I},m.angleBetweenNormalized2d=function(r,n){var a=r[0]*n[1]-r[1]*n[0];return Math.atan2(a,m.dot(r,n))},m.domain=function(r){return $.last(r)-$.first(r)},m.range=function(r){for(var n=[],a=0,l=0;l<r;)l++,n.push(a),a+=1;return n},m.span=function(r,n,a){if(a==null)return[];if(a<re.EPSILON)return[];if(r>n&&a>0)return[];if(n>r&&a<0)return[];for(var l=[],u=r;u<=n;)l.push(u),u+=a;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return z.fold(r,function(n,a){return Math.min(n,a)},1/0)},m.max=function(r){return z.fold(r,function(n,a){return Math.max(n,a)},-1/0)},m.all=function(r){return z.fold(r,function(n,a){return a&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,a){return m.add(r,m.mul(a,n))},m.lerp=function(r,n,a){return m.add(m.mul(r,n),m.mul(1-r,a))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,n){return[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]},m.dist=function(r,n){return m.norm(m.sub(r,n))},m.distSquared=function(r,n){return m.normSquared(m.sub(r,n))},m.sum=function(r){return z.fold(r,function(n,a){return a+n},0)},m.addAll=function(r){var n=Xt(r)();if(!n.hasNext())return null;var a=n.next().length;return z.fold(r,function(l,u){return m.add(u,l)},m.rep(a,0))},m.addAllMutate=function(r){for(var n=r[0],a=1,l=r.length;a<l;){var u=a++;m.addMutate(n,r[u])}},m.addMulMutate=function(r,n,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+n*a[d]}},m.subMulMutate=function(r,n,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-n*a[d]}},m.addMutate=function(r,n){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]+n[u]}},m.subMutate=function(r,n){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]-n[u]}},m.mulMutate=function(r,n){for(var a=0,l=n.length;a<l;){var u=a++;n[u]=n[u]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return z.fold(r,function(n,a){return a+n*n},0)},m.rep=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(n);return a},m.zeros1d=function(r){for(var n=[],a=0;a<r;)a++,n.push(0);return n},m.zeros2d=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(m.zeros1d(n));return a},m.zeros3d=function(r,n,a){for(var l=[],u=0;u<r;)u++,l.push(m.zeros2d(n,a));return l},m.dot=function(r,n){for(var a=0,l=0,u=r.length;l<u;){var d=l++;a+=r[d]*n[d]}return a},m.add=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]+n[d])}return a},m.mul=function(r,n){for(var a=[],l=0,u=n.length;l<u;){var d=l++;a.push(r*n[d])}return a},m.div=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]/n)}return a},m.sub=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]-n[d])}return a},m.isZero=function(r){for(var n=0,a=r.length;n<a;){var l=n++;if(Math.abs(r[l])>re.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var a=[],l=0,u=0;l<r.length||u<n.length;){if(l>=r.length){a.push(n[u]),u++;continue}else if(u>=n.length){a.push(r[l]),l++;continue}var d=r[l]-n[u];if(Math.abs(d)<re.EPSILON){a.push(r[l]),l++,u++;continue}if(d>0){a.push(n[u]),u++;continue}a.push(r[l]),l++}return a},m.sortedSetSub=function(r,n){for(var a=[],l=0,u=0;l<r.length;){if(u>=n.length){a.push(r[l]),l++;continue}if(Math.abs(r[l]-n[u])<re.EPSILON){l++,u++;continue}a.push(r[l]),l++}return a};var ye=g.eval.Analyze=function(){};x["verb.eval.Analyze"]=ye,ye.__name__=["verb","eval","Analyze"],ye.knotMultiplicities=function(r){for(var n=[new Pn(r[0],0)],a=n[0],l=0;l<r.length;){var u=r[l];++l,Math.abs(u-a.knot)>re.EPSILON&&(a=new Pn(u,0),n.push(a)),a.inc()}return n},ye.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var a;n?a=r.controlPoints:a=Ce.transpose(r.controlPoints);for(var l=0,u=a[0].length;l<u;){var d=l++,p=m.dist($.first(a)[d],$.last(a)[d])<re.EPSILON;if(!p)return!1}return!0},ye.rationalSurfaceClosestPoint=function(r,n){var a=ye.rationalSurfaceClosestParam(r,n);return N.rationalSurfacePoint(r,a[0],a[1])},ye.rationalSurfaceClosestParam=function(r,n){for(var a=5,l=0,u,d=1e-4,p=5e-4,_,v=r.knotsU[0],w=$.last(r.knotsU),I=r.knotsV[0],S=$.last(r.knotsV),P=ye.isRationalSurfaceClosed(r),k=ye.isRationalSurfaceClosed(r,!1),M,L=Oe.rationalSurfaceAdaptive(r,new Or),C=1/0,B=0,R=L.points.length;B<R;){var F=B++,V=L.points[F],q=m.normSquared(m.sub(n,V));q<C&&(C=q,M=L.uvs[F])}for(var J=function(Ge){return N.rationalSurfaceDerivatives(r,Ge[0],Ge[1],2)},H=function(Ge,Xe,Fe){var Ke=Xe[1][0],At=Xe[0][1],Ht=Xe[2][0],vt=Xe[0][2],ft=Xe[1][1],St=Xe[1][1],Mt=m.dot(Ke,Fe),Kt=m.dot(At,Fe),or=[-Mt,-Kt],$t=m.dot(Ke,Ke)+m.dot(Ht,Fe),Zt=m.dot(Ke,At)+m.dot(ft,Fe),Qt=m.dot(Ke,At)+m.dot(St,Fe),dr=m.dot(At,At)+m.dot(vt,Fe),Mn=[[$t,Zt],[Qt,dr]],Zr=Ce.solve(Mn,or);return m.add(Zr,Ge)};l<a;){u=J(M),_=m.sub(u[0][0],n);var j=m.norm(_),K=m.dot(u[1][0],_),ee=m.norm(u[1][0])*j,te=m.dot(u[0][1],_),ie=m.norm(u[0][1])*j,he=K/ee,ae=te/ie,ce=j<d,ne=he<p,me=ae<p;if(ce&&ne&&me)return M;var X=H(M,u,_);X[0]<v?P?X=[w-(X[0]-v),X[1]]:X=[v+re.EPSILON,X[1]]:X[0]>w&&(P?X=[v+(X[0]-w),X[1]]:X=[w-re.EPSILON,X[1]]),X[1]<I?k?X=[X[0],S-(X[1]-I)]:X=[X[0],I+re.EPSILON]:X[1]>S&&(k?X=[X[0],I+(X[0]-S)]:X=[X[0],S-re.EPSILON]);var fe=m.norm(m.mul(X[0]-M[0],u[1][0])),Ie=m.norm(m.mul(X[1]-M[1],u[0][1]));if(fe+Ie<d)return M;M=X,l++}return M},ye.rationalCurveClosestPoint=function(r,n){return N.rationalCurvePoint(r,ye.rationalCurveClosestParam(r,n))},ye.rationalCurveClosestParam=function(r,n){for(var a=1/0,l=0,u=Oe.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=u.length-1;d<p;){var _=d++,v=u[_][0],w=u[_+1][0],I=u[_].slice(1),S=u[_+1].slice(1),P=kt.segmentClosestPoint(n,I,S,v,w),k=m.norm(m.sub(n,P.pt));k<a&&(a=k,l=P.u)}for(var M=5,L=0,C,B=1e-4,R=5e-4,F,V=r.knots[0],q=$.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],$.last(r.controlPoints)))<re.EPSILON,H=l,j=function(X){return N.rationalCurveDerivatives(r,X,2)},K=function(X,fe,Ie){var Ge=m.dot(fe[1],Ie),Xe=m.dot(fe[2],Ie),Fe=m.dot(fe[1],fe[1]),Ke=Xe+Fe;return X-Ge/Ke};L<M;){C=j(H),F=m.sub(C[0],n);var ee=m.norm(F),te=m.dot(C[1],F),ie=m.norm(C[1])*ee,he=te/ie,ae=ee<B,ce=Math.abs(he)<R;if(ae&&ce)return H;var ne=K(H,C,F);ne<V?J?ne=q-(ne-V):ne=V:ne>q&&(J?ne=V+(ne-q):ne=q);var me=m.norm(m.mul(ne-H,C[1]));if(me<B)return H;H=ne,L++}return H},ye.rationalCurveParamAtArcLength=function(r,n,a,l,u){if(a==null&&(a=.001),n<re.EPSILON)return r.knots[0];var d;l!=null?d=l:d=ge.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-re.EPSILON,v;for(u!=null?v=u:v=[];_<n&&p<d.length;){if(p<v.length?v[p]=v[p]:v[p]=ye.rationalBezierCurveArcLength(r),_+=v[p],n<_+re.EPSILON)return ye.rationalBezierCurveParamAtArcLength(r,n,a,v[p]);p++}return-1},ye.rationalBezierCurveParamAtArcLength=function(r,n,a,l){if(n<0)return r.knots[0];var u;if(l!=null?u=l:u=ye.rationalBezierCurveArcLength(r),n>u)return $.last(r.knots);var d=r.knots[0],p=0,_=$.last(r.knots),v=u,w=0,I=0,S;for(a!=null?S=a:S=re.TOLERANCE*2;v-p>S;)w=(d+_)/2,I=ye.rationalBezierCurveArcLength(r,w),I>n?(_=w,v=I):(d=w,p=I);return(d+_)/2},ye.rationalCurveArcLength=function(r,n,a){a==null&&(a=16),n==null?n=$.last(r.knots):n=n;for(var l=ge.decomposeCurveIntoBeziers(r),u=0,d=l[0],p=0;u<l.length&&d.knots[0]+re.EPSILON<n;){var _=Math.min($.last(d.knots),n);p+=ye.rationalBezierCurveArcLength(d,_,a),d=l[++u]}return p},ye.rationalBezierCurveArcLength=function(r,n,a){a==null&&(a=16);var l;n==null?l=$.last(r.knots):l=n;for(var u=(l-r.knots[0])/2,d=0,p=r.degree+a,_,v,w=0;w<p;){var I=w++;_=u*ye.Tvalues[p][I]+u+r.knots[0],v=N.rationalCurveDerivatives(r,_,1),d+=ye.Cvalues[p][I]*m.norm(v[1])}return u*d};var Pn=g.eval.KnotMultiplicity=function(r,n){this.knot=r,this.mult=n};x["verb.eval.KnotMultiplicity"]=Pn,Pn.__name__=["verb","eval","KnotMultiplicity"],Pn.prototype={inc:function(){this.mult++},__class__:Pn};var Wt=g.eval.Check=function(){};x["verb.eval.Check"]=Wt,Wt.__name__=["verb","eval","Check"],Wt.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var a=$.first(r),l=0,u=n+1;l<u;){var d=l++;if(Math.abs(r[d]-a)>re.EPSILON)return!1}a=$.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var v=p++;if(Math.abs(r[v]-a)>re.EPSILON)return!1}return Wt.isNonDecreasing(r)},Wt.isNonDecreasing=function(r){for(var n=$.first(r),a=0,l=r.length;a<l;){var u=a++;if(r[u]<n-re.EPSILON)return!1;n=r[u]}return!0},Wt.isValidNurbsCurveData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degree==null)throw new Q("Degree cannot be null!");if(r.degree<1)throw new Q("Degree must be greater than 1!");if(r.knots==null)throw new Q("Knots cannot be null!");if(r.knots.length!=r.controlPoints.length+r.degree+1)throw new Q("controlPoints.length + degree + 1 must equal knots.length!");if(!Wt.isValidKnotVector(r.knots,r.degree))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r},Wt.isValidNurbsSurfaceData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degreeU==null)throw new Q("DegreeU cannot be null!");if(r.degreeV==null)throw new Q("DegreeV cannot be null!");if(r.degreeU<1)throw new Q("DegreeU must be greater than 1!");if(r.degreeV<1)throw new Q("DegreeV must be greater than 1!");if(r.knotsU==null)throw new Q("KnotsU cannot be null!");if(r.knotsV==null)throw new Q("KnotsV cannot be null!");if(r.knotsU.length!=r.controlPoints.length+r.degreeU+1)throw new Q("controlPointsU.length + degreeU + 1 must equal knotsU.length!");if(r.knotsV.length!=r.controlPoints[0].length+r.degreeV+1)throw new Q("controlPointsV.length + degreeV + 1 must equal knotsV.length!");if(!Wt.isValidKnotVector(r.knotsU,r.degreeU)||!Wt.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var lt=g.eval.Divide=function(){};x["verb.eval.Divide"]=lt,lt.__name__=["verb","eval","Divide"],lt.surfaceSplit=function(r,n,a){a==null&&(a=!1);var l,u,d;a?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Ce.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var p,_=[],v=0,w=u+1;v<w;)v++,_.push(n);p=_;for(var I=[],S=[],P=N.knotSpan(u,n,l),k=null,M=0;M<d.length;){var L=d[M];++M,k=ge.curveKnotRefine(new je(u,l,L),p),I.push(k.controlPoints.slice(0,P+1)),S.push(k.controlPoints.slice(P+1))}var C=k.knots.slice(0,P+u+2),B=k.knots.slice(P+1);return a?[new et(r.degreeU,u,r.knotsU.slice(),C,I),new et(r.degreeU,u,r.knotsU.slice(),B,S)]:(I=Ce.transpose(I),S=Ce.transpose(S),[new et(u,r.degreeV,C,r.knotsV.slice(),I),new et(u,r.degreeV,B,r.knotsV.slice(),S)])},lt.curveSplit=function(r,n){var a=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],p=0,_=a+1;p<_;)p++,d.push(n);u=d;var v=ge.curveKnotRefine(r,u),w=N.knotSpan(a,n,l),I=v.knots.slice(0,w+a+2),S=v.knots.slice(w+1),P=v.controlPoints.slice(0,w+1),k=v.controlPoints.slice(w+1);return[new je(a,I,P),new je(a,S,k)]},lt.rationalCurveByEqualArcLength=function(r,n){var a=ye.rationalCurveArcLength(r),l=a/n;return lt.rationalCurveByArcLength(r,l)},lt.rationalCurveByArcLength=function(r,n){var a=ge.decomposeCurveIntoBeziers(r),l=a.map(function(P){return ye.rationalBezierCurveArcLength(P)}),u=m.sum(l),d=[new En(r.knots[0],0)];if(n>u)return d;for(var p=n,_=0,v=p,w=0,I=0,S;_<a.length;){for(w+=l[_];v<w+re.EPSILON;)S=ye.rationalBezierCurveParamAtArcLength(a[_],v-I,re.TOLERANCE,l[_]),d.push(new En(S,v)),v+=p;I+=l[_],_++}return d};var En=g.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=En,En.__name__=["verb","eval","CurveLengthSample"],En.prototype={__class__:En};var N=g.eval.Eval=function(){};x["verb.eval.Eval"]=N,N.__name__=["verb","eval","Eval"],N.rationalCurveTangent=function(r,n){var a=N.rationalCurveDerivatives(r,n,1);return a[1]},N.rationalSurfaceNormal=function(r,n,a){var l=N.rationalSurfaceDerivatives(r,n,a,1);return m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,n,a,l){l==null&&(l=1);for(var u=N.surfaceDerivatives(r,n,a,l),d=N.rational2d(u),p=N.weight2d(u),_=[],v=d[0][0].length,w=0,I=l+1;w<I;){var S=w++;_.push([]);for(var P=0,k=l-S+1;P<k;){for(var M=P++,L=d[S][M],C=1,B=M+1;C<B;){var R=C++;m.subMulMutate(L,Be.get(M,R)*p[0][R],_[S][M-R])}for(var F=1,V=S+1;F<V;){var q=F++;m.subMulMutate(L,Be.get(S,q)*p[q][0],_[S-q][M]);for(var J=m.zeros1d(v),H=1,j=M+1;H<j;){var K=H++;m.addMulMutate(J,Be.get(M,K)*p[q][K],_[S-q][M-K])}m.subMulMutate(L,Be.get(S,q),J)}m.mulMutate(1/p[0][0],L),_[S].push(L)}}return _},N.rationalSurfacePoint=function(r,n,a){return N.dehomogenize(N.surfacePoint(r,n,a))},N.rationalCurveDerivatives=function(r,n,a){a==null&&(a=1);for(var l=N.curveDerivatives(r,n,a),u=N.rational1d(l),d=N.weight1d(l),p=[],_=0,v=a+1;_<v;){for(var w=_++,I=u[w],S=1,P=w+1;S<P;){var k=S++;m.subMulMutate(I,Be.get(w,k)*d[k],p[w-k])}m.mulMutate(1/d[0],I),p.push(I)}return p},N.rationalCurvePoint=function(r,n){return N.dehomogenize(N.curvePoint(r,n))},N.surfaceDerivatives=function(r,n,a,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(u,d,r,n,a,l)},N.surfaceDerivativesGivenNM=function(r,n,a,l,u,d){var p=a.degreeU,_=a.degreeV,v=a.controlPoints,w=a.knotsU,I=a.knotsV;if(!N.areValidRelations(p,v.length,w.length)||!N.areValidRelations(_,v[0].length,I.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=v[0][0].length,P;d<p?P=d:P=p;var k;d<_?k=d:k=_;for(var M=m.zeros3d(d+1,d+1,S),L=N.knotSpanGivenN(r,p,l,w),C=N.knotSpanGivenN(n,_,u,I),B=N.derivativeBasisFunctionsGivenNI(L,l,p,r,w),R=N.derivativeBasisFunctionsGivenNI(C,u,_,n,I),F=m.zeros2d(_+1,S),V=0,q=0,J=P+1;q<J;){for(var H=q++,j=0,K=_+1;j<K;){var ee=j++;F[ee]=m.zeros1d(S);for(var te=0,ie=p+1;te<ie;){var he=te++;m.addMulMutate(F[ee],B[H][he],v[L-p+he][C-_+ee])}}var ae=d-H;ae<k?V=ae:V=k;for(var ce=0,ne=V+1;ce<ne;){var me=ce++;M[H][me]=m.zeros1d(S);for(var X=0,fe=_+1;X<fe;){var Ie=X++;m.addMulMutate(M[H][me],R[me][Ie],F[Ie])}}}return M},N.surfacePoint=function(r,n,a){var l=r.knotsU.length-r.degreeU-2,u=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,u,r,n,a)},N.surfacePointGivenNM=function(r,n,a,l,u){var d=a.degreeU,p=a.degreeV,_=a.controlPoints,v=a.knotsU,w=a.knotsV;if(!N.areValidRelations(d,_.length,v.length)||!N.areValidRelations(p,_[0].length,w.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var I=_[0][0].length,S=N.knotSpanGivenN(r,d,l,v),P=N.knotSpanGivenN(n,p,u,w),k=N.basisFunctionsGivenKnotSpanIndex(S,l,d,v),M=N.basisFunctionsGivenKnotSpanIndex(P,u,p,w),L=S-d,C=P,B=m.zeros1d(I),R=m.zeros1d(I),F=0,V=p+1;F<V;){var q=F++;R=m.zeros1d(I),C=P-p+q;for(var J=0,H=d+1;J<H;){var j=J++;m.addMulMutate(R,k[j],_[L+j][C])}m.addMulMutate(B,M[q],R)}return B},N.curveRegularSamplePoints=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(u*.5,a[2]),v=m.mul(u*l*.5,a[3]),w=m.add(_,_),I=m.add(v,v),S=m.mul(.3333333333333333,v),P=[],k=0,M=n+1;k<M;)k++,P.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,w,v]),m.addAllMutate([w,I]),m.addAllMutate([_,v]);return P},N.curveRegularSamplePoints2=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(u*.5,a[2]),v=m.mul(u*l*.5,a[3]),w=m.add(_,_),I=m.add(v,v),S=m.mul(.3333333333333333,v),P=[],k=0,M=n+1;k<M;)k++,P.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,w,v]),m.addAllMutate([w,I]),m.addAllMutate([_,v]);return P},N.rationalSurfaceRegularSampleDerivatives=function(r,n,a,l){for(var u=N.surfaceRegularSampleDerivatives(r,n,a,l),d=[],p=n+1,_=a+1,v=l+1,w=0;w<p;){var I=w++,S=[];d.push(S);for(var P=0;P<_;){for(var k=P++,M=u[I][k],L=N.rational2d(M),C=N.weight2d(M),B=[],R=L[0][0].length,F=0;F<v;){var V=F++;B.push([]);for(var q=0,J=v-V;q<J;){for(var H=q++,j=L[V][H],K=1,ee=H+1;K<ee;){var te=K++;m.subMulMutate(j,Be.get(H,te)*C[0][te],B[V][H-te])}for(var ie=1,he=V+1;ie<he;){var ae=ie++;m.subMulMutate(j,Be.get(V,ae)*C[ae][0],B[V-ae][H]);for(var ce=m.zeros1d(R),ne=1,me=H+1;ne<me;){var X=ne++;m.addMulMutate(ce,Be.get(H,X)*C[ae][X],B[V-ae][H-X])}m.subMulMutate(j,Be.get(V,ae),ce)}m.mulMutate(1/C[0][0],j),B[V].push(j)}}S.push(B)}}return d},N.surfaceRegularSampleDerivatives=function(r,n,a,l){var u=r.degreeU,d=r.degreeV,p=r.controlPoints,_=r.knotsU,v=r.knotsV,w=p[0][0].length;($.last(_)-_[0])/n,($.last(v)-v[0])/a;for(var I=N.regularlySpacedDerivativeBasisFunctions(u,_,n),S=I.item0,P=I.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,v,a),M=k.item0,L=k.item1,C=[],B=n+1,R=a+1,F=0;F<B;){var V=F++,q=[];C.push(q);for(var J=0;J<R;){var H=J++;q.push(N.surfaceDerivativesGivenBasesKnotSpans(u,d,p,S[V],M[H],P[V],L[H],w,l))}}return C},N.rationalSurfaceRegularSamplePoints=function(r,n,a){return N.dehomogenize2d(N.surfaceRegularSamplePoints(r,n,a))},N.surfaceRegularSamplePoints=function(r,n,a){var l=r.degreeU,u=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,v=d[0][0].length;($.last(p)-p[0])/n,($.last(_)-_[0])/a;for(var w=N.regularlySpacedBasisFunctions(l,p,n),I=w.item0,S=w.item1,P=N.regularlySpacedBasisFunctions(u,_,a),k=P.item0,M=P.item1,L=[],C=n+1,B=a+1,R=0;R<C;){var F=R++,V=[];L.push(V);for(var q=0;q<B;){var J=q++;V.push(N.surfacePointGivenBasesKnotSpans(l,u,d,I[F],k[J],S[F],M[J],v))}}return L},N.regularlySpacedBasisFunctions=function(r,n,a){for(var l=n.length-r-2,u=($.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,I=0;I<w;){for(I++;_>=n[v+1];)v++;p.push(v),d.push(N.basisFunctionsGivenKnotSpanIndex(v,_,r,n)),_+=u}return new tt(p,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,n,a){for(var l=n.length-r-2,u=($.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,I=0;I<w;){for(I++;_>=n[v+1];)v++;p.push(v),d.push(N.derivativeBasisFunctionsGivenNI(v,_,r,l,n)),_+=u}return new tt(p,d)},N.surfacePointGivenBasesKnotSpans=function(r,n,a,l,u,d,p,_){for(var v=m.zeros1d(_),w,I=l-r,S=u-n,P=0,k=n+1;P<k;){var M=P++;w=m.zeros1d(_);for(var L=0,C=r+1;L<C;){var B=L++;m.addMulMutate(w,d[B],a[I+B][S])}S++,m.addMulMutate(v,p[M],w)}return v},N.surfaceDerivativesGivenBasesKnotSpans=function(r,n,a,l,u,d,p,_,v){var w=a[0][0].length,I;v<r?I=v:I=r;var S;v<n?S=v:S=n;for(var P=m.zeros3d(I+1,S+1,w),k=m.zeros2d(n+1,w),M=0,L=0,C=I+1;L<C;){for(var B=L++,R=0,F=n+1;R<F;){var V=R++;k[V]=m.zeros1d(w);for(var q=0,J=r+1;q<J;){var H=q++;m.addMulMutate(k[V],d[B][H],a[l-r+H][u-n+V])}}var j=v-B;j<S?M=j:M=S;for(var K=0,ee=M+1;K<ee;){var te=K++;P[B][te]=m.zeros1d(w);for(var ie=0,he=n+1;ie<he;){var ae=ie++;m.addMulMutate(P[B][te],p[te][ae],k[ae])}}}return P},N.curveDerivatives=function(r,n,a){var l=r.knots.length-r.degree-2;return N.curveDerivativesGivenN(l,r,n,a)},N.curveDerivativesGivenN=function(r,n,a,l){var u=n.degree,d=n.controlPoints,p=n.knots;if(!N.areValidRelations(u,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,v;l<u?v=l:v=u;for(var w=m.zeros2d(l+1,_),I=N.knotSpanGivenN(r,u,a,p),S=N.derivativeBasisFunctionsGivenNI(I,a,u,v,p),P=0,k=v+1;P<k;)for(var M=P++,L=0,C=u+1;L<C;){var B=L++;m.addMulMutate(w[M],S[M][B],d[I-u+B])}return w},N.curvePoint=function(r,n){var a=r.knots.length-r.degree-2;return N.curvePointGivenN(a,r,n)},N.areValidRelations=function(r,n,a){return n+r+1-a==0},N.curvePointGivenN=function(r,n,a){var l=n.degree,u=n.controlPoints,d=n.knots;if(!N.areValidRelations(l,u.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(p,a,l,d),v=m.zeros1d(u[0].length),w=0,I=l+1;w<I;){var S=w++;m.addMulMutate(v,_[S],u[p-l+S])}return v},N.volumePoint=function(r,n,a,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,u,d,p,n,a,l)},N.volumePointGivenNML=function(r,n,a,l,u,d,p){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,v=r.degreeU,w=r.degreeV,I=r.degreeW,S=r.knotsU,P=r.knotsV,k=r.knotsW,M=_[0][0][0].length,L=N.knotSpanGivenN(n,v,u,S),C=N.knotSpanGivenN(a,w,d,P),B=N.knotSpanGivenN(l,I,p,k),R=N.basisFunctionsGivenKnotSpanIndex(L,u,v,S),F=N.basisFunctionsGivenKnotSpanIndex(C,d,w,P),V=N.basisFunctionsGivenKnotSpanIndex(B,p,I,k),q=L-v,J=m.zeros1d(M),H=m.zeros1d(M),j=m.zeros1d(M),K=0,ee=I+1;K<ee;){var te=K++;j=m.zeros1d(M);for(var ie=B-I+te,he=0,ae=w+1;he<ae;){var ce=he++;H=m.zeros1d(M);for(var ne=C-w+ce,me=0,X=v+1;me<X;){var fe=me++;m.addMulMutate(H,R[fe],_[q+fe][ne][ie])}m.addMulMutate(j,F[ce],H)}m.addMulMutate(J,V[te],j)}return J},N.derivativeBasisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a),u=a.length-1,d=u-n-1;return N.derivativeBasisFunctionsGivenNI(l,r,n,d,a)},N.derivativeBasisFunctionsGivenNI=function(r,n,a,l,u){var d=m.zeros2d(a+1,a+1),p=m.zeros1d(a+1),_=m.zeros1d(a+1),v=0,w=0;d[0][0]=1;for(var I=1,S=a+1;I<S;){var P=I++;p[P]=n-u[r+1-P],_[P]=u[r+P]-n,v=0;for(var k=0;k<P;){var M=k++;d[P][M]=_[M+1]+p[P-M],w=d[M][P-1]/d[P][M],d[M][P]=v+_[M+1]*w,v=p[P-M]*w}d[P][P]=v}for(var L=m.zeros2d(l+1,a+1),C=m.zeros2d(2,a+1),B=0,R=1,F=0,V=0,q=0,J=0,H=0,j=0,K=a+1;j<K;){var ee=j++;L[0][ee]=d[ee][a]}for(var te=0,ie=a+1;te<ie;){var he=te++;B=0,R=1,C[0][0]=1;for(var ae=1,ce=l+1;ae<ce;){var ne=ae++;F=0,V=he-ne,q=a-ne,he>=ne&&(C[R][0]=C[B][0]/d[q+1][V],F=C[R][0]*d[V][q]),V>=-1?J=1:J=-V,he-1<=q?H=ne-1:H=a-he;for(var me=J,X=H+1;me<X;){var fe=me++;C[R][fe]=(C[B][fe]-C[B][fe-1])/d[q+1][V+fe],F+=C[R][fe]*d[V+fe][q]}he<=q&&(C[R][ne]=-C[B][ne-1]/d[q+1][he],F+=C[R][ne]*d[he][q]),L[ne][he]=F;var Ie=B;B=R,R=Ie}}for(var Ge=a,Xe=1,Fe=l+1;Xe<Fe;){for(var Ke=Xe++,At=0,Ht=a+1;At<Ht;){var vt=At++;L[Ke][vt]*=Ge}Ge*=a-Ke}return L},N.basisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a);return N.basisFunctionsGivenKnotSpanIndex(l,r,n,a)},N.basisFunctionsGivenKnotSpanIndex=function(r,n,a,l){var u=m.zeros1d(a+1),d=m.zeros1d(a+1),p=m.zeros1d(a+1),_=0,v=0;u[0]=1;for(var w=1,I=a+1;w<I;){var S=w++;d[S]=n-l[r+1-S],p[S]=l[r+S]-n,_=0;for(var P=0;P<S;){var k=P++;v=u[k]/(p[k+1]+d[S-k]),u[k]=_+p[k+1]*v,_=d[S-k]*v}u[S]=_}return u},N.knotSpan=function(r,n,a){return N.knotSpanGivenN(a.length-r-2,r,n,a)},N.knotSpanGivenN=function(r,n,a,l){if(a>l[r+1]-re.EPSILON)return r;if(a<l[n]+re.EPSILON)return n;for(var u=n,d=r+1,p=Math.floor((u+d)/2);a<l[p]||a>=l[p+1];)a<l[p]?d=p:u=p,p=Math.floor((u+d)/2);return p},N.dehomogenize=function(r){for(var n=r.length,a=[],l=r[n-1],u=r.length-1,d=0;d<u;){var p=d++;a.push(r[p]/l)}return a},N.rational1d=function(r){var n=r[0].length-1;return r.map(function(a){return a.slice(0,n)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var n=r[0].length-1;return r.map(function(a){return a[n]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,n){var a=r.length,l=r[0].length,u=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var v=0;v<a;){var w=v++,I=[];p=r[w],d=_[w];for(var S=0;S<l;){var P=S++;I.push(p[P]*d)}I.push(d),u.push(I)}return u},N.homogenize2d=function(r,n){var a=r.length,l=[],u;if(n!=null)u=n;else{for(var d=[],p=0;p<a;)p++,d.push(m.rep(r[0].length,1));u=d}for(var _=0;_<a;){var v=_++;l.push(N.homogenize1d(r[v],u[v]))}return l};var le=g.eval.Intersect=function(){};x["verb.eval.Intersect"]=le,le.__name__=["verb","eval","Intersect"],le.surfaces=function(r,n,a){var l=Oe.rationalSurfaceAdaptive(r),u=Oe.rationalSurfaceAdaptive(n),d=le.meshes(l,u),p=d.map(function(_){return _.map(function(v){return le.surfacesAtPointWithEstimate(r,n,v.uv0,v.uv1,a)})});return p.map(function(_){return pe.rationalInterpCurve(_.map(function(v){return v.point}),3)})},le.surfacesAtPointWithEstimate=function(r,n,a,l,u){var d,p,_,v,w,I,S,P,k,M,L,C,B,R=5,F=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),p=d[0][0],v=d[1][0],w=d[0][1],_=m.normalized(m.cross(v,w)),I=m.dot(_,p),S=N.rationalSurfaceDerivatives(n,l[0],l[1],1),P=S[0][0],M=S[1][0],L=S[0][1],k=m.normalized(m.cross(M,L)),C=m.dot(k,P),B=m.distSquared(p,P),B<u*u)break;var V=m.normalized(m.cross(_,k)),q=m.dot(V,p),J=le.threePlanes(_,I,k,C,V,q);if(J==null)throw new Q("panic!");var H=m.sub(J,p),j=m.sub(J,P),K=m.cross(v,_),ee=m.cross(w,_),te=m.cross(M,k),ie=m.cross(L,k),he=m.dot(ee,H)/m.dot(ee,v),ae=m.dot(K,H)/m.dot(K,w),ce=m.dot(ie,j)/m.dot(ie,M),ne=m.dot(te,j)/m.dot(te,L);a=m.add([he,ae],a),l=m.add([ce,ne],l),F++}while(F<R);return new Yn(a,l,p,B)},le.meshes=function(r,n,a,l){a==null&&(a=new ir(r)),l==null&&(l=new ir(n));var u=le.boundingBoxTrees(a,l,0),d=$.unique(u.map(function(p){return le.triangles(r,p.item0,n,p.item1)}).filter(function(p){return p!=null}).filter(function(p){return m.distSquared(p.min.point,p.max.point)>re.EPSILON}),function(p,_){var v=m.sub(p.min.uv0,_.min.uv0),w=m.dot(v,v),I=m.sub(p.max.uv0,_.max.uv0),S=m.dot(I,I),P=m.sub(p.min.uv0,_.max.uv0),k=m.dot(P,P),M=m.sub(p.max.uv0,_.min.uv0),L=m.dot(M,M);return w<re.EPSILON&&S<re.EPSILON||k<re.EPSILON&&L<re.EPSILON});return le.makeMeshIntersectionPolylines(d)},le.meshSlices=function(r,n,a,l){for(var u=new Lr(r),d=u.boundingBox(),p=d.min[0],_=d.min[1],v=d.max[0],w=d.max[1],I=m.span(n,a,l),S=[],P=0;P<I.length;){var k=I[P];++P;var M=[[p,_,k],[v,_,k],[v,w,k],[p,w,k]],L=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],B=new qt(C,M,null,L);S.push(le.meshes(r,B,u))}return S},le.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var n=0;n<r.length;){var a=r[n];++n,a.max.opp=a.min,a.min.opp=a.max}for(var l=le.kdTreeFromSegments(r),u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.min),u.push(p.max)}for(var _=0;_<u.length;){var v=u[_];if(++_,v.adj==null){var w=le.lookupAdjacentSegment(v,l,r.length);w!=null&&w.adj==null&&(v.adj=w,w.adj=v)}}var I=u.filter(function(R){return R.adj==null});I.length==0&&(I=u);for(var S=[],P=0,k=!1;I.length!=0;){var M=I.pop();if(!M.visited){for(var L=[],C=M;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,L.push(C),P+=2,C=C.opp.adj,C==M)););L.length>0&&(L.push(L[L.length-1].opp),S.push(L))}if(I.length==0&&u.length>0&&(k||P<u.length)){k=!0;var B=u.pop();I.push(B)}}return S},le.kdTreeFromSegments=function(r){for(var n=[],a=0;a<r.length;){var l=r[a];++a,n.push(new An(l.min.point,l.min)),n.push(new An(l.max.point,l.max))}return new Kn(n,m.distSquared)},le.lookupAdjacentSegment=function(r,n,a){var l=n.nearest(r.point,a,re.EPSILON).filter(function(u){return r!=u.item0.obj}).map(function(u){return u.item0.obj});return l.length==1?l[0]:null},le.curveAndSurface=function(r,n,a,l,u){a==null&&(a=.001),l!=null?l=l:l=new sr(r),u!=null?u=u:u=new Cr(n);var d=le.boundingBoxTrees(l,u,a);return $.unique(d.map(function(p){var _=p.item0,v=p.item1,w=$.first(_.knots),I=$.last(_.knots),S=(w+I)/2,P=$.first(v.knotsU),k=$.last(v.knotsU),M=$.first(v.knotsV),L=$.last(v.knotsV),C=[(P+k)/2,(M+L)/2];return le.curveAndSurfaceWithEstimate(_,v,[S].concat(C),a)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<a*a}),function(p,_){return Math.abs(p.u-_.u)<.5*a})},le.curveAndSurfaceWithEstimate=function(r,n,a,l){l==null&&(l=.001);var u=function(v){var w=N.rationalCurvePoint(r,v[0]),I=N.rationalSurfacePoint(n,v[1],v[2]),S=m.sub(w,I);return m.dot(S,S)},d=function(v){var w=N.rationalCurveDerivatives(r,v[0],1),I=N.rationalSurfaceDerivatives(n,v[1],v[2],1),S=m.sub(I[0][0],w[0]),P=m.mul(-1,w[1]),k=I[1][0],M=I[0][1];return[2*m.dot(P,S),2*m.dot(k,S),2*m.dot(M,S)]},p=Yt.uncmin(u,a,l*l,d),_=p.solution;return new Hn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(n,_[1],_[2]))},le.polylineAndMesh=function(r,n,a){for(var l=le.boundingBoxTrees(new ar(r),new ir(n),a),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=le.segmentWithTriangle(r.points[_],r.points[_+1],n.points,n.faces[v]);if(w!=null){var I=w.point,S=m.lerp(w.p,[r.params[_]],[r.params[_+1]])[0],P=rt.triangleUVFromPoint(n,v,I);u.push(new qn(I,S,P,_,v))}}return u},le.boundingBoxTrees=function(r,n,a){a==null&&(a=1e-9);var l=[],u=[];l.push(r),u.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=u.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),a)){var v=p.indivisible(a),w=_.indivisible(a);if(v&&w){d.push(new tt(p.yield(),_.yield()));continue}else if(v&&!w){var I=_.split();l.push(p),u.push(I.item1),l.push(p),u.push(I.item0);continue}else if(!v&&w){var S=p.split();l.push(S.item1),u.push(_),l.push(S.item0),u.push(_);continue}var P=p.split(),k=_.split();l.push(P.item1),u.push(k.item1),l.push(P.item1),u.push(k.item0),l.push(P.item0),u.push(k.item1),l.push(P.item0),u.push(k.item0)}}return d},le.curves=function(r,n,a){var l=le.boundingBoxTrees(new sr(r),new sr(n),0);return $.unique(l.map(function(u){return le.curvesWithEstimate(r,n,$.first(u.item0.knots),$.first(u.item1.knots),a)}).filter(function(u){return m.distSquared(u.point0,u.point1)<a}),function(u,d){return Math.abs(u.u0-d.u0)<a*5})},le.curvesWithEstimate=function(r,n,a,l,u){var d=function(P){var k=N.rationalCurvePoint(r,P[0]),M=N.rationalCurvePoint(n,P[1]),L=m.sub(k,M);return m.dot(L,L)},p=function(P){var k=N.rationalCurveDerivatives(r,P[0],1),M=N.rationalCurveDerivatives(n,P[1],1),L=m.sub(k[0],M[0]),C=k[1],B=m.mul(-1,M[1]);return[2*m.dot(C,L),2*m.dot(B,L)]},_=Yt.uncmin(d,[a,l],u*u,p),v=_.solution[0],w=_.solution[1],I=N.rationalCurvePoint(r,v),S=N.rationalCurvePoint(n,w);return new Kr(I,S,v,w)},le.triangles=function(r,n,a,l){var u=r.faces[n],d=a.faces[l],p=rt.getTriangleNorm(r.points,u),_=rt.getTriangleNorm(a.points,d),v=r.points[u[0]],w=a.points[d[0]],I=le.planes(v,p,w,_);if(I==null)return null;var S=le.clipRayInCoplanarTriangle(I,r,n);if(S==null)return null;var P=le.clipRayInCoplanarTriangle(I,a,l);if(P==null)return null;var k=le.mergeTriangleClipIntervals(S,P,r,n,a,l);return k==null?null:new wt(new Nr(k.min.uv0,k.min.uv1,k.min.point,n,l),new Nr(k.max.uv0,k.max.uv1,k.max.point,n,l))},le.clipRayInCoplanarTriangle=function(r,n,a){for(var l=n.faces[a],u=[n.points[l[0]],n.points[l[1]],n.points[l[2]]],d=[n.uvs[l[0]],n.uvs[l[1]],n.uvs[l[2]]],p=[m.sub(d[1],d[0]),m.sub(d[2],d[1]),m.sub(d[0],d[2])],_=[m.sub(u[1],u[0]),m.sub(u[2],u[1]),m.sub(u[0],u[2])],v=_.map(m.normalized),w=_.map(m.norm),I=null,S=null,P=0;P<3;){var k=P++,M=u[k],L=v[k],C=le.rays(M,L,r.origin,r.dir);if(C!=null){var B=C.u0,R=C.u1;B<-re.EPSILON||B>w[k]+re.EPSILON||((I==null||R<I.u)&&(I=new wn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],B/w[k]))),(S==null||R>S.u)&&(S=new wn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],B/w[k]))))}}return S==null||I==null?null:new wt(I,S)},le.mergeTriangleClipIntervals=function(r,n,a,l,u,d){if(n.min.u>r.max.u+re.EPSILON||r.min.u>n.max.u+re.EPSILON)return null;var p;r.min.u>n.min.u?p=new tt(r.min,0):p=new tt(n.min,1);var _;r.max.u<n.max.u?_=new tt(r.max,0):_=new tt(n.max,1);var v=new wt(new Nr(null,null,p.item0.point,l,d),new Nr(null,null,_.item0.point,l,d));return p.item1==0?(v.min.uv0=p.item0.uv,v.min.uv1=rt.triangleUVFromPoint(u,d,p.item0.point)):(v.min.uv0=rt.triangleUVFromPoint(a,l,p.item0.point),v.min.uv1=p.item0.uv),_.item1==0?(v.max.uv0=_.item0.uv,v.max.uv1=rt.triangleUVFromPoint(u,d,_.item0.point)):(v.max.uv0=rt.triangleUVFromPoint(a,l,_.item0.point),v.max.uv1=_.item0.uv),v},le.planes=function(r,n,a,l){var u=m.cross(n,l);if(m.dot(u,u)<re.EPSILON)return null;var d=0,p=Math.abs(u[0]),_=Math.abs(u[1]),v=Math.abs(u[2]);_>p&&(d=1,p=_),v>p&&(d=2,p=v);var w,I,S,P;d==0?(w=n[1],I=n[2],S=l[1],P=l[2]):d==1?(w=n[0],I=n[2],S=l[0],P=l[2]):(w=n[0],I=n[1],S=l[0],P=l[1]);var k=-m.dot(r,n),M=-m.dot(a,l),L=w*P-I*S,C=(I*M-k*P)/L,B=(k*S-w*M)/L,R;return d==0?R=[0,C,B]:d==1?R=[C,0,B]:R=[C,B,0],new xn(R,m.normalized(u))},le.threePlanes=function(r,n,a,l,u,d){var p=m.cross(a,u),_=m.dot(r,p);if(Math.abs(_)<re.EPSILON)return null;var v=m.sub(m.mul(d,a),m.mul(l,u)),w=m.add(m.mul(n,p),m.cross(r,v));return m.mul(1/_,w)},le.polylines=function(r,n,a){for(var l=le.boundingBoxTrees(new ar(r),new ar(n),a),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=le.segments(r.points[_],r.points[_+1],n.points[v],n.points[v+1],a);w!=null&&(w.u0=m.lerp(w.u0,[r.params[_]],[r.params[_+1]])[0],w.u1=m.lerp(w.u1,[n.params[v]],[n.params[v+1]])[0],u.push(w))}return u},le.segments=function(r,n,a,l,u){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),v=m.sub(l,a),w=Math.sqrt(m.dot(v,v)),I=m.mul(1/w,v),S=le.rays(r,_,a,I);if(S!=null){var P=Math.min(Math.max(0,S.u0/p),1),k=Math.min(Math.max(0,S.u1/w),1),M=m.onRay(r,d,P),L=m.onRay(a,v,k),C=m.distSquared(M,L);if(C<u*u)return new Kr(M,L,P,k)}return null},le.rays=function(r,n,a,l){var u=m.dot(n,l),d=m.dot(n,a),p=m.dot(n,r),_=m.dot(l,a),v=m.dot(l,r),w=m.dot(n,n),I=m.dot(l,l),S=w*I-u*u;if(Math.abs(S)<re.EPSILON)return null;var P=u*(d-p)-w*(_-v),k=P/S,M=(d-p+k*u)/w,L=m.onRay(r,n,M),C=m.onRay(a,l,k);return new Kr(L,C,M,k)},le.segmentWithTriangle=function(r,n,a,l){var u=a[l[0]],d=a[l[1]],p=a[l[2]],_=m.sub(d,u),v=m.sub(p,u),w=m.cross(_,v),I=m.sub(n,r),S=m.sub(r,u),P=-m.dot(w,S),k=m.dot(w,I);if(Math.abs(k)<re.EPSILON)return null;var M=P/k;if(M<0||M>1)return null;var L=m.add(r,m.mul(M,I)),C=m.dot(_,v),B=m.dot(_,_),R=m.dot(v,v),F=m.sub(L,u),V=m.dot(F,_),q=m.dot(F,v),J=C*C-B*R;if(Math.abs(J)<re.EPSILON)return null;var H=(C*q-R*V)/J,j=(C*V-B*q)/J;return H>1+re.EPSILON||j>1+re.EPSILON||j<-re.EPSILON||H<-re.EPSILON||H+j>1+re.EPSILON?null:new Xn(L,H,j,M)},le.segmentAndPlane=function(r,n,a,l){var u=m.dot(l,m.sub(n,r));if(Math.abs(u)<re.EPSILON)return null;var d=m.dot(l,m.sub(a,r)),p=d/u;return p>1+re.EPSILON||p<-re.EPSILON?null:{p}};var pe=g.eval.Make=function(){};x["verb.eval.Make"]=pe,pe.__name__=["verb","eval","Make"],pe.rationalTranslationalSurface=function(r,n){for(var a=N.rationalCurvePoint(n,$.first(n.knots)),l=$.first(n.knots),u=$.last(n.knots),d=2*n.controlPoints.length,p=(u-l)/(d-1),_=[],v=0;v<d;){var w=v++,I=m.sub(N.rationalCurvePoint(n,l+w*p),a),S=ge.rationalCurveTransform(r,[[1,0,0,I[0]],[0,1,0,I[1]],[0,0,1,I[2]],[0,0,0,1]]);_.push(S)}return pe.loftedSurface(_)},pe.surfaceBoundaryCurves=function(r){var n=pe.surfaceIsocurve(r,$.first(r.knotsU),!1),a=pe.surfaceIsocurve(r,$.last(r.knotsU),!1),l=pe.surfaceIsocurve(r,$.first(r.knotsV),!0),u=pe.surfaceIsocurve(r,$.last(r.knotsV),!0);return[n,a,l,u]},pe.surfaceIsocurve=function(r,n,a){a==null&&(a=!1);var l;a?l=r.knotsV:l=r.knotsU;var u;a?u=r.degreeV:u=r.degreeU;for(var d=ye.knotMultiplicities(l),p=-1,_=0,v=d.length;_<v;){var w=_++;if(Math.abs(n-d[w].knot)<re.EPSILON){p=w;break}}var I=u+1;p>=0&&(I=I-d[p].mult);var S;I>0?S=ge.surfaceKnotRefine(r,m.rep(I,n),a):S=r;var P=N.knotSpan(u,n,l);return Math.abs(n-$.first(l))<re.EPSILON?P=0:Math.abs(n-$.last(l))<re.EPSILON&&(P=(a?S.controlPoints[0].length:S.controlPoints.length)-1),a?new je(S.degreeU,S.knotsU,function(k){for(var M,L=[],C=0,B=S.controlPoints;C<B.length;){var R=B[C];++C,L.push(R[P])}return M=L,M}()):new je(S.degreeV,S.knotsV,S.controlPoints[P])},pe.loftedSurface=function(r,n){r=ge.unifyCurveKnotVectors(r);var a=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,u=[],d=[],p=0,_=r[0].controlPoints.length;p<_;){var v=[p++],w=r.map(function(S){return function(P){return P.controlPoints[S[0]]}}(v)),I=pe.rationalInterpCurve(w,n,!0);d.push(I.controlPoints),u=I.knots}return new et(a,n,l,u,d)},pe.clonedCurve=function(r){return new je(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},pe.rationalBezierCurve=function(r,n){for(var a=r.length-1,l=[],u=0,d=a+1;u<d;)u++,l.push(0);for(var p=0,_=a+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new je(a,l,N.homogenize1d(r,n))},pe.fourPointSurface=function(r,n,a,l,u){u==null&&(u=3);for(var d=u,p=[],_=0,v=u+1;_<v;){for(var w=_++,I=[],S=0,P=u+1;S<P;){var k=S++,M=1-w/d,L=m.lerp(M,r,n),C=m.lerp(M,l,a),B=m.lerp(1-k/d,L,C);B.push(1),I.push(B)}p.push(I)}var R=m.rep(u+1,0),F=m.rep(u+1,1);return new et(u,u,R.concat(F),R.concat(F),p)},pe.ellipseArc=function(r,n,a,l,u){var d=m.norm(n),p=m.norm(a);n=m.normalized(n),a=m.normalized(a),u<l&&(u=2*Math.PI+l);var _=u-l,v=0;_<=Math.PI/2?v=1:_<=Math.PI?v=2:_<=3*Math.PI/2?v=3:v=4;var w=_/v,I=Math.cos(w/2),S=m.add(r,m.add(m.mul(d*Math.cos(l),n),m.mul(p*Math.sin(l),a))),P=m.sub(m.mul(Math.cos(l),a),m.mul(Math.sin(l),n)),k=[],M=m.zeros1d(2*v+3),L=0,C=l,B=m.zeros1d(v*2);k[0]=S,B[0]=1;for(var R=1,F=v+1;R<F;){var V=R++;C+=w;var q=m.add(r,m.add(m.mul(d*Math.cos(C),n),m.mul(p*Math.sin(C),a)));B[L+2]=1,k[L+2]=q;var J=m.sub(m.mul(Math.cos(C),a),m.mul(Math.sin(C),n)),H=le.rays(S,m.mul(1/m.norm(P),P),q,m.mul(1/m.norm(J),J)),j=m.add(S,m.mul(H.u0,P));B[L+1]=I,k[L+1]=j,L+=2,V<v&&(S=q,P=J)}for(var K=2*v+1,ee=0;ee<3;){var te=ee++;M[te]=0,M[te+K]=1}switch(v){case 2:M[3]=M[4]=.5;break;case 3:M[3]=M[4]=.3333333333333333,M[5]=M[6]=.6666666666666666;break;case 4:M[3]=M[4]=.25,M[5]=M[6]=.5,M[7]=M[8]=.75;break}return new je(2,M,N.homogenize1d(k,B))},pe.arc=function(r,n,a,l,u,d){return pe.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(a)),u,d)},pe.polyline=function(r){for(var n=[0,0],a=0,l=0,u=r.length-1;l<u;){var d=l++;a+=m.dist(r[d],r[d+1]),n.push(a)}n.push(a),n=m.mul(1/a,n);for(var p,_=[],v=0,w=r.length;v<w;)v++,_.push(1);return p=_,new je(1,n,N.homogenize1d(r.slice(0),p))},pe.extrudedSurface=function(r,n,a){for(var l=[[],[],[]],u=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),p=N.weight1d(a.controlPoints),_=m.mul(n,r),v=m.mul(.5*n,r),w=0,I=d.length;w<I;){var S=w++;l[2][S]=d[S],l[1][S]=m.add(v,d[S]),l[0][S]=m.add(_,d[S]),u[0][S]=p[S],u[1][S]=p[S],u[2][S]=p[S]}return new et(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,u))},pe.cylindricalSurface=function(r,n,a,l,u){var d=m.cross(r,n),p=pe.arc(a,n,d,u,0,2*Math.PI);return pe.extrudedSurface(r,l,p)},pe.revolvedSurface=function(r,n,a,l){var u=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),p,_;l<=Math.PI/2?(p=1,_=m.zeros1d(6+2*(p-1))):l<=Math.PI?(p=2,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(p=3,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(p=4,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var v=l/p,w=3+2*(p-1),I=0;I<3;){var S=I++;_[S]=0,_[w+S]=1}for(var P=Math.cos(v/2),k=0,M=m.zeros1d(p+1),L=m.zeros1d(p+1),C=m.zeros3d(2*p+1,u.length,3),B=m.zeros2d(2*p+1,u.length),R=1,F=p+1;R<F;){var V=R++;k+=v,L[V]=Math.cos(k),M[V]=Math.sin(k)}for(var q=0,J=u.length;q<J;){var H=q++,j=kt.rayClosestPoint(u[H],n,a),K=m.sub(u[H],j),ee=m.norm(K),te=m.cross(a,K);ee>re.EPSILON&&(K=m.mul(1/ee,K),te=m.mul(1/ee,te)),C[0][H]=u[H];var ie=u[H];B[0][H]=d[H];for(var he=te,ae=0,ce=1,ne=p+1;ce<ne;){var me=ce++,X;ee==0?X=j:X=m.add(j,m.add(m.mul(ee*L[me],K),m.mul(ee*M[me],te))),C[ae+2][H]=X,B[ae+2][H]=d[H];var fe=m.sub(m.mul(L[me],te),m.mul(M[me],K));if(ee==0)C[ae+1][H]=j;else{var Ie=le.rays(ie,m.mul(1/m.norm(he),he),X,m.mul(1/m.norm(fe),fe)),Ge=m.add(ie,m.mul(Ie.u0,he));C[ae+1][H]=Ge}B[ae+1][H]=P*d[H],ae+=2,me<p&&(ie=X,he=fe)}}return new et(2,r.degree,_,r.knots,N.homogenize2d(C,B))},pe.sphericalSurface=function(r,n,a,l){var u=pe.arc(r,m.mul(-1,n),a,l,0,Math.PI);return pe.revolvedSurface(u,r,n,2*Math.PI)},pe.conicalSurface=function(r,n,a,l,u){var d=2*Math.PI,p=1,_=[m.add(a,m.mul(l,r)),m.add(a,m.mul(u,n))],v=[0,0,1,1],w=[1,1],I=new je(p,v,N.homogenize1d(_,w));return pe.revolvedSurface(I,a,r,d)},pe.rationalInterpCurve=function(r,n,a,l,u){if(a==null&&(a=!1),n==null&&(n=3),r.length<n+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],p=1,_=r.length;p<_;){var v=p++,w=m.norm(m.sub(r[v],r[v-1])),I=d[d.length-1];d.push(I+w)}for(var S=d[d.length-1],P=0,k=d.length;P<k;){var M=P++;d[M]=d[M]/S}var L=m.rep(n+1,0),C=l!=null&&u!=null,B;C?B=0:B=1;var R;C?R=d.length-n+1:R=d.length-n;for(var F=B;F<R;){for(var V=F++,q=0,J=0;J<n;){var H=J++;q+=d[V+H]}L.push(1/n*q)}var j=L.concat(m.rep(n+1,1)),K=[],ee;C?ee=r.length+1:ee=r.length-1;var te;C?te=r.length-(n-1):te=r.length-(n+1);for(var ie=0;ie<d.length;){var he=d[ie];++ie;var ae=N.knotSpanGivenN(ee,n,he,j),ce=N.basisFunctionsGivenKnotSpanIndex(ae,he,n,j),ne=ae-n,me=m.zeros1d(ne),X=m.zeros1d(te-ne);K.push(me.concat(ce).concat(X))}if(C){var fe=K[0].length-2,Ie=[-1,1].concat(m.zeros1d(fe)),Ge=m.zeros1d(fe).concat([-1,1]);$.spliceAndInsert(K,1,0,Ie),$.spliceAndInsert(K,K.length-1,0,Ge)}for(var Xe=r[0].length,Fe=[],Ke=(1-j[j.length-n-2])/n,At=j[n+1]/n,Ht=0;Ht<Xe;){var vt=[Ht++],ft;if(!C)ft=r.map(function(Qt){return function(dr){return dr[Qt[0]]}}(vt));else{ft=[r[0][vt[0]]],ft.push(At*l[vt[0]]);for(var St=1,Mt=r.length-1;St<Mt;){var Kt=St++;ft.push(r[Kt][vt[0]])}ft.push(Ke*u[vt[0]]),ft.push($.last(r)[vt[0]])}var or=Ce.solve(K,ft);Fe.push(or)}var $t=Ce.transpose(Fe);if(!a){var Zt=m.rep($t.length,1);$t=N.homogenize1d($t,Zt)}return new je(n,j,$t)};var ge=g.eval.Modify=function(){};x["verb.eval.Modify"]=ge,ge.__name__=["verb","eval","Modify"],ge.curveReverse=function(r){return new je(r.degree,ge.knotsReverse(r.knots),$.reversed(r.controlPoints))},ge.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new et(r.degreeU,r.degreeV,r.knotsU,ge.knotsReverse(r.knotsV),function(a){for(var l,u=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,u.push($.reversed(_))}return l=u,l}()):new et(r.degreeU,r.degreeV,ge.knotsReverse(r.knotsU),r.knotsV,$.reversed(r.controlPoints))},ge.knotsReverse=function(r){var n=$.first(r);$.last(r);for(var a=[n],l=r.length,u=1;u<l;){var d=u++;a.push(a[d-1]+(r[l-d]-r[l-d-1]))}return a},ge.unifyCurveKnotVectors=function(r){r=r.map(pe.clonedCurve);for(var n=z.fold(r,function(j,K){return ge.imax(j.degree,K)},0),a=0,l=r.length;a<l;){var u=a++;r[u].degree<n&&(r[u]=ge.curveElevateDegree(r[u],n))}for(var d,p=[],_=0;_<r.length;){var v=r[_];++_,p.push(new wt($.first(v.knots),$.last(v.knots)))}d=p;for(var w=0,I=r.length;w<I;){var S=w++,P=[d[S].min];r[S].knots=r[S].knots.map(function(j){return function(K){return K-j[0]}}(P))}for(var k=d.map(function(j){return j.max-j.min}),M=z.fold(k,function(j,K){return Math.max(j,K)},0),L=0,C=r.length;L<C;){var B=L++,R=[M/k[B]];r[B].knots=r[B].knots.map(function(j){return function(K){return K*j[0]}}(R))}for(var F=z.fold(r,function(j,K){return m.sortedSetUnion(j.knots,K)},[]),V=0,q=r.length;V<q;){var J=V++,H=m.sortedSetSub(F,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=ge.curveKnotRefine(r[J],H)}return r},ge.imin=function(r,n){return r<n?r:n},ge.imax=function(r,n){return r>n?r:n},ge.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var a=r.knots.length-r.degree-2,l=r.degree,u=r.knots,d=r.controlPoints,p=n-r.degree,_=r.controlPoints[0].length,v=m.zeros2d(l+p+1,l+1),w=[],I=[],S=[],P=a+l+1,k=n,M=Math.floor(k/2),L=[],C=[];v[0][0]=1,v[k][l]=1;for(var B=1,R=M+1;B<R;)for(var F=B++,V=1/Be.get(k,F),q=ge.imin(l,F),J=ge.imax(0,F-p),H=q+1;J<H;){var j=J++;v[F][j]=V*Be.get(l,j)*Be.get(p,F-j)}for(var K=M+1;K<k;)for(var ee=K++,te=ge.imin(l,ee),ie=ge.imax(0,ee-p),he=te+1;ie<he;){var ae=ie++;v[ee][ae]=v[k-ee][l-ae]}var ce=k+1,ne=-1,me=l,X=l+1,fe=1,Ie=u[0];L[0]=d[0];for(var Ge=0,Xe=k+1;Ge<Xe;){var Fe=Ge++;C[Fe]=Ie}for(var Ke=0,At=l+1;Ke<At;){var Ht=Ke++;w[Ht]=d[Ht]}for(;X<P;){for(var vt=X;X<P&&u[X]==u[X+1];)X=X+1;var ft=X-vt+1,St=u[X],Mt=ne;ne=l-ft;var Kt;Mt>0?Kt=Math.floor((Mt+2)/2):Kt=1;var or;if(ne>0?or=Math.floor(k-(ne+1)/2):or=k,ne>0){for(var $t=St-Ie,Zt=[],Qt=l;Qt>ft;)Zt[Qt-ft-1]=$t/(u[me+Qt]-Ie),Qt--;for(var dr=1,Mn=ne+1;dr<Mn;){for(var Zr=dr++,Ru=ne-Zr,Wi=ft+Zr,Qr=l;Qr>=Wi;)w[Qr]=m.add(m.mul(Zt[Qr-Wi],w[Qr]),m.mul(1-Zt[Qr-Wi],w[Qr-1])),Qr--;S[Ru]=w[l]}}for(var wo=Kt,Bu=k+1;wo<Bu;){var Nn=wo++;I[Nn]=m.zeros1d(_);for(var Du=ge.imin(l,Nn),Ao=ge.imax(0,Nn-p),Fu=Du+1;Ao<Fu;){var So=Ao++;I[Nn]=m.add(I[Nn],m.mul(v[Nn][So],w[So]))}}if(Mt>1)for(var Hi=ce-2,qi=ce,Io=St-Ie,Uu=(St-C[ce-1])/Io,Po=1;Po<Mt;){for(var Yi=Po++,mr=Hi,Jr=qi,Fr=Jr-ce+1;Jr-mr>Yi;){if(mr<fe){var Vu=(St-C[mr])/(Ie-C[mr]);L[mr]=m.lerp(Vu,L[mr],L[mr-1])}if(Jr>=Kt){if(Jr-Yi<=ce-k+Mt){var ju=(St-C[Jr-Yi])/Io;I[Fr]=m.lerp(ju,I[Fr],I[Fr+1])}}else I[Fr]=m.lerp(Uu,I[Fr],I[Fr+1]);mr=mr+1,Jr=Jr-1,Fr=Fr-1}Hi=Hi-1,qi=qi+1}if(me!=l)for(var Eo=0,Gu=k-Mt;Eo<Gu;)Eo++,C[ce]=Ie,ce=ce+1;for(var ko=Kt,Wu=or+1;ko<Wu;){var Hu=ko++;L[fe]=I[Hu],fe=fe+1}if(X<P){for(var To=0;To<ne;){var Mo=To++;w[Mo]=S[Mo]}for(var No=ne,qu=l+1;No<qu;){var Co=No++;w[Co]=d[X-l+Co]}me=X,X=X+1,Ie=St}else for(var Lo=0,Yu=k+1;Lo<Yu;){var Xu=Lo++;C[ce+Xu]=St}}return new je(n,C,L)},ge.rationalSurfaceTransform=function(r,n){for(var a=N.dehomogenize2d(r.controlPoints),l=0,u=a.length;l<u;)for(var d=l++,p=0,_=a[d].length;p<_;){var v=p++,w=a[d][v];w.push(1),a[d][v]=Ce.dot(n,w).slice(0,w.length-1)}return new et(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},ge.rationalCurveTransform=function(r,n){for(var a=N.dehomogenize1d(r.controlPoints),l=0,u=a.length;l<u;){var d=l++,p=a[d];p.push(1),a[d]=Ce.dot(n,p).slice(0,p.length-1)}return new je(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},ge.surfaceKnotRefine=function(r,n,a){var l=[],u,d,p;a?(p=r.controlPoints,u=r.knotsV,d=r.degreeV):(p=Ce.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,v=0;v<p.length;){var w=p[v];++v,_=ge.curveKnotRefine(new je(d,u,w),n),l.push(_.controlPoints)}var I=_.knots;return a?new et(r.degreeU,r.degreeV,r.knotsU.slice(),I,l):(l=Ce.transpose(l),new et(r.degreeU,r.degreeV,I,r.knotsV.slice(),l))},ge.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,a=r.controlPoints,l=r.knots,u=ye.knotMultiplicities(l),d=n+1,p=0;p<u.length;){var _=u[p];if(++p,_.mult<d){var v=m.rep(d-_.mult,_.knot),w=ge.curveKnotRefine(new je(n,l,a),v);l=w.knots,a=w.controlPoints}}l.length/d-1;for(var I=d*2,S=[],P=0;P<a.length;){var k=l.slice(P,P+I),M=a.slice(P,P+d);S.push(new je(n,k,M)),P+=d}return S},ge.curveKnotRefine=function(r,n){if(n.length==0)return pe.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,p=d+a+1,_=n.length-1,v=N.knotSpan(a,n[0],u),w=N.knotSpan(a,n[_],u),I=[],S=[],P=0,k=v-a+1;P<k;){var M=P++;I[M]=l[M]}for(var L=w-1,C=d+1;L<C;){var B=L++;I[B+_+1]=l[B]}for(var R=0,F=v+1;R<F;){var V=R++;S[V]=u[V]}for(var q=w+a,J=p+1;q<J;){var H=q++;S[H+_+1]=u[H]}for(var j=w+a-1,K=w+a+_,ee=_;ee>=0;){for(;n[ee]<=u[j]&&j>v;)I[K-a-1]=l[j-a-1],S[K]=u[j],K=K-1,j=j-1;I[K-a-1]=I[K-a];for(var te=1,ie=a+1;te<ie;){var he=te++,ae=K-a+he,ce=S[K+he]-n[ee];Math.abs(ce)<re.EPSILON?I[ae-1]=I[ae]:(ce=ce/(S[K+he]-u[j-a+he]),I[ae-1]=m.add(m.mul(ce,I[ae-1]),m.mul(1-ce,I[ae])))}S[K]=n[ee],K=K-1,ee--}return new je(a,S,I)},ge.curveKnotInsert=function(r,n,a){for(var l=r.degree,u=r.controlPoints,d=r.knots,p=0,_=u.length,v=N.knotSpan(l,n,d),w=[],I=[],S=[],P=1,k=v+1;P<k;){var M=P++;I[M]=d[M]}for(var L=1,C=a+1;L<C;){var B=L++;I[v+B]=n}for(var R=v+1,F=d.length;R<F;){var V=R++;I[V+a]=d[V]}for(var q=0,J=v-l+1;q<J;){var H=q++;S[H]=u[H]}for(var j=v-p;j<_;){var K=j++;S[K+a]=u[K]}for(var ee=0,te=l-p+1;ee<te;){var ie=ee++;w[ie]=u[v-l+ie]}for(var he=0,ae=0,ce=1,ne=a+1;ce<ne;){var me=ce++;he=v-l+me;for(var X=0,fe=l-me-p+1;X<fe;){var Ie=X++;ae=(n-d[he+Ie])/(d[Ie+v+1]-d[he+Ie]),w[Ie]=m.add(m.mul(ae,w[Ie+1]),m.mul(1-ae,w[Ie]))}S[he]=w[0],S[v+a-me-p]=w[l-me-p]}for(var Ge=he+1,Xe=v-p;Ge<Xe;){var Fe=Ge++;S[Fe]=w[Fe-he]}return new je(l,I,S)};var Oe=g.eval.Tess=function(){};x["verb.eval.Tess"]=Oe,Oe.__name__=["verb","eval","Tess"],Oe.rationalCurveRegularSample=function(r,n,a){return Oe.rationalCurveRegularSampleRange(r,r.knots[0],$.last(r.knots),n,a)},Oe.rationalCurveRegularSampleRange=function(r,n,a,l,u){l<1&&(l=2);for(var d=[],p=(a-n)/(l-1),_=0,v=0;v<l;){var w=v++;_=n+p*w,u?d.push([_].concat(N.rationalCurvePoint(r,_))):d.push(N.rationalCurvePoint(r,_))}return d},Oe.rationalCurveAdaptiveSample=function(r,n,a){if(a==null&&(a=!1),n==null&&(n=1e-6),r.degree==1)if(a){for(var l=[],u=0,d=r.controlPoints.length;u<d;){var p=u++;l.push([r.knots[p+1]].concat(N.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(N.dehomogenize);return Oe.rationalCurveAdaptiveSampleRange(r,r.knots[0],$.last(r.knots),n,a)},Oe.rationalCurveAdaptiveSampleRange=function(r,n,a,l,u){var d=N.rationalCurvePoint(r,n),p=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),v=n+(a-n)*_,w=N.rationalCurvePoint(r,v),I=m.sub(d,p),S=m.sub(d,w);if(m.dot(I,I)<l&&m.dot(S,S)>l||!kt.threePointsAreFlat(d,w,p,l)){var P=n+(a-n)*.5,k=Oe.rationalCurveAdaptiveSampleRange(r,n,P,l,u),M=Oe.rationalCurveAdaptiveSampleRange(r,P,a,l,u);return k.slice(0,-1).concat(M)}else return u?[[n].concat(d),[a].concat(p)]:[d,p]},Oe.rationalSurfaceNaive=function(r,n,a){n<1&&(n=1),a<1&&(a=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,u=r.knotsV,d=$.last(l)-l[0],p=$.last(u)-u[0],_=d/n,v=p/a,w=[],I=[],S=[],P=0,k=n+1;P<k;)for(var M=P++,L=0,C=a+1;L<C;){var B=L++,R=M*_,F=B*v;I.push([R,F]);var V=N.rationalSurfaceDerivatives(r,R,F,1),q=V[0][0];w.push(q);var J=m.normalized(m.cross(V[1][0],V[0][1]));S.push(J)}for(var H=[],j=0;j<n;)for(var K=j++,ee=0;ee<a;){var te=ee++,ie=K*(a+1)+te,he=(K+1)*(a+1)+te,ae=he+1,ce=ie+1,ne=[ie,he,ae],me=[ie,ae,ce];H.push(ne),H.push(me)}return new qt(H,w,S,I)},Oe.divideRationalSurfaceAdaptive=function(r,n){n==null&&(n=new Or),n.minDivsU!=null?n.minDivsU=n.minDivsU:n.minDivsU=1,n.minDivsV!=null?n.minDivsU=n.minDivsV:n.minDivsU=1,n.refine!=null?n.refine=n.refine:n.refine=!0;var a=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,u;n.minDivsU>a?u=n.minDivsU=n.minDivsU:u=n.minDivsU=a;var d;n.minDivsV>l?d=n.minDivsV=n.minDivsV:d=n.minDivsV=l;for(var p=$.last(r.knotsU),_=r.knotsU[0],v=$.last(r.knotsV),w=r.knotsV[0],I=(p-_)/u,S=(v-w)/d,P=[],k=[],M=0,L=d+1;M<L;){for(var C=M++,B=[],R=0,F=u+1;R<F;){var V=R++,q=_+I*V,J=w+S*C,H=N.rationalSurfaceDerivatives(r,q,J,1),j=m.normalized(m.cross(H[0][1],H[1][0]));B.push(new Gt(H[0][0],j,[q,J],-1,m.isZero(j)))}k.push(B)}for(var K=0;K<d;)for(var ee=K++,te=0;te<u;){var ie=te++,he=[k[d-ee-1][ie],k[d-ee-1][ie+1],k[d-ee][ie+1],k[d-ee][ie]];P.push(new cr(r,he))}if(!n.refine)return P;for(var ae=0;ae<d;)for(var ce=ae++,ne=0;ne<u;){var me=ne++,X=ce*u+me,fe=Oe.north(X,ce,me,u,d,P),Ie=Oe.east(X,ce,me,u,d,P),Ge=Oe.south(X,ce,me,u,d,P),Xe=Oe.west(X,ce,me,u,d,P);P[X].neighbors=[Ge,Ie,fe,Xe],P[X].divide(n)}return P},Oe.north=function(r,n,a,l,u,d){return n==0?null:d[r-l]},Oe.south=function(r,n,a,l,u,d){return n==u-1?null:d[r+l]},Oe.east=function(r,n,a,l,u,d){return a==l-1?null:d[r+1]},Oe.west=function(r,n,a,l,u,d){return a==0?null:d[r-1]},Oe.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=qt.empty(),a=0;a<r.length;){var l=r[a];++a,l.triangulate(n)}return n},Oe.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new Or;var a=Oe.divideRationalSurfaceAdaptive(r,n);return Oe.triangulateAdaptiveRefinementNodeTree(a)};var Or=g.core.AdaptiveRefinementOptions=function(){this.minDivsV=1,this.minDivsU=1,this.refine=!0,this.maxDepth=10,this.minDepth=0,this.normTol=.025};x["verb.eval.AdaptiveRefinementOptions"]=Or,Or.__name__=["verb","eval","AdaptiveRefinementOptions"],Or.prototype={__class__:Or};var cr=g.core.AdaptiveRefinementNode=function(r,n,a){if(this.srf=r,a==null?this.neighbors=[null,null,null,null]:this.neighbors=a,this.corners=n,this.corners==null){var l=r.knotsU[0],u=$.last(r.knotsU),d=r.knotsV[0],p=$.last(r.knotsV);this.corners=[Gt.fromUv(l,d),Gt.fromUv(u,d),Gt.fromUv(u,p),Gt.fromUv(l,p)]}};x["verb.eval.AdaptiveRefinementNode"]=cr,cr.__name__=["verb","eval","AdaptiveRefinementNode"],cr.prototype={isLeaf:function(){return this.children==null},center:function(){return this.centerPoint!=null?this.centerPoint:this.evalSrf(this.u05,this.v05)},evalCorners:function(){this.u05=(this.corners[0].uv[0]+this.corners[2].uv[0])/2,this.v05=(this.corners[0].uv[1]+this.corners[2].uv[1])/2;for(var r=0;r<4;){var n=r++;if(this.corners[n].point==null){var a=this.corners[n];this.evalSrf(a.uv[0],a.uv[1],a)}}},evalSrf:function(r,n,a){var l=N.rationalSurfaceDerivatives(this.srf,r,n,1),u=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),a!=null?(a.degen=p,a.point=u,a.normal=d,a):new Gt(u,d,[r,n],-1,p)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){case 0:return this.children[0].getEdgeCorners(0);case 1:return this.children[0].getEdgeCorners(1).concat(this.children[1].getEdgeCorners(1));case 2:return this.children[1].getEdgeCorners(2);case 3:return this.children[1].getEdgeCorners(3).concat(this.children[0].getEdgeCorners(3))}switch(r){case 0:return this.children[0].getEdgeCorners(0).concat(this.children[1].getEdgeCorners(0));case 1:return this.children[1].getEdgeCorners(1);case 2:return this.children[1].getEdgeCorners(2).concat(this.children[0].getEdgeCorners(2));case 3:return this.children[0].getEdgeCorners(3)}return null},getAllCorners:function(r){var n=[this.corners[r]];if(this.neighbors[r]==null)return n;var a=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,u=re.EPSILON,d=this,p=[function(v){return v.uv[0]>d.corners[0].uv[0]+u&&v.uv[0]<d.corners[2].uv[0]-u},function(v){return v.uv[1]>d.corners[0].uv[1]+u&&v.uv[1]<d.corners[2].uv[1]-u}],_=a.filter(p[l]);return _.reverse(),n.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){case 0:this.midPoints[0]=this.evalSrf(this.u05,this.corners[0].uv[1]);break;case 1:this.midPoints[1]=this.evalSrf(this.corners[1].uv[0],this.v05);break;case 2:this.midPoints[2]=this.evalSrf(this.u05,this.corners[2].uv[1]);break;case 3:this.midPoints[3]=this.evalSrf(this.corners[0].uv[0],this.v05);break}return this.midPoints[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,n=0;n<r;){var a=n++;if(this.corners[a],this.corners[a].degen){var l=this.corners[(a+1)%r],u=this.corners[(a+3)%r];l.degen?this.corners[a].normal=u.normal:this.corners[a].normal=l.normal}}},shouldDivide:function(r,n){if(n<r.minDepth)return!0;if(n>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=m.normSquared(m.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return m.normSquared(m.sub(a.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Or),r.normTol==null&&(r.normTol=.085),r.minDepth==null&&(r.minDepth=0),r.maxDepth==null&&(r.maxDepth=10),this._divide(r,0,!0)},_divide:function(r,n,a){if(this.evalCorners(),!!this.shouldDivide(r,n)){if(n++,this.splitVert&&!this.splitHoriz?a=!1:!this.splitVert&&this.splitHoriz&&(a=!0),this.horizontal=a,this.horizontal){var l=[this.corners[0],this.corners[1],this.midpoint(1),this.midpoint(3)],u=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new cr(this.srf,l),new cr(this.srf,u)],this.children[0].neighbors=[this.neighbors[0],this.neighbors[1],this.children[1],this.neighbors[3]],this.children[1].neighbors=[this.children[0],this.neighbors[1],this.neighbors[2],this.neighbors[3]]}else{var d=[this.corners[0],this.midpoint(0),this.midpoint(2),this.corners[3]],p=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new cr(this.srf,d),new cr(this.srf,p)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,v=this.children;_<v.length;){var w=v[_];++_,w._divide(r,n,!a)}}},triangulate:function(r){if(r==null&&(r=qt.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,a=this.children;n<a.length;){var l=a[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,a=[],l=[],u=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(u=p+1);for(var v=0,w=_.length;v<w;){var I=v++;a.push(_[I])}}for(var S=0;S<a.length;){var P=a[S];if(++S,P.id!=-1){l.push(P.id);continue}r.uvs.push(P.uv),r.points.push(P.point),r.normals.push(P.normal),P.id=n,l.push(n),n++}if(a.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(a.length==5){var k=l.length;return r.faces.push([l[u],l[(u+2)%k],l[(u+1)%k]]),r.faces.push([l[(u+4)%k],l[(u+3)%k],l[u]]),r.faces.push([l[u],l[(u+3)%k],l[(u+2)%k]]),r}var M=this.center();r.uvs.push(M.uv),r.points.push(M.point),r.normals.push(M.normal);for(var L=r.points.length-1,C=0,B=a.length-1;C<a.length;)r.faces.push([L,l[C],l[B]]),B=C++;return r},__class__:cr};var we=g.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=we,we.__name__=["verb","exe","Dispatcher"],we.init=function(){we._init||(we._workerPool=new zr(we.THREADS),we._init=!0)},we.dispatchMethod=function(r,n,a){we.init();var l=new yn,u=function(d){l.resolve(d)};return we._workerPool.addWork(ue.getClassName(r),n,a,u),new pt(l)};var zr=g.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new xe,this._working=new xe,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(zr.basePath+n)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(zr.basePath+n.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=zr,zr.__name__=["verb","exe","WorkerPool"],zr.prototype={addWork:function(r,n,a,l){var u=new $r(r,n,a);this._callbacks.set(u.id,l),this._queue.push(u),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),a=[n.id],l=[this._pool.shift()];this._working.h[a[0]]=l[0],l[0].onmessage=function(u,d){return function(p){r._working.remove(d[0]),r._pool.push(u[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](p.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,a),l[0].postMessage(n)}},__class__:zr};var $r=function(r,n,a){this.className=r,this.methodName=n,this.args=a,this.id=$r.uuid++};x["verb.exe._WorkerPool.Work"]=$r,$r.__name__=["verb","exe","_WorkerPool","Work"],$r.prototype={__class__:$r};var kn=function(){};x["verb.geom.ICurve"]=kn,kn.__name__=["verb","geom","ICurve"],kn.__interfaces__=[In],kn.prototype={__class__:kn};var Ne=g.geom.NurbsCurve=function(r){this._data=Wt.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Ne,Ne.__name__=["verb","geom","NurbsCurve"],Ne.__interfaces__=[kn],Ne.byKnotsControlPointsWeights=function(r,n,a,l){return new Ne(new je(r,n.slice(),N.homogenize1d(a,l)))},Ne.byPoints=function(r,n){return n==null&&(n=3),new Ne(pe.rationalInterpCurve(r,n))},Ne.__super__=Ze,Ne.prototype=T(Ze.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new je(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ne(this._data)},domain:function(){return new wt($.first(this._data.knots),$.last(this._data.knots))},transform:function(r){return new Ne(ge.rationalCurveTransform(this._data,r))},transformAsync:function(r){return we.dispatchMethod(ge,"rationalCurveTransform",[this._data,r]).then(function(n){return new Ne(n)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return we.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return we.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),N.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),we.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return ye.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return we.dispatchMethod(ye,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return ye.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return we.dispatchMethod(ye,"rationalCurveClosestParam",[this._data,r])},length:function(){return ye.rationalCurveArcLength(this._data)},lengthAsync:function(){return we.dispatchMethod(ye,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return ye.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return we.dispatchMethod(ye,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return ye.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return we.dispatchMethod(ye,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return lt.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return we.dispatchMethod(lt,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return lt.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return we.dispatchMethod(lt,"rationalCurveByArcLength",[this._data,r])},split:function(r){return lt.curveSplit(this._data,r).map(function(n){return new Ne(n)})},splitAsync:function(r){return we.dispatchMethod(lt,"curveSplit",[this._data,r]).then(function(n){return n.map(function(a){return new Ne(a)})})},reverse:function(){return new Ne(ge.curveReverse(this._data))},reverseAsync:function(){return we.dispatchMethod(ge,"curveReverse",[this._data]).then(function(r){return new Ne(r)})},tessellate:function(r){return Oe.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return we.dispatchMethod(Oe,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ne});var Rr=g.geom.Arc=function(r,n,a,l,u,d){Ne.call(this,pe.arc(r,n,a,l,u,d)),this._center=r,this._xaxis=n,this._yaxis=a,this._radius=l,this._minAngle=u,this._maxAngle=d};x["verb.geom.Arc"]=Rr,Rr.__name__=["verb","geom","Arc"],Rr.__super__=Ne,Rr.prototype=T(Ne.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},radius:function(){return this._radius},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Rr});var Jn=g.geom.BezierCurve=function(r,n){Ne.call(this,pe.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=Jn,Jn.__name__=["verb","geom","BezierCurve"],Jn.__super__=Ne,Jn.prototype=T(Ne.prototype,{__class__:Jn});var es=g.geom.Circle=function(r,n,a,l){Rr.call(this,r,n,a,l,0,Math.PI*2)};x["verb.geom.Circle"]=es,es.__name__=["verb","geom","Circle"],es.__super__=Rr,es.prototype=T(Rr.prototype,{__class__:es});var Tn=function(){};x["verb.geom.ISurface"]=Tn,Tn.__name__=["verb","geom","ISurface"],Tn.__interfaces__=[In],Tn.prototype={__class__:Tn};var Pe=g.geom.NurbsSurface=function(r){this._data=Wt.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Pe,Pe.__name__=["verb","geom","NurbsSurface"],Pe.__interfaces__=[Tn],Pe.byKnotsControlPointsWeights=function(r,n,a,l,u,d){return new Pe(new et(r,n,a,l,N.homogenize2d(u,d)))},Pe.byCorners=function(r,n,a,l){return new Pe(pe.fourPointSurface(r,n,a,l))},Pe.byLoftingCurves=function(r,n){return new Pe(pe.loftedSurface(function(a){for(var l,u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.asNurbs())}return l=u,l}(),n))},Pe.__super__=Ze,Pe.prototype=T(Ze.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new et(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Pe(this.asNurbs())},domainU:function(){return new wt($.first(this._data.knotsU),$.last(this._data.knotsU))},domainV:function(){return new wt($.first(this._data.knotsV),$.last(this._data.knotsV))},point:function(r,n){return N.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return we.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return N.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return we.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,a){return a==null&&(a=1),N.rationalSurfaceDerivatives(this._data,r,n,a)},derivativesAsync:function(r,n,a){return a==null&&(a=1),we.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,n,a])},closestParam:function(r){return ye.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return we.dispatchMethod(ye,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return ye.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return we.dispatchMethod(ye,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),lt.surfaceSplit(this._data,r,n).map(function(a){return new Pe(a)})},splitAsync:function(r,n){return n==null&&(n=!1),we.dispatchMethod(lt,"surfaceSplit",[this._data,r,n]).then(function(a){return a.map(function(l){return new Pe(l)})})},reverse:function(r){return r==null&&(r=!1),new Pe(ge.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),we.dispatchMethod(ge,"surfaceReverse",[this._data,r]).then(function(n){return new Pe(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Ne(pe.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),we.dispatchMethod(pe,"surfaceIsocurve",[this._data,r,n]).then(function(a){return new Ne(a)})},boundaries:function(r){return pe.surfaceBoundaryCurves(this._data).map(function(n){return new Ne(n)})},boundariesAsync:function(r){return we.dispatchMethod(pe,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(a){return new Ne(a)})})},tessellate:function(r){return Oe.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return we.dispatchMethod(Oe,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Pe(ge.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return we.dispatchMethod(ge,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new Pe(n)})},__class__:Pe});var ts=g.geom.ConicalSurface=function(r,n,a,l,u){Pe.call(this,pe.conicalSurface(r,n,a,l,u)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=u};x["verb.geom.ConicalSurface"]=ts,ts.__name__=["verb","geom","ConicalSurface"],ts.__super__=Pe,ts.prototype=T(Pe.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:ts});var rs=g.geom.CylindricalSurface=function(r,n,a,l,u){Pe.call(this,pe.cylindricalSurface(r,n,a,l,u)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=u};x["verb.geom.CylindricalSurface"]=rs,rs.__name__=["verb","geom","CylindricalSurface"],rs.__super__=Pe,rs.prototype=T(Pe.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:rs});var Br=g.geom.EllipseArc=function(r,n,a,l,u){Ne.call(this,pe.ellipseArc(r,n,a,l,u)),this._center=r,this._xaxis=n,this._yaxis=a,this._minAngle=l,this._maxAngle=u};x["verb.geom.EllipseArc"]=Br,Br.__name__=["verb","geom","EllipseArc"],Br.__super__=Ne,Br.prototype=T(Ne.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Br});var ns=g.geom.Ellipse=function(r,n,a){Br.call(this,r,n,a,0,Math.PI*2)};x["verb.geom.Ellipse"]=ns,ns.__name__=["verb","geom","Ellipse"],ns.__super__=Br,ns.prototype=T(Br.prototype,{__class__:ns});var ss=g.geom.ExtrudedSurface=function(r,n){Pe.call(this,pe.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=ss,ss.__name__=["verb","geom","ExtrudedSurface"],ss.__super__=Pe,ss.prototype=T(Pe.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:ss});var Dr=g.geom.Intersect=function(){};x["verb.geom.Intersect"]=Dr,Dr.__name__=["verb","geom","Intersect"],Dr.curves=function(r,n,a){return a==null&&(a=.001),le.curves(r.asNurbs(),n.asNurbs(),a)},Dr.curvesAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"curves",[r.asNurbs(),n.asNurbs(),a])},Dr.curveAndSurface=function(r,n,a){return a==null&&(a=.001),le.curveAndSurface(r.asNurbs(),n.asNurbs(),a)},Dr.curveAndSurfaceAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"curveAndSurface",[r.asNurbs(),n.asNurbs(),a])},Dr.surfaces=function(r,n,a){return a==null&&(a=.001),le.surfaces(r.asNurbs(),n.asNurbs(),a).map(function(l){return new Ne(l)})},Dr.surfacesAsync=function(r,n,a){return a==null&&(a=.001),we.dispatchMethod(le,"surfaces",[r.asNurbs(),n.asNurbs(),a]).then(function(l){return l.map(function(u){return new Ne(u)})})};var is=g.geom.Line=function(r,n){Ne.call(this,pe.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=is,is.__name__=["verb","geom","Line"],is.__super__=Ne,is.prototype=T(Ne.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:is});var as=g.geom.RevolvedSurface=function(r,n,a,l){Pe.call(this,pe.revolvedSurface(r.asNurbs(),n,a,l)),this._profile=r,this._center=n,this._axis=a,this._angle=l};x["verb.geom.RevolvedSurface"]=as,as.__name__=["verb","geom","RevolvedSurface"],as.__super__=Pe,as.prototype=T(Pe.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:as});var os=g.geom.SphericalSurface=function(r,n){Pe.call(this,pe.sphericalSurface(r,[0,0,1],[1,0,0],n)),this._center=r,this._radius=n};x["verb.geom.SphericalSurface"]=os,os.__name__=["verb","geom","SphericalSurface"],os.__super__=Pe,os.prototype=T(Pe.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:os});var ls=g.geom.SweptSurface=function(r,n){Pe.call(this,pe.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=ls,ls.__name__=["verb","geom","SweptSurface"],ls.__super__=Pe,ls.prototype=T(Pe.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:ls});function Xt(r){return r instanceof Array?function(){return O.iter(r)}:typeof r.iterator=="function"?Tt(r,r.iterator):r.iterator}var Vi,Lu=0;function Tt(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=Lu++);var a;return r.hx__closures__==null?r.hx__closures__={}:a=r.hx__closures__[n.__id__],a==null&&(a=function(){return a.method.apply(a.scope,arguments)},a.scope=r,a.method=n,r.hx__closures__[n.__id__]=a),a}x.Math=Math,String.prototype.__class__=x.String=String,String.__name__=["String"],x.Array=Array,Array.__name__=["Array"],Date.prototype.__class__=x.Date=Date,Date.__name__=["Date"];var Ou=x.Int={__name__:["Int"]},zu=x.Dynamic={__name__:["Dynamic"]},vo=x.Float=Number;vo.__name__=["Float"];var yo=x.Bool=Boolean;yo.__ename__=["Bool"];var bo=x.Class={__name__:["Class"]},xo={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],a=0,l=this.length;a<l;){var u=a++;n[u]=r(this[u])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],a=0,l=this.length;a<l;){var u=a++,d=this[u];r(d)&&n.push(d)}return n});var ji={},Vs=A.ArrayBuffer||ot;Vs.prototype.slice==null&&(Vs.prototype.slice=ot.sliceImpl),A.DataView;var Gi=A.Uint8Array||nr._new;(function(r,n){if(r.setImmediate)return;var a=1,l={},u=!1,d=r.document,p;function _(R){return l[a]=v.apply(n,R),a++}function v(R){var F=[].slice.call(arguments,1);return function(){typeof R=="function"?R.apply(n,F):new Function(""+R)()}}function w(R){if(u)setTimeout(v(w,R),0);else{var F=l[R];if(F){u=!0;try{F()}finally{I(R),u=!1}}}}function I(R){delete l[R]}function S(){p=function(){var R=_(arguments);return process.nextTick(v(w,R)),R}}function P(){if(r.postMessage&&!r.importScripts){var R=!0,F=r.onmessage;return r.onmessage=function(){R=!1},r.postMessage("","*"),r.onmessage=F,R}}function k(){var R="setImmediate$"+Math.random()+"$",F=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(R)===0&&w(+V.data.slice(R.length))};r.addEventListener?r.addEventListener("message",F,!1):r.attachEvent("onmessage",F),p=function(){var V=_(arguments);return r.postMessage(R+V,"*"),V}}function M(){var R=new MessageChannel;R.port1.onmessage=function(F){var V=F.data;w(V)},p=function(){var F=_(arguments);return R.port2.postMessage(F),F}}function L(){var R=d.documentElement;p=function(){var F=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){w(F),V.onreadystatechange=null,R.removeChild(V),V=null},R.appendChild(V),F}}function C(){p=function(){var R=_(arguments);return setTimeout(v(w,R),0),R}}var B=Object.getPrototypeOf&&Object.getPrototypeOf(r);B=B&&B.setTimeout?B:r,{}.toString.call(r.process)==="[object process]"?S():P()?k():r.MessageChannel?M():d&&"onreadystatechange"in d.createElement("script")?L():C(),B.setImmediate=p,B.clearImmediate=I})(new Function("return this")()),Ye.USE_CACHE=!1,Ye.USE_ENUM_INDEX=!1,Ye.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",We.DEFAULT_RESOLVER=ue,We.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Le.count=0,at.i64tmp=function(r){var n,a=new Ve(0,0);return n=a,n}(),Me.__toStr={}.toString,nr.BYTES_PER_ELEMENT=1,Se.queue=new U,Be.memo=new xe,re.TOLERANCE=1e-6,re.EPSILON=1e-10,re.VERSION="2.0.0",ye.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],ye.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],we.THREADS=1,we._init=!1,zr.basePath="",$r.uuid=0,Fs.main()}(typeof console<"u"?console:{log:function(){}},t,typeof c<"u"?c:typeof s<"u"?s:typeof self<"u"?self:this),t})})(ru);var e0=ru.exports;const On=Jd(e0);class la{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(e,t,s,o){this.c0=e,this.c1=s,this.c2=-3*e+3*t-2*s-o,this.c3=2*e-2*t+s+o}initCatmullRom(e,t,s,o,h){this.init(t,s,h*(s-e),h*(o-t))}initNonuniformCatmullRom(e,t,s,o,h,c,f){let b=(t-e)/h-(s-e)/(h+c)+(s-t)/c,g=(s-t)/c-(o-t)/(c+f)+(o-s)/f;b*=c,g*=c,this.init(t,s,b,g)}calc(e){const t=e*e,s=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*s}}class nu extends Bs{constructor(e=[],t=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new Z,this._px=new la,this._py=new la,this._pz=new la,this._points=e.map(h=>new Y(h)),this._closed=t,this._curveType=s,this._tension=o}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 Y}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new Y}get length(){if(this._points.length<2)return 0;let e=0;for(let t=1;t<this._points.length;t++)e+=this._points[t-1].distanceTo(this._points[t]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e}getPoint(e,t=new Y){const s=t,o=this._points,h=o.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(o[0]);const c=(h-(this._closed?0:1))*e;let f=Math.floor(c),b=c-f;this._closed?f+=f>0?0:(Math.floor(Math.abs(f)/h)+1)*h:b===0&&f===h-1&&(f=h-2,b=1);let g,A;this._closed||f>0?g=o[(f-1)%h]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),g=new Y(this._tmp.x,this._tmp.y,this._tmp.z));const x=o[f%h],E=o[(f+1)%h];if(this._closed||f+2<h?A=o[(f+2)%h]:(this._tmp.subVectors(o[h-1],o[h-2]).add(o[h-1]),A=new Y(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const T=this._curveType==="chordal"?.5:.25;let O=Math.pow(g.distanceToSquared(x),T),z=Math.pow(x.distanceToSquared(E),T),U=Math.pow(E.distanceToSquared(A),T);z<1e-4&&(z=1),O<1e-4&&(O=z),U<1e-4&&(U=z),this._px.initNonuniformCatmullRom(g.x,x.x,E.x,A.x,O,z,U),this._py.initNonuniformCatmullRom(g.y,x.y,E.y,A.y,O,z,U),this._pz.initNonuniformCatmullRom(g.z,x.z,E.z,A.z,O,z,U)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(g.x,x.x,E.x,A.x,this._tension),this._py.initCatmullRom(g.y,x.y,E.y,A.y,this._tension),this._pz.initCatmullRom(g.z,x.z,E.z,A.z,this._tension));return s.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),s}getPoints(e){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}setPoints(e){this._points=e.map(t=>new Y(t)),this._boundingBoxNeedsUpdate=!0}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)}setCurveType(e){this._curveType=e}setTension(e){this._tension=e}transform(e){return this._points=this._points.map(t=>{const s=new Y;return s.copy(t),s.applyMatrix3d(e),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Re;const e=new Re;return this._points.forEach(t=>{e.expandByPoint(t)}),e}}class fn{constructor(e,t,s,o){this._degree=e,this._knots=[...t],this._controlPoints=s.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=o?[...o]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(e=>({x:e.x,y:e.y,z:e.z}))}weights(){return[...this._weights]}point(e){const t=this._controlPoints.map(s=>[s.x,s.y,s.z]);return Ms(e,this._degree,this._knots,t,this._weights)}length(){const e=this._controlPoints.map(t=>[t.x,t.y,t.z]);return Kh(this._degree,this._knots,e,this._weights)}static byKnotsControlPointsWeights(e,t,s,o){return new fn(e,t,s,o)}static byPoints(e,t,s="Uniform"){let o;switch(s){case"Chord":o=Yh(t,e);break;case"SqrtChord":o=Xh(t,e);break;case"Uniform":default:o=qh(t,e.length);break}const h=e.map(f=>({x:f[0],y:f[1],z:f[2]})),c=new Array(h.length).fill(1);return new fn(t,o,h,c)}getParameterRange(){const e=this._knots[this._degree],t=this._knots[this._knots.length-this._degree-1];return{start:e,end:t}}getPoints(e){const t=[],{start:s,end:o}=this.getParameterRange();for(let h=0;h<=e;h++){const c=s+(o-s)*(h/e);t.push(this.point(c))}return t}isClosed(e=1e-6){const{start:t,end:s}=this.getParameterRange(),o=this.point(t),h=this.point(s),c=o[0]-h[0],f=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(c*c+f*f+b*b)<e}static createFitPointsForClosedCurve(e){if(e.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const t=new nu(e,!0,"centripetal"),s=Math.max(50,e.length*2);return t.getPoints(s)}static createClosedCurve(e,t,s="Chord"){const o=this.createFitPointsForClosedCurve(e).map(h=>[h.x,h.y,h.z]);return fn.byPoints(o,t,s)}}class Yr extends Bs{constructor(e,t,s,o,h){super();const c=arguments.length;if(c<2||c>5)throw Ut.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(t)){this._controlPoints=e;let f,b=3,g=!1;if(c>=3&&(Array.isArray(s)?(f=s,c>=4&&(b=o||3),c>=5&&(g=h)):s!==void 0&&(b=s||3,c>=4&&(g=o))),s===void 0&&c>=4&&(b=o||3,c>=5&&(g=h)),this._degree=b,this._closed=g,this._controlPoints.length<this._degree+1)throw Ut.ILLEGAL_PARAMETERS;const A=this.toVerbPoints(this._controlPoints);this._nurbsCurve=On.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,A,f)}else{if(this._fitPoints=e,this._knotParameterization=t,c>=3&&(this._degree=s||3),c>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw Ut.ILLEGAL_PARAMETERS;const f=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=On.geom.NurbsCurve.byPoints(f,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const e=fn.createFitPointsForClosedCurve(this._fitPoints),t=this.toNurbsPoints(e);this._nurbsCurve=On.geom.NurbsCurve.byPoints(t,this._degree)}else{const e=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=On.geom.NurbsCurve.byPoints(e,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const e=fn.createFitPointsForClosedCurve(this._controlPoints),t=this.toNurbsPoints(e);this._nurbsCurve=On.geom.NurbsCurve.byPoints(t,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const e=this._nurbsCurve.knots(),t=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=On.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,s,t)}}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),s=e[t],o=this._nurbsCurve.point(s);return new Y(o[0],o[1],o[2])}get endPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),s=e[e.length-t-1],o=this._nurbsCurve.point(s);return new Y(o[0],o[1],o[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(e){if(!this._fitPoints)throw new Error("No fit points in this spline");const t=this._fitPoints.length,s=e<0||e>=t?t-1:e,o=this._fitPoints[s];return{x:o.x,y:o.y,z:o.z||0}}getControlPointAt(e){const t=this._controlPoints.length,s=e<0||e>=t?t-1:e;return this._controlPoints[s]}getPoints(e=100){const t=this._nurbsCurve,s=[],o=t.knots(),h=this._nurbsCurve.degree(),c=o[h],f=o[o.length-h-1],b=(f-c)/(e-1);for(let g=0;g<e;g++){const A=g===e-1?f:c+g*b,x=t.point(A);s.push(new Y(x[0],x[1],x[2]))}return s}getCurvePoints(e,t){const s=[],o=e.knots(),h=o[3],c=(o[o.length-4]-h)/(t-1);for(let f=0;f<t;f++){const b=h+f*c;s.push(e.point(b))}return s}calculateBoundingBox(){const e=this.getPoints(100);return new Re().setFromPoints(e)}get closed(){return this._closed}set closed(e){this.setClosed(e)}transform(e){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]=[s.x,s.y,s.z||0]}),t}toVerbPoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]=[s.x,s.y,s.z||0]}),t}toGePoints(e){const t=new Array(e.length);return e.forEach((s,o)=>{t[o]={x:s[0],y:s[1],z:s[2]}}),t}static createClosedSpline(e,t="Uniform",s=3){if(e.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Yr(e,t,s,!0)}}var dn=256,su=[],Xo=256,Hs;for(;dn--;)su[dn]=(dn+256).toString(16).substring(1);function t0(i){var e=0,t=11;if(!Hs||dn+t>Xo*2)for(Hs="",dn=0;e<Xo;e++)Hs+=su[Math.random()*256|0];return Hs.substring(dn,dn+++t)}class Xr{constructor(e,t){e=e||{},Fn(e,{objectId:t0()}),this._attrs=new sl(e,t)}get attrs(){return this._attrs}getAttr(e){const t=this._attrs.get(e);if(t===void 0)throw new Error(`[AcDbObject] Attribute name '${e}' does't exist in this object!`);return t}getAttrWithoutException(e){return this._attrs.get(e)}setAttr(e,t){this._attrs.set(e,t)}get objectId(){return this.getAttr("objectId")}set objectId(e){this._attrs.set("objectId",e)}get ownerId(){return this.getAttr("ownerId")}set ownerId(e){this._attrs.set("ownerId",e)}get database(){return this._database?this._database:Va().workingDatabase}set database(e){this._database=e}close(){}}const ja=class ja extends Xr{constructor(){super(...arguments),this._layer="0",this._color=new Wr,this._lineType=Xs,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.typeName}get layer(){return this._layer}set layer(e){this._layer=e}get color(){return this._color}set color(e){this._color.copy(e)}get rgbColor(){let e=this.database.cecolor;if(this.color.isByLayer){const t=this.getLayerColor();t&&t.color&&(e=t)}else this.color.isByBlock||this.color.color!=null&&(e=this.color);return e.color==null?16777215:e.color}get lineType(){return this._lineType}set lineType(e){this._lineType=e||Xs}get lineWeight(){return this._lineWeight}set lineWeight(e){this._lineWeight=e}get linetypeScale(){return this._linetypeScale}set linetypeScale(e){this._linetypeScale=e}get visibility(){return this._visibility}set visibility(e){this._visibility=e}get transparency(){return this._transparency}set transparency(e){this._transparency=e}subGetGripPoints(){return new Array}subGetOsnapPoints(e,t,s,o,h){}transformBy(e){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}get lineStyle(){var s;const e=this.getLineType(),t=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(e);return t?{...t.linetype,color:this.rgbColor}:{name:e,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Xs){const e=this.database.tables.layerTable.getAt(this.layer);if(e&&e.linetype)return e.linetype}else return this.lineType==cl?ei:this.lineType;return ei}getLayerColor(){const e=this.database.tables.layerTable.getAt(this.layer);if(e==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return e.color;return null}attachEntityInfo(e){e&&(e.objectId=this.objectId,e.ownerId=this.ownerId,e.layerName=this.layer,e.visible=this.visibility)}};ja.typeName="Entity";let Vt=ja;const Ga=class Ga extends Vt{};Ga.typeName="Curve";let jt=Ga;const Wa=class Wa extends jt{constructor(e,t,s,o){super(),this._geo=new pn(e,t,s,o,Z.Z_AXIS,Z.X_AXIS)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get startAngle(){return this._geo.startAngle}set startAngle(e){this._geo.startAngle=e}get endAngle(){return this._geo.endAngle}set endAngle(e){this._geo.endAngle=e}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 e=new Array;return e.push(this.center),e.push(this.startPoint),e.push(this.endPoint),e}transformBy(e){return this._geo.transform(e),this}draw(e){return e.circularArc(this._geo,this.lineStyle)}};Wa.typeName="Arc";let si=Wa;const Ha=class Ha extends Vt{constructor(e){super(),this._blockName=e,this._position=new Y,this._rotation=0,this._normal=new Z(0,0,1),this._scaleFactors=new Y(1,1,1)}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scaleFactors(){return this._scaleFactors}set scaleFactors(e){this._scaleFactors.copy(e)}get normal(){return this._normal}set normal(e){this._normal.copy(e).normalize()}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}get geometricExtents(){const e=new Re,t=this.blockTableRecord;if(t!=null){const h=t.newIterator();for(const c of h)e.union(c.geometricExtents)}const s=new Hr().setFromEuler(new Jh(this.rotation,0,0)),o=new gn;return o.compose(this.position,s,this.scaleFactors),e.applyMatrix4(o),e}draw(e){const t=[],s=this.blockTableRecord;if(s!=null){const o=this.computeTransformMatrix(),h=Gr.instance.draw(e,s,this.rgbColor,!0,o,this.normal);return this.attachEntityInfo(h),h}else{const o=e.group(t);return this.attachEntityInfo(o),o}}computeTransformMatrix(){const e=new Hr;return e.setFromAxisAngle(Z.Z_AXIS,this.rotation),new gn().compose(this._position,e,this._scaleFactors)}};Ha.typeName="BlockReference";let Ls=Ha;const qa=class qa extends jt{constructor(e,t,s=Z.Z_AXIS){super(),this._geo=new pn(e,t,0,nt,s,Z.X_AXIS)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetGripPoints(){const e=new Array;return e.push(this.center),e}transformBy(e){return this._geo.transform(e),this}draw(e){return e.circularArc(this._geo,this.lineStyle)}};qa.typeName="Circle";let ii=qa;const Ya=class Ya extends jt{constructor(e,t,s,o,h,c,f){super(),this._geo=new Oi(e,t,s,o,h,c,f)}get center(){return this._geo.center}set center(e){this._geo.center=e}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(e){this._geo.majorAxisRadius=e}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(e){this._geo.minorAxisRadius=e}get normal(){return this._geo.normal}set normal(e){this._geo.normal=e}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}draw(e){return e.ellipticalArc(this._geo,this.lineStyle)}};Ya.typeName="Ellipse";let ai=Ya;const Xa=class Xa extends Vt{constructor(){super(),this._vertices=[new Y,new Y,new Y],this._edgeInvisibilities=0}getVertexAt(e){return e<0?this._vertices[0]:e>this._vertices.length?this._vertices[this._vertices.length-1]:this._vertices[e]}setVertexAt(e,t){if(e<0&&this._vertices[0].copy(t),e>=3)return this._vertices.length===3&&this._vertices.push(new Y),this._vertices[3].copy(t);this._vertices[e].copy(t)}setEdgeInvisibilities(e){this._edgeInvisibilities=e}isEdgeVisibleAt(e){if(e<0||e>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<e)===0}makeEdgeInvisibleAt(e){if(e<0||e>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<e}get geometricExtents(){return new Re().setFromPoints(this._vertices)}subGetGripPoints(){const e=new Array;for(let t=0;t<this._vertices.length;++t)e.push(this.getVertexAt(t));return e}draw(e){const t=this._vertices.length,s=new Float32Array(t*3),o=new Uint16Array(t*2);for(let h=0;h<t;h++)s[h*3]=this._vertices[h].x,s[h*3+1]=this._vertices[h].y,s[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(o[h*2]=h,o[h*2+1]=(h+1)%4);return e.lineSegments(s,3,o,this.lineStyle)}};Xa.typeName="Face";let oi=Xa;var iu=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(iu||{}),au=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(au||{});const Ka=class Ka extends Vt{constructor(){super(),this._elevation=0,this._geo=new Ci,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(e){this._patternName=e}get patternType(){return this._patternType}set patternType(e){this._patternType=e}get patternAngle(){return this._patternAngle}set patternAngle(e){this._patternAngle=e}get patternScale(){return this._patternScale}set patternScale(e){this._patternScale=e}get hatchStyle(){return this._hatchStyle}set hatchStyle(e){this._hatchStyle=e}add(e){this._geo.add(e)}get geometricExtents(){const e=this._geo.box;return new Re({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}draw(e){return e.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}};Ka.typeName="Hatch";let li=Ka;var ou=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(ou||{});const $a=class $a extends jt{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(e){this._isSplined=e}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(e){this._hasArrowHead=e}get hasHookLine(){return this._hasHookLine}set hasHookLine(e){this._hasHookLine=e}get numVertices(){return this._vertices.length}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(e){this._dimensionStyle=e}get annoType(){return this._annoType}set annoType(e){this._annoType=e}appendVertex(e){this._vertices.push(new Y().copy(e)),this._updated=!0}setVertexAt(e,t){throw(e<0||e>=this._vertices.length)&&(this._vertices[e].copy(t),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(e){throw(e<0||e>=this._vertices.length)&&this._vertices[e],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Re().setFromPoints(this._vertices)}get closed(){return!1}set closed(e){}draw(e){if(this.isSplined&&this.splineGeo){const t=this.splineGeo.getPoints(100);return e.lines(t,this.lineStyle)}else return e.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 Yr(this._vertices,"Uniform"),this._updated=!1)}};$a.typeName="Leader";let hi=$a;const Za=class Za extends jt{constructor(e,t){super(),this._geo=new qr(e,t)}get startPoint(){return this._geo.startPoint}set startPoint(e){this._geo.startPoint=e}get endPoint(){return this._geo.endPoint}set endPoint(e){this._geo.endPoint=e}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}subGetGripPoints(){const e=new Array;return e.push(this.midPoint),e.push(this.startPoint),e.push(this.endPoint),e}subGetOsnapPoints(e,t,s,o,h){const c=this.startPoint,f=this.endPoint;switch(e){case cn.EndPoint:h.push(c),h.push(f);break;case cn.MidPoint:h.push(this.midPoint);break;case cn.Nearest:{const b=this._geo.project(s);h.push(b)}break;case cn.Perpendicular:{const b=this._geo.perpPoint(s);h.push(b)}break;case cn.Tangent:h.push(c);break}}transformBy(e){return this._geo.transform(e),this}draw(e){const t=this.startPoint,s=this.endPoint,o=[new Y(t.x,t.y,0),new Y(s.x,s.y,0)];return e.lines(o,this.lineStyle)}};Za.typeName="Line";let ui=Za;var za=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(za||{}),Ri=(i=>(i[i.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",i[i.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",i[i.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",i[i.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",i[i.BY_STYLE=5]="BY_STYLE",i))(Ri||{}),Bn=(i=>(i[i.TopLeft=1]="TopLeft",i[i.TopCenter=2]="TopCenter",i[i.TopRight=3]="TopRight",i[i.MiddleLeft=4]="MiddleLeft",i[i.MiddleCenter=5]="MiddleCenter",i[i.MiddleRight=6]="MiddleRight",i[i.BottomLeft=7]="BottomLeft",i[i.BottomCenter=8]="BottomCenter",i[i.BottomRight=9]="BottomRight",i))(Bn||{}),Ra=(i=>(i[i.OPTIMIZED_2D=0]="OPTIMIZED_2D",i[i.WIREFRAME=1]="WIREFRAME",i[i.HIDDEN_LINE=2]="HIDDEN_LINE",i[i.FLAT_SHADED=3]="FLAT_SHADED",i[i.GOURAUD_SHADED=4]="GOURAUD_SHADED",i[i.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",i[i.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",i))(Ra||{}),Ba=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(Ba||{}),Da=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Da||{});class Bi{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new Y,this._height=0,this._width=0,this._viewCenter=new Y,this._viewHeight=0}get number(){return this._number}set number(e){this._number=e}get id(){return this._id}set id(e){this._id=e}get groupId(){return this._groupId}set groupId(e){this._groupId=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get box(){const e=new _t;return e.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter.copy(e)}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const e=new _t;return e.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),e}clone(){const e=new Bi;return e.id=this.id,e.groupId=this.groupId,e.number=this.number,e.centerPoint.copy(this.centerPoint),e.height=this.height,e.width=this.width,e.viewCenter.copy(this.viewCenter),e.viewHeight=this.viewHeight,e}copy(e){return this.id=e.id,this.groupId=e.groupId,this.number=e.number,this.centerPoint.copy(e.centerPoint),this.height=e.height,this.width=e.width,this.viewCenter.copy(e.viewCenter),this.viewHeight=e.viewHeight,this}}const Qa=class Qa extends Vt{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 Y,this._attachmentPoint=Bn.TopLeft,this._direction=new Z(1,0,0),this._drawingDirection=Ri.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(e){this._contents=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(e){this._lineSpacingFactor=e}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(e){this._lineSpacingStyle=e}get backgroundFill(){return this._backgroundFill}set backgroundFill(e){this._backgroundFill=e,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(e){this._backgroundFillColor=e}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(e){this._backgroundFillTransparency=e}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(e){this._backgroundScaleFactor=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get location(){return this._location}set location(e){this._location.copy(e)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get direction(){return this._direction}set direction(e){this._direction.copy(e)}get drawingDirection(){return this._drawingDirection}set drawingDirection(e){this._drawingDirection=e}get geometricExtents(){return new Re}getTextStyle(){const e=this.database.tables.textStyleTable;let t=e.getAt(this.styleName);return t||(t=e.getAt("STANDARD")||e.getAt("Standard")),t.textStyle}draw(e,t){const s={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor},o={...this.getTextStyle(),color:this.rgbColor};return e.mtext(s,o,t)}};Qa.typeName="MText";let ci=Qa;const Ja=class Ja extends jt{constructor(e,t,s,o,h){super();const c=+(e!==void 0)+ +(t!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c<2||c>5)throw Ut.ILLEGAL_PARAMETERS;!Array.isArray(t)?this._geo=new Yr(e,t,s,o):this._geo=new Yr(e,t,s,o,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}draw(e){const t=this._geo.getPoints(100);return e.lines(t,this.lineStyle)}};Ja.typeName="Spline";let Os=Ja;const r0=new Z,eo=class eo extends Ls{constructor(e,t,s){super(e),this._attachmentPoint=Bn.TopLeft,this._numColumns=s,this._numRows=t,this._columnWidth=new Array(s),this._rowHeight=new Array(t),this._cells=new Array(t*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get numRows(){return this._numRows}set numRows(e){this._numRows=e}get numColumns(){return this._numColumns}set numColumns(e){this._numColumns=e}numContents(e,t){return 1}rowHeight(e){return this._rowHeight[e]}setRowHeight(e,t){this._rowHeight[e]=t}setUniformRowHeight(e){this._rowHeight.fill(e)}columnWidth(e){return this._columnWidth[e]}setUniformColumnWidth(e){this._columnWidth.fill(e)}setColumnWidth(e,t){this._columnWidth[e]=t}cell(e){if(!(e<0||e>=this._cells.length))return this._cells[e]}setCell(e,t){this._cells[e]=t}textString(e,t,s){return this._cells[e*t].text}setTextString(e,t,s){this._cells[e*t].text=s}isEmpty(e,t){return!this._cells[e*t].text}get geometricExtents(){return new Re}draw(e){let t=0,s=0;const o=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let c=0;for(let E=0;E<=this.numRows;E++){t-=E>0?this.rowHeight(E-1):0,s=0;for(let T=0;T<=this.numColumns;T++)s+=T>0?this.columnWidth(T-1):0,h[c++]=s,h[c++]=t,h[c++]=0}const f=[],b=new Array(this.numRows*this.numColumns).fill(!1);s=0,c=0;let g=0;for(let E=0;E<this.numColumns;E++){s+=E>0?this.columnWidth(E-1):0,t=0;for(let T=0;T<this.numRows;T++){t+=T>0?this.rowHeight(T-1):0;const O=this.cell(T*this.numColumns+E);if(g=T*this.numColumns+E,O&&!b[g]){const z=O.borderWidth??1,U=O.borderHeight??1;this.fillVisited(b,g,this.numColumns,z,U),o[c++]=E+T*(this.numColumns+1),o[c++]=E+T*(this.numColumns+1)+z;const D=h[o[c-1]*3]-s,de=E+(T+U)*(this.numColumns+1)+z;E+z==this.numColumns&&(o[c++]=E+T*(this.numColumns+1)+z,o[c++]=de);const ve=-h[de*3+1]-t;if(T+U==this.numRows&&(o[c++]=E+(T+U)*(this.numColumns+1)+U,o[c++]=E+(T+U)*(this.numColumns+1)),o[c++]=E+(T+U)*(this.numColumns+1),o[c++]=E+T*(this.numColumns+1),O.text){const oe=O.attachmentPoint||this.attachmentPoint||Bn.MiddleCenter,W=this.getTableTextOffset(oe,D,ve),ue={text:O.text,height:O.textHeight,width:D,position:r0.set(s,-t,0).clone().add(W),rotation:this.rotation,attachmentPoint:oe},se={...this.getTextStyle(O),color:this.color.color};f.push(e.mtext(ue,se))}}}}f.push(e.lineSegments(h,3,o,this.lineStyle));const A=e.group(f),x=new Hr;return x.setFromAxisAngle(Z.Z_AXIS,this.rotation),Ko.compose(this.position,x,this.scaleFactors),A.applyMatrix(Ko),this.attachEntityInfo(A),A}fillVisited(e,t,s,o,h){if(h==1&&o==1)e[t]=!0;else for(let c=0;c<o;++c)for(let f=0;f<h;++f)e[t+c+f*s]=!0}getTextStyle(e){const t=this.database.tables.textStyleTable;let s;return e.textStyle&&(s=t.getAt(e.textStyle)),s||(s=t.getAt("STANDARD")||t.getAt("Standard")),s.textStyle}getTableTextOffset(e,t,s){const o=new Z;switch(e){case 1:break;case 2:o.setX(t/2);break;case 3:o.setX(t);break;case 4:o.setY(-s/2);break;case 5:o.set(t/2,-s/2,0);break;case 6:o.set(t,-s/2,0);break;case 7:o.setY(-s);break;case 8:o.set(t/2,-s,0);break;case 9:o.set(t,-s,0);break}return o}};eo.typeName="Table";let di=eo;const Ko=new gn;var lu=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(lu||{}),hu=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(hu||{});const to=class to extends Vt{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new Y,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(e){this._textString=e}get thickness(){return this._thickness}set thickness(e){this._thickness=e}get height(){return this._height}set height(e){this._height=e}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get horizontalMode(){return this._horizontalMode}set horizontalMode(e){this._horizontalMode=e}get verticalMode(){return this._verticalModel}set verticalMode(e){this._verticalModel=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor=e}get geometricExtents(){return new Re}getTextStyle(){const e=this.database.tables.textStyleTable;let t=e.getAt(this.styleName);return t||(t=e.getAt("STANDARD")||e.getAt("Standard")),t.textStyle}draw(e,t){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Ri.BOTTOM_TO_TOP,attachmentPoint:Bn.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return e.mtext(s,o,t)}};to.typeName="Text";let mi=to;const ro=class ro extends jt{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new Y,new Y,new Y,new Y]}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return!0}get thickness(){return this._thickness}set thickness(e){this._thickness=e}getPointAt(e){return e<0?this._vertices[0]:e>3?this._vertices[3]:this._vertices[e]}setPointAt(e,t){if(e<0&&this._vertices[0].copy(t),e>3)return this._vertices[3].copy(t);this._vertices[e].copy(t)}get geometricExtents(){return new Re().setFromPoints(this._vertices)}subGetGripPoints(){const e=new Array;for(let t=0;t<4;++t)e.push(this.getPointAt(t));return e}draw(e){const t=new Ds(this._vertices,!0),s=new Ci;return s.add(t),e.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};ro.typeName="Trace";let pi=ro;const no=class no extends jt{constructor(){super(),this._elevation=0,this._geo=new Ds}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}addVertexAt(e,t,s=0,o=-1,h=-1){const c=o<0?void 0:o,f=h<0?void 0:h,b={x:t.x,y:t.y,bulge:s,startWidth:c,endWidth:f};this._geo.addVertexAt(e,b)}getPoint2dAt(e){return this._geo.getPointAt(e)}getPoint3dAt(e){const t=this.getPoint2dAt(e);return new Y(t.x,t.y,this._elevation)}get geometricExtents(){const e=this._geo.box;return new Re({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}subGetGripPoints(){const e=new Array;for(let t=0;t<this.numberOfVertices;++t)e.push(this.getPoint3dAt(t));return e}draw(e){const t=[];return this._geo.getPoints(100).forEach(o=>t.push(new Y().set(o.x,o.y,this.elevation))),e.lines(t,this.lineStyle)}};no.typeName="Polyline";let fi=no;const so=class so extends Vt{constructor(){super(),this._geo=new Y}get position(){return this._geo}set position(e){this._geo.set(e.x,e.y,e.z||0)}get geometricExtents(){return new Re().expandByPoint(this._geo)}transformBy(e){return this._geo.applyMatrix3d(e),this}draw(e){return e.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}};so.typeName="Point";let gi=so;var uu=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(uu||{}),cu=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(cu||{});const io=class io extends Vt{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new Y,this._scale=new $e(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(e){this._brightness=e}get contrast(){return this._contrast}set contrast(e){this._contrast=e}get fade(){return this._fade}set fade(e){this._fade=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get position(){return this._position}set position(e){this._position=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scale(){return this._scale}set scale(e){this._scale.copy(e)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(e){this._clipBoundaryType=e}get clipBoundary(){return this._clipBoundary}set clipBoundary(e){this._clipBoundary=[],this._clipBoundary.push(...e)}get isClipped(){return this._isClipped}set isClipped(e){this._isClipped=e}get isShownClipped(){return this._isShownClipped}set isShownClipped(e){this._isShownClipped=e}get isImageShown(){return this._isImageShown}set isImageShown(e){this._isImageShown=e}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(e){this._isImageTransparent=e}get image(){return this._image}set image(e){this._image=e}get imageDefId(){return this._imageDefId}set imageDefId(e){this._imageDefId=e}get imageFileName(){if(this._imageDefId){const e=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(e)return e.sourceFileName}return""}get geometricExtents(){const e=new Re;return e.min.copy(this._position),e.max.set(this._position.x+this._width,this._position.y+this._height,0),e}subGetGripPoints(){return this.boundaryPath()}draw(e){const t=this.boundaryPath();return this._image?e.image(this._image,{boundary:t,roation:this._rotation}):e.lines(t,this.lineStyle)}boundaryPath(){const e=[];if(this.isClipped&&this._clipBoundary.length>3){const t=this._width,s=this._height,o=new _t;o.setFromPoints(this._clipBoundary);const h=new Te;h.setX(this._position.x-o.min.x*t),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(c=>{const f=c.x*t+h.x,b=c.y*s+h.y;e.push(new Y(f,b,this._position.z))})}else{if(e.push(this._position),e.push(this._position.clone().setX(this._position.x+this._width)),e.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),e.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){$o.copy(e[1]);for(let t=1;t<4;t++)qs.copy(e[t]),qs.rotateAround($o,this._rotation),e[t].setX(qs.x),e[t].setY(qs.y)}e.push(e[0])}return e}};io.typeName="RasterImage";let zs=io;const $o=new Te,qs=new Te,ao=class ao extends jt{constructor(){super(),this._basePoint=new Y,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new Re;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}draw(e){const t=[];return t.push(this.basePoint),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t,this.lineStyle)}};ao.typeName="Ray";let _i=ao;const oo=class oo extends Vt{constructor(){super(),this._centerPoint=new Y,this._height=0,this._width=0,this._viewCenter=new Y,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(e){this._number=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter=e}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get geometricExtents(){return new Re}draw(e){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const t=this.toGiViewport(),s=e.group(this.createViewportRect(t,e));return this.attachEntityInfo(s),s}}toGiViewport(){const e=new Bi;return e.id=this.objectId,e.groupId=this.ownerId,e.number=this.number,e.centerPoint=this.centerPoint,e.width=this.width,e.height=this.height,e.viewHeight=this.viewHeight,e.viewCenter=this.viewCenter,e}createViewportRect(e,t){const s=[];return s.push(t.lines([new Y(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0),new Y(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0)],this.lineStyle)),s.push(t.lines([new Y(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0),new Y(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0)],this.lineStyle)),s.push(t.lines([new Y(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0),new Y(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0)],this.lineStyle)),s.push(t.lines([new Y(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0),new Y(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0)],this.lineStyle)),s}};oo.typeName="Viewport";let vi=oo;const lo=class lo extends zs{draw(e){const t=this.boundaryPath(),s=new Ci;return s.add(new Ds(t)),e.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};lo.typeName="Wipeout";let yi=lo;const ho=class ho extends jt{constructor(){super(),this._basePoint=new Y,this._unitDir=new Z}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new Re;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}draw(e){const t=[];return t.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t,this.lineStyle)}};ho.typeName="Xline";let bi=ho;var du=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(du||{});const uo=class uo extends Vt{constructor(){super(),this._dimBlockId=null,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new Y,this._textRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(e){this._dimBlockId=e}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(e){this._dimensionStyleName=e}get dimensionStyle(){if(this._dimStyle==null){let e;this.dimensionStyleName&&(e=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),e==null&&(e=new Dn),this._dimStyle=e}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(e){this._dimensionText=e}get measurement(){return this._measurement}set measurement(e){this._measurement=e}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(e){this._textLineSpacingFactor=e}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(e){this._textLineSpacingStyle=e}get textPosition(){return this._textPosition}set textPosition(e){this._textPosition.copy(e)}get textRotation(){return this._textRotation}set textRotation(e){this._textRotation=e}draw(e){if(this.dimBlockId){const s=this.database.tables.blockTable.getAt(this.dimBlockId);if(s){const o=Gr.instance.draw(e,s,this.rgbColor,!1);return this.attachEntityInfo(o),o}}const t=e.group([]);return this.attachEntityInfo(t),t}drawFirstArrow(e){const t=this.database.tables.blockTable.getAt(this.firstArrowType);if(t)return Gr.instance.draw(e,t,this.rgbColor,!1)}drawSecondArrow(e){const t=this.database.tables.blockTable.getAt(this.secondArrowType);if(t)return Gr.instance.draw(e,t,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 e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk1}get firstArrowType(){const e=this.firstArrowTypeBtrId;return this.getArrowName(e)}get secondArrowTypeBtrId(){const e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk2}get secondArrowType(){const e=this.secondArrowTypeBtrId;return this.getArrowName(e)}get arrowLineCount(){return 1}getLineArrowStyle(e){}findPointOnLine1(e,t,s){const o=new Y().subVectors(t,e).normalize();return new Y(t).addScaledVector(o,s)}findPointOnLine2(e,t,s){const o=e.x+s*Math.cos(t),h=e.y+s*Math.sin(t);return{x:o,y:h}}adjustExtensionLine(e){const t=this.dimensionStyle;e.extend(t.dimexe),e.extend(-t.dimexo,!0)}getArrowName(e){const t=this.database.tables.blockTable.getIdAt(e);return t?t.name.toUpperCase():za.Closed}};uo.typeName="Dimension";let Tr=uo;const co=class co extends Tr{constructor(e,t,s,o,h=null,c=null){super(),this._centerPoint=new Y().copy(e),this._xLine1Point=new Y().copy(t),this._xLine2Point=new Y().copy(s),this._arcPoint=new Y().copy(o),this.dimensionText=h,this.dimensionStyleName=c}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get geometricExtents(){return new Re}};co.typeName="3PointAngularDimension";let xi=co;const mo=class mo extends Tr{constructor(e,t,s,o=null,h=null){super(),this._dimLinePoint=new Y().copy(s),this._xLine1Point=new Y().copy(e),this._xLine2Point=new Y().copy(t),this._oblique=0,this._rotation=0,this.dimensionText=o,this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(e){this._dimLinePoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get geometricExtents(){return new Re}get isAppendArrow(){return!1}calculateLines(){const e=[],t=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(t,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),c=new qr(o,h);return e.push(c),t.endPoint=o,this.adjustExtensionLine(t),e.push(t),s.endPoint=h,this.adjustExtensionLine(s),e.push(s),e}createExtensionLine(e){const t=this.rotation+Math.PI/2,s=this.findPointOnLine2(e,t,100);return new qr(e,{...s,z:e.z})}findIntersectionPoint(e,t){const s=e.startPoint,o=e.endPoint,h=new Z().subVectors(o,s).normalize(),f=new Z().subVectors(t,s).dot(h),b=new Z().copy(h).multiplyScalar(f);return new Z().addVectors(s,b)}};mo.typeName="AlignedDimension";let wi=mo;const po=class po extends Tr{constructor(e,t,s,o,h=null,c=null){super(),this._arcPoint=new Y().copy(o),this._xLine1Point=new Y().copy(t),this._xLine2Point=new Y().copy(s),this._centerPoint=new Y().copy(e),this.dimensionText=h,this.dimensionStyleName=c}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get geometricExtents(){return new Re}};po.typeName="ArcDimension";let pa=po;const fo=class fo extends Tr{constructor(e,t,s=0,o=null,h=null){super(),this._chordPoint=new Y().copy(e),this._farChordPoint=new Y().copy(t),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=o,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get farChordPoint(){return this._farChordPoint}set farChordPoint(e){this._farChordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Re}drawLines(e,t){const s=[],o=t.length;return o==1?s.push(this.drawLine(e,t[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(t),s.push(this.drawLine(e,t[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(e,t[1])),s.push(this.drawLine(e,t[2],{firstArrow:this.firstArrowStyle}))):t.forEach(h=>{s.push(this.drawLine(e,h))}),s}drawLine(e,t,s){if(s){const o=[t.startPoint,t.endPoint];return e.lines(o,{...this.lineStyle,arrows:s})}else return t.draw(e)}sortLines(e){const t=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;e.sort((s,o)=>{const h=t(s.startPoint,o.startPoint);return h!==0?h:t(s.endPoint,o.endPoint)})}};fo.typeName="DiametricDimension";let Ai=fo;const go=class go extends Tr{constructor(e,t,s=null,o=null){super(),this._definingPoint=new Y().copy(e),this._leaderEndPoint=new Y().copy(t),this.dimensionText=s,this.dimensionStyleName=o}get definingPoint(){return this._definingPoint}set definingPoint(e){this._definingPoint.copy(e)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(e){this._leaderEndPoint.copy(e)}get geometricExtents(){return new Re}get arrowLineCount(){return 0}};go.typeName="OrdinateDimension";let Si=go;const _o=class _o extends Tr{constructor(e,t,s,o=null,h=null){super(),this._center=new Y().copy(e),this._chordPoint=new Y().copy(t),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=o,this.dimensionStyleName=h}get center(){return this._center}set center(e){this._center.copy(e)}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}set leaderLenght(e){this._leaderLength=e}get geometricExtents(){return new Re}getLineArrowStyle(e){return{secondArrow:this.secondArrowStyle}}};_o.typeName="RadialDimension";let Ii=_o;class Zo{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="MTEXT"?this.convertMText(e):e.type=="POLYLINE"||e.type=="LWPOLYLINE"?this.convertPolyline(e):e.type=="POINT"?this.convertPoint(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):null}convertFace(e){const t=new oi;return e.vertices.forEach((s,o)=>t.setVertexAt(o,s)),t}convertArc(e){return new si(e.center,e.radius,Ee.degToRad(e.startAngle),Ee.degToRad(e.endAngle))}convertCirle(e){return new ii(e.center,e.radius)}convertEllipse(e){const t=new Z(e.majorAxisEndPoint),s=t.length();return new ai(e.center,e.extrusionDirection??Z.Z_AXIS,t,s,s*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,s=e.endPoint;return new ui(new Y(t.x,t.y,t.z||0),new Y(s.x,s.y,s.z||0))}convertSpline(e){try{if(e.numberOfControlPoints>0&&e.numberOfKnots>0)return new Os(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1));if(e.numberOfFitPoints>0){const t=this.numberArrayToPointArray(e.fitPoints,e.numberOfFitPoints);if(t!=null)return new Os(t,"Uniform",e.degree,!!(e.flag&1))}}catch(t){console.log(`Failed to convert spline with error: ${t}`)}return null}convertPoint(e){const t=new gi;return t.position=e.position,t}convertSolid(e){const t=new pi;return e.points.forEach((s,o)=>t.setPointAt(o,s)),t.thickness=e.thickness,t}convertPolyline(e){const t=new fi;return t.closed=!!(e.flag&1),e.vertices.forEach((s,o)=>{t.addVertexAt(o,new Te(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),t}convertHatch(e){var o;const t=new li;return(o=e.definitionLines)==null||o.forEach(h=>{t.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:e.patternAngle,t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const f=h,b=new Ds;b.closed=f.isClosed,f.vertices.forEach((g,A)=>{b.addVertexAt(A,{x:g.x,y:g.y,bulge:g.bulge})}),t.add(b)}else{const f=h,b=new tu;f.edges.forEach(g=>{if(g.type==1){const A=g;b.add(new zi(A.start,A.end))}else if(g.type==2){const A=g;b.add(new Rn(A.center,A.radius,Ee.degToRad(A.startAngle||0),Ee.degToRad(A.endAngle||0),!A.isCCW))}else if(g.type==3){const A=g;new $e().subVectors(A.end,A.center);const E=Math.sqrt(Math.pow(A.end.x,2)+Math.pow(A.end.y,2)),T=E*A.lengthOfMinorAxis;let O=Ee.degToRad(A.startAngle||0),z=Ee.degToRad(A.endAngle||0);const U=Math.atan2(A.end.y,A.end.x);A.isCCW||(O=Math.PI*2-O,z=Math.PI*2-z),b.add(new Li({...A.center,z:0},E,T,O,z,!A.isCCW,U))}else if(g.type==4){const A=g;if(A.numberOfControlPoints>0&&A.numberOfKnots>0){const x=A.controlPoints.map(O=>({x:O.x,y:O.y,z:0}));let E=!0;const T=A.controlPoints.map(O=>(O.weight==null&&(E=!1),O.weight||1));b.add(new Yr(x,A.knots,E?T:void 0))}else if(A.numberOfFitData>0){const x=A.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new Yr(x,"Uniform"))}}}),t.add(b)}}),t}convertTable(e){const t=new di(e.name,e.rowCount,e.columnCount);return t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),e.columnWidthArr.forEach((s,o)=>t.setColumnWidth(o,s)),e.rowHeightArr.forEach((s,o)=>t.setRowHeight(o,s)),e.cells.forEach((s,o)=>{t.setCell(o,s)}),t}convertText(e){const t=new mi;return t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint),t.rotation=Ee.degToRad(e.rotation||0),t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertMText(e){const t=new ci;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=Ee.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new Z(e.direction)),t.drawingDirection=e.drawingDirection,t}convertLeader(e){const t=new hi;return e.vertices.forEach(s=>{t.appendVertex(s)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName,t.annoType=e.leaderCreationFlag,t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"||e.subclassMarker=="AcDbRotatedDimension"){const t=e,s=new wi(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return s.rotation=Ee.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,s=new xi(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,s=new Si(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,s=new Ii(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,s=new Ai(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,s),s}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.isShownClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,t.imageDefId=e.imageDefHandle,t.isClipped=e.isClipped,e.clippingBoundaryPath.forEach(s=>{t.clipBoundary.push(new Te(s))}),t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new zs;return this.processImage(e,t),t.clipBoundaryType=e.clippingBoundaryType,t}processWipeout(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.isShownClipped=(e.displayFlag|4)>0,t.isImageShown=(e.displayFlag|3)>0,t.isImageTransparent=(e.displayFlag|8)>0,t.imageDefId=e.imageDefHardId,t.isClipped=e.isClipping,e.boundary.forEach(s=>{t.clipBoundary.push(new Te(s))}),t.clipBoundaryType=e.boundaryType,t.width=Math.sqrt(e.uDirection.x**2+e.uDirection.y**2+e.uDirection.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vDirection.x**2+e.vDirection.y**2+e.vDirection.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uDirection.y,e.uDirection.x)}convertWipeout(e){const t=new yi;return this.processWipeout(e,t),t}convertViewport(e){const t=new vi;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new _i;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new bi;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new Ls(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale||1,t.scaleFactors.y=e.yScale||1,t.scaleFactors.z=e.zScale||1,t.rotation=e.rotation!=null?Ee.degToRad(e.rotation):0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement}processCommonAttrs(e,t){t.layer=e.layer||"0",e.handle&&(t.objectId=e.handle),t.ownerId=e.ownerBlockRecordSoftId||"",e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null&&(t.color.color=e.color),e.colorIndex!=null&&(t.color.colorIndex=e.colorIndex),e.colorName!=null&&(t.color.colorName=e.colorName),e.isVisible!=null&&(t.visibility=e.isVisible),e.transparency!=null&&(t.transparency=e.transparency)}numberArrayToPointArray(e,t){const s=e.length;let o=0;if(s/2==t?o=2:s/3==t&&(o=3),o==0)return;const h=[];for(let c=0,f=s/o;c<f;++c)h.push({x:e[c*o],y:e[c*o+1],z:o==3?e[c*o+2]:0});return h}}class Di extends Xr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _t,this._extents=new Re}get layoutName(){return this._layoutName}set layoutName(e){this._layoutName=e.length>256?e.slice(0,256):e}get tabOrder(){return this._tabOrder}set tabOrder(e){this._tabOrder=e}get tabSelected(){return this._tabSelected}set tabSelected(e){this._tabSelected=e}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(e){this._blockTableRecordId=e}get limits(){return this._limits}set limits(e){this._limits.copy(e)}get extents(){return this._extents}set extents(e){this._extents.copy(e)}}class Fa extends Xr{constructor(e){super(),this.database=e,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(e,t){t.database=this.database,this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t),this.database.events.dictObjetSet.dispatch({database:this.database,object:t,key:e})}remove(e){const t=this.getAt(e);return t?(this._recordsByName.delete(e.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e}),!0):!1}removeId(e){const t=this.getIdAt(e);return t?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,o)=>{s===t&&(this._recordsByName.delete(o),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:o}))}),!0):!1}removeAll(){this._recordsByName.forEach((e,t)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t})}),this._recordsByName.clear(),this._recordsById.clear()}has(e){return this._recordsByName.has(e.toUpperCase())}hasId(e){return this._recordsById.has(e)}getAt(e){return this._recordsByName.get(e)}getIdAt(e){return this._recordsById.get(e)}newIterator(){return new Ti(this._recordsByName)}}class mu extends Fa{getBtrIdAt(e){for(const[t,s]of this._recordsByName)if(s.blockTableRecordId==e)return s}get maxTabOrder(){let e=-1;return this._recordsByName.forEach(t=>{t.tabOrder>e&&(e=t.tabOrder)}),e}}class pu extends Xr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(e){this._sourceFileName=e}}class n0{convertLayout(e,t){var o;const s=new Di;return s.layoutName=e.layoutName,s.tabOrder=e.tabOrder,(o=t.tables.BLOCK_RECORD)==null||o.entries.some(h=>h.layoutObjects===e.handle?(s.blockTableRecordId=h.handle,!0):!1),s.limits.min.copy(e.minLimit),s.limits.max.copy(e.maxLimit),s.extents.min.copy(e.minExtent),s.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,s),s}convertImageDef(e){const t=new pu;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,t.ownerId=e.ownerObjectId}}class fu{constructor(e){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:e.workerUrl,timeout:e.timeout??3e4,maxConcurrentWorkers:e.maxConcurrentWorkers??4}}async execute(e,t){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,e,t||this.config.workerUrl)}catch(h){const c=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:c}}}async executeInWorker(e,t,s){const o=Date.now();return new Promise((h,c)=>{const f=this.getAvailableWorker(s),b=setTimeout(()=>{this.cleanupTask(e),this.releaseWorker(f),c(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(e,{resolve:x=>{clearTimeout(b),this.releaseWorker(f),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(f),c(x)},timeout:b});const g=x=>{const{id:E,success:T,data:O,error:z}=x.data;if(E!==e)return;this.cleanupTask(e);const U=Date.now()-o;h(T?{success:!0,data:O,duration:U}:{success:!1,error:z,duration:U})},A=x=>{this.cleanupTask(e),c(new Error(`Worker error: ${x.message}`))};f.addEventListener("message",g),f.addEventListener("error",A),f.postMessage({id:e,input:t})})}cleanupTask(e){const t=this.pendingTasks.get(e);t&&(clearTimeout(t.timeout),this.pendingTasks.delete(e))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(e){for(const[s,o]of this.workers)if(!o.isBusy)return o.isBusy=!0,o.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const s=new Worker(e,{type:"module"}),o=this.generateWorkerId(),h={worker:s,isBusy:!0,id:o,createdAt:new Date};return this.workers.set(o,h),s}const t=Array.from(this.workers.values()).sort((s,o)=>s.createdAt.getTime()-o.createdAt.getTime())[0];return t.isBusy=!0,t.worker}releaseWorker(e){for(const[t,s]of this.workers)if(s.worker===e){s.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(e=>e.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[e,t]of this.pendingTasks)clearTimeout(t.timeout),t.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[e,t]of this.workers)t.worker.terminate();this.workers.clear()}}class gu{constructor(e){this.framework=new fu(e)}async execute(e,t){return this.framework.execute(e,t)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function _u(i){return new gu(i)}class s0{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async e=>{const{id:t,input:s}=e.data;try{const o=await this.executeTask(s);this.sendResponse(t,!0,o)}catch(o){this.sendResponse(t,!1,void 0,o instanceof Error?o.message:String(o))}}}sendResponse(e,t,s,o){const h={id:e,success:t,data:s,error:o};self.postMessage(h)}}class vu extends ba{constructor(e={}){super(e),e.parserWorkerUrl||(e.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e){if(this.config.useWorker&&this.config.parserWorkerUrl){const t=_u({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await t.execute(e);if(t.destroy(),s.success)return{model:s.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${s.error}'`)}else return{model:new Hd().parse(e),data:{unknownEntityCount:0}}}getFonts(e){var h;const t=new Map,s=c=>{if(c){const f=c.lastIndexOf(".");return f>=0?c.substring(0,f).toLowerCase():c.toLowerCase()}};(h=e.tables.STYLE)==null||h.entries.forEach(c=>{const f=[];let b=s(c.font);b&&f.push(b),b=s(c.bigFont),b&&f.push(b),t.set(c.name,f)});const o=new Set;return this.getFontsInBlock(e.entities,e.blocks,t,o),Array.from(o)}getFontsInBlock(e,t,s,o){const h=/\\f(.*?)\|/g;e.forEach(c=>{if(c.type=="MTEXT"){const f=c;[...f.text.matchAll(h)].forEach(A=>{o.add(A[1].toLowerCase())});const g=s.get(f.styleName);g==null||g.forEach(A=>o.add(A))}else if(c.type=="TEXT"){const f=c,b=s.get(f.styleName);b==null||b.forEach(g=>o.add(g))}else if(c.type=="INSERT"){const b=t[c.name];b&&b.entities&&this.getFontsInBlock(b.entities,t,s,o)}})}async processEntities(e,t,s,o,h){const c=new Zo;let f=e.entities;const b=f.length,g=new ga(b,100-o.value,s);this.config.convertByEntityType&&(f=this.groupAndFlattenByType(f));const A=t.tables.blockTable.modelSpace;await g.processChunk(async(x,E)=>{let T=[],O=x<E?f[x].type:"";for(let z=x;z<E;z++){const U=f[z],D=c.convert(U);D&&(this.config.convertByEntityType&&U.type!==O&&(A.appendEntity(T),T=[],O=U.type),T.push(D))}if(A.appendEntity(T),h){let z=o.value+E/b*(100-o.value);z>100&&(z=100),await h(z,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(e,t){const s=new Zo,o=e.length,h=[];for(let c=0;c<o;c++){const f=e[c],b=s.convert(f);b&&h.push(b)}t.appendEntity(h)}processBlocks(e,t){const s=e.blocks;for(const[o,h]of Object.entries(s)){let c=t.tables.blockTable.getAt(h.name);c||(c=new Ft,c.objectId=h.handle,c.name=o,c.origin.copy(h.position),t.tables.blockTable.add(c)),h.entities&&this.processEntitiesInBlock(h.entities,c)}}processHeader(e,t){const s=e.header;s.$ACADVER&&(t.version=s.$ACADVER),t.cecolor.colorIndex=s.$CECOLOR||256,t.angBase=s.$ANGBASE||0,t.angDir=s.$ANGDIR||0,s.$AUNITS!=null&&(t.aunits=s.$AUNITS),s.$EXTMAX&&(t.extmax=s.$EXTMAX),s.$EXTMIN&&(t.extmin=s.$EXTMIN),s.$INSUNITS!=null&&(t.insunits=s.$INSUNITS),t.pdmode=s.$PDMODE||0,t.pdsize=s.$PDSIZE||0}processBlockTables(e,t){var o;const s=(o=e.tables.BLOCK_RECORD)==null?void 0:o.entries;s&&s.length>0&&(t.tables.blockTable.removeAll(),s.forEach(h=>{const c=new Ft;c.objectId=h.handle,c.name=h.name,c.layoutId=h.layoutObjects,t.tables.blockTable.add(c)}))}processObjects(e,t){const s=e.objects.byName,o=new n0;if("LAYOUT"in s){const h=t.dictionaries.layouts;s.LAYOUT.forEach(c=>{const f=o.convertLayout(c,e);h.setAt(f.layoutName,f)})}if("IMAGEDEF"in s){const h=t.dictionaries.imageDefs;s.IMAGEDEF.forEach(c=>{const f=o.convertImageDef(c);h.setAt(f.objectId,f)})}}processViewports(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const f=new Nu;this.processCommonTableEntryAttrs(c,f),c.circleSides&&(f.circleSides=c.circleSides),f.standardFlag=c.standardFlag,f.center.copy(c.center),f.lowerLeftCorner.copy(c.lowerLeftCorner),f.upperRightCorner.copy(c.upperRightCorner),c.snapBasePoint&&f.snapBase.copy(c.snapBasePoint),c.snapRotationAngle&&(f.snapAngle=c.snapRotationAngle),c.snapSpacing&&f.snapIncrements.copy(c.snapSpacing),c.majorGridLines&&(f.gridMajor=c.majorGridLines),c.gridSpacing&&f.gridIncrements.copy(c.gridSpacing),c.backgroundObjectId&&(f.backgroundObjectId=c.backgroundObjectId),f.gsView.center.copy(c.center),f.gsView.viewDirectionFromTarget.copy(c.viewDirectionFromTarget),f.gsView.viewTarget.copy(c.viewTarget),c.lensLength&&(f.gsView.lensLength=c.lensLength),c.frontClippingPlane&&(f.gsView.frontClippingPlane=c.frontClippingPlane),c.backClippingPlane&&(f.gsView.backClippingPlane=c.backClippingPlane),c.viewHeight&&(f.gsView.viewHeight=c.viewHeight),c.viewTwistAngle&&(f.gsView.viewTwistAngle=c.viewTwistAngle),c.frozenLayers&&(f.gsView.frozenLayers=c.frozenLayers),c.styleSheet&&(f.gsView.styleSheet=c.styleSheet),c.renderMode&&(f.gsView.renderMode=c.renderMode),c.viewMode&&(f.gsView.viewMode=c.viewMode),c.ucsIconSetting&&(f.gsView.ucsIconSetting=c.ucsIconSetting),c.ucsOrigin&&f.gsView.ucsOrigin.copy(c.ucsOrigin),c.ucsXAxis&&f.gsView.ucsXAxis.copy(c.ucsXAxis),c.ucsYAxis&&f.gsView.ucsYAxis.copy(c.ucsYAxis),c.orthographicType&&(f.gsView.orthographicType=c.orthographicType),c.shadePlotSetting&&(f.gsView.shadePlotSetting=c.shadePlotSetting),c.shadePlotObjectId&&(f.gsView.shadePlotObjectId=c.shadePlotObjectId),c.visualStyleObjectId&&(f.gsView.visualStyleObjectId=c.visualStyleObjectId),c.isDefaultLightingOn&&(f.gsView.isDefaultLightingOn=c.isDefaultLightingOn),c.defaultLightingType&&(f.gsView.defaultLightingType=c.defaultLightingType),c.brightness&&(f.gsView.brightness=c.brightness),c.contrast&&(f.gsView.contrast=c.contrast),c.ambientColor&&(f.gsView.ambientColor=c.ambientColor),t.tables.viewportTable.add(f)})}processLayers(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const f=new Wr;f.colorIndex=c.colorIndex;const b=new Fi({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:f,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,b),t.tables.layerTable.add(b)})}processLineTypes(e,t){var o,h;const s=(h=(o=e.tables)==null?void 0:o.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const f=new Cs(c);this.processCommonTableEntryAttrs(c,f),f.name=c.name,t.tables.linetypeTable.add(f)})}processTextStyles(e,t){var o;const s=(o=e.tables.STYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c=new Ua(h);this.processCommonTableEntryAttrs(h,c),t.tables.textStyleTable.add(c)})}processDimStyles(e,t){var o;const s=(o=e.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c={name:h.name,ownerId:h.ownerObjectId,dimpost:h.DIMPOST||"",dimapost:h.DIMAPOST||"",dimscale:h.DIMSCALE,dimasz:h.DIMASZ,dimexo:h.DIMEXO,dimdli:h.DIMDLI,dimexe:h.DIMEXE,dimrnd:h.DIMRND,dimdle:h.DIMDLE,dimtp:h.DIMTP,dimtm:h.DIMTM,dimtxt:h.DIMTXT,dimcen:h.DIMCEN,dimtsz:h.DIMTSZ,dimaltf:h.DIMALTF,dimlfac:h.DIMLFAC,dimtvp:h.DIMTVP,dimtfac:h.DIMTFAC,dimgap:h.DIMGAP,dimaltrnd:h.DIMALTRND,dimtol:h.DIMTOL==null||h.DIMTOL==0?0:1,dimlim:h.DIMLIM==null||h.DIMLIM==0?0:1,dimtih:h.DIMTIH==null||h.DIMTIH==0?0:1,dimtoh:h.DIMTOH==null||h.DIMTOH==0?0:1,dimse1:h.DIMSE1==null||h.DIMSE1==0?0:1,dimse2:h.DIMSE2==null||h.DIMSE2==0?0:1,dimtad:h.DIMTAD,dimzin:h.DIMZIN,dimazin:h.DIMAZIN,dimalt:h.DIMALT,dimaltd:h.DIMALTD,dimtofl:h.DIMTOFL,dimsah:h.DIMSAH,dimtix:h.DIMTIX,dimsoxd:h.DIMSOXD,dimclrd:h.DIMCLRD,dimclre:h.DIMCLRE,dimclrt:h.DIMCLRT,dimadec:h.DIMADEC||0,dimunit:h.DIMUNIT||2,dimdec:h.DIMDEC,dimtdec:h.DIMTDEC,dimaltu:h.DIMALTU,dimalttd:h.DIMALTTD,dimaunit:h.DIMAUNIT,dimfrac:h.DIMFRAC,dimlunit:h.DIMLUNIT,dimdsep:h.DIMDSEP,dimtmove:h.DIMTMOVE||0,dimjust:h.DIMJUST,dimsd1:h.DIMSD1,dimsd2:h.DIMSD2,dimtolj:h.DIMTOLJ,dimtzin:h.DIMTZIN,dimaltz:h.DIMALTZ,dimalttz:h.DIMALTTZ,dimfit:h.DIMFIT||0,dimupt:h.DIMUPT,dimatfit:h.DIMATFIT,dimtxsty:h.DIMTXSTY||"Standard",dimldrblk:h.DIMLDRBLK||"",dimblk:h.DIMBLK||"",dimblk1:h.DIMBLK1||"",dimblk2:h.DIMBLK2||"",dimlwd:h.DIMLWD,dimlwe:h.DIMLWE},f=new Dn(c);this.processCommonTableEntryAttrs(h,f),t.tables.dimStyleTable.add(f)})}processCommonTableEntryAttrs(e,t){t.name=e.name,t.objectId=e.handle,t.ownerId=e.ownerObjectId}groupAndFlattenByType(e){const t={},s=[];for(const o of e)t[o.type]||(t[o.type]=[],s.push(o.type)),t[o.type].push(o);return s.flatMap(o=>t[o])}}class yu extends ba{constructor(e){super({}),this._database=e}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(e,t,s,o,h){let c=e.tables.blockTable.modelSpace.newIterator().toArray();const f=c.length,b=new ga(f,100-o.value,s);this.config.convertByEntityType&&(c=this.groupAndFlattenByType(c));const g=t.tables.blockTable.modelSpace;await b.processChunk(async(A,x)=>{let E=[],T=A<x?c[A].type:"";for(let O=A;O<x;O++){const z=c[O];this.config.convertByEntityType&&z.type!==T&&(this.triggerEvents(g,E),E=[],T=z.type),E.push(z)}if(this.triggerEvents(g,E),h){let O=o.value+x/f*(100-o.value);O>100&&(O=100),await h(O,"ENTITY","IN-PROGRESS")}})}processBlocks(){const e=this._database.tables.blockTable.newIterator();for(const t of e){const s=t.newIterator().toArray();this.triggerEvents(t,s)}}processHeader(){}processBlockTables(){}processObjects(){const e=this._database.dictionaries.layouts.newIterator();for(const s of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.layoutName});const t=this._database.dictionaries.imageDefs.newIterator();for(const s of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(t=>{this._database.events.layerAppended.dispatch({database:this._database,layer:t})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(e){const t={},s=[];for(const o of e)t[o.type]||(t[o.type]=[],s.push(o.type)),t[o.type].push(o);return s.flatMap(o=>t[o])}triggerEvents(e,t){(e.isModelSapce||e.isPaperSapce)&&e.database.events.entityAppended.dispatch({database:e.database,entity:t})}}var Ns=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Ns||{});class lr{constructor(){this.events={registered:new it,unregistered:new it},this._converters=new Map,this.register("dxf",new vu)}static createInstance(){return lr._instance==null&&(lr._instance=new lr),this._instance}static get instance(){return lr._instance||(lr._instance=new lr),lr._instance}get fileTypes(){return this._converters.keys()}register(e,t){this._converters.set(e,t),this.events.registered.dispatch({fileType:e,converter:t})}get(e){return this._converters.get(e)}unregister(e){const t=this._converters.get(e);t&&(this._converters.delete(e),this.events.unregistered.dispatch({fileType:e,converter:t}))}}class _n extends Xr{constructor(e,t){e=e||{},Fn(e,{name:""}),super(e,t)}get name(){return this.getAttr("name")}set name(e){this.setAttr("name",e)}}const jr=class jr extends _n{static isModelSapceName(e){return e.toLowerCase()==jr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(e){return e.toLowerCase().startsWith(jr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new Y,this._layoutId="",this._entities=new Map}get isModelSapce(){return jr.isModelSapceName(this.name)}get isPaperSapce(){return jr.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(e){this._origin.copy(e)}get layoutId(){return this._layoutId}set layoutId(e){this._layoutId=e}appendEntity(e){if(Array.isArray(e))for(let t=0;t<e.length;++t){const s=e[t];s.database=this.database,s.ownerId=this.objectId,this._entities.set(s.objectId,s)}else e.database=this.database,e.ownerId=this.objectId,this._entities.set(e.objectId,e);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:e})}newIterator(){return new Ti(this._entities)}getIdAt(e){return this._entities.get(e)}};jr.MODEL_SPACE_NAME="*MODEL_SPACE",jr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let Ft=jr;class vn extends Xr{constructor(e){super(),this.database=e,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}add(e){e.database=this.database;const t=this.normalizeName(e.name);this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(e){const t=this.normalizeName(e),s=this._recordsByName.get(t);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(e),!0):!1}removeId(e){const t=this._recordsById.get(e);return t?(this._recordsByName.delete(t.name),this._recordsById.delete(e),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(e){const t=this.normalizeName(e);return this._recordsByName.has(t)}hasId(e){return this._recordsById.has(e)}getAt(e){const t=this.normalizeName(e);return this._recordsByName.get(t)}getIdAt(e){return this._recordsById.get(e)}getOwnerIdAt(e){return this._recordsById.get(e)}newIterator(){return new Ti(this._recordsByName)}normalizeName(e){return e}}class bu extends vn{constructor(e){super(e)}get modelSpace(){let e=this.getAt(Ft.MODEL_SPACE_NAME);return e||(e=new Ft,e.name=Ft.MODEL_SPACE_NAME,this.add(e)),e}normalizeName(e){let t=e;if(Ft.isModelSapceName(e))t=Ft.MODEL_SPACE_NAME;else if(Ft.isPaperSapceName(e)){const s=Ft.PAPER_SPACE_NAME_PREFIX,o=e.substring(s.length);t=s+o}return t}}class xu extends vn{constructor(e){super(e)}}class Fi extends _n{constructor(e,t){e=e||{},Fn(e,{color:new Wr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(e,t),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(e){this.setAttr("color",e.clone())}get description(){return this.getAttr("description")}set description(e){this.setAttr("description",e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(e){this.setAttr("standardFlags",e)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(e){const t=e?1:0;this.standardFlags=this.standardFlags|t}get isHidden(){return this.getAttr("isHidden")}set isHidden(e){this.setAttr("isHidden",e)}get isInUse(){return this.getAttr("isInUse")}set isInUse(e){this.setAttr("isInUse",e)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(e){const t=e?4:0;this.standardFlags=this.standardFlags|t}get isOff(){return this.getAttr("isOff")}set isOff(e){this.setAttr("isOff",e)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(e){this.setAttr("isPlottable",e)}get transparency(){return this.getAttr("transparency")}set transparency(e){this.setAttr("transparency",e)}get linetype(){return this.getAttr("linetype")}set linetype(e){this.setAttr("linetype",e)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(e){this.setAttr("lineWeight",e)}get materialId(){return this.getAttr("materialId")}set materialId(e){this.setAttr("materialId",e)}}class wu extends vn{constructor(e){super(e);const t=new Wr;t.color=16777215;const s=new Fi({name:"0",standardFlags:0,linetype:ei,lineWeight:1,isOff:!1,color:t,isPlottable:!0});this.add(s)}add(e){super.add(e),this.database.events.layerAppended.dispatch({database:this.database,layer:e})}}class Au extends vn{constructor(e){super(e)}}class Su extends vn{constructor(e){super(e)}get fonts(){const e=new Set,t=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const c=o.substring(0,h).toLowerCase();e.add(c)}else e.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)t(o.fileName),t(o.bigFontFileName);return Array.from(e)}}class Iu extends vn{constructor(e){super(e)}}class Cs extends _n{constructor(e){super(),this.name=e.name,this._linetype=e}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(e){if(e<0||e>=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[e].elementLength}}class Ua extends _n{constructor(e){super(),this.name=e.name,this._textStyle=e,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(e){this._textStyle.obliqueAngle=e}get priorSize(){return this._textStyle.lastHeight}set priorSize(e){this._textStyle.lastHeight=e}get textSize(){return this._textStyle.fixedTextHeight}set textSize(e){this._textStyle.fixedTextHeight=e}get xScale(){return this._textStyle.widthFactor}set xScale(e){this._textStyle.widthFactor=e}get isVertical(){return this._isVertical}set isVertical(e){this._isVertical=e}get fileName(){return this._textStyle.font}set fileName(e){this._textStyle.font=e}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(e){this._textStyle.bigFont=e}get textStyle(){return this._textStyle}getFileNameWithoutExtension(e){const t=e.split("/").pop();if(t){const s=t.lastIndexOf(".");return s===-1?t:t.substring(0,s)}return e}}var Pu=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(Pu||{}),Eu=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(Eu||{}),ku=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(ku||{}),Tu=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(Tu||{}),Mu=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(Mu||{});const Ei=class Ei extends _n{constructor(e,t){e=e||{},Fn(e,Ei.DEFAULT_DIM_VALUES),super(e,t)}get dimpost(){return this.getAttr("dimpost")}set dimpost(e){this.setAttr("dimpost",e)}get dimapost(){return this.getAttr("dimapost")}set dimapost(e){this.setAttr("dimapost",e)}get dimscale(){return this.getAttr("dimscale")}set dimscale(e){this.setAttr("dimscale",e)}get dimasz(){return this.getAttr("dimasz")}set dimasz(e){this.setAttr("dimasz",e)}get dimexo(){return this.getAttr("dimexo")}set dimexo(e){this.setAttr("dimexo",e)}get dimdli(){return this.getAttr("dimdli")}set dimdli(e){this.setAttr("dimdli",e)}get dimexe(){return this.getAttr("dimexe")}set dimexe(e){this.setAttr("dimexe",e)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(e){this.setAttr("dimrnd",e)}get dimdle(){return this.getAttr("dimdle")}set dimdle(e){this.setAttr("dimdle",e)}get dimtp(){return this.getAttr("dimtp")}set dimtp(e){this.setAttr("dimtp",e)}get dimtm(){return this.getAttr("dimtm")}set dimtm(e){this.setAttr("dimtm",e)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(e){this.setAttr("dimtxt",e)}get dimcen(){return this.getAttr("dimcen")}set dimcen(e){this.setAttr("dimcen",e)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(e){this.setAttr("dimtsz",e)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(e){this.setAttr("dimaltf",e)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(e){this.setAttr("dimlfac",e)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(e){this.setAttr("dimtvp",e)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(e){this.setAttr("dimtfac",e)}get dimgap(){return this.getAttr("dimgap")}set dimgap(e){this.setAttr("dimgap",e)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(e){this.setAttr("dimaltrnd",e)}get dimtol(){return this.getAttr("dimtol")}set dimtol(e){this.setAttr("dimtol",e)}get dimlim(){return this.getAttr("dimlim")}set dimlim(e){this.setAttr("dimlim",e)}get dimtih(){return this.getAttr("dimtih")}set dimtih(e){this.setAttr("dimtih",e)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(e){this.setAttr("dimtoh",e)}get dimse1(){return this.getAttr("dimse1")}set dimse1(e){this.setAttr("dimse1",e)}get dimse2(){return this.getAttr("dimse2")}set dimse2(e){this.setAttr("dimse2",e)}get dimtad(){return this.getAttr("dimtad")}set dimtad(e){this.setAttr("dimtad",e)}get dimzin(){return this.getAttr("dimzin")}set dimzin(e){this.setAttr("dimzin",e)}get dimazin(){return this.getAttr("dimazin")}set dimazin(e){this.setAttr("dimazin",e)}get dimalt(){return this.getAttr("dimalt")}set dimalt(e){this.setAttr("dimalt",e)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(e){this.setAttr("dimaltd",e)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(e){this.setAttr("dimtofl",e)}get dimsah(){return this.getAttr("dimsah")}set dimsah(e){this.setAttr("dimsah",e)}get dimtix(){return this.getAttr("dimtix")}set dimtix(e){this.setAttr("dimtix",e)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(e){this.setAttr("dimsoxd",e)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(e){this.setAttr("dimclrd",e)}get dimclre(){return this.getAttr("dimclre")}set dimclre(e){this.setAttr("dimclre",e)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(e){this.setAttr("dimclrt",e)}get dimadec(){return this.getAttr("dimadec")}set dimadec(e){this.setAttr("dimadec",e)}get dimunit(){return this.getAttr("dimunit")}set dimunit(e){this.setAttr("dimunit",e)}get dimdec(){return this.getAttr("dimdec")}set dimdec(e){this.setAttr("dimdec",e)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(e){this.setAttr("dimtdec",e)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(e){this.setAttr("dimaltu",e)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(e){this.setAttr("dimalttd",e)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(e){this.setAttr("dimaunit",e)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(e){this.setAttr("dimfrac",e)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(e){this.setAttr("dimlunit",e)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(e){this.setAttr("dimdsep",e)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(e){this.setAttr("dimtmove",e)}get dimjust(){return this.getAttr("dimjust")}set dimjust(e){this.setAttr("dimjust",e)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(e){this.setAttr("dimsd1",e)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(e){this.setAttr("dimsd2",e)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(e){this.setAttr("dimtolj",e)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(e){this.setAttr("dimtzin",e)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(e){this.setAttr("dimaltz",e)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(e){this.setAttr("dimalttz",e)}get dimfit(){return this.getAttr("dimfit")}set dimfit(e){this.setAttr("dimfit",e)}get dimupt(){return this.getAttr("dimupt")}set dimupt(e){this.setAttr("dimupt",e)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(e){this.setAttr("dimatfit",e)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(e){this.setAttr("dimtxsty",e)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(e){this.setAttr("dimldrblk",e)}get dimblk(){return this.getAttr("dimblk")}set dimblk(e){this.setAttr("dimblk",e)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(e){this.setAttr("dimblk1",e)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(e){this.setAttr("dimblk2",e)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(e){this.setAttr("dimlwd",e)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(e){this.setAttr("dimlwe",e)}};Ei.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 Dn=Ei;class i0 extends Xr{constructor(){super(),this.events={dictObjetSet:new it,dictObjectErased:new it,entityAppended:new it,entityModified:new it,layerAppended:new it,layerModified:new it,layerErased:new it,openProgress:new it,headerSysVarChanged:new it},this._version=new ri("AC1014"),this._angBase=0,this._angDir=0,this._aunits=_a.DecimalDegrees,this._celtscale=1,this._cecolor=new Wr,this._extents=new Re,this._insunits=ya.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new bu(this),dimStyleTable:new xu(this),linetypeTable:new Au(this),textStyleTable:new Su(this),layerTable:new wu(this),viewportTable:new Iu(this)},this._dictionaries={layouts:new mu(this),imageDefs:new Fa(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(e){const t=this.tables.blockTable.getIdAt(e);if(t==null)throw new Error(`[AcDbDatabase] The specified block table record id '${e}' doesn't exist in the drawing database!`);this._currentSpace=t}get aunits(){return this._aunits}set aunits(e){this._aunits=e||0,this.triggerHeaderSysVarChangedEvent("aunits")}get version(){return this._version}set version(e){this._version=new ri(e),this.triggerHeaderSysVarChangedEvent("version")}get insunits(){return this._insunits}set insunits(e){this._insunits=e||4,this.triggerHeaderSysVarChangedEvent("insunits")}get ltscale(){return this._ltscale}set ltscale(e){this._ltscale=e||1,this.triggerHeaderSysVarChangedEvent("ltscale")}get cecolor(){return this._cecolor}set cecolor(e){this._cecolor=e||0,this.triggerHeaderSysVarChangedEvent("cecolor")}get celtscale(){return this._celtscale}set celtscale(e){this._celtscale=e||1,this.triggerHeaderSysVarChangedEvent("celtscale")}get angBase(){return this._angBase}set angBase(e){this._angBase=e||0,this.triggerHeaderSysVarChangedEvent("angbase")}get angDir(){return this._angDir}set angDir(e){this._angDir=e||0,this.triggerHeaderSysVarChangedEvent("angdir")}get extmax(){return this._extents.max}set extmax(e){e&&(this._extents.expandByPoint(e),this.triggerHeaderSysVarChangedEvent("extmax"))}get extmin(){return this._extents.min}set extmin(e){e&&(this._extents.expandByPoint(e),this.triggerHeaderSysVarChangedEvent("extmin"))}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(e){this._pdmode=e||0,this.triggerHeaderSysVarChangedEvent("pdmode")}get pdsize(){return this._pdsize}set pdsize(e){this._pdsize=e||0,this.triggerHeaderSysVarChangedEvent("pdsize")}async read(e,t,s=Ns.DXF){const o=lr.instance.get(s);if(o==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await o.read(e,this,t&&t.minimumChunkSize||10,async(h,c,f,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,subStageStatus:f,data:b}),t&&t.fontLoader&&c=="FONT"&&f=="END"){const g=b||this.tables.textStyleTable.fonts;await t.fontLoader.load(g)}})}async openUri(e,t){var E;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const s=await fetch(e);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${e}' with HTTP status code '${s.status}'!`);const o=s.headers.get("content-length"),h=o?parseInt(o,10):null;let c=0;const f=(E=s.body)==null?void 0:E.getReader();if(!f)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:T,value:O}=await f.read();if(T)break;if(b.push(O),c+=O.length,h!==null){const z=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:z,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const g=new Uint8Array(c);let A=0;for(const T of b)g.set(T,A),A+=T.length;e.toLowerCase().split(".").pop()==="dwg"?await this.read(g.buffer,t,Ns.DWG):await this.read(g.buffer,t,Ns.DXF),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}async regen(){await new yu(this).read(null,this,500,async(t,s,o,h)=>{this.events.openProgress.dispatch({database:this,percentage:t,stage:"CONVERSION",subStage:s,subStageStatus:o,data:h})})}createDefaultData(e={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){if(e.layer){const t=new Wr;t.colorIndex=7,this._tables.layerTable.add(new Fi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}if(e.lineType&&(this._tables.linetypeTable.add(new Cs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Cs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Cs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))),e.textStyle&&this._tables.textStyleTable.add(new Ua({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),e.dimStyle&&this._tables.dimStyleTable.add(new Dn({name:"Standard",dimtxsty:"Standard"})),e.layout){const t=new Di;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this._tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this._dictionaries.layouts.setAt(t.layoutName,t),this._tables.blockTable.modelSpace.layoutId=t.objectId}}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,this._extents.makeEmpty()}triggerHeaderSysVarChangedEvent(e){this.events.headerSysVarChanged.dispatch({database:this,name:e})}}const a0={center:new Te,viewDirectionFromTarget:new Y(0,0,1),viewTarget:new Y(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:Ra.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new Y(0,0,0),ucsXAxis:new Y(1,0,0),ucsYAxis:new Y(0,1,0),orthographicType:Ba.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Da.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Nu extends _n{constructor(){super(),this._circleSides=100,this._center=new Te,this._lowerLeftCorner=new Te(0,0),this._upperRightCorner=new Te(1,1),this._snapBase=new Te(0,0),this._snapAngle=0,this._snapSpacing=new Te(0,0),this._standardFlag=0,this._gridSpacing=new Te,this._gridMajor=10,this._gsView=a0}get circleSides(){return this._circleSides}set circleSides(e){this._circleSides=e}get center(){return this._center}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(e){this._lowerLeftCorner.copy(e)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(e){this._upperRightCorner.copy(e)}get snapBase(){return this._snapBase}set snapBase(e){this._snapBase.copy(e)}get snapAngle(){return this._snapAngle}set snapAngle(e){this._snapAngle=e}get snapIncrements(){return this._snapSpacing}set snapIncrements(e){this._snapSpacing.copy(e)}get gridMajor(){return this._gridMajor}set gridMajor(e){this._gridMajor=e}get gridIncrements(){return this._gridSpacing}set gridIncrements(e){this._gridSpacing.copy(e)}get standardFlag(){return this._standardFlag}set standardFlag(e){this._standardFlag=e}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(e){this._backgroundObjectId=e}get gsView(){return this._gsView}}class Cu{constructor(){this.events={layoutCreated:new it,layoutRemoved:new it,layoutRenamed:new it,layoutSwitched:new it}}countLayouts(e){return this.getWorkingDatabase(e).dictionaries.layouts.numEntries}findLayoutNamed(e,t){return this.getWorkingDatabase(t).dictionaries.layouts.getAt(e)}findActiveLayout(){const e=this.getActiveLayout();return e?e.layoutName:"Model"}setCurrentLayoutId(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getIdAt(e);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getBtrIdAt(e);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(e,t){const s=this.getWorkingDatabase(t),o=s.dictionaries.layouts.getAt(e);return this.setCurrentLayoutInternal(o,s)}renameLayout(e,t,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(e);return h?(h.layoutName=t,this.events.layoutRenamed.dispatch({layout:h,oldName:e,newName:t}),!0):!1}layoutExists(e,t){return this.getWorkingDatabase(t).dictionaries.layouts.has(e)}deleteLayout(e,t){const s=this.getWorkingDatabase(t).dictionaries.layouts,o=s.getAt(e);let h=!1;return o&&(h=s.remove(e),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(e,t){const s=this.getWorkingDatabase(t),o=new Di;o.layoutName=e,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new Ft;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(e,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(e){const t=this.getWorkingDatabase(e);return t.dictionaries.layouts.getBtrIdAt(t.currentSpaceId)}getWorkingDatabase(e){return e||Va().workingDatabase}setCurrentLayoutInternal(e,t){return e?(this.events.layoutSwitched.dispatch({layout:e}),t.currentSpaceId=e.blockTableRecordId,!0):!1}}function Va(){return Pi.instance}const ki=class ki{constructor(){this._workingDatabase=null,this._layoutManager=new Cu}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(e){this._workingDatabase=e}get layoutManager(){return this._layoutManager}};ki.instance=new ki;let Pi=ki;exports.AcCmColor=Wr;exports.AcCmErrors=Ut;exports.AcCmEventDispatcher=$u;exports.AcCmEventManager=it;exports.AcCmLoader=sc;exports.AcCmLoadingManager=ll;exports.AcCmObject=sl;exports.AcCmPerformanceCollector=fa;exports.AcCmTask=al;exports.AcCmTaskScheduler=ol;exports.AcDb3PointAngularDimension=xi;exports.AcDbAlignedDimension=wi;exports.AcDbAngleUnits=_a;exports.AcDbArc=si;exports.AcDbArcDimension=pa;exports.AcDbBaseWorker=s0;exports.AcDbBatchProcessing=ga;exports.AcDbBlockReference=Ls;exports.AcDbBlockTable=bu;exports.AcDbBlockTableRecord=Ft;exports.AcDbCircle=ii;exports.AcDbCodePage=va;exports.AcDbCurve=jt;exports.AcDbDatabase=i0;exports.AcDbDatabaseConverter=ba;exports.AcDbDatabaseConverterManager=lr;exports.AcDbDiametricDimension=Ai;exports.AcDbDictionary=Fa;exports.AcDbDimArrowType=dl;exports.AcDbDimStyleTable=xu;exports.AcDbDimStyleTableRecord=Dn;exports.AcDbDimTextHorizontal=Pu;exports.AcDbDimTextVertical=Eu;exports.AcDbDimVerticalJustification=Mu;exports.AcDbDimZeroSuppression=ku;exports.AcDbDimZeroSuppressionAngular=Tu;exports.AcDbDimension=Tr;exports.AcDbDwgVersion=ri;exports.AcDbDxfConverter=vu;exports.AcDbEllipse=ai;exports.AcDbEntity=Vt;exports.AcDbFace=oi;exports.AcDbFileType=Ns;exports.AcDbHatch=li;exports.AcDbHatchPatternType=iu;exports.AcDbHatchStyle=au;exports.AcDbHostApplicationServices=Pi;exports.AcDbLayerTable=wu;exports.AcDbLayerTableRecord=Fi;exports.AcDbLayout=Di;exports.AcDbLayoutDictionary=mu;exports.AcDbLayoutManager=Cu;exports.AcDbLeader=hi;exports.AcDbLeaderAnnotationType=ou;exports.AcDbLine=ui;exports.AcDbLineSpacingStyle=du;exports.AcDbLinetypeTable=Au;exports.AcDbLinetypeTableRecord=Cs;exports.AcDbMText=ci;exports.AcDbObject=Xr;exports.AcDbObjectIterator=Ti;exports.AcDbOrdinateDimension=Si;exports.AcDbOsnapMode=cn;exports.AcDbPoint=gi;exports.AcDbPolyline=fi;exports.AcDbRadialDimension=Ii;exports.AcDbRasterImage=zs;exports.AcDbRasterImageClipBoundaryType=uu;exports.AcDbRasterImageDef=pu;exports.AcDbRasterImageImageDisplayOpt=cu;exports.AcDbRay=_i;exports.AcDbRegenerator=yu;exports.AcDbRenderingCache=Gr;exports.AcDbSpline=Os;exports.AcDbSymbolTable=vn;exports.AcDbSymbolTableRecord=_n;exports.AcDbTable=di;exports.AcDbText=mi;exports.AcDbTextHorizontalMode=lu;exports.AcDbTextStyleTable=Su;exports.AcDbTextStyleTableRecord=Ua;exports.AcDbTextVerticalMode=hu;exports.AcDbTrace=pi;exports.AcDbUnitsValue=ya;exports.AcDbViewport=vi;exports.AcDbViewportTable=Iu;exports.AcDbViewportTableRecord=Nu;exports.AcDbWipeout=yi;exports.AcDbWorkerApi=gu;exports.AcDbWorkerManager=fu;exports.AcDbXline=bi;exports.AcGeArea2d=Ci;exports.AcGeBox2d=_t;exports.AcGeBox3d=Re;exports.AcGeCatmullRomCurve3d=nu;exports.AcGeCircArc2d=Rn;exports.AcGeCircArc3d=pn;exports.AcGeCurve2d=Vn;exports.AcGeEllipseArc2d=Li;exports.AcGeEllipseArc3d=Oi;exports.AcGeEuler=Jh;exports.AcGeGeometryUtil=Hh;exports.AcGeLine2d=zi;exports.AcGeLine3d=qr;exports.AcGeLoop2d=tu;exports.AcGeMathUtil=Ee;exports.AcGeMatrix2d=Ni;exports.AcGeMatrix3d=gn;exports.AcGeNurbsCurve=fn;exports.AcGePlane=Rs;exports.AcGePoint2d=Te;exports.AcGePoint3d=Y;exports.AcGePolyline2d=Ds;exports.AcGeQuaternion=Hr;exports.AcGeShape2d=Oa;exports.AcGeSpline3d=Yr;exports.AcGeTol=Na;exports.AcGeVector2d=$e;exports.AcGeVector3d=Z;exports.AcGiArrowType=za;exports.AcGiDefaultLightingType=Da;exports.AcGiMTextAttachmentPoint=Bn;exports.AcGiMTextFlowDirection=Ri;exports.AcGiOrthographicType=Ba;exports.AcGiRenderMode=Ra;exports.AcGiViewport=Bi;exports.AcTrStringUtil=nc;exports.ByBlock=cl;exports.ByLayer=Xs;exports.DEBUG_MODE=tc;exports.DEFAULT_LINE_TYPE=ei;exports.DEFAULT_TOL=Ca;exports.DEG2RAD=Ia;exports.DefaultLoadingManager=hl;exports.FLOAT_TOL=un;exports.ORIGIN_POINT_2D=qd;exports.ORIGIN_POINT_3D=Ma;exports.RAD2DEG=Pa;exports.TAU=nt;exports.acdbHostApplicationServices=Va;exports.basisFunction=ni;exports.calculateCurveLength=Kh;exports.ceilPowerOfTwo=Bh;exports.clamp=kr;exports.clone=Ps;exports.createWorkerApi=_u;exports.damp=Ph;exports.defaults=Fn;exports.degToRad=Oh;exports.dwgCodePageToEncoding=ul;exports.euclideanModulo=Ea;exports.evaluateNurbsPoint=Ms;exports.floorPowerOfTwo=Dh;exports.generateChordKnots=Yh;exports.generateSqrtChordKnots=Xh;exports.generateUUID=Ah;exports.generateUniformKnots=qh;exports.has=rl;exports.intPartLength=Ta;exports.interpolateControlPoints=Yd;exports.inverseLerp=Ih;exports.isBetween=Fh;exports.isBetweenAngle=Uh;exports.isEmpty=nl;exports.isEqual=zn;exports.isImperialUnits=oc;exports.isMetricUnits=ac;exports.isPointInPolygon=La;exports.isPolygonIntersect=Wh;exports.isPowerOfTwo=Rh;exports.lerp=ka;exports.log=ks;exports.mapLinear=Sh;exports.normalizeAngle=Ts;exports.pingpong=Eh;exports.radToDeg=zh;exports.randFloat=Nh;exports.randFloatSpread=Ch;exports.randInt=Mh;exports.relativeEps=Vh;exports.seededRandom=Lh;exports.setLogLevel=rc;exports.smootherstep=Th;exports.smoothstep=kh;
|
|
4
|
+
`),M+=n+k+" : "+Nt.__string_rec(r[k],n));return n=n.substring(1),M+=`
|
|
5
|
+
`+n+"}",M;case"function":return"<function>";case"string":return r;default:return String(r)}},Nt.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var a=r.__interfaces__;if(a!=null)for(var l=0,u=a.length;l<u;){var d=l++,p=a[d];if(p==n||Nt.__interfLoop(p,n))return!0}return Nt.__interfLoop(r.__super__,n)},Nt.__instanceof=function(r,n){if(n==null)return!1;switch(n){case Yu:return(r|0)===r;case To:return typeof r=="number";case Mo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case Xu:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||Nt.__interfLoop(Nt.getClass(r),n))return!0}else if(typeof n=="object"&&Nt.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==No&&r.__name__!=null||n==Co&&r.__ename__!=null?!0:r.__enum__==n}},Nt.__nativeClassName=function(r){var n=Nt.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},Nt.__isNativeObj=function(r){return Nt.__nativeClassName(r)!=null},Nt.__resolveNativeClass=function(r){return A[r]};var oe=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var a=0;a<n;){var l=a++;this.a[l]=0}this.byteLength=n}};b["js.html.compat.ArrayBuffer"]=oe,oe.__name__=["js","html","compat","ArrayBuffer"],oe.sliceImpl=function(r,n){var a=new Xi(this,r,n==null?null:n-r),l=new Gs(a.byteLength),u=new Xi(l);return u.set(a),l},oe.prototype={slice:function(r,n){return new oe(this.a.slice(r,n))},__class__:oe};var hr=function(r,n,a){if(this.buf=r,n==null?this.offset=0:this.offset=n,a==null?this.length=r.byteLength-this.offset:this.length=a,this.offset<0||this.length<0||this.offset+this.length>r.byteLength)throw new Q(Jt.OutsideBounds)};b["js.html.compat.DataView"]=hr,hr.__name__=["js","html","compat","DataView"],hr.prototype={getInt8:function(r){var n=this.buf.a[this.offset+r];return n>=128?n-256:n},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,n){var a=this.getUint16(r,n);return a>=32768?a-65536:a},getUint16:function(r,n){return n?this.buf.a[this.offset+r]|this.buf.a[this.offset+r+1]<<8:this.buf.a[this.offset+r]<<8|this.buf.a[this.offset+r+1]},getInt32:function(r,n){var a=this.offset+r,l=this.buf.a[a++],u=this.buf.a[a++],d=this.buf.a[a++],p=this.buf.a[a++];return n?l|u<<8|d<<16|p<<24:p|d<<8|u<<16|l<<24},getUint32:function(r,n){var a=this.getInt32(r,n);return a<0?a+4294967296:a},getFloat32:function(r,n){return ae.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var a=this.getInt32(r,n),l=this.getInt32(r+4,n);return ae.i64ToDouble(n?a:l,n?l:a)},setInt8:function(r,n){n<0?this.buf.a[r+this.offset]=n+128&255:this.buf.a[r+this.offset]=n&255},setUint8:function(r,n){this.buf.a[r+this.offset]=n&255},setInt16:function(r,n,a){this.setUint16(r,n<0?n+65536:n,a)},setUint16:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l]=n&255,this.buf.a[l++]=n>>8&255):(this.buf.a[l++]=n>>8&255,this.buf.a[l]=n&255)},setInt32:function(r,n,a){this.setUint32(r,n,a)},setUint32:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l++]=n&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>>24):(this.buf.a[l++]=n>>>24,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n&255)},setFloat32:function(r,n,a){this.setUint32(r,ae.floatToI32(n),a)},setFloat64:function(r,n,a){var l=ae.doubleToI64(n);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:hr};var nr=function(){};b["js.html.compat.Uint8Array"]=nr,nr.__name__=["js","html","compat","Uint8Array"],nr._new=function(r,n,a){var l;if(typeof r=="number"){l=[];for(var u=0;u<r;){var d=u++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l)}else if(Nt.__instanceof(r,oe)){var p=r;n==null&&(n=0),a==null&&(a=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+a),l.byteLength=l.length,l.byteOffset=n,l.buffer=p}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l);else throw new Q("TODO "+dt.string(r));return l.subarray=nr._subarray,l.set=nr._set,l},nr._set=function(r,n){var a=this;if(Nt.__instanceof(r.buffer,oe)){var l=r;if(r.byteLength+n>a.byteLength)throw new Q("set() outside of range");for(var u=0,d=r.byteLength;u<d;){var p=u++;a[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>a.byteLength)throw new Q("set() outside of range");for(var v=0,w=_.length;v<w;){var I=v++;a[I+n]=_[I]}}else throw new Q("TODO")},nr._subarray=function(r,n){var a=this,l=nr._new(a.slice(r,n));return l.byteOffset=r,l};var kt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&kt.link(r,this,function(n){return n})};b["promhx.base.AsyncBase"]=kt,kt.__name__=["promhx","base","AsyncBase"],kt.link=function(r,n,a){r._update.push({async:n,linkf:function(l){n.handleResolve(a(l))}}),kt.immediateLinkUpdate(r,n,a)},kt.immediateLinkUpdate=function(r,n,a){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(a(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},kt.linkAll=function(r,n){for(var a=function(d,p,_){if(d.length==0||kt.allFulfilled(d)){for(var v,w=[],I=Xe(r)();I.hasNext();){var S=I.next();w.push(S==p?_:S._val)}v=w,n.handleResolve(v)}},l=Xe(r)();l.hasNext();){var u=l.next();u._update.push({async:n,linkf:function(d,p,_){return function(v){d(p,_,v)}}(a,function(d){for(var p,_=[],v=Xe(r)();v.hasNext();){var w=v.next();w!=u&&_.push(w)}return p=_,p}(),u)})}kt.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],v=Xe(r)();v.hasNext();){var w=v.next();_.push(w._val)}return p=_,p}())},kt.pipeLink=function(r,n,a){var l=!1,u=function(d){if(!l){l=!0;var p=a(d);p._update.push({async:n,linkf:Ne(n,n.handleResolve)}),kt.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:u}),r._resolved&&!r._pending)try{u(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},kt.allResolved=function(r){for(var n=Xe(r)();n.hasNext();){var a=n.next();if(!a._resolved)return!1}return!0},kt.allFulfilled=function(r){for(var n=Xe(r)();n.hasNext();){var a=n.next();if(!a._fulfilled)return!1}return!0},kt.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,this},isResolved:function(){return this._resolved},isErrored:function(){return this._errored},isErrorHandled:function(){return this._error.length>0},isErrorPending:function(){return this._errorPending},isFulfilled:function(){return this._fulfilled},isPending:function(){return this._pending},handleResolve:function(r){this._resolve(r)},_resolve:function(r){var n=this;this._pending?St.enqueue(function(a,l){return function(){a(l)}}(Ne(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,St.queue.add(function(){n._val=r;for(var a=0,l=n._update;a<l.length;){var u=l[a];++a;try{u.linkf(r)}catch(d){d instanceof Q&&(d=d.val),u.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),St.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,a=function(l){if(n._error.length>0)for(var u=0,d=n._error;u<d.length;){var p=d[u];++u,p(l)}else if(n._update.length>0)for(var _=0,v=n._update;_<v.length;){var w=v[_];++_,w.async.handleError(l)}else throw new Q(l);n._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,St.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),a(l)}else a(r)}),St.continueOnNextLoop())},then:function(r){var n=new kt(null);return kt.link(this,n,r),n},unlink:function(r){var n=this;St.queue.add(function(){n._update=n._update.filter(function(a){return a.async!=r})}),St.continueOnNextLoop()},isLinked:function(r){for(var n=!1,a=0,l=this._update;a<l.length;){var u=l[a];if(++a,u.async==r)return!0}return n},__class__:kt};var xn=f.promhx.Deferred=function(){kt.call(this)};b["promhx.Deferred"]=xn,xn.__name__=["promhx","Deferred"],xn.__super__=kt,xn.prototype=T(kt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pe(this)},stream:function(){return new Ht(this)},publicStream:function(){return new Mr(this)},__class__:xn});var pe=f.promhx.Promise=function(r){kt.call(this,r),this._rejected=!1};b["promhx.Promise"]=pe,pe.__name__=["promhx","Promise"],pe.whenAll=function(r){var n=new pe(null);return kt.linkAll(r,n),n},pe.promise=function(r){var n=new pe;return n.handleResolve(r),n},pe.__super__=kt,pe.prototype=T(kt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var n="Promise has already been resolved";throw new Q(bn.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pe(null);return kt.link(this,n,r),n},unlink:function(r){var n=this;St.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var a="Downstream Promise is not fullfilled";n.handleError(bn.DownstreamNotFullfilled(a))}}),St.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pe(null);return kt.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pe;return this.catchError(function(a){var l=r(a);l.then(Ne(n,n._resolve))}),this.then(Ne(n,n._resolve)),n},__class__:pe});var Ht=f.promhx.Stream=function(r){kt.call(this,r),this._end_promise=new pe};b["promhx.Stream"]=Ht,Ht.__name__=["promhx","Stream"],Ht.foreach=function(r){for(var n=new Ht(null),a=Xe(r)();a.hasNext();){var l=a.next();n.handleResolve(l)}return n.end(),n},Ht.wheneverAll=function(r){var n=new Ht(null);return kt.linkAll(r,n),n},Ht.concatAll=function(r){for(var n=new Ht(null),a=Xe(r)();a.hasNext();){var l=a.next();n.concat(l)}return n},Ht.mergeAll=function(r){for(var n=new Ht(null),a=Xe(r)();a.hasNext();){var l=a.next();n.merge(l)}return n},Ht.stream=function(r){var n=new Ht(null);return n.handleResolve(r),n},Ht.__super__=kt,Ht.prototype=T(kt.prototype,{then:function(r){var n=new Ht(null);return kt.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(a){n.end()}}),n},detachStream:function(r){for(var n=[],a=!1,l=0,u=this._update;l<u.length;){var d=u[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),a=!0):n.push(d)}return this._update=n,a},first:function(){var r=new pe(null);return this.then(function(n){r._resolved||r.handleResolve(n)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var n=new Ht(null);return kt.pipeLink(this,n,r),this._end_promise.then(function(a){n.end()}),n},errorPipe:function(r){var n=new Ht(null);return this.catchError(function(a){var l=r(a);l.then(Ne(n,n._resolve)),l._end_promise.then((qi=n._end_promise,Ne(qi,qi._resolve)))}),this.then(Ne(n,n._resolve)),this._end_promise.then(function(a){n.end()}),n},handleEnd:function(){if(this._pending)St.queue.add(Ne(this,this.handleEnd)),St.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=de.Some(this._val):r=de.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return St.queue.add(Ne(this,this.handleEnd)),St.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:function(a){r(a)&&n.handleResolve(a)}}),kt.immediateLinkUpdate(this,n,function(a){return a}),n},concat:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:Ne(n,n.handleResolve)}),kt.immediateLinkUpdate(this,n,function(a){return a}),this._end_promise.then(function(a){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:Ne(n,n.handleResolve)}),r._update.push({async:n,linkf:Ne(n,n.handleResolve)}),kt.immediateLinkUpdate(this,n,function(a){return a}),kt.immediateLinkUpdate(r,n,function(a){return a}),n},__class__:Ht});var Mr=f.promhx.PublicStream=function(r){Ht.call(this,r)};b["promhx.PublicStream"]=Mr,Mr.__name__=["promhx","PublicStream"],Mr.publicstream=function(r){var n=new Mr(null);return n.handleResolve(r),n},Mr.__super__=Ht,Mr.prototype=T(Ht.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Mr});var St=function(){};b["promhx.base.EventLoop"]=St,St.__name__=["promhx","base","EventLoop"],St.enqueue=function(r){St.queue.add(r),St.continueOnNextLoop()},St.set_nextLoop=function(r){if(St.nextLoop!=null)throw new Q("nextLoop has already been set");return St.nextLoop=r,St.nextLoop},St.queueEmpty=function(){return St.queue.isEmpty()},St.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=St.queue.pop())!=null;)n();return St.queue.isEmpty()},St.clear=function(){St.queue=new U},St.f=function(){var r=St.queue.pop();r!=null&&r(),St.queue.isEmpty()||St.continueOnNextLoop()},St.continueOnNextLoop=function(){St.nextLoop!=null?St.nextLoop(St.f):setImmediate(St.f)};var bn=b["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};bn.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=bn,n.toString=E,n},bn.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=bn,n.toString=E,n};var Vs=function(){};b["verb.Verb"]=Vs,Vs.__name__=["verb","Verb"],Vs.main=function(){x.log("verb 2.1.0")};var $=function(){};b["verb.core.ArrayExtensions"]=$,$.__name__=["verb","core","ArrayExtensions"],$.alloc=function(r,n){if(!(n<0))for(;r.length<n;)r.push(null)},$.reversed=function(r){var n=r.slice();return n.reverse(),n},$.last=function(r){return r[r.length-1]},$.first=function(r){return r[0]},$.spliceAndInsert=function(r,n,a,l){r.splice(n,a),r.splice(n,0,l)},$.left=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(0,n)},$.right=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n)},$.rightWithPivot=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n-1)},$.unique=function(r,n){if(r.length==0)return[];for(var a=[r.pop()];r.length>0;){for(var l=r.pop(),u=!0,d=0;d<a.length;){var p=a[d];if(++d,n(l,p)){u=!1;break}}u&&a.push(l)}return a};var Bt=function(){};b["verb.core.Binomial"]=Bt,Bt.__name__=["verb","core","Binomial"],Bt.get=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;if(n>r-n&&(n=r-n),Bt.memo_exists(r,n))return Bt.get_memo(r,n);for(var a=1,l=r,u=1,d=n+1;u<d;){var p=u++;if(Bt.memo_exists(l,p)){r--,a=Bt.get_memo(l,p);continue}a*=r--,a/=p,Bt.memoize(l,p,a)}return a},Bt.get_no_memo=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;n>r-n&&(n=r-n);for(var a=1,l=1,u=n+1;l<u;){var d=l++;a*=r--,a/=d}return a},Bt.memo_exists=function(r,n){return Bt.memo.h.hasOwnProperty(r)&&Bt.memo.h[r].h.hasOwnProperty(n)},Bt.get_memo=function(r,n){return Bt.memo.h[r].h[n]},Bt.memoize=function(r,n,a){Bt.memo.h.hasOwnProperty(r)||Bt.memo.set(r,new bt),Bt.memo.h[r].h[n]=a};var Te=f.core.BoundingBox=function(r){this.max=null,this.min=null,this.dim=3,this.initialized=!1,r!=null&&this.addRange(r)};b["verb.core.BoundingBox"]=Te,Te.__name__=["verb","core","BoundingBox"],Te.intervalsOverlap=function(r,n,a,l,u){u==null&&(u=-1);var d;u<-.5?d=rt.TOLERANCE:d=u;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,v=Math.min(a,l)-d,w=Math.max(a,l)+d;return p>=v&&p<=w||_>=v&&_<=w||v>=p&&v<=_||w>=p&&w<=_},Te.prototype={fromPoint:function(r){return new Te([r])},add:function(r){if(!this.initialized)return this.dim=r.length,this.min=r.slice(0),this.max=r.slice(0),this.initialized=!0,this;for(var n=0,a=this.dim;n<a;){var l=n++;r[l]>this.max[l]&&(this.max[l]=r[l]),r[l]<this.min[l]&&(this.min[l]=r[l])}return this},addRange:function(r){for(var n=r.length,a=0;a<n;){var l=a++;this.add(r[l])}return this},contains:function(r,n){return n==null&&(n=-1),this.initialized?this.intersects(new Te([r]),n):!1},intersects:function(r,n){if(n==null&&(n=-1),!this.initialized||!r.initialized)return!1;for(var a=this.min,l=this.max,u=r.min,d=r.max,p=0,_=this.dim;p<_;){var v=p++;if(!Te.intervalsOverlap(a[v],l[v],u[v],d[v],n))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,n=0,a=0,l=this.dim;a<l;){var u=a++,d=this.getAxisLength(u);d>r&&(r=d,n=u)}return n},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,n){if(!this.initialized)return null;var a=this.min,l=this.max,u=r.min,d=r.max;if(!this.intersects(r,n))return null;for(var p=[],_=[],v=0,w=this.dim;v<w;){var I=v++;p.push(Math.min(l[I],d[I])),_.push(Math.max(a[I],u[I]))}return new Te([_,p])},__class__:Te};var rt=f.core.Constants=function(){};b["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var Zt=f.core.SerializableBase=function(){};b["verb.core.SerializableBase"]=Zt,Zt.__name__=["verb","core","SerializableBase"],Zt.prototype={serialize:function(){var r=new Yt;return r.serialize(this),r.toString()},__class__:Zt};var Wn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};b["verb.core.Plane"]=Wn,Wn.__name__=["verb","core","Plane"],Wn.__super__=Zt,Wn.prototype=T(Zt.prototype,{__class__:Wn});var wn=f.core.Ray=function(r,n){this.origin=r,this.dir=n};b["verb.core.Ray"]=wn,wn.__name__=["verb","core","Ray"],wn.__super__=Zt,wn.prototype=T(Zt.prototype,{__class__:wn});var jt=f.core.NurbsCurveData=function(r,n,a){this.degree=r,this.controlPoints=a,this.knots=n};b["verb.core.NurbsCurveData"]=jt,jt.__name__=["verb","core","NurbsCurveData"],jt.__super__=Zt,jt.prototype=T(Zt.prototype,{__class__:jt});var te=f.core.NurbsSurfaceData=function(r,n,a,l,u){this.degreeU=r,this.degreeV=n,this.knotsU=a,this.knotsV=l,this.controlPoints=u};b["verb.core.NurbsSurfaceData"]=te,te.__name__=["verb","core","NurbsSurfaceData"],te.__super__=Zt,te.prototype=T(Zt.prototype,{__class__:te});var qe=f.core.MeshData=function(r,n,a,l){this.faces=r,this.points=n,this.normals=a,this.uvs=l};b["verb.core.MeshData"]=qe,qe.__name__=["verb","core","MeshData"],qe.empty=function(){return new qe([],[],[],[])},qe.__super__=Zt,qe.prototype=T(Zt.prototype,{__class__:qe});var Hn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};b["verb.core.PolylineData"]=Hn,Hn.__name__=["verb","core","PolylineData"],Hn.__super__=Zt,Hn.prototype=T(Zt.prototype,{__class__:Hn});var qn=f.core.VolumeData=function(r,n,a,l,u,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=a,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=p};b["verb.core.VolumeData"]=qn,qn.__name__=["verb","core","VolumeData"],qn.__super__=Zt,qn.prototype=T(Zt.prototype,{__class__:qn});var ee=f.core.Pair=function(r,n){this.item0=r,this.item1=n};b["verb.core.Pair"]=ee,ee.__name__=["verb","core","Pair"],ee.prototype={__class__:ee};var Se=f.core.Interval=function(r,n){this.min=r,this.max=n};b["verb.core.Interval"]=Se,Se.__name__=["verb","core","Interval"],Se.prototype={__class__:Se};var $r=f.core.CurveCurveIntersection=function(r,n,a,l){this.point0=r,this.point1=n,this.u0=a,this.u1=l};b["verb.core.CurveCurveIntersection"]=$r,$r.__name__=["verb","core","CurveCurveIntersection"],$r.prototype={__class__:$r};var Yn=f.core.CurveSurfaceIntersection=function(r,n,a,l){this.u=r,this.uv=n,this.curvePoint=a,this.surfacePoint=l};b["verb.core.CurveSurfaceIntersection"]=Yn,Yn.__name__=["verb","core","CurveSurfaceIntersection"],Yn.prototype={__class__:Yn};var Nr=f.core.MeshIntersectionPoint=function(r,n,a,l,u){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=n,this.point=a,this.faceIndex0,this.faceIndex1};b["verb.core.MeshIntersectionPoint"]=Nr,Nr.__name__=["verb","core","MeshIntersectionPoint"],Nr.prototype={__class__:Nr};var Xn=f.core.PolylineMeshIntersection=function(r,n,a,l,u){this.point=r,this.u=n,this.uv=a,this.polylineIndex=l,this.faceIndex=u};b["verb.core.PolylineMeshIntersection"]=Xn,Xn.__name__=["verb","core","PolylineMeshIntersection"],Xn.prototype={__class__:Xn};var Kn=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,a,l){this.uv0=r,this.uv1=n,this.point=a,this.dist=l};b["verb.core.SurfaceSurfaceIntersectionPoint"]=Kn,Kn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Kn.prototype={__class__:Kn};var $n=f.core.TriSegmentIntersection=function(r,n,a,l){this.point=r,this.s=n,this.t=a,this.p=l};b["verb.core.TriSegmentIntersection"]=$n,$n.__name__=["verb","core","TriSegmentIntersection"],$n.prototype={__class__:$n};var An=f.core.CurveTriPoint=function(r,n,a){this.u=r,this.point=n,this.uv=a};b["verb.core.CurveTriPoint"]=An,An.__name__=["verb","core","CurveTriPoint"],An.prototype={__class__:An};var Ge=function(r,n,a,l,u){u==null&&(u=!1),l==null&&(l=-1),this.uv=a,this.point=r,this.normal=n,this.id=l,this.degen=u};b["verb.core.SurfacePoint"]=Ge,Ge.__name__=["verb","core","SurfacePoint"],Ge.fromUv=function(r,n){return new Ge(null,null,[r,n])},Ge.prototype={__class__:Ge};var js=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};b["verb.core.CurvePoint"]=js,js.__name__=["verb","core","CurvePoint"],js.prototype={__class__:js};var Zn=f.core.KdTree=function(r,n){this.dim=3,this.points=r,this.distanceFunction=n,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};b["verb.core.KdTree"]=Zn,Zn.__name__=["verb","core","KdTree"],Zn.prototype={buildTree:function(r,n,a){var l=n%this.dim,u,d;return r.length==0?null:r.length==1?new In(r[0],l,a):(r.sort(function(p,_){var v=p.point[l]-_.point[l];return v==0?0:v>0?1:-1}),u=Math.floor(r.length/2),d=new In(r[u],l,a),d.left=this.buildTree(r.slice(0,u),n+1,d),d.right=this.buildTree(r.slice(u+1),n+1,d),d)},nearest:function(r,n,a){var l=this,u=new Qn(function(S){return-S.item1}),d,p=null;p=function(S){for(var P,k=S.dimension,M=l.distanceFunction(r,S.kdPoint.point),L,C=[],B=0,R=l.dim;B<R;)B++,C.push(0);L=C;for(var D,V,Y=function(K,tt){u.push(new ee(K,tt)),u.size()>n&&u.pop()},J=0,H=l.dim;J<H;){var j=J++;j==S.dimension?L[j]=r[j]:L[j]=S.kdPoint.point[j]}if(D=l.distanceFunction(L,S.kdPoint.point),S.right==null&&S.left==null){(u.size()<n||M<u.peek().item1)&&Y(S,M);return}S.right==null?P=S.left:S.left==null?P=S.right:r[k]<S.kdPoint.point[k]?P=S.left:P=S.right,p(P),(u.size()<n||M<u.peek().item1)&&Y(S,M),(u.size()<n||Math.abs(D)<u.peek().item1)&&(P==S.left?V=S.right:V=S.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,u.push(new ee(null,a));d(this.root);for(var v=[],w=0;w<n;){var I=w++;u.content[I].item0!=null&&v.push(new ee(u.content[I].item0.kdPoint,u.content[I].item1))}return v},__class__:Zn};var Qn=function(r){this.content=[],this.scoreFunction=r};b["verb.core.BinaryHeap"]=Qn,Qn.__name__=["verb","core","BinaryHeap"],Qn.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],n=this.content.pop();return this.content.length>0&&(this.content[0]=n,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var n=this.content.length,a=0;a<n;){var l=a++;if(this.content[l]==r){var u=this.content.pop();l!=n-1&&(this.content[l]=u,this.scoreFunction(u)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var n=this.content[r];r>0;){var a=Math.floor((r+1)/2)-1,l=this.content[a];if(this.scoreFunction(n)<this.scoreFunction(l))this.content[a]=n,this.content[r]=l,r=a;else break}},sinkDown:function(r){for(var n=this.content.length,a=this.content[r],l=this.scoreFunction(a);;){var u=(r+1)*2,d=u-1,p=-1,_=0;if(d<n){var v=this.content[d];_=this.scoreFunction(v),_<l&&(p=d)}if(u<n){var w=this.content[u],I=this.scoreFunction(w);I<(p==-1?l:_)&&(p=u)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=a,r=p;else break}},__class__:Qn};var Sn=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};b["verb.core.KdPoint"]=Sn,Sn.__name__=["verb","core","KdPoint"],Sn.prototype={__class__:Sn};var In=f.core.KdNode=function(r,n,a){this.kdPoint=r,this.left=null,this.right=null,this.parent=a,this.dimension=n};b["verb.core.KdNode"]=In,In.__name__=["verb","core","KdNode"],In.prototype={__class__:In};var ur=function(){};b["verb.eval.IBoundingBoxTree"]=ur,ur.__name__=["verb","eval","IBoundingBoxTree"],ur.prototype={__class__:ur};var sr=function(r,n){this._boundingBox=null,this._curve=r,n==null&&(n=m.domain(this._curve.knots)/64),this._knotTol=n};b["verb.core.LazyCurveBoundingBoxTree"]=sr,sr.__name__=["verb","core","LazyCurveBoundingBoxTree"],sr.__interfaces__=[ur],sr.prototype={split:function(){var r=$.first(this._curve.knots),n=$.last(this._curve.knots),a=n-r,l=le.curveSplit(this._curve,(n+r)/2+a*.1*Math.random());return new ee(new sr(l[0],this._knotTol),new sr(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Te(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:sr};var ir=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var a=[],l=0,u=r.faces.length;l<u;){var d=l++;a.push(d)}n=a}this._faceIndices=n};b["verb.core.LazyMeshBoundingBoxTree"]=ir,ir.__name__=["verb","core","LazyMeshBoundingBoxTree"],ir.__interfaces__=[ur],ir.prototype={split:function(){var r=re.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=$.left(r),a=$.right(r);return new ee(new ir(this._mesh,n),new ir(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=re.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:ir};var ar=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new Se(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};b["verb.core.LazyPolylineBoundingBoxTree"]=ar,ar.__name__=["verb","core","LazyPolylineBoundingBoxTree"],ar.__interfaces__=[ur],ar.prototype={split:function(){var r=this._interval.min,n=this._interval.max,a=r+Math.ceil((n-r)/2),l=new Se(r,a),u=new Se(a,n);return new ee(new ar(this._polyline,l),new ar(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Te(this._polyline.points)),this._boundingBox},yield:function(){return this._interval.min},indivisible:function(r){return this._interval.max-this._interval.min==1},empty:function(){return this._interval.max-this._interval.min==0},__class__:ar};var Cr=function(r,n,a,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,a==null&&(a=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};b["verb.core.LazySurfaceBoundingBoxTree"]=Cr,Cr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Cr.__interfaces__=[ur],Cr.prototype={split:function(){var r,n;this._splitV?(r=$.first(this._surface.knotsV),n=$.last(this._surface.knotsV)):(r=$.first(this._surface.knotsU),n=$.last(this._surface.knotsU));var a=(r+n)/2,l=le.surfaceSplit(this._surface,a,this._splitV);return new ee(new Cr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Cr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Te;for(var r=0,n=this._surface.controlPoints;r<n.length;){var a=n[r];++r,this._boundingBox.addRange(N.dehomogenize1d(a))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Cr};var Lt=f.core.Mat=function(){};b["verb.core.Mat"]=Lt,Lt.__name__=["verb","core","Mat"],Lt.mul=function(r,n){for(var a=[],l=0,u=n.length;l<u;){var d=l++;a.push(m.mul(r,n[d]))}return a},Lt.mult=function(r,n){var a,l,u,d,p,_,v,w;a=r.length,l=n.length,u=n[0].length,d=[];for(var I=a-1,S=0,P=0;I>=0;){for(p=[],_=r[I],P=u-1;P>=0;){for(v=_[l-1]*n[l-1][P],S=l-2;S>=1;)w=S-1,v+=_[S]*n[S][P]+_[w]*n[w][P],S-=2;S==0&&(v+=_[0]*n[0][P]),p[P]=v,P--}d[I]=p,I--}return d},Lt.add=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.add(r[d],n[d]))}return a},Lt.div=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.div(r[d],n))}return a},Lt.sub=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.sub(r[d],n[d]))}return a},Lt.dot=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(m.dot(r[d],n))}return a},Lt.identity=function(r){for(var n=m.zeros2d(r,r),a=0;a<r;){var l=a++;n[l][l]=1}return n},Lt.transpose=function(r){if(r.length==0)return[];for(var n=[],a=0,l=r[0].length;a<l;){var u=a++;n.push(function(d){for(var p,_=[],v=0,w=r.length;v<w;){var I=v++;_.push(r[I][u])}return p=_,p}())}return n},Lt.solve=function(r,n){return Lt.LUsolve(Lt.LU(r),n)},Lt.LUsolve=function(r,n){var a,l,u=r.LU,d=u.length,p=n.slice(),_=r.P,v,w,I;for(a=d-1;a!=-1;)p[a]=n[a],--a;for(a=0;a<d;){for(v=_[a],_[a]!=a&&(I=p[a],p[a]=p[v],p[v]=I),w=u[a],l=0;l<a;)p[a]-=p[l]*w[l],++l;++a}for(a=d-1;a>=0;){for(w=u[a],l=a+1;l<d;)p[a]-=p[l]*w[l],++l;p[a]/=w[a],--a}return p},Lt.LU=function(r){for(var n,a,l,u,d,p,_,v,w,I=[],S=0,P=r.length;S<P;){var k=S++;I.push(r[k].slice())}r=I;var M=r.length,L=M-1,C=[];for(l=0;l<M;){for(_=l,p=r[l],w=Math.abs(p[l]),a=l+1;a<M;)u=Math.abs(r[a][l]),w<u&&(w=u,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=p,p=r[l]),d=p[l],n=l+1;n<M;)r[n][l]/=d,++n;for(n=l+1;n<M;){for(v=r[n],a=l+1;a<L;)v[a]-=v[l]*p[a],++a,v[a]-=v[l]*p[a],++a;a==L&&(v[a]-=v[l]*p[a]),++n}++l}return new Jn(r,C)};var Jn=function(r,n){this.LU=r,this.P=n};b["verb.core._Mat.LUDecomp"]=Jn,Jn.__name__=["verb","core","_Mat","LUDecomp"],Jn.prototype={__class__:Jn};var re=f.core.Mesh=function(){};b["verb.core.Mesh"]=re,re.__name__=["verb","core","Mesh"],re.getTriangleNorm=function(r,n){var a=r[n[0]],l=r[n[1]],u=r[n[2]],d=m.sub(l,a),p=m.sub(u,a),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},re.makeMeshAabb=function(r,n){for(var a=new Te,l=0;l<n.length;){var u=n[l];++l,a.add(r.points[r.faces[u][0]]),a.add(r.points[r.faces[u][1]]),a.add(r.points[r.faces[u][2]])}return a},re.sortTrianglesOnLongestAxis=function(r,n,a){for(var l=r.getLongestAxis(),u=[],d=0;d<a.length;){var p=a[d];++d;var _=re.getMinCoordOnAxis(n.points,n.faces[p],l);u.push(new ee(_,p))}u.sort(function(P,k){var M=P.item0,L=k.item0;return M==L?0:M>L?1:-1});for(var v=[],w=0,I=u.length;w<I;){var S=w++;v.push(u[S].item1)}return v},re.getMinCoordOnAxis=function(r,n,a){for(var l=1/0,u=0;u<3;){var d=u++,p=r[n[d]][a];p<l&&(l=p)}return l},re.getTriangleCentroid=function(r,n){for(var a=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var p=d++;a[p]+=r[n[u]][p]}for(var _=0;_<3;){var v=_++;a[v]/=3}return a},re.triangleUVFromPoint=function(r,n,a){var l=r.faces[n],u=r.points[l[0]],d=r.points[l[1]],p=r.points[l[2]],_=r.uvs[l[0]],v=r.uvs[l[1]],w=r.uvs[l[2]],I=m.sub(u,a),S=m.sub(d,a),P=m.sub(p,a),k=m.norm(m.cross(m.sub(u,d),m.sub(u,p))),M=m.norm(m.cross(S,P))/k,L=m.norm(m.cross(P,I))/k,C=m.norm(m.cross(I,S))/k;return m.add(m.mul(M,_),m.add(m.mul(L,v),m.mul(C,w)))};var Lr=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var a=[],l=0,u=r.faces.length;l<u;){var d=l++;a.push(d)}n=a}if(this._boundingBox=re.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=re.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=$.left(p),v=$.right(p);this._children=new ee(new Lr(r,_),new Lr(r,v))};b["verb.core.MeshBoundingBoxTree"]=Lr,Lr.__name__=["verb","core","MeshBoundingBoxTree"],Lr.__interfaces__=[ur],Lr.prototype={split:function(){return this._children},boundingBox:function(){return this._boundingBox},yield:function(){return this._face},indivisible:function(r){return this._children==null},empty:function(){return this._empty},__class__:Lr};var Ye=f.core.Minimizer=function(){};b["verb.core.Minimizer"]=Ye,Ye.__name__=["verb","core","Minimizer"],Ye.uncmin=function(r,n,a,l,u){a==null&&(a=1e-8),l==null&&(l=function(J){return Ye.numericalGradient(r,J)}),u==null&&(u=1e3),n=n.slice(0);var d=n.length,p=r(n),_=p,v;if(isNaN(p))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,rt.EPSILON);var w,I,S,P=Lt.identity(d),k=0,M=[],L,C,B,R,D,V,Y="";for(I=l(n);k<u;){if(!m.all(m.finite(I))){Y="Gradient has Infinity or NaN";break}if(w=m.neg(Lt.dot(P,I)),!m.all(m.finite(w))){Y="Search direction has Infinity or NaN";break}if(V=m.norm(w),V<a){Y="Newton step smaller than tol";break}for(D=1,v=m.dot(I,w),L=n;k<u&&!(D*V<a);){if(M=m.mul(D,w),L=m.add(n,M),_=r(L),_-p>=.1*D*v||isNaN(_)){D*=.5,++k;continue}break}if(D*V<a){Y="Line search step size smaller than tol";break}if(k==u){Y="maxit reached during line search";break}S=l(L),C=m.sub(S,I),R=m.dot(C,M),B=Lt.dot(P,C),P=Lt.sub(Lt.add(P,Lt.mul((R+m.dot(C,B))/(R*R),Ye.tensor(M,M))),Lt.div(Lt.add(Ye.tensor(B,M),Ye.tensor(M,B)),R)),n=L,p=_,I=S,++k}return new ts(n,p,I,P,k,Y)},Ye.numericalGradient=function(r,n){var a=n.length,l=r(n);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var u=n.slice(0),d,p,_=[],v,w=.001,I,S,P,k=0,M,L,C,B=0;B<a;)for(var R=B++,D=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(u[R]=n[R]+D,d=r(u),u[R]=n[R]-D,p=r(u),u[R]=n[R],isNaN(d)||isNaN(p)){D/=16;continue}if(_[R]=(d-p)/(2*D),I=n[R]-D,S=n[R],P=n[R]+D,M=(d-l)/D,L=(l-p)/D,C=m.max([Math.abs(_[R]),Math.abs(l),Math.abs(d),Math.abs(p),Math.abs(I),Math.abs(S),Math.abs(P),1e-8]),v=Math.min(m.max([Math.abs(M-_[R]),Math.abs(L-_[R]),Math.abs(M-L)])/C,D/C),v>w)D/=16;else break}return _},Ye.tensor=function(r,n){for(var a=r.length,l=n.length,u=[],d,p,_=a-1;_>=0;){d=[],p=r[_];for(var v=l-1;v>=3;)d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v,d[v]=p*n[v],--v;for(;v>=0;)d[v]=p*n[v],--v;u[_]=d,_--}return u};var ts=function(r,n,a,l,u,d){this.solution=r,this.value=n,this.gradient=a,this.invHessian=l,this.iterations=u,this.message=d};b["verb.core.MinimizationResult"]=ts,ts.__name__=["verb","core","MinimizationResult"],ts.prototype={__class__:ts};var Pn=function(){};b["verb.core.ISerializable"]=Pn,Pn.__name__=["verb","core","ISerializable"],Pn.prototype={__class__:Pn};var Hi=f.core.Deserializer=function(){};b["verb.core.Deserializer"]=Hi,Hi.__name__=["verb","core","Deserializer"],Hi.deserialize=function(r){var n=new Wt(r),a=n.unserialize();return a};var Me=f.core.Trig=function(){};b["verb.core.Trig"]=Me,Me.__name__=["verb","core","Trig"],Me.isPointInPlane=function(r,n,a){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<a},Me.distToSegment=function(r,n,a){var l=Me.segmentClosestPoint(n,r,a,0,1);return m.dist(n,l.pt)},Me.rayClosestPoint=function(r,n,a){var l=m.sub(r,n),u=m.dot(l,a),d=m.add(n,m.mul(u,a));return d},Me.distToRay=function(r,n,a){var l=Me.rayClosestPoint(r,n,a),u=m.sub(l,r);return m.norm(u)},Me.threePointsAreFlat=function(r,n,a,l){var u=m.sub(n,r),d=m.sub(a,r),p=m.cross(u,d),_=m.dot(p,p);return _<l},Me.segmentClosestPoint=function(r,n,a,l,u){var d=m.sub(a,n),p=m.norm(d);if(p<rt.EPSILON)return{u:l,pt:n};var _=n,v=m.mul(1/p,d),w=m.sub(r,_),I=m.dot(w,v);return I<0?{u:l,pt:n}:I>p?{u,pt:a}:{u:l+(u-l)*I/p,pt:m.add(_,m.mul(I,v))}};var m=f.core.Vec=function(){};b["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,n){return Math.acos(m.dot(r,n)/(m.norm(r)*m.norm(n)))},m.positiveAngleBetween=function(r,n,a){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,I=Math.atan2(v,w),S=m.dot(a,l);return Math.abs(S)<rt.EPSILON||S>0?I:-I},m.signedAngleBetween=function(r,n,a){var l=m.cross(r,n),u=m.norm(r),d=m.norm(n),p=u*d,_=m.dot(r,n),v=m.norm(l)/p,w=_/p,I=Math.atan2(v,w),S=m.dot(a,l);return S>0?I:2*Math.PI-I},m.angleBetweenNormalized2d=function(r,n){var a=r[0]*n[1]-r[1]*n[0];return Math.atan2(a,m.dot(r,n))},m.domain=function(r){return $.last(r)-$.first(r)},m.range=function(r){for(var n=[],a=0,l=0;l<r;)l++,n.push(a),a+=1;return n},m.span=function(r,n,a){if(a==null)return[];if(a<rt.EPSILON)return[];if(r>n&&a>0)return[];if(n>r&&a<0)return[];for(var l=[],u=r;u<=n;)l.push(u),u+=a;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return z.fold(r,function(n,a){return Math.min(n,a)},1/0)},m.max=function(r){return z.fold(r,function(n,a){return Math.max(n,a)},-1/0)},m.all=function(r){return z.fold(r,function(n,a){return a&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,a){return m.add(r,m.mul(a,n))},m.lerp=function(r,n,a){return m.add(m.mul(r,n),m.mul(1-r,a))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,n){return[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]},m.dist=function(r,n){return m.norm(m.sub(r,n))},m.distSquared=function(r,n){return m.normSquared(m.sub(r,n))},m.sum=function(r){return z.fold(r,function(n,a){return a+n},0)},m.addAll=function(r){var n=Xe(r)();if(!n.hasNext())return null;var a=n.next().length;return z.fold(r,function(l,u){return m.add(u,l)},m.rep(a,0))},m.addAllMutate=function(r){for(var n=r[0],a=1,l=r.length;a<l;){var u=a++;m.addMutate(n,r[u])}},m.addMulMutate=function(r,n,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+n*a[d]}},m.subMulMutate=function(r,n,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-n*a[d]}},m.addMutate=function(r,n){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]+n[u]}},m.subMutate=function(r,n){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]-n[u]}},m.mulMutate=function(r,n){for(var a=0,l=n.length;a<l;){var u=a++;n[u]=n[u]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return z.fold(r,function(n,a){return a+n*n},0)},m.rep=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(n);return a},m.zeros1d=function(r){for(var n=[],a=0;a<r;)a++,n.push(0);return n},m.zeros2d=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(m.zeros1d(n));return a},m.zeros3d=function(r,n,a){for(var l=[],u=0;u<r;)u++,l.push(m.zeros2d(n,a));return l},m.dot=function(r,n){for(var a=0,l=0,u=r.length;l<u;){var d=l++;a+=r[d]*n[d]}return a},m.add=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]+n[d])}return a},m.mul=function(r,n){for(var a=[],l=0,u=n.length;l<u;){var d=l++;a.push(r*n[d])}return a},m.div=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]/n)}return a},m.sub=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]-n[d])}return a},m.isZero=function(r){for(var n=0,a=r.length;n<a;){var l=n++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var a=[],l=0,u=0;l<r.length||u<n.length;){if(l>=r.length){a.push(n[u]),u++;continue}else if(u>=n.length){a.push(r[l]),l++;continue}var d=r[l]-n[u];if(Math.abs(d)<rt.EPSILON){a.push(r[l]),l++,u++;continue}if(d>0){a.push(n[u]),u++;continue}a.push(r[l]),l++}return a},m.sortedSetSub=function(r,n){for(var a=[],l=0,u=0;l<r.length;){if(u>=n.length){a.push(r[l]),l++;continue}if(Math.abs(r[l]-n[u])<rt.EPSILON){l++,u++;continue}a.push(r[l]),l++}return a};var yt=f.eval.Analyze=function(){};b["verb.eval.Analyze"]=yt,yt.__name__=["verb","eval","Analyze"],yt.knotMultiplicities=function(r){for(var n=[new En(r[0],0)],a=n[0],l=0;l<r.length;){var u=r[l];++l,Math.abs(u-a.knot)>rt.EPSILON&&(a=new En(u,0),n.push(a)),a.inc()}return n},yt.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var a;n?a=r.controlPoints:a=Lt.transpose(r.controlPoints);for(var l=0,u=a[0].length;l<u;){var d=l++,p=m.dist($.first(a)[d],$.last(a)[d])<rt.EPSILON;if(!p)return!1}return!0},yt.rationalSurfaceClosestPoint=function(r,n){var a=yt.rationalSurfaceClosestParam(r,n);return N.rationalSurfacePoint(r,a[0],a[1])},yt.rationalSurfaceClosestParam=function(r,n){for(var a=5,l=0,u,d=1e-4,p=5e-4,_,v=r.knotsU[0],w=$.last(r.knotsU),I=r.knotsV[0],S=$.last(r.knotsV),P=yt.isRationalSurfaceClosed(r),k=yt.isRationalSurfaceClosed(r,!1),M,L=zt.rationalSurfaceAdaptive(r,new Or),C=1/0,B=0,R=L.points.length;B<R;){var D=B++,V=L.points[D],Y=m.normSquared(m.sub(n,V));Y<C&&(C=Y,M=L.uvs[D])}for(var J=function(Gt){return N.rationalSurfaceDerivatives(r,Gt[0],Gt[1],2)},H=function(Gt,Xt,Dt){var Kt=Xt[1][0],Ie=Xt[0][1],He=Xt[2][0],ve=Xt[0][2],ge=Xt[1][1],Pe=Xt[1][1],Ce=m.dot(Kt,Dt),Ke=m.dot(Ie,Dt),or=[-Ce,-Ke],$e=m.dot(Kt,Kt)+m.dot(He,Dt),Ze=m.dot(Kt,Ie)+m.dot(ge,Dt),Qe=m.dot(Kt,Ie)+m.dot(Pe,Dt),dr=m.dot(Ie,Ie)+m.dot(ve,Dt),Nn=[[$e,Ze],[Qe,dr]],Qr=Lt.solve(Nn,or);return m.add(Qr,Gt)};l<a;){u=J(M),_=m.sub(u[0][0],n);var j=m.norm(_),K=m.dot(u[1][0],_),tt=m.norm(u[1][0])*j,et=m.dot(u[0][1],_),it=m.norm(u[0][1])*j,ht=K/tt,at=et/it,ct=j<d,nt=ht<p,mt=at<p;if(ct&&nt&&mt)return M;var X=H(M,u,_);X[0]<v?P?X=[w-(X[0]-v),X[1]]:X=[v+rt.EPSILON,X[1]]:X[0]>w&&(P?X=[v+(X[0]-w),X[1]]:X=[w-rt.EPSILON,X[1]]),X[1]<I?k?X=[X[0],S-(X[1]-I)]:X=[X[0],I+rt.EPSILON]:X[1]>S&&(k?X=[X[0],I+(X[0]-S)]:X=[X[0],S-rt.EPSILON]);var gt=m.norm(m.mul(X[0]-M[0],u[1][0])),It=m.norm(m.mul(X[1]-M[1],u[0][1]));if(gt+It<d)return M;M=X,l++}return M},yt.rationalCurveClosestPoint=function(r,n){return N.rationalCurvePoint(r,yt.rationalCurveClosestParam(r,n))},yt.rationalCurveClosestParam=function(r,n){for(var a=1/0,l=0,u=zt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=u.length-1;d<p;){var _=d++,v=u[_][0],w=u[_+1][0],I=u[_].slice(1),S=u[_+1].slice(1),P=Me.segmentClosestPoint(n,I,S,v,w),k=m.norm(m.sub(n,P.pt));k<a&&(a=k,l=P.u)}for(var M=5,L=0,C,B=1e-4,R=5e-4,D,V=r.knots[0],Y=$.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],$.last(r.controlPoints)))<rt.EPSILON,H=l,j=function(X){return N.rationalCurveDerivatives(r,X,2)},K=function(X,gt,It){var Gt=m.dot(gt[1],It),Xt=m.dot(gt[2],It),Dt=m.dot(gt[1],gt[1]),Kt=Xt+Dt;return X-Gt/Kt};L<M;){C=j(H),D=m.sub(C[0],n);var tt=m.norm(D),et=m.dot(C[1],D),it=m.norm(C[1])*tt,ht=et/it,at=tt<B,ct=Math.abs(ht)<R;if(at&&ct)return H;var nt=K(H,C,D);nt<V?J?nt=Y-(nt-V):nt=V:nt>Y&&(J?nt=V+(nt-Y):nt=Y);var mt=m.norm(m.mul(nt-H,C[1]));if(mt<B)return H;H=nt,L++}return H},yt.rationalCurveParamAtArcLength=function(r,n,a,l,u){if(a==null&&(a=.001),n<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=ft.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-rt.EPSILON,v;for(u!=null?v=u:v=[];_<n&&p<d.length;){if(p<v.length?v[p]=v[p]:v[p]=yt.rationalBezierCurveArcLength(r),_+=v[p],n<_+rt.EPSILON)return yt.rationalBezierCurveParamAtArcLength(r,n,a,v[p]);p++}return-1},yt.rationalBezierCurveParamAtArcLength=function(r,n,a,l){if(n<0)return r.knots[0];var u;if(l!=null?u=l:u=yt.rationalBezierCurveArcLength(r),n>u)return $.last(r.knots);var d=r.knots[0],p=0,_=$.last(r.knots),v=u,w=0,I=0,S;for(a!=null?S=a:S=rt.TOLERANCE*2;v-p>S;)w=(d+_)/2,I=yt.rationalBezierCurveArcLength(r,w),I>n?(_=w,v=I):(d=w,p=I);return(d+_)/2},yt.rationalCurveArcLength=function(r,n,a){a==null&&(a=16),n==null?n=$.last(r.knots):n=n;for(var l=ft.decomposeCurveIntoBeziers(r),u=0,d=l[0],p=0;u<l.length&&d.knots[0]+rt.EPSILON<n;){var _=Math.min($.last(d.knots),n);p+=yt.rationalBezierCurveArcLength(d,_,a),d=l[++u]}return p},yt.rationalBezierCurveArcLength=function(r,n,a){a==null&&(a=16);var l;n==null?l=$.last(r.knots):l=n;for(var u=(l-r.knots[0])/2,d=0,p=r.degree+a,_,v,w=0;w<p;){var I=w++;_=u*yt.Tvalues[p][I]+u+r.knots[0],v=N.rationalCurveDerivatives(r,_,1),d+=yt.Cvalues[p][I]*m.norm(v[1])}return u*d};var En=f.eval.KnotMultiplicity=function(r,n){this.knot=r,this.mult=n};b["verb.eval.KnotMultiplicity"]=En,En.__name__=["verb","eval","KnotMultiplicity"],En.prototype={inc:function(){this.mult++},__class__:En};var We=f.eval.Check=function(){};b["verb.eval.Check"]=We,We.__name__=["verb","eval","Check"],We.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var a=$.first(r),l=0,u=n+1;l<u;){var d=l++;if(Math.abs(r[d]-a)>rt.EPSILON)return!1}a=$.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var v=p++;if(Math.abs(r[v]-a)>rt.EPSILON)return!1}return We.isNonDecreasing(r)},We.isNonDecreasing=function(r){for(var n=$.first(r),a=0,l=r.length;a<l;){var u=a++;if(r[u]<n-rt.EPSILON)return!1;n=r[u]}return!0},We.isValidNurbsCurveData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degree==null)throw new Q("Degree cannot be null!");if(r.degree<1)throw new Q("Degree must be greater than 1!");if(r.knots==null)throw new Q("Knots cannot be null!");if(r.knots.length!=r.controlPoints.length+r.degree+1)throw new Q("controlPoints.length + degree + 1 must equal knots.length!");if(!We.isValidKnotVector(r.knots,r.degree))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r},We.isValidNurbsSurfaceData=function(r){if(r.controlPoints==null)throw new Q("Control points array cannot be null!");if(r.degreeU==null)throw new Q("DegreeU cannot be null!");if(r.degreeV==null)throw new Q("DegreeV cannot be null!");if(r.degreeU<1)throw new Q("DegreeU must be greater than 1!");if(r.degreeV<1)throw new Q("DegreeV must be greater than 1!");if(r.knotsU==null)throw new Q("KnotsU cannot be null!");if(r.knotsV==null)throw new Q("KnotsV cannot be null!");if(r.knotsU.length!=r.controlPoints.length+r.degreeU+1)throw new Q("controlPointsU.length + degreeU + 1 must equal knotsU.length!");if(r.knotsV.length!=r.controlPoints[0].length+r.degreeV+1)throw new Q("controlPointsV.length + degreeV + 1 must equal knotsV.length!");if(!We.isValidKnotVector(r.knotsU,r.degreeU)||!We.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var le=f.eval.Divide=function(){};b["verb.eval.Divide"]=le,le.__name__=["verb","eval","Divide"],le.surfaceSplit=function(r,n,a){a==null&&(a=!1);var l,u,d;a?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Lt.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var p,_=[],v=0,w=u+1;v<w;)v++,_.push(n);p=_;for(var I=[],S=[],P=N.knotSpan(u,n,l),k=null,M=0;M<d.length;){var L=d[M];++M,k=ft.curveKnotRefine(new jt(u,l,L),p),I.push(k.controlPoints.slice(0,P+1)),S.push(k.controlPoints.slice(P+1))}var C=k.knots.slice(0,P+u+2),B=k.knots.slice(P+1);return a?[new te(r.degreeU,u,r.knotsU.slice(),C,I),new te(r.degreeU,u,r.knotsU.slice(),B,S)]:(I=Lt.transpose(I),S=Lt.transpose(S),[new te(u,r.degreeV,C,r.knotsV.slice(),I),new te(u,r.degreeV,B,r.knotsV.slice(),S)])},le.curveSplit=function(r,n){var a=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],p=0,_=a+1;p<_;)p++,d.push(n);u=d;var v=ft.curveKnotRefine(r,u),w=N.knotSpan(a,n,l),I=v.knots.slice(0,w+a+2),S=v.knots.slice(w+1),P=v.controlPoints.slice(0,w+1),k=v.controlPoints.slice(w+1);return[new jt(a,I,P),new jt(a,S,k)]},le.rationalCurveByEqualArcLength=function(r,n){var a=yt.rationalCurveArcLength(r),l=a/n;return le.rationalCurveByArcLength(r,l)},le.rationalCurveByArcLength=function(r,n){var a=ft.decomposeCurveIntoBeziers(r),l=a.map(function(P){return yt.rationalBezierCurveArcLength(P)}),u=m.sum(l),d=[new kn(r.knots[0],0)];if(n>u)return d;for(var p=n,_=0,v=p,w=0,I=0,S;_<a.length;){for(w+=l[_];v<w+rt.EPSILON;)S=yt.rationalBezierCurveParamAtArcLength(a[_],v-I,rt.TOLERANCE,l[_]),d.push(new kn(S,v)),v+=p;I+=l[_],_++}return d};var kn=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};b["verb.eval.CurveLengthSample"]=kn,kn.__name__=["verb","eval","CurveLengthSample"],kn.prototype={__class__:kn};var N=f.eval.Eval=function(){};b["verb.eval.Eval"]=N,N.__name__=["verb","eval","Eval"],N.rationalCurveTangent=function(r,n){var a=N.rationalCurveDerivatives(r,n,1);return a[1]},N.rationalSurfaceNormal=function(r,n,a){var l=N.rationalSurfaceDerivatives(r,n,a,1);return m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,n,a,l){l==null&&(l=1);for(var u=N.surfaceDerivatives(r,n,a,l),d=N.rational2d(u),p=N.weight2d(u),_=[],v=d[0][0].length,w=0,I=l+1;w<I;){var S=w++;_.push([]);for(var P=0,k=l-S+1;P<k;){for(var M=P++,L=d[S][M],C=1,B=M+1;C<B;){var R=C++;m.subMulMutate(L,Bt.get(M,R)*p[0][R],_[S][M-R])}for(var D=1,V=S+1;D<V;){var Y=D++;m.subMulMutate(L,Bt.get(S,Y)*p[Y][0],_[S-Y][M]);for(var J=m.zeros1d(v),H=1,j=M+1;H<j;){var K=H++;m.addMulMutate(J,Bt.get(M,K)*p[Y][K],_[S-Y][M-K])}m.subMulMutate(L,Bt.get(S,Y),J)}m.mulMutate(1/p[0][0],L),_[S].push(L)}}return _},N.rationalSurfacePoint=function(r,n,a){return N.dehomogenize(N.surfacePoint(r,n,a))},N.rationalCurveDerivatives=function(r,n,a){a==null&&(a=1);for(var l=N.curveDerivatives(r,n,a),u=N.rational1d(l),d=N.weight1d(l),p=[],_=0,v=a+1;_<v;){for(var w=_++,I=u[w],S=1,P=w+1;S<P;){var k=S++;m.subMulMutate(I,Bt.get(w,k)*d[k],p[w-k])}m.mulMutate(1/d[0],I),p.push(I)}return p},N.rationalCurvePoint=function(r,n){return N.dehomogenize(N.curvePoint(r,n))},N.surfaceDerivatives=function(r,n,a,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(u,d,r,n,a,l)},N.surfaceDerivativesGivenNM=function(r,n,a,l,u,d){var p=a.degreeU,_=a.degreeV,v=a.controlPoints,w=a.knotsU,I=a.knotsV;if(!N.areValidRelations(p,v.length,w.length)||!N.areValidRelations(_,v[0].length,I.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=v[0][0].length,P;d<p?P=d:P=p;var k;d<_?k=d:k=_;for(var M=m.zeros3d(d+1,d+1,S),L=N.knotSpanGivenN(r,p,l,w),C=N.knotSpanGivenN(n,_,u,I),B=N.derivativeBasisFunctionsGivenNI(L,l,p,r,w),R=N.derivativeBasisFunctionsGivenNI(C,u,_,n,I),D=m.zeros2d(_+1,S),V=0,Y=0,J=P+1;Y<J;){for(var H=Y++,j=0,K=_+1;j<K;){var tt=j++;D[tt]=m.zeros1d(S);for(var et=0,it=p+1;et<it;){var ht=et++;m.addMulMutate(D[tt],B[H][ht],v[L-p+ht][C-_+tt])}}var at=d-H;at<k?V=at:V=k;for(var ct=0,nt=V+1;ct<nt;){var mt=ct++;M[H][mt]=m.zeros1d(S);for(var X=0,gt=_+1;X<gt;){var It=X++;m.addMulMutate(M[H][mt],R[mt][It],D[It])}}}return M},N.surfacePoint=function(r,n,a){var l=r.knotsU.length-r.degreeU-2,u=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,u,r,n,a)},N.surfacePointGivenNM=function(r,n,a,l,u){var d=a.degreeU,p=a.degreeV,_=a.controlPoints,v=a.knotsU,w=a.knotsV;if(!N.areValidRelations(d,_.length,v.length)||!N.areValidRelations(p,_[0].length,w.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var I=_[0][0].length,S=N.knotSpanGivenN(r,d,l,v),P=N.knotSpanGivenN(n,p,u,w),k=N.basisFunctionsGivenKnotSpanIndex(S,l,d,v),M=N.basisFunctionsGivenKnotSpanIndex(P,u,p,w),L=S-d,C=P,B=m.zeros1d(I),R=m.zeros1d(I),D=0,V=p+1;D<V;){var Y=D++;R=m.zeros1d(I),C=P-p+Y;for(var J=0,H=d+1;J<H;){var j=J++;m.addMulMutate(R,k[j],_[L+j][C])}m.addMulMutate(B,M[Y],R)}return B},N.curveRegularSamplePoints=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(u*.5,a[2]),v=m.mul(u*l*.5,a[3]),w=m.add(_,_),I=m.add(v,v),S=m.mul(.3333333333333333,v),P=[],k=0,M=n+1;k<M;)k++,P.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,w,v]),m.addAllMutate([w,I]),m.addAllMutate([_,v]);return P},N.curveRegularSamplePoints2=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,u=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(u*.5,a[2]),v=m.mul(u*l*.5,a[3]),w=m.add(_,_),I=m.add(v,v),S=m.mul(.3333333333333333,v),P=[],k=0,M=n+1;k<M;)k++,P.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,w,v]),m.addAllMutate([w,I]),m.addAllMutate([_,v]);return P},N.rationalSurfaceRegularSampleDerivatives=function(r,n,a,l){for(var u=N.surfaceRegularSampleDerivatives(r,n,a,l),d=[],p=n+1,_=a+1,v=l+1,w=0;w<p;){var I=w++,S=[];d.push(S);for(var P=0;P<_;){for(var k=P++,M=u[I][k],L=N.rational2d(M),C=N.weight2d(M),B=[],R=L[0][0].length,D=0;D<v;){var V=D++;B.push([]);for(var Y=0,J=v-V;Y<J;){for(var H=Y++,j=L[V][H],K=1,tt=H+1;K<tt;){var et=K++;m.subMulMutate(j,Bt.get(H,et)*C[0][et],B[V][H-et])}for(var it=1,ht=V+1;it<ht;){var at=it++;m.subMulMutate(j,Bt.get(V,at)*C[at][0],B[V-at][H]);for(var ct=m.zeros1d(R),nt=1,mt=H+1;nt<mt;){var X=nt++;m.addMulMutate(ct,Bt.get(H,X)*C[at][X],B[V-at][H-X])}m.subMulMutate(j,Bt.get(V,at),ct)}m.mulMutate(1/C[0][0],j),B[V].push(j)}}S.push(B)}}return d},N.surfaceRegularSampleDerivatives=function(r,n,a,l){var u=r.degreeU,d=r.degreeV,p=r.controlPoints,_=r.knotsU,v=r.knotsV,w=p[0][0].length;($.last(_)-_[0])/n,($.last(v)-v[0])/a;for(var I=N.regularlySpacedDerivativeBasisFunctions(u,_,n),S=I.item0,P=I.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,v,a),M=k.item0,L=k.item1,C=[],B=n+1,R=a+1,D=0;D<B;){var V=D++,Y=[];C.push(Y);for(var J=0;J<R;){var H=J++;Y.push(N.surfaceDerivativesGivenBasesKnotSpans(u,d,p,S[V],M[H],P[V],L[H],w,l))}}return C},N.rationalSurfaceRegularSamplePoints=function(r,n,a){return N.dehomogenize2d(N.surfaceRegularSamplePoints(r,n,a))},N.surfaceRegularSamplePoints=function(r,n,a){var l=r.degreeU,u=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,v=d[0][0].length;($.last(p)-p[0])/n,($.last(_)-_[0])/a;for(var w=N.regularlySpacedBasisFunctions(l,p,n),I=w.item0,S=w.item1,P=N.regularlySpacedBasisFunctions(u,_,a),k=P.item0,M=P.item1,L=[],C=n+1,B=a+1,R=0;R<C;){var D=R++,V=[];L.push(V);for(var Y=0;Y<B;){var J=Y++;V.push(N.surfacePointGivenBasesKnotSpans(l,u,d,I[D],k[J],S[D],M[J],v))}}return L},N.regularlySpacedBasisFunctions=function(r,n,a){for(var l=n.length-r-2,u=($.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,I=0;I<w;){for(I++;_>=n[v+1];)v++;p.push(v),d.push(N.basisFunctionsGivenKnotSpanIndex(v,_,r,n)),_+=u}return new ee(p,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,n,a){for(var l=n.length-r-2,u=($.last(n)-n[0])/a,d=[],p=[],_=n[0],v=N.knotSpanGivenN(l,r,_,n),w=a+1,I=0;I<w;){for(I++;_>=n[v+1];)v++;p.push(v),d.push(N.derivativeBasisFunctionsGivenNI(v,_,r,l,n)),_+=u}return new ee(p,d)},N.surfacePointGivenBasesKnotSpans=function(r,n,a,l,u,d,p,_){for(var v=m.zeros1d(_),w,I=l-r,S=u-n,P=0,k=n+1;P<k;){var M=P++;w=m.zeros1d(_);for(var L=0,C=r+1;L<C;){var B=L++;m.addMulMutate(w,d[B],a[I+B][S])}S++,m.addMulMutate(v,p[M],w)}return v},N.surfaceDerivativesGivenBasesKnotSpans=function(r,n,a,l,u,d,p,_,v){var w=a[0][0].length,I;v<r?I=v:I=r;var S;v<n?S=v:S=n;for(var P=m.zeros3d(I+1,S+1,w),k=m.zeros2d(n+1,w),M=0,L=0,C=I+1;L<C;){for(var B=L++,R=0,D=n+1;R<D;){var V=R++;k[V]=m.zeros1d(w);for(var Y=0,J=r+1;Y<J;){var H=Y++;m.addMulMutate(k[V],d[B][H],a[l-r+H][u-n+V])}}var j=v-B;j<S?M=j:M=S;for(var K=0,tt=M+1;K<tt;){var et=K++;P[B][et]=m.zeros1d(w);for(var it=0,ht=n+1;it<ht;){var at=it++;m.addMulMutate(P[B][et],p[et][at],k[at])}}}return P},N.curveDerivatives=function(r,n,a){var l=r.knots.length-r.degree-2;return N.curveDerivativesGivenN(l,r,n,a)},N.curveDerivativesGivenN=function(r,n,a,l){var u=n.degree,d=n.controlPoints,p=n.knots;if(!N.areValidRelations(u,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,v;l<u?v=l:v=u;for(var w=m.zeros2d(l+1,_),I=N.knotSpanGivenN(r,u,a,p),S=N.derivativeBasisFunctionsGivenNI(I,a,u,v,p),P=0,k=v+1;P<k;)for(var M=P++,L=0,C=u+1;L<C;){var B=L++;m.addMulMutate(w[M],S[M][B],d[I-u+B])}return w},N.curvePoint=function(r,n){var a=r.knots.length-r.degree-2;return N.curvePointGivenN(a,r,n)},N.areValidRelations=function(r,n,a){return n+r+1-a==0},N.curvePointGivenN=function(r,n,a){var l=n.degree,u=n.controlPoints,d=n.knots;if(!N.areValidRelations(l,u.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(p,a,l,d),v=m.zeros1d(u[0].length),w=0,I=l+1;w<I;){var S=w++;m.addMulMutate(v,_[S],u[p-l+S])}return v},N.volumePoint=function(r,n,a,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,u,d,p,n,a,l)},N.volumePointGivenNML=function(r,n,a,l,u,d,p){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,v=r.degreeU,w=r.degreeV,I=r.degreeW,S=r.knotsU,P=r.knotsV,k=r.knotsW,M=_[0][0][0].length,L=N.knotSpanGivenN(n,v,u,S),C=N.knotSpanGivenN(a,w,d,P),B=N.knotSpanGivenN(l,I,p,k),R=N.basisFunctionsGivenKnotSpanIndex(L,u,v,S),D=N.basisFunctionsGivenKnotSpanIndex(C,d,w,P),V=N.basisFunctionsGivenKnotSpanIndex(B,p,I,k),Y=L-v,J=m.zeros1d(M),H=m.zeros1d(M),j=m.zeros1d(M),K=0,tt=I+1;K<tt;){var et=K++;j=m.zeros1d(M);for(var it=B-I+et,ht=0,at=w+1;ht<at;){var ct=ht++;H=m.zeros1d(M);for(var nt=C-w+ct,mt=0,X=v+1;mt<X;){var gt=mt++;m.addMulMutate(H,R[gt],_[Y+gt][nt][it])}m.addMulMutate(j,D[ct],H)}m.addMulMutate(J,V[et],j)}return J},N.derivativeBasisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a),u=a.length-1,d=u-n-1;return N.derivativeBasisFunctionsGivenNI(l,r,n,d,a)},N.derivativeBasisFunctionsGivenNI=function(r,n,a,l,u){var d=m.zeros2d(a+1,a+1),p=m.zeros1d(a+1),_=m.zeros1d(a+1),v=0,w=0;d[0][0]=1;for(var I=1,S=a+1;I<S;){var P=I++;p[P]=n-u[r+1-P],_[P]=u[r+P]-n,v=0;for(var k=0;k<P;){var M=k++;d[P][M]=_[M+1]+p[P-M],w=d[M][P-1]/d[P][M],d[M][P]=v+_[M+1]*w,v=p[P-M]*w}d[P][P]=v}for(var L=m.zeros2d(l+1,a+1),C=m.zeros2d(2,a+1),B=0,R=1,D=0,V=0,Y=0,J=0,H=0,j=0,K=a+1;j<K;){var tt=j++;L[0][tt]=d[tt][a]}for(var et=0,it=a+1;et<it;){var ht=et++;B=0,R=1,C[0][0]=1;for(var at=1,ct=l+1;at<ct;){var nt=at++;D=0,V=ht-nt,Y=a-nt,ht>=nt&&(C[R][0]=C[B][0]/d[Y+1][V],D=C[R][0]*d[V][Y]),V>=-1?J=1:J=-V,ht-1<=Y?H=nt-1:H=a-ht;for(var mt=J,X=H+1;mt<X;){var gt=mt++;C[R][gt]=(C[B][gt]-C[B][gt-1])/d[Y+1][V+gt],D+=C[R][gt]*d[V+gt][Y]}ht<=Y&&(C[R][nt]=-C[B][nt-1]/d[Y+1][ht],D+=C[R][nt]*d[ht][Y]),L[nt][ht]=D;var It=B;B=R,R=It}}for(var Gt=a,Xt=1,Dt=l+1;Xt<Dt;){for(var Kt=Xt++,Ie=0,He=a+1;Ie<He;){var ve=Ie++;L[Kt][ve]*=Gt}Gt*=a-Kt}return L},N.basisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a);return N.basisFunctionsGivenKnotSpanIndex(l,r,n,a)},N.basisFunctionsGivenKnotSpanIndex=function(r,n,a,l){var u=m.zeros1d(a+1),d=m.zeros1d(a+1),p=m.zeros1d(a+1),_=0,v=0;u[0]=1;for(var w=1,I=a+1;w<I;){var S=w++;d[S]=n-l[r+1-S],p[S]=l[r+S]-n,_=0;for(var P=0;P<S;){var k=P++;v=u[k]/(p[k+1]+d[S-k]),u[k]=_+p[k+1]*v,_=d[S-k]*v}u[S]=_}return u},N.knotSpan=function(r,n,a){return N.knotSpanGivenN(a.length-r-2,r,n,a)},N.knotSpanGivenN=function(r,n,a,l){if(a>l[r+1]-rt.EPSILON)return r;if(a<l[n]+rt.EPSILON)return n;for(var u=n,d=r+1,p=Math.floor((u+d)/2);a<l[p]||a>=l[p+1];)a<l[p]?d=p:u=p,p=Math.floor((u+d)/2);return p},N.dehomogenize=function(r){for(var n=r.length,a=[],l=r[n-1],u=r.length-1,d=0;d<u;){var p=d++;a.push(r[p]/l)}return a},N.rational1d=function(r){var n=r[0].length-1;return r.map(function(a){return a.slice(0,n)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var n=r[0].length-1;return r.map(function(a){return a[n]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,n){var a=r.length,l=r[0].length,u=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var v=0;v<a;){var w=v++,I=[];p=r[w],d=_[w];for(var S=0;S<l;){var P=S++;I.push(p[P]*d)}I.push(d),u.push(I)}return u},N.homogenize2d=function(r,n){var a=r.length,l=[],u;if(n!=null)u=n;else{for(var d=[],p=0;p<a;)p++,d.push(m.rep(r[0].length,1));u=d}for(var _=0;_<a;){var v=_++;l.push(N.homogenize1d(r[v],u[v]))}return l};var lt=f.eval.Intersect=function(){};b["verb.eval.Intersect"]=lt,lt.__name__=["verb","eval","Intersect"],lt.surfaces=function(r,n,a){var l=zt.rationalSurfaceAdaptive(r),u=zt.rationalSurfaceAdaptive(n),d=lt.meshes(l,u),p=d.map(function(_){return _.map(function(v){return lt.surfacesAtPointWithEstimate(r,n,v.uv0,v.uv1,a)})});return p.map(function(_){return pt.rationalInterpCurve(_.map(function(v){return v.point}),3)})},lt.surfacesAtPointWithEstimate=function(r,n,a,l,u){var d,p,_,v,w,I,S,P,k,M,L,C,B,R=5,D=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),p=d[0][0],v=d[1][0],w=d[0][1],_=m.normalized(m.cross(v,w)),I=m.dot(_,p),S=N.rationalSurfaceDerivatives(n,l[0],l[1],1),P=S[0][0],M=S[1][0],L=S[0][1],k=m.normalized(m.cross(M,L)),C=m.dot(k,P),B=m.distSquared(p,P),B<u*u)break;var V=m.normalized(m.cross(_,k)),Y=m.dot(V,p),J=lt.threePlanes(_,I,k,C,V,Y);if(J==null)throw new Q("panic!");var H=m.sub(J,p),j=m.sub(J,P),K=m.cross(v,_),tt=m.cross(w,_),et=m.cross(M,k),it=m.cross(L,k),ht=m.dot(tt,H)/m.dot(tt,v),at=m.dot(K,H)/m.dot(K,w),ct=m.dot(it,j)/m.dot(it,M),nt=m.dot(et,j)/m.dot(et,L);a=m.add([ht,at],a),l=m.add([ct,nt],l),D++}while(D<R);return new Kn(a,l,p,B)},lt.meshes=function(r,n,a,l){a==null&&(a=new ir(r)),l==null&&(l=new ir(n));var u=lt.boundingBoxTrees(a,l,0),d=$.unique(u.map(function(p){return lt.triangles(r,p.item0,n,p.item1)}).filter(function(p){return p!=null}).filter(function(p){return m.distSquared(p.min.point,p.max.point)>rt.EPSILON}),function(p,_){var v=m.sub(p.min.uv0,_.min.uv0),w=m.dot(v,v),I=m.sub(p.max.uv0,_.max.uv0),S=m.dot(I,I),P=m.sub(p.min.uv0,_.max.uv0),k=m.dot(P,P),M=m.sub(p.max.uv0,_.min.uv0),L=m.dot(M,M);return w<rt.EPSILON&&S<rt.EPSILON||k<rt.EPSILON&&L<rt.EPSILON});return lt.makeMeshIntersectionPolylines(d)},lt.meshSlices=function(r,n,a,l){for(var u=new Lr(r),d=u.boundingBox(),p=d.min[0],_=d.min[1],v=d.max[0],w=d.max[1],I=m.span(n,a,l),S=[],P=0;P<I.length;){var k=I[P];++P;var M=[[p,_,k],[v,_,k],[v,w,k],[p,w,k]],L=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],B=new qe(C,M,null,L);S.push(lt.meshes(r,B,u))}return S},lt.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var n=0;n<r.length;){var a=r[n];++n,a.max.opp=a.min,a.min.opp=a.max}for(var l=lt.kdTreeFromSegments(r),u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.min),u.push(p.max)}for(var _=0;_<u.length;){var v=u[_];if(++_,v.adj==null){var w=lt.lookupAdjacentSegment(v,l,r.length);w!=null&&w.adj==null&&(v.adj=w,w.adj=v)}}var I=u.filter(function(R){return R.adj==null});I.length==0&&(I=u);for(var S=[],P=0,k=!1;I.length!=0;){var M=I.pop();if(!M.visited){for(var L=[],C=M;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,L.push(C),P+=2,C=C.opp.adj,C==M)););L.length>0&&(L.push(L[L.length-1].opp),S.push(L))}if(I.length==0&&u.length>0&&(k||P<u.length)){k=!0;var B=u.pop();I.push(B)}}return S},lt.kdTreeFromSegments=function(r){for(var n=[],a=0;a<r.length;){var l=r[a];++a,n.push(new Sn(l.min.point,l.min)),n.push(new Sn(l.max.point,l.max))}return new Zn(n,m.distSquared)},lt.lookupAdjacentSegment=function(r,n,a){var l=n.nearest(r.point,a,rt.EPSILON).filter(function(u){return r!=u.item0.obj}).map(function(u){return u.item0.obj});return l.length==1?l[0]:null},lt.curveAndSurface=function(r,n,a,l,u){a==null&&(a=.001),l!=null?l=l:l=new sr(r),u!=null?u=u:u=new Cr(n);var d=lt.boundingBoxTrees(l,u,a);return $.unique(d.map(function(p){var _=p.item0,v=p.item1,w=$.first(_.knots),I=$.last(_.knots),S=(w+I)/2,P=$.first(v.knotsU),k=$.last(v.knotsU),M=$.first(v.knotsV),L=$.last(v.knotsV),C=[(P+k)/2,(M+L)/2];return lt.curveAndSurfaceWithEstimate(_,v,[S].concat(C),a)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<a*a}),function(p,_){return Math.abs(p.u-_.u)<.5*a})},lt.curveAndSurfaceWithEstimate=function(r,n,a,l){l==null&&(l=.001);var u=function(v){var w=N.rationalCurvePoint(r,v[0]),I=N.rationalSurfacePoint(n,v[1],v[2]),S=m.sub(w,I);return m.dot(S,S)},d=function(v){var w=N.rationalCurveDerivatives(r,v[0],1),I=N.rationalSurfaceDerivatives(n,v[1],v[2],1),S=m.sub(I[0][0],w[0]),P=m.mul(-1,w[1]),k=I[1][0],M=I[0][1];return[2*m.dot(P,S),2*m.dot(k,S),2*m.dot(M,S)]},p=Ye.uncmin(u,a,l*l,d),_=p.solution;return new Yn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(n,_[1],_[2]))},lt.polylineAndMesh=function(r,n,a){for(var l=lt.boundingBoxTrees(new ar(r),new ir(n),a),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=lt.segmentWithTriangle(r.points[_],r.points[_+1],n.points,n.faces[v]);if(w!=null){var I=w.point,S=m.lerp(w.p,[r.params[_]],[r.params[_+1]])[0],P=re.triangleUVFromPoint(n,v,I);u.push(new Xn(I,S,P,_,v))}}return u},lt.boundingBoxTrees=function(r,n,a){a==null&&(a=1e-9);var l=[],u=[];l.push(r),u.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=u.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),a)){var v=p.indivisible(a),w=_.indivisible(a);if(v&&w){d.push(new ee(p.yield(),_.yield()));continue}else if(v&&!w){var I=_.split();l.push(p),u.push(I.item1),l.push(p),u.push(I.item0);continue}else if(!v&&w){var S=p.split();l.push(S.item1),u.push(_),l.push(S.item0),u.push(_);continue}var P=p.split(),k=_.split();l.push(P.item1),u.push(k.item1),l.push(P.item1),u.push(k.item0),l.push(P.item0),u.push(k.item1),l.push(P.item0),u.push(k.item0)}}return d},lt.curves=function(r,n,a){var l=lt.boundingBoxTrees(new sr(r),new sr(n),0);return $.unique(l.map(function(u){return lt.curvesWithEstimate(r,n,$.first(u.item0.knots),$.first(u.item1.knots),a)}).filter(function(u){return m.distSquared(u.point0,u.point1)<a}),function(u,d){return Math.abs(u.u0-d.u0)<a*5})},lt.curvesWithEstimate=function(r,n,a,l,u){var d=function(P){var k=N.rationalCurvePoint(r,P[0]),M=N.rationalCurvePoint(n,P[1]),L=m.sub(k,M);return m.dot(L,L)},p=function(P){var k=N.rationalCurveDerivatives(r,P[0],1),M=N.rationalCurveDerivatives(n,P[1],1),L=m.sub(k[0],M[0]),C=k[1],B=m.mul(-1,M[1]);return[2*m.dot(C,L),2*m.dot(B,L)]},_=Ye.uncmin(d,[a,l],u*u,p),v=_.solution[0],w=_.solution[1],I=N.rationalCurvePoint(r,v),S=N.rationalCurvePoint(n,w);return new $r(I,S,v,w)},lt.triangles=function(r,n,a,l){var u=r.faces[n],d=a.faces[l],p=re.getTriangleNorm(r.points,u),_=re.getTriangleNorm(a.points,d),v=r.points[u[0]],w=a.points[d[0]],I=lt.planes(v,p,w,_);if(I==null)return null;var S=lt.clipRayInCoplanarTriangle(I,r,n);if(S==null)return null;var P=lt.clipRayInCoplanarTriangle(I,a,l);if(P==null)return null;var k=lt.mergeTriangleClipIntervals(S,P,r,n,a,l);return k==null?null:new Se(new Nr(k.min.uv0,k.min.uv1,k.min.point,n,l),new Nr(k.max.uv0,k.max.uv1,k.max.point,n,l))},lt.clipRayInCoplanarTriangle=function(r,n,a){for(var l=n.faces[a],u=[n.points[l[0]],n.points[l[1]],n.points[l[2]]],d=[n.uvs[l[0]],n.uvs[l[1]],n.uvs[l[2]]],p=[m.sub(d[1],d[0]),m.sub(d[2],d[1]),m.sub(d[0],d[2])],_=[m.sub(u[1],u[0]),m.sub(u[2],u[1]),m.sub(u[0],u[2])],v=_.map(m.normalized),w=_.map(m.norm),I=null,S=null,P=0;P<3;){var k=P++,M=u[k],L=v[k],C=lt.rays(M,L,r.origin,r.dir);if(C!=null){var B=C.u0,R=C.u1;B<-rt.EPSILON||B>w[k]+rt.EPSILON||((I==null||R<I.u)&&(I=new An(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],B/w[k]))),(S==null||R>S.u)&&(S=new An(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],B/w[k]))))}}return S==null||I==null?null:new Se(I,S)},lt.mergeTriangleClipIntervals=function(r,n,a,l,u,d){if(n.min.u>r.max.u+rt.EPSILON||r.min.u>n.max.u+rt.EPSILON)return null;var p;r.min.u>n.min.u?p=new ee(r.min,0):p=new ee(n.min,1);var _;r.max.u<n.max.u?_=new ee(r.max,0):_=new ee(n.max,1);var v=new Se(new Nr(null,null,p.item0.point,l,d),new Nr(null,null,_.item0.point,l,d));return p.item1==0?(v.min.uv0=p.item0.uv,v.min.uv1=re.triangleUVFromPoint(u,d,p.item0.point)):(v.min.uv0=re.triangleUVFromPoint(a,l,p.item0.point),v.min.uv1=p.item0.uv),_.item1==0?(v.max.uv0=_.item0.uv,v.max.uv1=re.triangleUVFromPoint(u,d,_.item0.point)):(v.max.uv0=re.triangleUVFromPoint(a,l,_.item0.point),v.max.uv1=_.item0.uv),v},lt.planes=function(r,n,a,l){var u=m.cross(n,l);if(m.dot(u,u)<rt.EPSILON)return null;var d=0,p=Math.abs(u[0]),_=Math.abs(u[1]),v=Math.abs(u[2]);_>p&&(d=1,p=_),v>p&&(d=2,p=v);var w,I,S,P;d==0?(w=n[1],I=n[2],S=l[1],P=l[2]):d==1?(w=n[0],I=n[2],S=l[0],P=l[2]):(w=n[0],I=n[1],S=l[0],P=l[1]);var k=-m.dot(r,n),M=-m.dot(a,l),L=w*P-I*S,C=(I*M-k*P)/L,B=(k*S-w*M)/L,R;return d==0?R=[0,C,B]:d==1?R=[C,0,B]:R=[C,B,0],new wn(R,m.normalized(u))},lt.threePlanes=function(r,n,a,l,u,d){var p=m.cross(a,u),_=m.dot(r,p);if(Math.abs(_)<rt.EPSILON)return null;var v=m.sub(m.mul(d,a),m.mul(l,u)),w=m.add(m.mul(n,p),m.cross(r,v));return m.mul(1/_,w)},lt.polylines=function(r,n,a){for(var l=lt.boundingBoxTrees(new ar(r),new ar(n),a),u=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,v=p.item1,w=lt.segments(r.points[_],r.points[_+1],n.points[v],n.points[v+1],a);w!=null&&(w.u0=m.lerp(w.u0,[r.params[_]],[r.params[_+1]])[0],w.u1=m.lerp(w.u1,[n.params[v]],[n.params[v+1]])[0],u.push(w))}return u},lt.segments=function(r,n,a,l,u){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),v=m.sub(l,a),w=Math.sqrt(m.dot(v,v)),I=m.mul(1/w,v),S=lt.rays(r,_,a,I);if(S!=null){var P=Math.min(Math.max(0,S.u0/p),1),k=Math.min(Math.max(0,S.u1/w),1),M=m.onRay(r,d,P),L=m.onRay(a,v,k),C=m.distSquared(M,L);if(C<u*u)return new $r(M,L,P,k)}return null},lt.rays=function(r,n,a,l){var u=m.dot(n,l),d=m.dot(n,a),p=m.dot(n,r),_=m.dot(l,a),v=m.dot(l,r),w=m.dot(n,n),I=m.dot(l,l),S=w*I-u*u;if(Math.abs(S)<rt.EPSILON)return null;var P=u*(d-p)-w*(_-v),k=P/S,M=(d-p+k*u)/w,L=m.onRay(r,n,M),C=m.onRay(a,l,k);return new $r(L,C,M,k)},lt.segmentWithTriangle=function(r,n,a,l){var u=a[l[0]],d=a[l[1]],p=a[l[2]],_=m.sub(d,u),v=m.sub(p,u),w=m.cross(_,v),I=m.sub(n,r),S=m.sub(r,u),P=-m.dot(w,S),k=m.dot(w,I);if(Math.abs(k)<rt.EPSILON)return null;var M=P/k;if(M<0||M>1)return null;var L=m.add(r,m.mul(M,I)),C=m.dot(_,v),B=m.dot(_,_),R=m.dot(v,v),D=m.sub(L,u),V=m.dot(D,_),Y=m.dot(D,v),J=C*C-B*R;if(Math.abs(J)<rt.EPSILON)return null;var H=(C*Y-R*V)/J,j=(C*V-B*Y)/J;return H>1+rt.EPSILON||j>1+rt.EPSILON||j<-rt.EPSILON||H<-rt.EPSILON||H+j>1+rt.EPSILON?null:new $n(L,H,j,M)},lt.segmentAndPlane=function(r,n,a,l){var u=m.dot(l,m.sub(n,r));if(Math.abs(u)<rt.EPSILON)return null;var d=m.dot(l,m.sub(a,r)),p=d/u;return p>1+rt.EPSILON||p<-rt.EPSILON?null:{p}};var pt=f.eval.Make=function(){};b["verb.eval.Make"]=pt,pt.__name__=["verb","eval","Make"],pt.rationalTranslationalSurface=function(r,n){for(var a=N.rationalCurvePoint(n,$.first(n.knots)),l=$.first(n.knots),u=$.last(n.knots),d=2*n.controlPoints.length,p=(u-l)/(d-1),_=[],v=0;v<d;){var w=v++,I=m.sub(N.rationalCurvePoint(n,l+w*p),a),S=ft.rationalCurveTransform(r,[[1,0,0,I[0]],[0,1,0,I[1]],[0,0,1,I[2]],[0,0,0,1]]);_.push(S)}return pt.loftedSurface(_)},pt.surfaceBoundaryCurves=function(r){var n=pt.surfaceIsocurve(r,$.first(r.knotsU),!1),a=pt.surfaceIsocurve(r,$.last(r.knotsU),!1),l=pt.surfaceIsocurve(r,$.first(r.knotsV),!0),u=pt.surfaceIsocurve(r,$.last(r.knotsV),!0);return[n,a,l,u]},pt.surfaceIsocurve=function(r,n,a){a==null&&(a=!1);var l;a?l=r.knotsV:l=r.knotsU;var u;a?u=r.degreeV:u=r.degreeU;for(var d=yt.knotMultiplicities(l),p=-1,_=0,v=d.length;_<v;){var w=_++;if(Math.abs(n-d[w].knot)<rt.EPSILON){p=w;break}}var I=u+1;p>=0&&(I=I-d[p].mult);var S;I>0?S=ft.surfaceKnotRefine(r,m.rep(I,n),a):S=r;var P=N.knotSpan(u,n,l);return Math.abs(n-$.first(l))<rt.EPSILON?P=0:Math.abs(n-$.last(l))<rt.EPSILON&&(P=(a?S.controlPoints[0].length:S.controlPoints.length)-1),a?new jt(S.degreeU,S.knotsU,function(k){for(var M,L=[],C=0,B=S.controlPoints;C<B.length;){var R=B[C];++C,L.push(R[P])}return M=L,M}()):new jt(S.degreeV,S.knotsV,S.controlPoints[P])},pt.loftedSurface=function(r,n){r=ft.unifyCurveKnotVectors(r);var a=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,u=[],d=[],p=0,_=r[0].controlPoints.length;p<_;){var v=[p++],w=r.map(function(S){return function(P){return P.controlPoints[S[0]]}}(v)),I=pt.rationalInterpCurve(w,n,!0);d.push(I.controlPoints),u=I.knots}return new te(a,n,l,u,d)},pt.clonedCurve=function(r){return new jt(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},pt.rationalBezierCurve=function(r,n){for(var a=r.length-1,l=[],u=0,d=a+1;u<d;)u++,l.push(0);for(var p=0,_=a+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new jt(a,l,N.homogenize1d(r,n))},pt.fourPointSurface=function(r,n,a,l,u){u==null&&(u=3);for(var d=u,p=[],_=0,v=u+1;_<v;){for(var w=_++,I=[],S=0,P=u+1;S<P;){var k=S++,M=1-w/d,L=m.lerp(M,r,n),C=m.lerp(M,l,a),B=m.lerp(1-k/d,L,C);B.push(1),I.push(B)}p.push(I)}var R=m.rep(u+1,0),D=m.rep(u+1,1);return new te(u,u,R.concat(D),R.concat(D),p)},pt.ellipseArc=function(r,n,a,l,u){var d=m.norm(n),p=m.norm(a);n=m.normalized(n),a=m.normalized(a),u<l&&(u=2*Math.PI+l);var _=u-l,v=0;_<=Math.PI/2?v=1:_<=Math.PI?v=2:_<=3*Math.PI/2?v=3:v=4;var w=_/v,I=Math.cos(w/2),S=m.add(r,m.add(m.mul(d*Math.cos(l),n),m.mul(p*Math.sin(l),a))),P=m.sub(m.mul(Math.cos(l),a),m.mul(Math.sin(l),n)),k=[],M=m.zeros1d(2*v+3),L=0,C=l,B=m.zeros1d(v*2);k[0]=S,B[0]=1;for(var R=1,D=v+1;R<D;){var V=R++;C+=w;var Y=m.add(r,m.add(m.mul(d*Math.cos(C),n),m.mul(p*Math.sin(C),a)));B[L+2]=1,k[L+2]=Y;var J=m.sub(m.mul(Math.cos(C),a),m.mul(Math.sin(C),n)),H=lt.rays(S,m.mul(1/m.norm(P),P),Y,m.mul(1/m.norm(J),J)),j=m.add(S,m.mul(H.u0,P));B[L+1]=I,k[L+1]=j,L+=2,V<v&&(S=Y,P=J)}for(var K=2*v+1,tt=0;tt<3;){var et=tt++;M[et]=0,M[et+K]=1}switch(v){case 2:M[3]=M[4]=.5;break;case 3:M[3]=M[4]=.3333333333333333,M[5]=M[6]=.6666666666666666;break;case 4:M[3]=M[4]=.25,M[5]=M[6]=.5,M[7]=M[8]=.75;break}return new jt(2,M,N.homogenize1d(k,B))},pt.arc=function(r,n,a,l,u,d){return pt.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(a)),u,d)},pt.polyline=function(r){for(var n=[0,0],a=0,l=0,u=r.length-1;l<u;){var d=l++;a+=m.dist(r[d],r[d+1]),n.push(a)}n.push(a),n=m.mul(1/a,n);for(var p,_=[],v=0,w=r.length;v<w;)v++,_.push(1);return p=_,new jt(1,n,N.homogenize1d(r.slice(0),p))},pt.extrudedSurface=function(r,n,a){for(var l=[[],[],[]],u=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),p=N.weight1d(a.controlPoints),_=m.mul(n,r),v=m.mul(.5*n,r),w=0,I=d.length;w<I;){var S=w++;l[2][S]=d[S],l[1][S]=m.add(v,d[S]),l[0][S]=m.add(_,d[S]),u[0][S]=p[S],u[1][S]=p[S],u[2][S]=p[S]}return new te(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,u))},pt.cylindricalSurface=function(r,n,a,l,u){var d=m.cross(r,n),p=pt.arc(a,n,d,u,0,2*Math.PI);return pt.extrudedSurface(r,l,p)},pt.revolvedSurface=function(r,n,a,l){var u=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),p,_;l<=Math.PI/2?(p=1,_=m.zeros1d(6+2*(p-1))):l<=Math.PI?(p=2,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(p=3,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(p=4,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var v=l/p,w=3+2*(p-1),I=0;I<3;){var S=I++;_[S]=0,_[w+S]=1}for(var P=Math.cos(v/2),k=0,M=m.zeros1d(p+1),L=m.zeros1d(p+1),C=m.zeros3d(2*p+1,u.length,3),B=m.zeros2d(2*p+1,u.length),R=1,D=p+1;R<D;){var V=R++;k+=v,L[V]=Math.cos(k),M[V]=Math.sin(k)}for(var Y=0,J=u.length;Y<J;){var H=Y++,j=Me.rayClosestPoint(u[H],n,a),K=m.sub(u[H],j),tt=m.norm(K),et=m.cross(a,K);tt>rt.EPSILON&&(K=m.mul(1/tt,K),et=m.mul(1/tt,et)),C[0][H]=u[H];var it=u[H];B[0][H]=d[H];for(var ht=et,at=0,ct=1,nt=p+1;ct<nt;){var mt=ct++,X;tt==0?X=j:X=m.add(j,m.add(m.mul(tt*L[mt],K),m.mul(tt*M[mt],et))),C[at+2][H]=X,B[at+2][H]=d[H];var gt=m.sub(m.mul(L[mt],et),m.mul(M[mt],K));if(tt==0)C[at+1][H]=j;else{var It=lt.rays(it,m.mul(1/m.norm(ht),ht),X,m.mul(1/m.norm(gt),gt)),Gt=m.add(it,m.mul(It.u0,ht));C[at+1][H]=Gt}B[at+1][H]=P*d[H],at+=2,mt<p&&(it=X,ht=gt)}}return new te(2,r.degree,_,r.knots,N.homogenize2d(C,B))},pt.sphericalSurface=function(r,n,a,l){var u=pt.arc(r,m.mul(-1,n),a,l,0,Math.PI);return pt.revolvedSurface(u,r,n,2*Math.PI)},pt.conicalSurface=function(r,n,a,l,u){var d=2*Math.PI,p=1,_=[m.add(a,m.mul(l,r)),m.add(a,m.mul(u,n))],v=[0,0,1,1],w=[1,1],I=new jt(p,v,N.homogenize1d(_,w));return pt.revolvedSurface(I,a,r,d)},pt.rationalInterpCurve=function(r,n,a,l,u){if(a==null&&(a=!1),n==null&&(n=3),r.length<n+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],p=1,_=r.length;p<_;){var v=p++,w=m.norm(m.sub(r[v],r[v-1])),I=d[d.length-1];d.push(I+w)}for(var S=d[d.length-1],P=0,k=d.length;P<k;){var M=P++;d[M]=d[M]/S}var L=m.rep(n+1,0),C=l!=null&&u!=null,B;C?B=0:B=1;var R;C?R=d.length-n+1:R=d.length-n;for(var D=B;D<R;){for(var V=D++,Y=0,J=0;J<n;){var H=J++;Y+=d[V+H]}L.push(1/n*Y)}var j=L.concat(m.rep(n+1,1)),K=[],tt;C?tt=r.length+1:tt=r.length-1;var et;C?et=r.length-(n-1):et=r.length-(n+1);for(var it=0;it<d.length;){var ht=d[it];++it;var at=N.knotSpanGivenN(tt,n,ht,j),ct=N.basisFunctionsGivenKnotSpanIndex(at,ht,n,j),nt=at-n,mt=m.zeros1d(nt),X=m.zeros1d(et-nt);K.push(mt.concat(ct).concat(X))}if(C){var gt=K[0].length-2,It=[-1,1].concat(m.zeros1d(gt)),Gt=m.zeros1d(gt).concat([-1,1]);$.spliceAndInsert(K,1,0,It),$.spliceAndInsert(K,K.length-1,0,Gt)}for(var Xt=r[0].length,Dt=[],Kt=(1-j[j.length-n-2])/n,Ie=j[n+1]/n,He=0;He<Xt;){var ve=[He++],ge;if(!C)ge=r.map(function(Qe){return function(dr){return dr[Qe[0]]}}(ve));else{ge=[r[0][ve[0]]],ge.push(Ie*l[ve[0]]);for(var Pe=1,Ce=r.length-1;Pe<Ce;){var Ke=Pe++;ge.push(r[Ke][ve[0]])}ge.push(Kt*u[ve[0]]),ge.push($.last(r)[ve[0]])}var or=Lt.solve(K,ge);Dt.push(or)}var $e=Lt.transpose(Dt);if(!a){var Ze=m.rep($e.length,1);$e=N.homogenize1d($e,Ze)}return new jt(n,j,$e)};var ft=f.eval.Modify=function(){};b["verb.eval.Modify"]=ft,ft.__name__=["verb","eval","Modify"],ft.curveReverse=function(r){return new jt(r.degree,ft.knotsReverse(r.knots),$.reversed(r.controlPoints))},ft.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new te(r.degreeU,r.degreeV,r.knotsU,ft.knotsReverse(r.knotsV),function(a){for(var l,u=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,u.push($.reversed(_))}return l=u,l}()):new te(r.degreeU,r.degreeV,ft.knotsReverse(r.knotsU),r.knotsV,$.reversed(r.controlPoints))},ft.knotsReverse=function(r){var n=$.first(r);$.last(r);for(var a=[n],l=r.length,u=1;u<l;){var d=u++;a.push(a[d-1]+(r[l-d]-r[l-d-1]))}return a},ft.unifyCurveKnotVectors=function(r){r=r.map(pt.clonedCurve);for(var n=z.fold(r,function(j,K){return ft.imax(j.degree,K)},0),a=0,l=r.length;a<l;){var u=a++;r[u].degree<n&&(r[u]=ft.curveElevateDegree(r[u],n))}for(var d,p=[],_=0;_<r.length;){var v=r[_];++_,p.push(new Se($.first(v.knots),$.last(v.knots)))}d=p;for(var w=0,I=r.length;w<I;){var S=w++,P=[d[S].min];r[S].knots=r[S].knots.map(function(j){return function(K){return K-j[0]}}(P))}for(var k=d.map(function(j){return j.max-j.min}),M=z.fold(k,function(j,K){return Math.max(j,K)},0),L=0,C=r.length;L<C;){var B=L++,R=[M/k[B]];r[B].knots=r[B].knots.map(function(j){return function(K){return K*j[0]}}(R))}for(var D=z.fold(r,function(j,K){return m.sortedSetUnion(j.knots,K)},[]),V=0,Y=r.length;V<Y;){var J=V++,H=m.sortedSetSub(D,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=ft.curveKnotRefine(r[J],H)}return r},ft.imin=function(r,n){return r<n?r:n},ft.imax=function(r,n){return r>n?r:n},ft.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var a=r.knots.length-r.degree-2,l=r.degree,u=r.knots,d=r.controlPoints,p=n-r.degree,_=r.controlPoints[0].length,v=m.zeros2d(l+p+1,l+1),w=[],I=[],S=[],P=a+l+1,k=n,M=Math.floor(k/2),L=[],C=[];v[0][0]=1,v[k][l]=1;for(var B=1,R=M+1;B<R;)for(var D=B++,V=1/Bt.get(k,D),Y=ft.imin(l,D),J=ft.imax(0,D-p),H=Y+1;J<H;){var j=J++;v[D][j]=V*Bt.get(l,j)*Bt.get(p,D-j)}for(var K=M+1;K<k;)for(var tt=K++,et=ft.imin(l,tt),it=ft.imax(0,tt-p),ht=et+1;it<ht;){var at=it++;v[tt][at]=v[k-tt][l-at]}var ct=k+1,nt=-1,mt=l,X=l+1,gt=1,It=u[0];L[0]=d[0];for(var Gt=0,Xt=k+1;Gt<Xt;){var Dt=Gt++;C[Dt]=It}for(var Kt=0,Ie=l+1;Kt<Ie;){var He=Kt++;w[He]=d[He]}for(;X<P;){for(var ve=X;X<P&&u[X]==u[X+1];)X=X+1;var ge=X-ve+1,Pe=u[X],Ce=nt;nt=l-ge;var Ke;Ce>0?Ke=Math.floor((Ce+2)/2):Ke=1;var or;if(nt>0?or=Math.floor(k-(nt+1)/2):or=k,nt>0){for(var $e=Pe-It,Ze=[],Qe=l;Qe>ge;)Ze[Qe-ge-1]=$e/(u[mt+Qe]-It),Qe--;for(var dr=1,Nn=nt+1;dr<Nn;){for(var Qr=dr++,Ku=nt-Qr,Ki=ge+Qr,Jr=l;Jr>=Ki;)w[Jr]=m.add(m.mul(Ze[Jr-Ki],w[Jr]),m.mul(1-Ze[Jr-Ki],w[Jr-1])),Jr--;S[Ku]=w[l]}}for(var Lo=Ke,$u=k+1;Lo<$u;){var Cn=Lo++;I[Cn]=m.zeros1d(_);for(var Zu=ft.imin(l,Cn),Oo=ft.imax(0,Cn-p),Qu=Zu+1;Oo<Qu;){var zo=Oo++;I[Cn]=m.add(I[Cn],m.mul(v[Cn][zo],w[zo]))}}if(Ce>1)for(var $i=ct-2,Zi=ct,Ro=Pe-It,Ju=(Pe-C[ct-1])/Ro,Bo=1;Bo<Ce;){for(var Qi=Bo++,mr=$i,tn=Zi,Dr=tn-ct+1;tn-mr>Qi;){if(mr<gt){var tc=(Pe-C[mr])/(It-C[mr]);L[mr]=m.lerp(tc,L[mr],L[mr-1])}if(tn>=Ke){if(tn-Qi<=ct-k+Ce){var ec=(Pe-C[tn-Qi])/Ro;I[Dr]=m.lerp(ec,I[Dr],I[Dr+1])}}else I[Dr]=m.lerp(Ju,I[Dr],I[Dr+1]);mr=mr+1,tn=tn-1,Dr=Dr-1}$i=$i-1,Zi=Zi+1}if(mt!=l)for(var Fo=0,rc=k-Ce;Fo<rc;)Fo++,C[ct]=It,ct=ct+1;for(var Do=Ke,nc=or+1;Do<nc;){var sc=Do++;L[gt]=I[sc],gt=gt+1}if(X<P){for(var Uo=0;Uo<nt;){var Vo=Uo++;w[Vo]=S[Vo]}for(var jo=nt,ic=l+1;jo<ic;){var Go=jo++;w[Go]=d[X-l+Go]}mt=X,X=X+1,It=Pe}else for(var Wo=0,ac=k+1;Wo<ac;){var oc=Wo++;C[ct+oc]=Pe}}return new jt(n,C,L)},ft.rationalSurfaceTransform=function(r,n){for(var a=N.dehomogenize2d(r.controlPoints),l=0,u=a.length;l<u;)for(var d=l++,p=0,_=a[d].length;p<_;){var v=p++,w=a[d][v];w.push(1),a[d][v]=Lt.dot(n,w).slice(0,w.length-1)}return new te(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},ft.rationalCurveTransform=function(r,n){for(var a=N.dehomogenize1d(r.controlPoints),l=0,u=a.length;l<u;){var d=l++,p=a[d];p.push(1),a[d]=Lt.dot(n,p).slice(0,p.length-1)}return new jt(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},ft.surfaceKnotRefine=function(r,n,a){var l=[],u,d,p;a?(p=r.controlPoints,u=r.knotsV,d=r.degreeV):(p=Lt.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,v=0;v<p.length;){var w=p[v];++v,_=ft.curveKnotRefine(new jt(d,u,w),n),l.push(_.controlPoints)}var I=_.knots;return a?new te(r.degreeU,r.degreeV,r.knotsU.slice(),I,l):(l=Lt.transpose(l),new te(r.degreeU,r.degreeV,I,r.knotsV.slice(),l))},ft.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,a=r.controlPoints,l=r.knots,u=yt.knotMultiplicities(l),d=n+1,p=0;p<u.length;){var _=u[p];if(++p,_.mult<d){var v=m.rep(d-_.mult,_.knot),w=ft.curveKnotRefine(new jt(n,l,a),v);l=w.knots,a=w.controlPoints}}l.length/d-1;for(var I=d*2,S=[],P=0;P<a.length;){var k=l.slice(P,P+I),M=a.slice(P,P+d);S.push(new jt(n,k,M)),P+=d}return S},ft.curveKnotRefine=function(r,n){if(n.length==0)return pt.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,p=d+a+1,_=n.length-1,v=N.knotSpan(a,n[0],u),w=N.knotSpan(a,n[_],u),I=[],S=[],P=0,k=v-a+1;P<k;){var M=P++;I[M]=l[M]}for(var L=w-1,C=d+1;L<C;){var B=L++;I[B+_+1]=l[B]}for(var R=0,D=v+1;R<D;){var V=R++;S[V]=u[V]}for(var Y=w+a,J=p+1;Y<J;){var H=Y++;S[H+_+1]=u[H]}for(var j=w+a-1,K=w+a+_,tt=_;tt>=0;){for(;n[tt]<=u[j]&&j>v;)I[K-a-1]=l[j-a-1],S[K]=u[j],K=K-1,j=j-1;I[K-a-1]=I[K-a];for(var et=1,it=a+1;et<it;){var ht=et++,at=K-a+ht,ct=S[K+ht]-n[tt];Math.abs(ct)<rt.EPSILON?I[at-1]=I[at]:(ct=ct/(S[K+ht]-u[j-a+ht]),I[at-1]=m.add(m.mul(ct,I[at-1]),m.mul(1-ct,I[at])))}S[K]=n[tt],K=K-1,tt--}return new jt(a,S,I)},ft.curveKnotInsert=function(r,n,a){for(var l=r.degree,u=r.controlPoints,d=r.knots,p=0,_=u.length,v=N.knotSpan(l,n,d),w=[],I=[],S=[],P=1,k=v+1;P<k;){var M=P++;I[M]=d[M]}for(var L=1,C=a+1;L<C;){var B=L++;I[v+B]=n}for(var R=v+1,D=d.length;R<D;){var V=R++;I[V+a]=d[V]}for(var Y=0,J=v-l+1;Y<J;){var H=Y++;S[H]=u[H]}for(var j=v-p;j<_;){var K=j++;S[K+a]=u[K]}for(var tt=0,et=l-p+1;tt<et;){var it=tt++;w[it]=u[v-l+it]}for(var ht=0,at=0,ct=1,nt=a+1;ct<nt;){var mt=ct++;ht=v-l+mt;for(var X=0,gt=l-mt-p+1;X<gt;){var It=X++;at=(n-d[ht+It])/(d[It+v+1]-d[ht+It]),w[It]=m.add(m.mul(at,w[It+1]),m.mul(1-at,w[It]))}S[ht]=w[0],S[v+a-mt-p]=w[l-mt-p]}for(var Gt=ht+1,Xt=v-p;Gt<Xt;){var Dt=Gt++;S[Dt]=w[Dt-ht]}return new jt(l,I,S)};var zt=f.eval.Tess=function(){};b["verb.eval.Tess"]=zt,zt.__name__=["verb","eval","Tess"],zt.rationalCurveRegularSample=function(r,n,a){return zt.rationalCurveRegularSampleRange(r,r.knots[0],$.last(r.knots),n,a)},zt.rationalCurveRegularSampleRange=function(r,n,a,l,u){l<1&&(l=2);for(var d=[],p=(a-n)/(l-1),_=0,v=0;v<l;){var w=v++;_=n+p*w,u?d.push([_].concat(N.rationalCurvePoint(r,_))):d.push(N.rationalCurvePoint(r,_))}return d},zt.rationalCurveAdaptiveSample=function(r,n,a){if(a==null&&(a=!1),n==null&&(n=1e-6),r.degree==1)if(a){for(var l=[],u=0,d=r.controlPoints.length;u<d;){var p=u++;l.push([r.knots[p+1]].concat(N.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(N.dehomogenize);return zt.rationalCurveAdaptiveSampleRange(r,r.knots[0],$.last(r.knots),n,a)},zt.rationalCurveAdaptiveSampleRange=function(r,n,a,l,u){var d=N.rationalCurvePoint(r,n),p=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),v=n+(a-n)*_,w=N.rationalCurvePoint(r,v),I=m.sub(d,p),S=m.sub(d,w);if(m.dot(I,I)<l&&m.dot(S,S)>l||!Me.threePointsAreFlat(d,w,p,l)){var P=n+(a-n)*.5,k=zt.rationalCurveAdaptiveSampleRange(r,n,P,l,u),M=zt.rationalCurveAdaptiveSampleRange(r,P,a,l,u);return k.slice(0,-1).concat(M)}else return u?[[n].concat(d),[a].concat(p)]:[d,p]},zt.rationalSurfaceNaive=function(r,n,a){n<1&&(n=1),a<1&&(a=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,u=r.knotsV,d=$.last(l)-l[0],p=$.last(u)-u[0],_=d/n,v=p/a,w=[],I=[],S=[],P=0,k=n+1;P<k;)for(var M=P++,L=0,C=a+1;L<C;){var B=L++,R=M*_,D=B*v;I.push([R,D]);var V=N.rationalSurfaceDerivatives(r,R,D,1),Y=V[0][0];w.push(Y);var J=m.normalized(m.cross(V[1][0],V[0][1]));S.push(J)}for(var H=[],j=0;j<n;)for(var K=j++,tt=0;tt<a;){var et=tt++,it=K*(a+1)+et,ht=(K+1)*(a+1)+et,at=ht+1,ct=it+1,nt=[it,ht,at],mt=[it,at,ct];H.push(nt),H.push(mt)}return new qe(H,w,S,I)},zt.divideRationalSurfaceAdaptive=function(r,n){n==null&&(n=new Or),n.minDivsU!=null?n.minDivsU=n.minDivsU:n.minDivsU=1,n.minDivsV!=null?n.minDivsU=n.minDivsV:n.minDivsU=1,n.refine!=null?n.refine=n.refine:n.refine=!0;var a=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,u;n.minDivsU>a?u=n.minDivsU=n.minDivsU:u=n.minDivsU=a;var d;n.minDivsV>l?d=n.minDivsV=n.minDivsV:d=n.minDivsV=l;for(var p=$.last(r.knotsU),_=r.knotsU[0],v=$.last(r.knotsV),w=r.knotsV[0],I=(p-_)/u,S=(v-w)/d,P=[],k=[],M=0,L=d+1;M<L;){for(var C=M++,B=[],R=0,D=u+1;R<D;){var V=R++,Y=_+I*V,J=w+S*C,H=N.rationalSurfaceDerivatives(r,Y,J,1),j=m.normalized(m.cross(H[0][1],H[1][0]));B.push(new Ge(H[0][0],j,[Y,J],-1,m.isZero(j)))}k.push(B)}for(var K=0;K<d;)for(var tt=K++,et=0;et<u;){var it=et++,ht=[k[d-tt-1][it],k[d-tt-1][it+1],k[d-tt][it+1],k[d-tt][it]];P.push(new cr(r,ht))}if(!n.refine)return P;for(var at=0;at<d;)for(var ct=at++,nt=0;nt<u;){var mt=nt++,X=ct*u+mt,gt=zt.north(X,ct,mt,u,d,P),It=zt.east(X,ct,mt,u,d,P),Gt=zt.south(X,ct,mt,u,d,P),Xt=zt.west(X,ct,mt,u,d,P);P[X].neighbors=[Gt,It,gt,Xt],P[X].divide(n)}return P},zt.north=function(r,n,a,l,u,d){return n==0?null:d[r-l]},zt.south=function(r,n,a,l,u,d){return n==u-1?null:d[r+l]},zt.east=function(r,n,a,l,u,d){return a==l-1?null:d[r+1]},zt.west=function(r,n,a,l,u,d){return a==0?null:d[r-1]},zt.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=qe.empty(),a=0;a<r.length;){var l=r[a];++a,l.triangulate(n)}return n},zt.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new Or;var a=zt.divideRationalSurfaceAdaptive(r,n);return zt.triangulateAdaptiveRefinementNodeTree(a)};var Or=f.core.AdaptiveRefinementOptions=function(){this.minDivsV=1,this.minDivsU=1,this.refine=!0,this.maxDepth=10,this.minDepth=0,this.normTol=.025};b["verb.eval.AdaptiveRefinementOptions"]=Or,Or.__name__=["verb","eval","AdaptiveRefinementOptions"],Or.prototype={__class__:Or};var cr=f.core.AdaptiveRefinementNode=function(r,n,a){if(this.srf=r,a==null?this.neighbors=[null,null,null,null]:this.neighbors=a,this.corners=n,this.corners==null){var l=r.knotsU[0],u=$.last(r.knotsU),d=r.knotsV[0],p=$.last(r.knotsV);this.corners=[Ge.fromUv(l,d),Ge.fromUv(u,d),Ge.fromUv(u,p),Ge.fromUv(l,p)]}};b["verb.eval.AdaptiveRefinementNode"]=cr,cr.__name__=["verb","eval","AdaptiveRefinementNode"],cr.prototype={isLeaf:function(){return this.children==null},center:function(){return this.centerPoint!=null?this.centerPoint:this.evalSrf(this.u05,this.v05)},evalCorners:function(){this.u05=(this.corners[0].uv[0]+this.corners[2].uv[0])/2,this.v05=(this.corners[0].uv[1]+this.corners[2].uv[1])/2;for(var r=0;r<4;){var n=r++;if(this.corners[n].point==null){var a=this.corners[n];this.evalSrf(a.uv[0],a.uv[1],a)}}},evalSrf:function(r,n,a){var l=N.rationalSurfaceDerivatives(this.srf,r,n,1),u=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),a!=null?(a.degen=p,a.point=u,a.normal=d,a):new Ge(u,d,[r,n],-1,p)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){case 0:return this.children[0].getEdgeCorners(0);case 1:return this.children[0].getEdgeCorners(1).concat(this.children[1].getEdgeCorners(1));case 2:return this.children[1].getEdgeCorners(2);case 3:return this.children[1].getEdgeCorners(3).concat(this.children[0].getEdgeCorners(3))}switch(r){case 0:return this.children[0].getEdgeCorners(0).concat(this.children[1].getEdgeCorners(0));case 1:return this.children[1].getEdgeCorners(1);case 2:return this.children[1].getEdgeCorners(2).concat(this.children[0].getEdgeCorners(2));case 3:return this.children[0].getEdgeCorners(3)}return null},getAllCorners:function(r){var n=[this.corners[r]];if(this.neighbors[r]==null)return n;var a=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,u=rt.EPSILON,d=this,p=[function(v){return v.uv[0]>d.corners[0].uv[0]+u&&v.uv[0]<d.corners[2].uv[0]-u},function(v){return v.uv[1]>d.corners[0].uv[1]+u&&v.uv[1]<d.corners[2].uv[1]-u}],_=a.filter(p[l]);return _.reverse(),n.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){case 0:this.midPoints[0]=this.evalSrf(this.u05,this.corners[0].uv[1]);break;case 1:this.midPoints[1]=this.evalSrf(this.corners[1].uv[0],this.v05);break;case 2:this.midPoints[2]=this.evalSrf(this.u05,this.corners[2].uv[1]);break;case 3:this.midPoints[3]=this.evalSrf(this.corners[0].uv[0],this.v05);break}return this.midPoints[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,n=0;n<r;){var a=n++;if(this.corners[a],this.corners[a].degen){var l=this.corners[(a+1)%r],u=this.corners[(a+3)%r];l.degen?this.corners[a].normal=u.normal:this.corners[a].normal=l.normal}}},shouldDivide:function(r,n){if(n<r.minDepth)return!0;if(n>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=m.normSquared(m.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return m.normSquared(m.sub(a.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Or),r.normTol==null&&(r.normTol=.085),r.minDepth==null&&(r.minDepth=0),r.maxDepth==null&&(r.maxDepth=10),this._divide(r,0,!0)},_divide:function(r,n,a){if(this.evalCorners(),!!this.shouldDivide(r,n)){if(n++,this.splitVert&&!this.splitHoriz?a=!1:!this.splitVert&&this.splitHoriz&&(a=!0),this.horizontal=a,this.horizontal){var l=[this.corners[0],this.corners[1],this.midpoint(1),this.midpoint(3)],u=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new cr(this.srf,l),new cr(this.srf,u)],this.children[0].neighbors=[this.neighbors[0],this.neighbors[1],this.children[1],this.neighbors[3]],this.children[1].neighbors=[this.children[0],this.neighbors[1],this.neighbors[2],this.neighbors[3]]}else{var d=[this.corners[0],this.midpoint(0),this.midpoint(2),this.corners[3]],p=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new cr(this.srf,d),new cr(this.srf,p)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,v=this.children;_<v.length;){var w=v[_];++_,w._divide(r,n,!a)}}},triangulate:function(r){if(r==null&&(r=qe.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,a=this.children;n<a.length;){var l=a[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,a=[],l=[],u=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(u=p+1);for(var v=0,w=_.length;v<w;){var I=v++;a.push(_[I])}}for(var S=0;S<a.length;){var P=a[S];if(++S,P.id!=-1){l.push(P.id);continue}r.uvs.push(P.uv),r.points.push(P.point),r.normals.push(P.normal),P.id=n,l.push(n),n++}if(a.length==4)return r.faces.push([l[0],l[3],l[1]]),r.faces.push([l[3],l[2],l[1]]),r;if(a.length==5){var k=l.length;return r.faces.push([l[u],l[(u+2)%k],l[(u+1)%k]]),r.faces.push([l[(u+4)%k],l[(u+3)%k],l[u]]),r.faces.push([l[u],l[(u+3)%k],l[(u+2)%k]]),r}var M=this.center();r.uvs.push(M.uv),r.points.push(M.point),r.normals.push(M.normal);for(var L=r.points.length-1,C=0,B=a.length-1;C<a.length;)r.faces.push([L,l[C],l[B]]),B=C++;return r},__class__:cr};var wt=f.exe.Dispatcher=function(){};b["verb.exe.Dispatcher"]=wt,wt.__name__=["verb","exe","Dispatcher"],wt.init=function(){wt._init||(wt._workerPool=new zr(wt.THREADS),wt._init=!0)},wt.dispatchMethod=function(r,n,a){wt.init();var l=new xn,u=function(d){l.resolve(d)};return wt._workerPool.addWork(ut.getClassName(r),n,a,u),new pe(l)};var zr=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new bt,this._working=new bt,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(zr.basePath+n)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(zr.basePath+n.substring(0,-3)+".min.js")}this._pool.push(l)}};b["verb.exe.WorkerPool"]=zr,zr.__name__=["verb","exe","WorkerPool"],zr.prototype={addWork:function(r,n,a,l){var u=new Zr(r,n,a);this._callbacks.set(u.id,l),this._queue.push(u),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),a=[n.id],l=[this._pool.shift()];this._working.h[a[0]]=l[0],l[0].onmessage=function(u,d){return function(p){r._working.remove(d[0]),r._pool.push(u[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](p.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),x.log(_)}r.processQueue()}}(l,a),l[0].postMessage(n)}},__class__:zr};var Zr=function(r,n,a){this.className=r,this.methodName=n,this.args=a,this.id=Zr.uuid++};b["verb.exe._WorkerPool.Work"]=Zr,Zr.__name__=["verb","exe","_WorkerPool","Work"],Zr.prototype={__class__:Zr};var Tn=function(){};b["verb.geom.ICurve"]=Tn,Tn.__name__=["verb","geom","ICurve"],Tn.__interfaces__=[Pn],Tn.prototype={__class__:Tn};var Ct=f.geom.NurbsCurve=function(r){this._data=We.isValidNurbsCurveData(r)};b["verb.geom.NurbsCurve"]=Ct,Ct.__name__=["verb","geom","NurbsCurve"],Ct.__interfaces__=[Tn],Ct.byKnotsControlPointsWeights=function(r,n,a,l){return new Ct(new jt(r,n.slice(),N.homogenize1d(a,l)))},Ct.byPoints=function(r,n){return n==null&&(n=3),new Ct(pt.rationalInterpCurve(r,n))},Ct.__super__=Zt,Ct.prototype=T(Zt.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new jt(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ct(this._data)},domain:function(){return new Se($.first(this._data.knots),$.last(this._data.knots))},transform:function(r){return new Ct(ft.rationalCurveTransform(this._data,r))},transformAsync:function(r){return wt.dispatchMethod(ft,"rationalCurveTransform",[this._data,r]).then(function(n){return new Ct(n)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return wt.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return wt.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),N.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),wt.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return yt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return wt.dispatchMethod(yt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return yt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return wt.dispatchMethod(yt,"rationalCurveClosestParam",[this._data,r])},length:function(){return yt.rationalCurveArcLength(this._data)},lengthAsync:function(){return wt.dispatchMethod(yt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return yt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return wt.dispatchMethod(yt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return yt.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return wt.dispatchMethod(yt,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return le.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return wt.dispatchMethod(le,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return le.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return wt.dispatchMethod(le,"rationalCurveByArcLength",[this._data,r])},split:function(r){return le.curveSplit(this._data,r).map(function(n){return new Ct(n)})},splitAsync:function(r){return wt.dispatchMethod(le,"curveSplit",[this._data,r]).then(function(n){return n.map(function(a){return new Ct(a)})})},reverse:function(){return new Ct(ft.curveReverse(this._data))},reverseAsync:function(){return wt.dispatchMethod(ft,"curveReverse",[this._data]).then(function(r){return new Ct(r)})},tessellate:function(r){return zt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return wt.dispatchMethod(zt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ct});var Rr=f.geom.Arc=function(r,n,a,l,u,d){Ct.call(this,pt.arc(r,n,a,l,u,d)),this._center=r,this._xaxis=n,this._yaxis=a,this._radius=l,this._minAngle=u,this._maxAngle=d};b["verb.geom.Arc"]=Rr,Rr.__name__=["verb","geom","Arc"],Rr.__super__=Ct,Rr.prototype=T(Ct.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},radius:function(){return this._radius},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Rr});var es=f.geom.BezierCurve=function(r,n){Ct.call(this,pt.rationalBezierCurve(r,n))};b["verb.geom.BezierCurve"]=es,es.__name__=["verb","geom","BezierCurve"],es.__super__=Ct,es.prototype=T(Ct.prototype,{__class__:es});var rs=f.geom.Circle=function(r,n,a,l){Rr.call(this,r,n,a,l,0,Math.PI*2)};b["verb.geom.Circle"]=rs,rs.__name__=["verb","geom","Circle"],rs.__super__=Rr,rs.prototype=T(Rr.prototype,{__class__:rs});var Mn=function(){};b["verb.geom.ISurface"]=Mn,Mn.__name__=["verb","geom","ISurface"],Mn.__interfaces__=[Pn],Mn.prototype={__class__:Mn};var Pt=f.geom.NurbsSurface=function(r){this._data=We.isValidNurbsSurfaceData(r)};b["verb.geom.NurbsSurface"]=Pt,Pt.__name__=["verb","geom","NurbsSurface"],Pt.__interfaces__=[Mn],Pt.byKnotsControlPointsWeights=function(r,n,a,l,u,d){return new Pt(new te(r,n,a,l,N.homogenize2d(u,d)))},Pt.byCorners=function(r,n,a,l){return new Pt(pt.fourPointSurface(r,n,a,l))},Pt.byLoftingCurves=function(r,n){return new Pt(pt.loftedSurface(function(a){for(var l,u=[],d=0;d<r.length;){var p=r[d];++d,u.push(p.asNurbs())}return l=u,l}(),n))},Pt.__super__=Zt,Pt.prototype=T(Zt.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new te(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Pt(this.asNurbs())},domainU:function(){return new Se($.first(this._data.knotsU),$.last(this._data.knotsU))},domainV:function(){return new Se($.first(this._data.knotsV),$.last(this._data.knotsV))},point:function(r,n){return N.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return wt.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return N.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return wt.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,a){return a==null&&(a=1),N.rationalSurfaceDerivatives(this._data,r,n,a)},derivativesAsync:function(r,n,a){return a==null&&(a=1),wt.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,n,a])},closestParam:function(r){return yt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return wt.dispatchMethod(yt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return yt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return wt.dispatchMethod(yt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),le.surfaceSplit(this._data,r,n).map(function(a){return new Pt(a)})},splitAsync:function(r,n){return n==null&&(n=!1),wt.dispatchMethod(le,"surfaceSplit",[this._data,r,n]).then(function(a){return a.map(function(l){return new Pt(l)})})},reverse:function(r){return r==null&&(r=!1),new Pt(ft.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),wt.dispatchMethod(ft,"surfaceReverse",[this._data,r]).then(function(n){return new Pt(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Ct(pt.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),wt.dispatchMethod(pt,"surfaceIsocurve",[this._data,r,n]).then(function(a){return new Ct(a)})},boundaries:function(r){return pt.surfaceBoundaryCurves(this._data).map(function(n){return new Ct(n)})},boundariesAsync:function(r){return wt.dispatchMethod(pt,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(a){return new Ct(a)})})},tessellate:function(r){return zt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return wt.dispatchMethod(zt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Pt(ft.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return wt.dispatchMethod(ft,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new Pt(n)})},__class__:Pt});var ns=f.geom.ConicalSurface=function(r,n,a,l,u){Pt.call(this,pt.conicalSurface(r,n,a,l,u)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=u};b["verb.geom.ConicalSurface"]=ns,ns.__name__=["verb","geom","ConicalSurface"],ns.__super__=Pt,ns.prototype=T(Pt.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:ns});var ss=f.geom.CylindricalSurface=function(r,n,a,l,u){Pt.call(this,pt.cylindricalSurface(r,n,a,l,u)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=u};b["verb.geom.CylindricalSurface"]=ss,ss.__name__=["verb","geom","CylindricalSurface"],ss.__super__=Pt,ss.prototype=T(Pt.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:ss});var Br=f.geom.EllipseArc=function(r,n,a,l,u){Ct.call(this,pt.ellipseArc(r,n,a,l,u)),this._center=r,this._xaxis=n,this._yaxis=a,this._minAngle=l,this._maxAngle=u};b["verb.geom.EllipseArc"]=Br,Br.__name__=["verb","geom","EllipseArc"],Br.__super__=Ct,Br.prototype=T(Ct.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Br});var is=f.geom.Ellipse=function(r,n,a){Br.call(this,r,n,a,0,Math.PI*2)};b["verb.geom.Ellipse"]=is,is.__name__=["verb","geom","Ellipse"],is.__super__=Br,is.prototype=T(Br.prototype,{__class__:is});var as=f.geom.ExtrudedSurface=function(r,n){Pt.call(this,pt.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};b["verb.geom.ExtrudedSurface"]=as,as.__name__=["verb","geom","ExtrudedSurface"],as.__super__=Pt,as.prototype=T(Pt.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:as});var Fr=f.geom.Intersect=function(){};b["verb.geom.Intersect"]=Fr,Fr.__name__=["verb","geom","Intersect"],Fr.curves=function(r,n,a){return a==null&&(a=.001),lt.curves(r.asNurbs(),n.asNurbs(),a)},Fr.curvesAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"curves",[r.asNurbs(),n.asNurbs(),a])},Fr.curveAndSurface=function(r,n,a){return a==null&&(a=.001),lt.curveAndSurface(r.asNurbs(),n.asNurbs(),a)},Fr.curveAndSurfaceAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"curveAndSurface",[r.asNurbs(),n.asNurbs(),a])},Fr.surfaces=function(r,n,a){return a==null&&(a=.001),lt.surfaces(r.asNurbs(),n.asNurbs(),a).map(function(l){return new Ct(l)})},Fr.surfacesAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"surfaces",[r.asNurbs(),n.asNurbs(),a]).then(function(l){return l.map(function(u){return new Ct(u)})})};var os=f.geom.Line=function(r,n){Ct.call(this,pt.polyline([r,n])),this._start=r,this._end=n};b["verb.geom.Line"]=os,os.__name__=["verb","geom","Line"],os.__super__=Ct,os.prototype=T(Ct.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:os});var ls=f.geom.RevolvedSurface=function(r,n,a,l){Pt.call(this,pt.revolvedSurface(r.asNurbs(),n,a,l)),this._profile=r,this._center=n,this._axis=a,this._angle=l};b["verb.geom.RevolvedSurface"]=ls,ls.__name__=["verb","geom","RevolvedSurface"],ls.__super__=Pt,ls.prototype=T(Pt.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:ls});var hs=f.geom.SphericalSurface=function(r,n){Pt.call(this,pt.sphericalSurface(r,[0,0,1],[1,0,0],n)),this._center=r,this._radius=n};b["verb.geom.SphericalSurface"]=hs,hs.__name__=["verb","geom","SphericalSurface"],hs.__super__=Pt,hs.prototype=T(Pt.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:hs});var us=f.geom.SweptSurface=function(r,n){Pt.call(this,pt.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};b["verb.geom.SweptSurface"]=us,us.__name__=["verb","geom","SweptSurface"],us.__super__=Pt,us.prototype=T(Pt.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:us});function Xe(r){return r instanceof Array?function(){return O.iter(r)}:typeof r.iterator=="function"?Ne(r,r.iterator):r.iterator}var qi,qu=0;function Ne(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=qu++);var a;return r.hx__closures__==null?r.hx__closures__={}:a=r.hx__closures__[n.__id__],a==null&&(a=function(){return a.method.apply(a.scope,arguments)},a.scope=r,a.method=n,r.hx__closures__[n.__id__]=a),a}b.Math=Math,String.prototype.__class__=b.String=String,String.__name__=["String"],b.Array=Array,Array.__name__=["Array"],Date.prototype.__class__=b.Date=Date,Date.__name__=["Date"];var Yu=b.Int={__name__:["Int"]},Xu=b.Dynamic={__name__:["Dynamic"]},To=b.Float=Number;To.__name__=["Float"];var Mo=b.Bool=Boolean;Mo.__ename__=["Bool"];var No=b.Class={__name__:["Class"]},Co={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],a=0,l=this.length;a<l;){var u=a++;n[u]=r(this[u])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],a=0,l=this.length;a<l;){var u=a++,d=this[u];r(d)&&n.push(d)}return n});var Yi={},Gs=A.ArrayBuffer||oe;Gs.prototype.slice==null&&(Gs.prototype.slice=oe.sliceImpl),A.DataView;var Xi=A.Uint8Array||nr._new;(function(r,n){if(r.setImmediate)return;var a=1,l={},u=!1,d=r.document,p;function _(R){return l[a]=v.apply(n,R),a++}function v(R){var D=[].slice.call(arguments,1);return function(){typeof R=="function"?R.apply(n,D):new Function(""+R)()}}function w(R){if(u)setTimeout(v(w,R),0);else{var D=l[R];if(D){u=!0;try{D()}finally{I(R),u=!1}}}}function I(R){delete l[R]}function S(){p=function(){var R=_(arguments);return process.nextTick(v(w,R)),R}}function P(){if(r.postMessage&&!r.importScripts){var R=!0,D=r.onmessage;return r.onmessage=function(){R=!1},r.postMessage("","*"),r.onmessage=D,R}}function k(){var R="setImmediate$"+Math.random()+"$",D=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(R)===0&&w(+V.data.slice(R.length))};r.addEventListener?r.addEventListener("message",D,!1):r.attachEvent("onmessage",D),p=function(){var V=_(arguments);return r.postMessage(R+V,"*"),V}}function M(){var R=new MessageChannel;R.port1.onmessage=function(D){var V=D.data;w(V)},p=function(){var D=_(arguments);return R.port2.postMessage(D),D}}function L(){var R=d.documentElement;p=function(){var D=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){w(D),V.onreadystatechange=null,R.removeChild(V),V=null},R.appendChild(V),D}}function C(){p=function(){var R=_(arguments);return setTimeout(v(w,R),0),R}}var B=Object.getPrototypeOf&&Object.getPrototypeOf(r);B=B&&B.setTimeout?B:r,{}.toString.call(r.process)==="[object process]"?S():P()?k():r.MessageChannel?M():d&&"onreadystatechange"in d.createElement("script")?L():C(),B.setImmediate=p,B.clearImmediate=I})(new Function("return this")()),Yt.USE_CACHE=!1,Yt.USE_ENUM_INDEX=!1,Yt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Wt.DEFAULT_RESOLVER=ut,Wt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Ot.count=0,ae.i64tmp=function(r){var n,a=new Vt(0,0);return n=a,n}(),Nt.__toStr={}.toString,nr.BYTES_PER_ELEMENT=1,St.queue=new U,Bt.memo=new bt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",yt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],yt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],wt.THREADS=1,wt._init=!1,zr.basePath="",Zr.uuid=0,Vs.main()}(typeof console<"u"?console:{log:function(){}},e,typeof c<"u"?c:typeof s<"u"?s:typeof self<"u"?self:this),e})})(mu);var p0=mu.exports;const zn=m0(p0);class ma{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,o){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-o,this.c3=2*t-2*e+s+o}initCatmullRom(t,e,s,o,h){this.init(e,s,h*(s-t),h*(o-e))}initNonuniformCatmullRom(t,e,s,o,h,c,g){let x=(e-t)/h-(s-t)/(h+c)+(s-e)/c,f=(s-e)/c-(o-e)/(c+g)+(o-s)/g;x*=c,f*=c,this.init(e,s,x,f)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}class pu extends Us{constructor(t=[],e=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new Z,this._px=new ma,this._py=new ma,this._pz=new ma,this._points=t.map(h=>new q(h)),this._closed=e,this._curveType=s,this._tension=o}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 q}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new q}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 q){const s=e,o=this._points,h=o.length;if(h===0)return s.set(0,0,0);if(h===1)return s.copy(o[0]);const c=(h-(this._closed?0:1))*t;let g=Math.floor(c),x=c-g;this._closed?g+=g>0?0:(Math.floor(Math.abs(g)/h)+1)*h:x===0&&g===h-1&&(g=h-2,x=1);let f,A;this._closed||g>0?f=o[(g-1)%h]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),f=new q(this._tmp.x,this._tmp.y,this._tmp.z));const b=o[g%h],E=o[(g+1)%h];if(this._closed||g+2<h?A=o[(g+2)%h]:(this._tmp.subVectors(o[h-1],o[h-2]).add(o[h-1]),A=new q(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const T=this._curveType==="chordal"?.5:.25;let O=Math.pow(f.distanceToSquared(b),T),z=Math.pow(b.distanceToSquared(E),T),U=Math.pow(E.distanceToSquared(A),T);z<1e-4&&(z=1),O<1e-4&&(O=z),U<1e-4&&(U=z),this._px.initNonuniformCatmullRom(f.x,b.x,E.x,A.x,O,z,U),this._py.initNonuniformCatmullRom(f.y,b.y,E.y,A.y,O,z,U),this._pz.initNonuniformCatmullRom(f.z,b.z,E.z,A.z,O,z,U)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,b.x,E.x,A.x,this._tension),this._py.initCatmullRom(f.y,b.y,E.y,A.y,this._tension),this._pz.initCatmullRom(f.z,b.z,E.z,A.z,this._tension));return s.set(this._px.calc(x),this._py.calc(x),this._pz.calc(x)),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 q(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 q;return s.copy(e),s.applyMatrix4(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Mt;const t=new Mt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}class fn{constructor(t,e,s,o){this._degree=t,this._knots=[...e],this._controlPoints=s.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=o?[...o]: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 Cs(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return au(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,o){return new fn(t,e,s,o)}static byPoints(t,e,s="Uniform"){let o;switch(s){case"Chord":o=su(e,t);break;case"SqrtChord":o=iu(e,t);break;case"Uniform":default:o=nu(e,t.length);break}const h=t.map(g=>({x:g[0],y:g[1],z:g[2]})),c=new Array(h.length).fill(1);return new fn(e,o,h,c)}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:o}=this.getParameterRange();for(let h=0;h<=t;h++){const c=s+(o-s)*(h/t);e.push(this.point(c))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),o=this.point(e),h=this.point(s),c=o[0]-h[0],g=o[1]-h[1],x=o[2]-h[2];return Math.sqrt(c*c+g*g+x*x)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new pu(t,!0,"centripetal"),s=Math.max(50,t.length*2);return e.getPoints(s)}static createClosedCurve(t,e,s="Chord"){const o=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return fn.byPoints(o,e,s)}}class Xr extends Us{constructor(t,e,s,o,h){super();const c=arguments.length;if(c<2||c>5)throw je.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let g,x=3,f=!1;if(c>=3&&(Array.isArray(s)?(g=s,c>=4&&(x=o||3),c>=5&&(f=h)):s!==void 0&&(x=s||3,c>=4&&(f=o))),s===void 0&&c>=4&&(x=o||3,c>=5&&(f=h)),this._degree=x,this._closed=f,this._controlPoints.length<this._degree+1)throw je.ILLEGAL_PARAMETERS;const A=this.toVerbPoints(this._controlPoints);this._nurbsCurve=zn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,A,g)}else{if(this._fitPoints=t,this._knotParameterization=e,c>=3&&(this._degree=s||3),c>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw je.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=zn.geom.NurbsCurve.byPoints(g,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=fn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=zn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=zn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=fn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=zn.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),s=this.toVerbPoints(this._controlPoints);this._nurbsCurve=zn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,s,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],o=this._nurbsCurve.point(s);return new q(o[0],o[1],o[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],o=this._nurbsCurve.point(s);return new q(o[0],o[1],o[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,o=this._fitPoints[s];return{x:o.x,y:o.y,z:o.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=[],o=e.knots(),h=this._nurbsCurve.degree(),c=o[h],g=o[o.length-h-1],x=(g-c)/(t-1);for(let f=0;f<t;f++){const A=f===t-1?g:c+f*x,b=e.point(A);s.push(new q(b[0],b[1],b[2]))}return s}getCurvePoints(t,e){const s=[],o=t.knots(),h=o[3],c=(o[o.length-4]-h)/(e-1);for(let g=0;g<e;g++){const x=h+g*c;s.push(t.point(x))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Mt().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,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]={x:s[0],y:s[1],z:s[2]}}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Xr(t,e,s,!0)}}var mn=256,gu=[],il=256,Xs;for(;mn--;)gu[mn]=(mn+256).toString(16).substring(1);function g0(i){var t=0,e=11;if(!Xs||mn+e>il*2)for(Xs="",mn=0;t<il;t++)Xs+=gu[Math.random()*256|0];return Xs.substring(mn,mn+++e)}class Kr{constructor(t,e){t=t||{},Vn(t,{objectId:g0()}),this._attrs=new gl(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:Xa().workingDatabase}set database(t){this._database=t}close(){}}const Ka=class Ka extends Kr{constructor(){super(...arguments),this._layer="0",this._color=new Wr,this._lineType=Zs,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.typeName}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||Zs}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,o,h){}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==Zs){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==wl?ni:this.lineType;return ni}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}attachEntityInfo(t){t&&(t.objectId=this.objectId,t.ownerId=this.ownerId,t.layerName=this.layer,t.visible=this.visibility)}};Ka.typeName="Entity";let we=Ka;const $a=class $a extends we{};$a.typeName="Curve";let Ae=$a;var Rn=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(Rn||{});const Za=class Za extends Ae{constructor(t,e,s=0,o=!1,h=0,c=0,g=null){super(),this._polyType=t,this._elevation=s;const x=g&&(g==null?void 0:g.length)===e.length,f=e.map((A,b)=>({x:A.x,y:A.y,bulge:x?g[b]:void 0}));this._geo=new _n(f,o)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){return new Array}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new q().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};Za.typeName="2dPolyline";let oi=Za;var fu=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(fu||{});const Qa=class Qa extends we{constructor(){super(),this._position=new q,this._bulge=0,this._startWidth=0,this._endWidth=0,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get bulge(){return this._bulge}set bulge(t){this._bulge=t}get startWidth(){return this._startWidth}set startWidth(t){this._startWidth=t}get endWidth(){return this._endWidth}set endWidth(t){this._endWidth=t}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Mt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};Qa.typeName="2dVertex";let ya=Qa;var Ls=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(Ls||{});const Ja=class Ja extends Ae{constructor(t,e,s=!1){super(),this._polyType=t,this._geo=new _n(e,s)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){return new Array}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new q().set(o.x,o.y,0))),t.lines(e,this.lineStyle)}};Ja.typeName="3dPolyline";let li=Ja;var _u=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(_u||{});const to=class to extends we{constructor(){super(),this._position=new q,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Mt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};to.typeName="3dVertex";let xa=to;const eo=class eo extends Ae{constructor(t,e,s,o){super(),this._geo=new gn(t,e,s,o,Z.Z_AXIS,Z.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)}};eo.typeName="Arc";let hi=eo;const ro=class ro extends we{constructor(t){super(),this._blockName=t,this._position=new q,this._rotation=0,this._normal=new Z(0,0,1),this._scaleFactors=new q(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 Mt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const c of h)t.union(c.geometricExtents)}const s=new Hr().setFromEuler(new uu(this.rotation,0,0)),o=new qr;return o.compose(this.position,s,this.scaleFactors),t.applyMatrix4(o),t}draw(t){const e=[],s=this.blockTableRecord;if(s!=null){const o=this.computeTransformMatrix(),h=Gr.instance.draw(t,s,this.rgbColor,!0,o,this.normal);return this.attachEntityInfo(h),h}else{const o=t.group(e);return this.attachEntityInfo(o),o}}computeTransformMatrix(){const t=new Hr;return t.setFromAxisAngle(Z.Z_AXIS,this.rotation),new qr().compose(this._position,t,this._scaleFactors)}};ro.typeName="BlockReference";let Rs=ro;const no=class no extends Ae{constructor(t,e,s=Z.Z_AXIS){super(),this._geo=new gn(t,e,0,ne,s,Z.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)}};no.typeName="Circle";let ui=no;const so=class so extends Ae{constructor(t,e,s,o,h,c,g){super(),this._geo=new Di(t,e,s,o,h,c,g)}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)}};so.typeName="Ellipse";let ci=so;const io=class io extends we{constructor(){super(),this._vertices=[new q,new q,new q],this._edgeInvisibilities=0}getVertexAt(t){return t<0?this._vertices[0]:t>this._vertices.length?this._vertices[this._vertices.length-1]:this._vertices[t]}setVertexAt(t,e){if(t<0&&this._vertices[0].copy(e),t>=3)return this._vertices.length===3&&this._vertices.push(new q),this._vertices[3].copy(e);this._vertices[t].copy(e)}setEdgeInvisibilities(t){this._edgeInvisibilities=t}isEdgeVisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<t)===0}makeEdgeInvisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<t}get geometricExtents(){return new Mt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._vertices.length;++e)t.push(this.getVertexAt(e));return t}draw(t){const e=this._vertices.length,s=new Float32Array(e*3),o=new Uint16Array(e*2);for(let h=0;h<e;h++)s[h*3]=this._vertices[h].x,s[h*3+1]=this._vertices[h].y,s[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(o[h*2]=h,o[h*2+1]=(h+1)%4);return t.lineSegments(s,3,o,this.lineStyle)}};io.typeName="Face";let di=io;var vu=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(vu||{}),yu=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(yu||{});const ao=class ao extends we{constructor(){super(),this._elevation=0,this._geo=new Bi,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 Mt({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})}};ao.typeName="Hatch";let mi=ao;var xu=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(xu||{});const oo=class oo extends Ae{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 q().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 Mt().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 Xr(this._vertices,"Uniform"),this._updated=!1)}};oo.typeName="Leader";let pi=oo;const lo=class lo extends Ae{constructor(t,e){super(),this._geo=new Yr(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,o,h){const c=this.startPoint,g=this.endPoint;switch(t){case dn.EndPoint:h.push(c),h.push(g);break;case dn.MidPoint:h.push(this.midPoint);break;case dn.Nearest:{const x=this._geo.project(s);h.push(x)}break;case dn.Perpendicular:{const x=this._geo.perpPoint(s);h.push(x)}break;case dn.Tangent:h.push(c);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,s=this.endPoint,o=[new q(e.x,e.y,0),new q(s.x,s.y,0)];return t.lines(o,this.lineStyle)}};lo.typeName="Line";let gi=lo;var ja=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(ja||{}),Vi=(i=>(i[i.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",i[i.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",i[i.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",i[i.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",i[i.BY_STYLE=5]="BY_STYLE",i))(Vi||{}),Dn=(i=>(i[i.TopLeft=1]="TopLeft",i[i.TopCenter=2]="TopCenter",i[i.TopRight=3]="TopRight",i[i.MiddleLeft=4]="MiddleLeft",i[i.MiddleCenter=5]="MiddleCenter",i[i.MiddleRight=6]="MiddleRight",i[i.BottomLeft=7]="BottomLeft",i[i.BottomCenter=8]="BottomCenter",i[i.BottomRight=9]="BottomRight",i))(Dn||{}),Ga=(i=>(i[i.OPTIMIZED_2D=0]="OPTIMIZED_2D",i[i.WIREFRAME=1]="WIREFRAME",i[i.HIDDEN_LINE=2]="HIDDEN_LINE",i[i.FLAT_SHADED=3]="FLAT_SHADED",i[i.GOURAUD_SHADED=4]="GOURAUD_SHADED",i[i.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",i[i.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",i))(Ga||{}),Wa=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(Wa||{}),Ha=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Ha||{});class ji{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new q,this._height=0,this._width=0,this._viewCenter=new q,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 _e;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 _e;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new ji;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}const ho=class ho extends we{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 q,this._attachmentPoint=Dn.TopLeft,this._direction=new Z(1,0,0),this._drawingDirection=Vi.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 Mt}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,e){const s={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor},o={...this.getTextStyle(),color:this.rgbColor};return t.mtext(s,o,e)}};ho.typeName="MText";let fi=ho;const uo=class uo extends Ae{constructor(t,e,s,o,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c<2||c>5)throw je.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Xr(t,e,s,o):this._geo=new Xr(t,e,s,o,h)}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)}};uo.typeName="Spline";let Bs=uo;const f0=new Z,co=class co extends Rs{constructor(t,e,s){super(t),this._attachmentPoint=Dn.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 Mt}draw(t){let e=0,s=0;const o=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let c=0;for(let E=0;E<=this.numRows;E++){e-=E>0?this.rowHeight(E-1):0,s=0;for(let T=0;T<=this.numColumns;T++)s+=T>0?this.columnWidth(T-1):0,h[c++]=s,h[c++]=e,h[c++]=0}const g=[],x=new Array(this.numRows*this.numColumns).fill(!1);s=0,c=0;let f=0;for(let E=0;E<this.numColumns;E++){s+=E>0?this.columnWidth(E-1):0,e=0;for(let T=0;T<this.numRows;T++){e+=T>0?this.rowHeight(T-1):0;const O=this.cell(T*this.numColumns+E);if(f=T*this.numColumns+E,O&&!x[f]){const z=O.borderWidth??1,U=O.borderHeight??1;this.fillVisited(x,f,this.numColumns,z,U),o[c++]=E+T*(this.numColumns+1),o[c++]=E+T*(this.numColumns+1)+z;const F=h[o[c-1]*3]-s,dt=E+(T+U)*(this.numColumns+1)+z;E+z==this.numColumns&&(o[c++]=E+T*(this.numColumns+1)+z,o[c++]=dt);const vt=-h[dt*3+1]-e;if(T+U==this.numRows&&(o[c++]=E+(T+U)*(this.numColumns+1)+U,o[c++]=E+(T+U)*(this.numColumns+1)),o[c++]=E+(T+U)*(this.numColumns+1),o[c++]=E+T*(this.numColumns+1),O.text){const ot=O.attachmentPoint||this.attachmentPoint||Dn.MiddleCenter,W=this.getTableTextOffset(ot,F,vt),ut={text:O.text,height:O.textHeight,width:F,position:f0.set(s,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ot},st={...this.getTextStyle(O),color:this.color.color};g.push(t.mtext(ut,st))}}}}g.push(t.lineSegments(h,3,o,this.lineStyle));const A=t.group(g),b=new Hr;return b.setFromAxisAngle(Z.Z_AXIS,this.rotation),al.compose(this.position,b,this.scaleFactors),A.applyMatrix(al),this.attachEntityInfo(A),A}fillVisited(t,e,s,o,h){if(h==1&&o==1)t[e]=!0;else for(let c=0;c<o;++c)for(let g=0;g<h;++g)t[e+c+g*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 o=new Z;switch(t){case 1:break;case 2:o.setX(e/2);break;case 3:o.setX(e);break;case 4:o.setY(-s/2);break;case 5:o.set(e/2,-s/2,0);break;case 6:o.set(e,-s/2,0);break;case 7:o.setY(-s);break;case 8:o.set(e/2,-s,0);break;case 9:o.set(e,-s,0);break}return o}};co.typeName="Table";let _i=co;const al=new qr;var bu=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(bu||{}),wu=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(wu||{});const mo=class mo extends we{constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new q,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 Mt}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,e){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Vi.BOTTOM_TO_TOP,attachmentPoint:Dn.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return t.mtext(s,o,e)}};mo.typeName="Text";let vi=mo;const po=class po extends Ae{constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new q,new q,new q,new q]}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 Mt().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 _n(this._vertices,!0),s=new Bi;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};po.typeName="Trace";let yi=po;const go=class go extends Ae{constructor(){super(),this._elevation=0,this._geo=new _n}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,o=-1,h=-1){const c=o<0?void 0:o,g=h<0?void 0:h,x={x:e.x,y:e.y,bulge:s,startWidth:c,endWidth:g};this._geo.addVertexAt(t,x)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new q(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Mt({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(o=>e.push(new q().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};go.typeName="Polyline";let xi=go;const fo=class fo extends we{constructor(){super(),this._geo=new q}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Mt().expandByPoint(this._geo)}transformBy(t){return this._geo.applyMatrix4(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize,color:this.rgbColor})}};fo.typeName="Point";let bi=fo;var Au=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(Au||{}),Su=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(Su||{});const _o=class _o extends we{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new q,this._scale=new $t(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Mt;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,o=new _e;o.setFromPoints(this._clipBoundary);const h=new Tt;h.setX(this._position.x-o.min.x*e),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(c=>{const g=c.x*e+h.x,x=c.y*s+h.y;t.push(new q(g,x,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){ol.copy(t[1]);for(let e=1;e<4;e++)Ks.copy(t[e]),Ks.rotateAround(ol,this._rotation),t[e].setX(Ks.x),t[e].setY(Ks.y)}t.push(t[0])}return t}};_o.typeName="RasterImage";let Fs=_o;const ol=new Tt,Ks=new Tt,vo=class vo extends Ae{constructor(){super(),this._basePoint=new q,this._unitDir=new Z}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 Mt;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)}};vo.typeName="Ray";let wi=vo;const yo=class yo extends we{constructor(){super(),this._centerPoint=new q,this._height=0,this._width=0,this._viewCenter=new q,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 Mt}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport(),s=t.group(this.createViewportRect(e,t));return this.attachEntityInfo(s),s}}toGiViewport(){const t=new ji;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 q(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new q(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s.push(e.lines([new q(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new q(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new q(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new q(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)],this.lineStyle)),s.push(e.lines([new q(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new q(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)],this.lineStyle)),s}};yo.typeName="Viewport";let Ai=yo;const xo=class xo extends Fs{draw(t){const e=this.boundaryPath(),s=new Bi;return s.add(new _n(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};xo.typeName="Wipeout";let Si=xo;const bo=class bo extends Ae{constructor(){super(),this._basePoint=new q,this._unitDir=new Z}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 Mt;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)}};bo.typeName="Xline";let Ii=bo;var Iu=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(Iu||{});const wo=class wo extends we{constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new q,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new q,this._textRotation=0,this._normal=new Z(0,0,1)}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(t)}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new Un),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}draw(t){if(this.dimBlockId){const s=this.database.tables.blockTable.getAt(this.dimBlockId);if(s){const o=new qr().makeTranslation(this.dimBlockPosition),h=Gr.instance.draw(t,s,this.rgbColor,!1,o,this.normal);return this.attachEntityInfo(h),h}}const e=t.group([]);return this.attachEntityInfo(e),e}drawFirstArrow(t){const e=this.database.tables.blockTable.getAt(this.firstArrowType);if(e)return Gr.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Gr.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 o=new q().subVectors(e,t).normalize();return new q(e).addScaledVector(o,s)}findPointOnLine2(t,e,s){const o=t.x+s*Math.cos(e),h=t.y+s*Math.sin(e);return{x:o,y:h}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():ja.Closed}};wo.typeName="Dimension";let Tr=wo;const Ao=class Ao extends Tr{constructor(t,e,s,o,h=null,c=null){super(),this._centerPoint=new q().copy(t),this._xLine1Point=new q().copy(e),this._xLine2Point=new q().copy(s),this._arcPoint=new q().copy(o),this.dimensionText=h,this.dimensionStyleName=c}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 Mt}};Ao.typeName="3PointAngularDimension";let Pi=Ao;const So=class So extends Tr{constructor(t,e,s,o=null,h=null){super(),this._dimLinePoint=new q().copy(s),this._xLine1Point=new q().copy(t),this._xLine2Point=new q().copy(e),this._oblique=0,this._rotation=0,this.dimensionText=o,this.dimensionStyleName=h}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get geometricExtents(){return new Mt}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),c=new Yr(o,h);return t.push(c),e.endPoint=o,this.adjustExtensionLine(e),t.push(e),s.endPoint=h,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Yr(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,o=t.endPoint,h=new Z().subVectors(o,s).normalize(),g=new Z().subVectors(e,s).dot(h),x=new Z().copy(h).multiplyScalar(g);return new Z().addVectors(s,x)}};So.typeName="AlignedDimension";let Ei=So;const Io=class Io extends Tr{constructor(t,e,s,o,h=null,c=null){super(),this._arcPoint=new q().copy(o),this._xLine1Point=new q().copy(e),this._xLine2Point=new q().copy(s),this._centerPoint=new q().copy(t),this.dimensionText=h,this.dimensionStyleName=c}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 Mt}};Io.typeName="ArcDimension";let ba=Io;const Po=class Po extends Tr{constructor(t,e,s=0,o=null,h=null){super(),this._chordPoint=new q().copy(t),this._farChordPoint=new q().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=o,this.dimensionStyleName=h}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}get geometricExtents(){return new Mt}drawLines(t,e){const s=[],o=e.length;return o==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{s.push(this.drawLine(t,h))}),s}drawLine(t,e,s){if(s){const o=[e.startPoint,e.endPoint];return t.lines(o,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;t.sort((s,o)=>{const h=e(s.startPoint,o.startPoint);return h!==0?h:e(s.endPoint,o.endPoint)})}};Po.typeName="DiametricDimension";let ki=Po;const Eo=class Eo extends Tr{constructor(t,e,s=null,o=null){super(),this._definingPoint=new q().copy(t),this._leaderEndPoint=new q().copy(e),this.dimensionText=s,this.dimensionStyleName=o}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 Mt}get arrowLineCount(){return 0}};Eo.typeName="OrdinateDimension";let Ti=Eo;const ko=class ko extends Tr{constructor(t,e,s,o=null,h=null){super(),this._center=new q().copy(t),this._chordPoint=new q().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=o,this.dimensionStyleName=h}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new Mt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};ko.typeName="RadialDimension";let Mi=ko;class ll{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertFace(t){const e=new di;return t.vertices.forEach((s,o)=>e.setVertexAt(o,s)),e}convertArc(t){return new hi(t.center,t.radius,Et.degToRad(t.startAngle),Et.degToRad(t.endAngle))}convertCirle(t){return new ui(t.center,t.radius)}convertEllipse(t){const e=new Z(t.majorAxisEndPoint),s=e.length();return new ci(t.center,t.extrusionDirection??Z.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new gi(new q(e.x,e.y,e.z||0),new q(s.x,s.y,s.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Bs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new Bs(e,"Uniform",t.degree,!!(t.flag&1))}}catch(e){console.log(`Failed to convert spline with error: ${e}`)}return null}convertPoint(t){const e=new bi;return e.position=t.position,e}convertSolid(t){const e=new yi;return t.points.forEach((s,o)=>e.setPointAt(o,s)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),s=!!(t.flag&8),o=[],h=[];if(t.vertices.map(c=>{c.flag&fd.SPLINE_CONTROL_POINT||(o.push({x:c.x,y:c.y,z:c.z}),h.push(c.bulge??0))}),s){let c=Ls.SimplePoly;return t.flag&4&&(t.smoothType==Hs.CUBIC?c=Ls.CubicSplinePoly:t.smoothType==Hs.QUADRATIC&&(c=Ls.QuadSplinePoly)),new li(c,o,e)}else{let c=Rn.SimplePoly;return t.flag&2?c=Rn.FitCurvePoly:t.flag&4&&(t.smoothType==Hs.CUBIC?c=Rn.CubicSplinePoly:t.smoothType==Hs.QUADRATIC&&(c=Rn.QuadSplinePoly)),new oi(c,o,0,e,t.startWidth,t.endWidth,h)}}convertLWPolyline(t){const e=new xi;return e.closed=!!(t.flag&1),t.vertices.forEach((s,o)=>{e.addVertexAt(o,new Tt(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),e}convertHatch(t){var o;const e=new mi;return(o=t.definitionLines)==null||o.forEach(h=>{e.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.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(h=>{if(h.boundaryPathTypeFlag&2){const g=h,x=new _n;x.closed=g.isClosed,g.vertices.forEach((f,A)=>{x.addVertexAt(A,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(x)}else{const g=h,x=new du;g.edges.forEach(f=>{if(f.type==1){const A=f;x.add(new Ui(A.start,A.end))}else if(f.type==2){const A=f;x.add(new Fn(A.center,A.radius,Et.degToRad(A.startAngle||0),Et.degToRad(A.endAngle||0),!A.isCCW))}else if(f.type==3){const A=f;new $t().subVectors(A.end,A.center);const E=Math.sqrt(Math.pow(A.end.x,2)+Math.pow(A.end.y,2)),T=E*A.lengthOfMinorAxis;let O=Et.degToRad(A.startAngle||0),z=Et.degToRad(A.endAngle||0);const U=Math.atan2(A.end.y,A.end.x);A.isCCW||(O=Math.PI*2-O,z=Math.PI*2-z),x.add(new Fi({...A.center,z:0},E,T,O,z,!A.isCCW,U))}else if(f.type==4){const A=f;if(A.numberOfControlPoints>0&&A.numberOfKnots>0){const b=A.controlPoints.map(O=>({x:O.x,y:O.y,z:0}));let E=!0;const T=A.controlPoints.map(O=>(O.weight==null&&(E=!1),O.weight||1));x.add(new Xr(b,A.knots,E?T:void 0))}else if(A.numberOfFitData>0){const b=A.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));x.add(new Xr(b,"Uniform"))}}}),e.add(x)}}),e}convertTable(t){const e=new _i(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((s,o)=>e.setColumnWidth(o,s)),t.rowHeightArr.forEach((s,o)=>e.setRowHeight(o,s)),t.cells.forEach((s,o)=>{e.setCell(o,s)}),e}convertText(t){const e=new vi;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=Et.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 fi;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=Et.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new Z(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new pi;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 Ei(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(s.dimBlockPosition={...e.insertionPoint,z:0}),s.rotation=Et.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new Pi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new Ti(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new Mi(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new ki(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,e.imageDefId=t.imageDefHandle,e.isClipped=t.isClipped,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new Tt(s))}),e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new Fs;return this.processImage(t,e),e.clipBoundaryType=t.clippingBoundaryType,e}processWipeout(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.isShownClipped=(t.displayFlag|4)>0,e.isImageShown=(t.displayFlag|3)>0,e.isImageTransparent=(t.displayFlag|8)>0,e.imageDefId=t.imageDefHardId,e.isClipped=t.isClipping,t.boundary.forEach(s=>{e.clipBoundary.push(new Tt(s))}),e.clipBoundaryType=t.boundaryType,e.width=Math.sqrt(t.uDirection.x**2+t.uDirection.y**2+t.uDirection.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vDirection.x**2+t.vDirection.y**2+t.vDirection.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uDirection.y,t.uDirection.x)}convertWipeout(t){const e=new Si;return this.processWipeout(t,e),e}convertViewport(t){const e=new Ai;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 wi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Ii;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Rs(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?Et.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.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 o=0;if(s/2==e?o=2:s/3==e&&(o=3),o==0)return;const h=[];for(let c=0,g=s/o;c<g;++c)h.push({x:t[c*o],y:t[c*o+1],z:o==3?t[c*o+2]:0});return h}}class Gi extends Kr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _e,this._extents=new Mt}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 qa extends Kr{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),this.database.events.dictObjetSet.dispatch({database:this.database,object:e,key:t})}remove(t){const e=this.getAt(t);return e?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t}),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,o)=>{s===e&&(this._recordsByName.delete(o),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:o}))}),!0):!1}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new Oi(this._recordsByName)}}class Pu extends qa{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 Eu extends Kr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class _0{convertLayout(t,e){var o;const s=new Gi;return s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,(o=e.tables.BLOCK_RECORD)==null||o.entries.some(h=>h.layoutObjects===t.handle?(s.blockTableRecordId=h.handle,!0):!1),s.limits.min.copy(t.minLimit),s.limits.max.copy(t.maxLimit),s.extents.min.copy(t.minExtent),s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new Eu;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class ku{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,t,e||this.config.workerUrl)}catch(h){const c=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:c}}}async executeInWorker(t,e,s){const o=Date.now();return new Promise((h,c)=>{const g=this.getAvailableWorker(s),x=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(g),c(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:b=>{clearTimeout(x),this.releaseWorker(g),h(b)},reject:b=>{clearTimeout(x),this.releaseWorker(g),c(b)},timeout:x});const f=b=>{const{id:E,success:T,data:O,error:z}=b.data;if(E!==t)return;this.cleanupTask(t);const U=Date.now()-o;h(T?{success:!0,data:O,duration:U}:{success:!1,error:z,duration:U})},A=b=>{this.cleanupTask(t),c(new Error(`Worker error: ${b.message}`))};g.addEventListener("message",f),g.addEventListener("error",A),g.postMessage({id:t,input:e})})}cleanupTask(t){const e=this.pendingTasks.get(t);e&&(clearTimeout(e.timeout),this.pendingTasks.delete(t))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(t){for(const[s,o]of this.workers)if(!o.isBusy)return o.isBusy=!0,o.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const s=new Worker(t,{type:"module"}),o=this.generateWorkerId(),h={worker:s,isBusy:!0,id:o,createdAt:new Date};return this.workers.set(o,h),s}const e=Array.from(this.workers.values()).sort((s,o)=>s.createdAt.getTime()-o.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,s]of this.workers)if(s.worker===t){s.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(t=>t.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[t,e]of this.pendingTasks)clearTimeout(e.timeout),e.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[t,e]of this.workers)e.worker.terminate();this.workers.clear()}}class Tu{constructor(t){this.framework=new ku(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Mu(i){return new Tu(i)}class v0{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:s}=t.data;try{const o=await this.executeTask(s);this.sendResponse(e,!0,o)}catch(o){this.sendResponse(e,!1,void 0,o instanceof Error?o.message:String(o))}}}sendResponse(t,e,s,o){const h={id:t,success:e,data:s,error:o};self.postMessage(h)}}class Nu extends Ea{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t){if(this.config.useWorker&&this.config.parserWorkerUrl){const e=Mu({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await e.execute(t);if(e.destroy(),s.success)return{model:s.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${s.error}'`)}else return{model:new i0().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,s=c=>{if(c){const g=c.lastIndexOf(".");return g>=0?c.substring(0,g).toLowerCase():c.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(c=>{const g=[];if(c.font){const x=s(c.font);x&&g.push(x)}if(c.bigFont){const x=s(c.bigFont);x&&g.push(x)}if(c.extendedFont){const x=s(c.extendedFont);x&&g.push(x)}e.set(c.name,g)});const o=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,o),Array.from(o)}getFontsInBlock(t,e,s,o){const h=/\\f(.*?)\|/g;t.forEach(c=>{if(c.type=="MTEXT"){const g=c;[...g.text.matchAll(h)].forEach(A=>{o.add(A[1].toLowerCase())});const f=s.get(g.styleName);f==null||f.forEach(A=>o.add(A))}else if(c.type=="TEXT"){const g=c,x=s.get(g.styleName);x==null||x.forEach(f=>o.add(f))}else if(c.type=="INSERT"){const x=e[c.name];x&&x.entities&&this.getFontsInBlock(x.entities,e,s,o)}})}async processEntities(t,e,s,o,h){const c=new ll;let g=t.entities;const x=g.length,f=new Aa(x,100-o.value,s);this.config.convertByEntityType&&(g=this.groupAndFlattenByType(g));const A=e.tables.blockTable.modelSpace;await f.processChunk(async(b,E)=>{let T=[],O=b<E?g[b].type:"";for(let z=b;z<E;z++){const U=g[z],F=c.convert(U);F&&(this.config.convertByEntityType&&U.type!==O&&(A.appendEntity(T),T=[],O=U.type),T.push(F))}if(A.appendEntity(T),h){let z=o.value+E/x*(100-o.value);z>100&&(z=100),await h(z,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e){const s=new ll,o=t.length,h=[];for(let c=0;c<o;c++){const g=t[c],x=s.convert(g);x&&h.push(x)}e.appendEntity(h)}processBlocks(t,e){const s=t.blocks;for(const[o,h]of Object.entries(s)){let c=e.tables.blockTable.getAt(h.name);c||(c=new Ve,c.objectId=h.handle,c.name=o,c.origin.copy(h.position),e.tables.blockTable.add(c)),h.entities&&this.processEntitiesInBlock(h.entities,c)}}processHeader(t,e){const s=t.header;s.$ACADVER&&(e.version=s.$ACADVER),e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,s.$AUNITS!=null&&(e.aunits=s.$AUNITS),s.$EXTMAX&&(e.extmax=s.$EXTMAX),s.$EXTMIN&&(e.extmin=s.$EXTMIN),s.$INSUNITS!=null&&(e.insunits=s.$INSUNITS),e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0}processBlockTables(t,e){var o;const s=(o=t.tables.BLOCK_RECORD)==null?void 0:o.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(h=>{const c=new Ve;c.objectId=h.handle,c.name=h.name,c.layoutId=h.layoutObjects,e.tables.blockTable.add(c)}))}processObjects(t,e){const s=t.objects.byName,o=new _0;if("LAYOUT"in s){const h=e.dictionaries.layouts;s.LAYOUT.forEach(c=>{const g=o.convertLayout(c,t);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in s){const h=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(c=>{const g=o.convertImageDef(c);h.setAt(g.objectId,g)})}}processViewports(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.VPORT)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new Wu;this.processCommonTableEntryAttrs(c,g),c.circleSides&&(g.circleSides=c.circleSides),g.standardFlag=c.standardFlag,g.center.copy(c.center),g.lowerLeftCorner.copy(c.lowerLeftCorner),g.upperRightCorner.copy(c.upperRightCorner),c.snapBasePoint&&g.snapBase.copy(c.snapBasePoint),c.snapRotationAngle&&(g.snapAngle=c.snapRotationAngle),c.snapSpacing&&g.snapIncrements.copy(c.snapSpacing),c.majorGridLines&&(g.gridMajor=c.majorGridLines),c.gridSpacing&&g.gridIncrements.copy(c.gridSpacing),c.backgroundObjectId&&(g.backgroundObjectId=c.backgroundObjectId),g.gsView.center.copy(c.center),g.gsView.viewDirectionFromTarget.copy(c.viewDirectionFromTarget),g.gsView.viewTarget.copy(c.viewTarget),c.lensLength&&(g.gsView.lensLength=c.lensLength),c.frontClippingPlane&&(g.gsView.frontClippingPlane=c.frontClippingPlane),c.backClippingPlane&&(g.gsView.backClippingPlane=c.backClippingPlane),c.viewHeight&&(g.gsView.viewHeight=c.viewHeight),c.viewTwistAngle&&(g.gsView.viewTwistAngle=c.viewTwistAngle),c.frozenLayers&&(g.gsView.frozenLayers=c.frozenLayers),c.styleSheet&&(g.gsView.styleSheet=c.styleSheet),c.renderMode&&(g.gsView.renderMode=c.renderMode),c.viewMode&&(g.gsView.viewMode=c.viewMode),c.ucsIconSetting&&(g.gsView.ucsIconSetting=c.ucsIconSetting),c.ucsOrigin&&g.gsView.ucsOrigin.copy(c.ucsOrigin),c.ucsXAxis&&g.gsView.ucsXAxis.copy(c.ucsXAxis),c.ucsYAxis&&g.gsView.ucsYAxis.copy(c.ucsYAxis),c.orthographicType&&(g.gsView.orthographicType=c.orthographicType),c.shadePlotSetting&&(g.gsView.shadePlotSetting=c.shadePlotSetting),c.shadePlotObjectId&&(g.gsView.shadePlotObjectId=c.shadePlotObjectId),c.visualStyleObjectId&&(g.gsView.visualStyleObjectId=c.visualStyleObjectId),c.isDefaultLightingOn&&(g.gsView.isDefaultLightingOn=c.isDefaultLightingOn),c.defaultLightingType&&(g.gsView.defaultLightingType=c.defaultLightingType),c.brightness&&(g.gsView.brightness=c.brightness),c.contrast&&(g.gsView.contrast=c.contrast),c.ambientColor&&(g.gsView.ambientColor=c.ambientColor),e.tables.viewportTable.add(g)})}processLayers(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.LAYER)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new Wr;g.colorIndex=c.colorIndex;const x=new Wi({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:g,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,x),e.tables.layerTable.add(x)})}processLineTypes(t,e){var o,h;const s=(h=(o=t.tables)==null?void 0:o.LTYPE)==null?void 0:h.entries;s&&s.length>0&&s.forEach(c=>{const g=new zs(c);this.processCommonTableEntryAttrs(c,g),g.name=c.name,e.tables.linetypeTable.add(g)})}processTextStyles(t,e){var o;const s=(o=t.tables.STYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c=new Ya(h);this.processCommonTableEntryAttrs(h,c),e.tables.textStyleTable.add(c)})}processDimStyles(t,e){var o;const s=(o=t.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const c={name:h.name,ownerId:h.ownerObjectId,dimpost:h.DIMPOST||"",dimapost:h.DIMAPOST||"",dimscale:h.DIMSCALE,dimasz:h.DIMASZ,dimexo:h.DIMEXO,dimdli:h.DIMDLI,dimexe:h.DIMEXE,dimrnd:h.DIMRND,dimdle:h.DIMDLE,dimtp:h.DIMTP,dimtm:h.DIMTM,dimtxt:h.DIMTXT,dimcen:h.DIMCEN,dimtsz:h.DIMTSZ,dimaltf:h.DIMALTF,dimlfac:h.DIMLFAC,dimtvp:h.DIMTVP,dimtfac:h.DIMTFAC,dimgap:h.DIMGAP,dimaltrnd:h.DIMALTRND,dimtol:h.DIMTOL==null||h.DIMTOL==0?0:1,dimlim:h.DIMLIM==null||h.DIMLIM==0?0:1,dimtih:h.DIMTIH==null||h.DIMTIH==0?0:1,dimtoh:h.DIMTOH==null||h.DIMTOH==0?0:1,dimse1:h.DIMSE1==null||h.DIMSE1==0?0:1,dimse2:h.DIMSE2==null||h.DIMSE2==0?0:1,dimtad:h.DIMTAD,dimzin:h.DIMZIN,dimazin:h.DIMAZIN,dimalt:h.DIMALT,dimaltd:h.DIMALTD,dimtofl:h.DIMTOFL,dimsah:h.DIMSAH,dimtix:h.DIMTIX,dimsoxd:h.DIMSOXD,dimclrd:h.DIMCLRD,dimclre:h.DIMCLRE,dimclrt:h.DIMCLRT,dimadec:h.DIMADEC||0,dimunit:h.DIMUNIT||2,dimdec:h.DIMDEC,dimtdec:h.DIMTDEC,dimaltu:h.DIMALTU,dimalttd:h.DIMALTTD,dimaunit:h.DIMAUNIT,dimfrac:h.DIMFRAC,dimlunit:h.DIMLUNIT,dimdsep:h.DIMDSEP,dimtmove:h.DIMTMOVE||0,dimjust:h.DIMJUST,dimsd1:h.DIMSD1,dimsd2:h.DIMSD2,dimtolj:h.DIMTOLJ,dimtzin:h.DIMTZIN,dimaltz:h.DIMALTZ,dimalttz:h.DIMALTTZ,dimfit:h.DIMFIT||0,dimupt:h.DIMUPT,dimatfit:h.DIMATFIT,dimtxsty:h.DIMTXSTY||"Standard",dimldrblk:h.DIMLDRBLK||"",dimblk:h.DIMBLK||"",dimblk1:h.DIMBLK1||"",dimblk2:h.DIMBLK2||"",dimlwd:h.DIMLWD,dimlwe:h.DIMLWE},g=new Un(c);this.processCommonTableEntryAttrs(h,g),e.tables.dimStyleTable.add(g)})}processCommonTableEntryAttrs(t,e){e.name=t.name,e.objectId=t.handle,e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},s=[];for(const o of t)e[o.type]||(e[o.type]=[],s.push(o.type)),e[o.type].push(o);return s.flatMap(o=>e[o])}}class Cu extends Ea{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,s,o,h){let c=t.tables.blockTable.modelSpace.newIterator().toArray();const g=c.length,x=new Aa(g,100-o.value,s);this.config.convertByEntityType&&(c=this.groupAndFlattenByType(c));const f=e.tables.blockTable.modelSpace;await x.processChunk(async(A,b)=>{let E=[],T=A<b?c[A].type:"";for(let O=A;O<b;O++){const z=c[O];this.config.convertByEntityType&&z.type!==T&&(this.triggerEvents(f,E),E=[],T=z.type),E.push(z)}if(this.triggerEvents(f,E),h){let O=o.value+b/g*(100-o.value);O>100&&(O=100),await h(O,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const s=e.newIterator().toArray();this.triggerEvents(e,s)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.dictionaries.layouts.newIterator();for(const s of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.layoutName});const e=this._database.dictionaries.imageDefs.newIterator();for(const s of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},s=[];for(const o of t)e[o.type]||(e[o.type]=[],s.push(o.type)),e[o.type].push(o);return s.flatMap(o=>e[o])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}var Os=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Os||{});class lr{constructor(){this.events={registered:new ie,unregistered:new ie},this._converters=new Map,this.register("dxf",new Nu)}static createInstance(){return lr._instance==null&&(lr._instance=new lr),this._instance}static get instance(){return lr._instance||(lr._instance=new lr),lr._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 vn extends Kr{constructor(t,e){t=t||{},Vn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const jr=class jr extends vn{static isModelSapceName(t){return t.toLowerCase()==jr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(jr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new q,this._layoutId="",this._entities=new Map}get isModelSapce(){return jr.isModelSapceName(this.name)}get isPaperSapce(){return jr.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(t){this._origin.copy(t)}get layoutId(){return this._layoutId}set layoutId(t){this._layoutId=t}appendEntity(t){if(Array.isArray(t))for(let e=0;e<t.length;++e){const s=t[e];s.database=this.database,s.ownerId=this.objectId,this._entities.set(s.objectId,s)}else 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 Oi(this._entities)}getIdAt(t){return this._entities.get(t)}};jr.MODEL_SPACE_NAME="*MODEL_SPACE",jr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let Ve=jr;class yn extends Kr{constructor(t){super(),this.database=t,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}add(t){t.database=this.database;const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),s=this._recordsByName.get(e);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(e.name),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this._recordsById.has(t)}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new Oi(this._recordsByName)}normalizeName(t){return t}}class Lu extends yn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(Ve.MODEL_SPACE_NAME);return t||(t=new Ve,t.name=Ve.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(Ve.isModelSapceName(t))e=Ve.MODEL_SPACE_NAME;else if(Ve.isPaperSapceName(t)){const s=Ve.PAPER_SPACE_NAME_PREFIX,o=t.substring(s.length);e=s+o}return e}}class Ou extends yn{constructor(t){super(t)}}class Wi extends vn{constructor(t,e){t=t||{},Vn(t,{color:new Wr,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 zu extends yn{constructor(t){super(t);const e=new Wr;e.color=16777215;const s=new Wi({name:"0",standardFlags:0,linetype:ni,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 Ru extends yn{constructor(t){super(t)}}class Bu extends yn{constructor(t){super(t)}get fonts(){const t=new Set,e=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const c=o.substring(0,h).toLowerCase();t.add(c)}else t.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)e(o.fileName),e(o.bigFontFileName);return Array.from(t)}}class Fu extends yn{constructor(t){super(t)}}class zs extends vn{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 Ya extends vn{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}}var Du=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(Du||{}),Uu=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(Uu||{}),Vu=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(Vu||{}),ju=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(ju||{}),Gu=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(Gu||{});const Ci=class Ci extends vn{constructor(t,e){t=t||{},Vn(t,Ci.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)}};Ci.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 Un=Ci;class y0 extends Kr{constructor(){super(),this.events={dictObjetSet:new ie,dictObjectErased:new ie,entityAppended:new ie,entityModified:new ie,layerAppended:new ie,layerModified:new ie,layerErased:new ie,openProgress:new ie,headerSysVarChanged:new ie},this._version=new ii("AC1014"),this._angBase=0,this._angDir=0,this._aunits=Sa.DecimalDegrees,this._celtscale=1,this._cecolor=new Wr,this._extents=new Mt,this._insunits=Pa.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Lu(this),dimStyleTable:new Ou(this),linetypeTable:new Ru(this),textStyleTable:new Bu(this),layerTable:new zu(this),viewportTable:new Fu(this)},this._dictionaries={layouts:new Pu(this),imageDefs:new qa(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 version(){return this._version}set version(t){this._version=new ii(t),this.triggerHeaderSysVarChangedEvent("version")}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 extmax(){return this._extents.max}set extmax(t){t&&(this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmax"))}get extmin(){return this._extents.min}set extmin(t){t&&(this._extents.expandByPoint(t),this.triggerHeaderSysVarChangedEvent("extmin"))}get extents(){return this._extents}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=Os.DXF){const o=lr.instance.get(s);if(o==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await o.read(t,this,e&&e.minimumChunkSize||10,async(h,c,g,x)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,subStageStatus:g,data:x}),e&&e.fontLoader&&c=="FONT"&&g=="END"){const f=x||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var E;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const s=await fetch(t);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${s.status}'!`);const o=s.headers.get("content-length"),h=o?parseInt(o,10):null;let c=0;const g=(E=s.body)==null?void 0:E.getReader();if(!g)throw new Error("Failed to get response reader");const x=[];for(;;){const{done:T,value:O}=await g.read();if(T)break;if(x.push(O),c+=O.length,h!==null){const z=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:z,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(c);let A=0;for(const T of x)f.set(T,A),A+=T.length;t.toLowerCase().split(".").pop()==="dwg"?await this.read(f.buffer,e,Os.DWG):await this.read(f.buffer,e,Os.DXF),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}async regen(){await new Cu(this).read(null,this,500,async(e,s,o,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:s,subStageStatus:o,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){if(t.layer){const e=new Wr;e.colorIndex=7,this._tables.layerTable.add(new Wi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(t.lineType&&(this._tables.linetypeTable.add(new zs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new zs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new zs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))),t.textStyle&&this._tables.textStyleTable.add(new Ya({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),t.dimStyle&&this._tables.dimStyleTable.add(new Un({name:"Standard",dimtxsty:"Standard"})),t.layout){const e=new Gi;e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=this._tables.blockTable.modelSpace.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this._dictionaries.layouts.setAt(e.layoutName,e),this._tables.blockTable.modelSpace.layoutId=e.objectId}}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,this._extents.makeEmpty()}triggerHeaderSysVarChangedEvent(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}}const x0={center:new Tt,viewDirectionFromTarget:new q(0,0,1),viewTarget:new q(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:Ga.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new q(0,0,0),ucsXAxis:new q(1,0,0),ucsYAxis:new q(0,1,0),orthographicType:Wa.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Ha.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Wu extends vn{constructor(){super(),this._circleSides=100,this._center=new Tt,this._lowerLeftCorner=new Tt(0,0),this._upperRightCorner=new Tt(1,1),this._snapBase=new Tt(0,0),this._snapAngle=0,this._snapSpacing=new Tt(0,0),this._standardFlag=0,this._gridSpacing=new Tt,this._gridMajor=10,this._gsView=x0}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 Hu{constructor(){this.events={layoutCreated:new ie,layoutRemoved:new ie,layoutRenamed:new ie,layoutSwitched:new ie}}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),o=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(o,s)}renameLayout(t,e,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return h?(h.layoutName=e,this.events.layoutRenamed.dispatch({layout:h,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).dictionaries.layouts,o=s.getAt(t);let h=!1;return o&&(h=s.remove(t),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(t,e){const s=this.getWorkingDatabase(e),o=new Gi;o.layoutName=t,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new Ve;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(t,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Xa().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function Xa(){return Ni.instance}const Li=class Li{constructor(){this._workingDatabase=null,this._layoutManager=new Hu}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}};Li.instance=new Li;let Ni=Li;exports.AcCmColor=Wr;exports.AcCmErrors=je;exports.AcCmEventDispatcher=hc;exports.AcCmEventManager=ie;exports.AcCmLoader=_c;exports.AcCmLoadingManager=yl;exports.AcCmObject=gl;exports.AcCmPerformanceCollector=wa;exports.AcCmTask=_l;exports.AcCmTaskScheduler=vl;exports.AcDb2dPolyline=oi;exports.AcDb2dVertex=ya;exports.AcDb2dVertexType=fu;exports.AcDb3PointAngularDimension=Pi;exports.AcDb3dPolyline=li;exports.AcDb3dVertex=xa;exports.AcDb3dVertexType=_u;exports.AcDbAlignedDimension=Ei;exports.AcDbAngleUnits=Sa;exports.AcDbArc=hi;exports.AcDbArcDimension=ba;exports.AcDbBaseWorker=v0;exports.AcDbBatchProcessing=Aa;exports.AcDbBlockReference=Rs;exports.AcDbBlockTable=Lu;exports.AcDbBlockTableRecord=Ve;exports.AcDbCircle=ui;exports.AcDbCodePage=Ia;exports.AcDbCurve=Ae;exports.AcDbDatabase=y0;exports.AcDbDatabaseConverter=Ea;exports.AcDbDatabaseConverterManager=lr;exports.AcDbDiametricDimension=ki;exports.AcDbDictionary=qa;exports.AcDbDimArrowType=Al;exports.AcDbDimStyleTable=Ou;exports.AcDbDimStyleTableRecord=Un;exports.AcDbDimTextHorizontal=Du;exports.AcDbDimTextVertical=Uu;exports.AcDbDimVerticalJustification=Gu;exports.AcDbDimZeroSuppression=Vu;exports.AcDbDimZeroSuppressionAngular=ju;exports.AcDbDimension=Tr;exports.AcDbDwgVersion=ii;exports.AcDbDxfConverter=Nu;exports.AcDbEllipse=ci;exports.AcDbEntity=we;exports.AcDbFace=di;exports.AcDbFileType=Os;exports.AcDbHatch=mi;exports.AcDbHatchPatternType=vu;exports.AcDbHatchStyle=yu;exports.AcDbHostApplicationServices=Ni;exports.AcDbLayerTable=zu;exports.AcDbLayerTableRecord=Wi;exports.AcDbLayout=Gi;exports.AcDbLayoutDictionary=Pu;exports.AcDbLayoutManager=Hu;exports.AcDbLeader=pi;exports.AcDbLeaderAnnotationType=xu;exports.AcDbLine=gi;exports.AcDbLineSpacingStyle=Iu;exports.AcDbLinetypeTable=Ru;exports.AcDbLinetypeTableRecord=zs;exports.AcDbMText=fi;exports.AcDbObject=Kr;exports.AcDbObjectIterator=Oi;exports.AcDbOrdinateDimension=Ti;exports.AcDbOsnapMode=dn;exports.AcDbPoint=bi;exports.AcDbPoly2dType=Rn;exports.AcDbPoly3dType=Ls;exports.AcDbPolyline=xi;exports.AcDbRadialDimension=Mi;exports.AcDbRasterImage=Fs;exports.AcDbRasterImageClipBoundaryType=Au;exports.AcDbRasterImageDef=Eu;exports.AcDbRasterImageImageDisplayOpt=Su;exports.AcDbRay=wi;exports.AcDbRegenerator=Cu;exports.AcDbRenderingCache=Gr;exports.AcDbSpline=Bs;exports.AcDbSymbolTable=yn;exports.AcDbSymbolTableRecord=vn;exports.AcDbTable=_i;exports.AcDbText=vi;exports.AcDbTextHorizontalMode=bu;exports.AcDbTextStyleTable=Bu;exports.AcDbTextStyleTableRecord=Ya;exports.AcDbTextVerticalMode=wu;exports.AcDbTrace=yi;exports.AcDbUnitsValue=Pa;exports.AcDbViewport=Ai;exports.AcDbViewportTable=Fu;exports.AcDbViewportTableRecord=Wu;exports.AcDbWipeout=Si;exports.AcDbWorkerApi=Tu;exports.AcDbWorkerManager=ku;exports.AcDbXline=Ii;exports.AcGeArea2d=Bi;exports.AcGeBox2d=_e;exports.AcGeBox3d=Mt;exports.AcGeCatmullRomCurve3d=pu;exports.AcGeCircArc2d=Fn;exports.AcGeCircArc3d=gn;exports.AcGeCurve2d=Gn;exports.AcGeEllipseArc2d=Fi;exports.AcGeEllipseArc3d=Di;exports.AcGeEuler=uu;exports.AcGeGeometryUtil=ru;exports.AcGeLine2d=Ui;exports.AcGeLine3d=Yr;exports.AcGeLoop2d=du;exports.AcGeMathUtil=Et;exports.AcGeMatrix2d=Ri;exports.AcGeMatrix3d=qr;exports.AcGeNurbsCurve=fn;exports.AcGePlane=Ds;exports.AcGePoint2d=Tt;exports.AcGePoint3d=q;exports.AcGePolyline2d=_n;exports.AcGeQuaternion=Hr;exports.AcGeShape2d=Va;exports.AcGeSpline3d=Xr;exports.AcGeTol=Fa;exports.AcGeVector2d=$t;exports.AcGeVector3d=Z;exports.AcGiArrowType=ja;exports.AcGiDefaultLightingType=Ha;exports.AcGiMTextAttachmentPoint=Dn;exports.AcGiMTextFlowDirection=Vi;exports.AcGiOrthographicType=Wa;exports.AcGiRenderMode=Ga;exports.AcGiViewport=ji;exports.AcTrStringUtil=fc;exports.ByBlock=wl;exports.ByLayer=Zs;exports.DEBUG_MODE=pc;exports.DEFAULT_LINE_TYPE=ni;exports.DEFAULT_TOL=Da;exports.DEG2RAD=Ca;exports.DefaultLoadingManager=xl;exports.FLOAT_TOL=cn;exports.ORIGIN_POINT_2D=a0;exports.ORIGIN_POINT_3D=Ba;exports.RAD2DEG=La;exports.TAU=ne;exports.acdbHostApplicationServices=Xa;exports.basisFunction=ai;exports.calculateCurveLength=au;exports.ceilPowerOfTwo=Xh;exports.clamp=kr;exports.clone=ks;exports.createWorkerApi=Mu;exports.damp=Bh;exports.defaults=Vn;exports.degToRad=Hh;exports.dwgCodePageToEncoding=bl;exports.euclideanModulo=Oa;exports.evaluateNurbsPoint=Cs;exports.floorPowerOfTwo=Kh;exports.generateChordKnots=su;exports.generateSqrtChordKnots=iu;exports.generateUUID=Oh;exports.generateUniformKnots=nu;exports.has=ml;exports.intPartLength=Ra;exports.interpolateControlPoints=o0;exports.inverseLerp=Rh;exports.isBetween=$h;exports.isBetweenAngle=Zh;exports.isEmpty=pl;exports.isEqual=Bn;exports.isImperialUnits=xc;exports.isMetricUnits=yc;exports.isPointInPolygon=Ua;exports.isPolygonIntersect=eu;exports.isPowerOfTwo=Yh;exports.lerp=za;exports.log=Ms;exports.mapLinear=zh;exports.normalizeAngle=Ns;exports.pingpong=Fh;exports.radToDeg=qh;exports.randFloat=jh;exports.randFloatSpread=Gh;exports.randInt=Vh;exports.relativeEps=Qh;exports.seededRandom=Wh;exports.setLogLevel=gc;exports.smootherstep=Uh;exports.smoothstep=Dh;
|