@mlightcad/data-model 1.3.17 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function fc(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"}))}var mt=(i=>(i[i.ByColor=1]="ByColor",i[i.ByACI=2]="ByACI",i[i.ByLayer=3]="ByLayer",i[i.ByBlock=4]="ByBlock",i[i.None=0]="None",i))(mt||{});const $o={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},ta=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];let pn=class{static getColorByIndex(t){return ta[t]}static getIndexByColor(t){const e=ta.length-1;for(let s=1;s<e;++s)if(ta[s]===t)return s}static getColorByName(t){return $o[t.toLowerCase()]}static getNameByColor(t){for(const[e,s]of Object.entries($o))if(s===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},$r=class mn{constructor(t=mt.ByLayer,e){this._colorMethod=t,this._colorMethod==mt.ByColor&&e==null?this._value=16777215:this._colorMethod==mt.ByACI?e==null?this._value=8:e===0?this._colorMethod=mt.ByBlock:e===256?this._colorMethod=mt.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}get colorMethod(){return this._colorMethod}set colorMethod(t){this._colorMethod=t}get red(){const t=this.RGB;return t!=null?t>>16&255:void 0}get green(){const t=this.RGB;return t!=null?t>>8&255:void 0}get blue(){const t=this.RGB;return t!=null?t&255:void 0}get RGB(){switch(this._colorMethod){case mt.ByColor:case mt.ByBlock:case mt.ByLayer:return this._value;case mt.ByACI:return this._value?pn.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,s){const o=Math.max(0,Math.min(255,Math.round(t))),h=Math.max(0,Math.min(255,Math.round(e))),c=Math.max(0,Math.min(255,Math.round(s)));return this._value=o<<16|h<<8|c,this._colorMethod=mt.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=mt.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let h=0,c=0,g=0;if(e.length===7)h=parseInt(e.substr(1,2),16),c=parseInt(e.substr(3,2),16),g=parseInt(e.substr(5,2),16);else if(e.length===4)h=parseInt(e[1]+e[1],16),c=parseInt(e[2]+e[2],16),g=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(h,c,g)}const s=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(s){const h=parseInt(s[1],10),c=parseInt(s[2],10),g=parseInt(s[3],10);return this.setRGB(h,c,g)}const o=pn.getColorByName(t);return o!==void 0?this.setRGBValue(o):(console.warn("Unknown CSS color string:",t),this)}setScalar(t){return this.setRGB(t,t,t)}get hexColor(){const t=this.RGB;return t==null?void 0:"0x"+t.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const t=this.RGB;if(t!=null)return`rgb(${t>>16&255},${t>>8&255},${t&255})`}get colorIndex(){return this._colorMethod===mt.ByACI?this._value:this._colorMethod===mt.ByLayer?256:this._colorMethod===mt.ByBlock?0:void 0}set colorIndex(t){if(t==null)return;const e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=mt.ByBlock,this._value=void 0):e===256?(this._colorMethod=mt.ByLayer,this._value=void 0):(this._colorMethod=mt.ByACI,this._value=e)}get isByColor(){return this._colorMethod===mt.ByColor}get isByACI(){return this._colorMethod===mt.ByACI}get isByLayer(){return this._colorMethod===mt.ByLayer}setByLayer(t){return this._colorMethod=mt.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===mt.ByBlock}setByBlock(t){return this._colorMethod=mt.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case mt.ByLayer:return"ByLayer";case mt.ByBlock:return"ByBlock";case mt.ByColor:return this._value?pn.getNameByColor(this._value):"";case mt.ByACI:return this._value?pn.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=pn.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=mt.ByColor):console.warn("Unknown color name:",t)}clone(){const t=new mn;return t._colorMethod=this._colorMethod,t._value=this._value,t}copy(t){return this._colorMethod=t._colorMethod,this._value=t._value,this}equals(t){return this._colorMethod===t._colorMethod&&this._value===t._value}toString(){switch(this._colorMethod){case mt.ByLayer:return"ByLayer";case mt.ByBlock:return"ByBlock";case mt.ByACI:return this._value!==void 0?String(this._value):"";case mt.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(t){if(!t)return;const e=t.trim();if(/^bylayer$/i.test(e))return new mn(mt.ByLayer);if(/^byblock$/i.test(e))return new mn(mt.ByBlock);if(/^\d{1,3},\d{1,3},\d{1,3}$/i.test(e)){const[o,h,c]=e.split(",").map(Number),g=new mn(mt.ByColor);return g.setRGB(o,h,c),g}if(/^\d+$/.test(e)){const o=parseInt(e,10);return new mn(mt.ByACI,o)}const s=pn.getColorByName(e);if(s!=null)return new mn(mt.ByColor,s);console.warn("Unknown color name:",t)}},_c=class{constructor(t=mt.ByColor,e=0){this._colorMethod=t,this._value=e}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(t){this._colorMethod=mt.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=mt.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=mt.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,s){this._colorMethod=mt.ByColor,this._value=(t&255)<<16|(e&255)<<8|s&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=mt.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=mt.ByLayer,this._value=t}isByColor(){return this._colorMethod===mt.ByColor}isByLayer(){return this._colorMethod===mt.ByLayer}isByBlock(){return this._colorMethod===mt.ByBlock}isByACI(){return this._colorMethod===mt.ByACI}isNone(){return this._colorMethod===mt.None}get rawValue(){return this._value}set rawValue(t){this._value=t}};const We={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class yc{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)}}}let ae=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 vc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var gl={exports:{}};(function(i){(function(t,e){i.exports?i.exports=e():t.log=e()})(vc,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(B,D){var F=B[D];if(typeof F.bind=="function")return F.bind(B);try{return Function.prototype.bind.call(F,B)}catch{return function(){return Function.prototype.apply.apply(F,[B,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 f(B){return B==="debug"&&(B="log"),typeof console===e?!1:B==="trace"&&s?b:console[B]!==void 0?g(console,B):console.log!==void 0?g(console,"log"):t}function w(){for(var B=this.getLevel(),D=0;D<o.length;D++){var F=o[D];this[F]=D<B?t:this.methodFactory(F,B,this.name)}if(this.log=this.debug,typeof console===e&&B<this.levels.SILENT)return"No console available for logging"}function x(B){return function(){typeof console!==e&&(w.call(this),this[B].apply(this,arguments))}}function E(B,D,F){return f(B)||x.apply(this,arguments)}function M(B,D){var F=this,dt,vt,ot,W="loglevel";typeof B=="string"?W+=":"+B:typeof B=="symbol"&&(W=void 0);function ut(wt){var Bt=(o[wt]||"silent").toUpperCase();if(!(typeof window===e||!W)){try{window.localStorage[W]=Bt;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Bt+";"}catch{}}}function st(){var wt;if(!(typeof window===e||!W)){try{wt=window.localStorage[W]}catch{}if(typeof wt===e)try{var Bt=window.document.cookie,me=encodeURIComponent(W),ge=Bt.indexOf(me+"=");ge!==-1&&(wt=/^([^;]+)/.exec(Bt.slice(ge+me.length+1))[1])}catch{}return F.levels[wt]===void 0&&(wt=void 0),wt}}function Gt(){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 Xt(wt){var Bt=wt;if(typeof Bt=="string"&&F.levels[Bt.toUpperCase()]!==void 0&&(Bt=F.levels[Bt.toUpperCase()]),typeof Bt=="number"&&Bt>=0&&Bt<=F.levels.SILENT)return Bt;throw new TypeError("log.setLevel() called with invalid level: "+wt)}F.name=B,F.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},F.methodFactory=D||E,F.getLevel=function(){return ot??vt??dt},F.setLevel=function(wt,Bt){return ot=Xt(wt),Bt!==!1&&ut(ot),w.call(F)},F.setDefaultLevel=function(wt){vt=Xt(wt),st()||F.setLevel(wt,!1)},F.resetLevel=function(){ot=null,Gt(),w.call(F)},F.enableAll=function(wt){F.setLevel(F.levels.TRACE,wt)},F.disableAll=function(wt){F.setLevel(F.levels.SILENT,wt)},F.rebuild=function(){if(c!==F&&(dt=Xt(c.getLevel())),w.call(F),c===F)for(var wt in h)h[wt].rebuild()},dt=Xt(c?c.getLevel():"WARN");var Ht=st();Ht!=null&&(ot=Xt(Ht)),w.call(F)}c=new M,c.getLogger=function(B){if(typeof B!="symbol"&&typeof B!="string"||B==="")throw new TypeError("You must supply a name when creating a logger.");var D=h[B];return D||(D=h[B]=new M(B,c.methodFactory)),D};var L=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=L),c},c.getLoggers=function(){return h},c.default=c,c})})(gl);var fl=gl.exports;const xc=bc(fl),wc=fc({__proto__:null,default:xc},[fl]),Ac=!0,Ns=wc;Ns.setLevel("debug");const Sc=i=>{try{Ns.setLevel(i)}catch(t){Ns.setLevel("error"),Ns.error(t)}};function Ms(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function ga(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(Array.isArray(i))return i.map(ga);const t={};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=ga(i[e]));return t}function jn(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 _l(i,t){return i!=null&&Object.prototype.hasOwnProperty.call(i,t)}function yl(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 Un(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(!Un(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)||!Un(i[o],t[o]))return!1;return!0}let vl=class bl{constructor(t,e){this.events={attrChanged:new ae,modelChanged:new ae},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&jn(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=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=Ms(this.attributes),this.changed={});const f=this.attributes,w=this.changed,x=this._previousAttributes;for(const E in o)e=o[E],Un(f[E],e)||g.push(E),Un(x[E],e)?delete w[E]:w[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(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(t){return this.get(t)!=null}hasChanged(t){return t==null?!yl(this.changed):_l(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?Ms(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const o in t){const h=t[o];Un(e[o],h)||(s[o]=h)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return Ms(this._previousAttributes)}clone(){const t=Ms(this.attributes);return new bl(t)}},Ia=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 Ic{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]}`}}let xl=class{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}};class wl{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 Al=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 Sl=new Al;class Pc{constructor(t){this.manager=t!==void 0?t:Sl,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 Pa{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 Ea=(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))(Ea||{});class Yr{static get instance(){return this._instance||(this._instance=new Yr),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){var b;const g=[];if(e!=null){const f=this.createKey(e.name,s);let w;if(this.has(f))w=this.get(f);else{const x=(b=t.basePoint)==null?void 0:b.clone();t.basePoint=void 0;const E=e.newIterator();let M=!0;for(const L of E)if(L.color.isByBlock&&s?(Zo.copy(L.color),L.color.setRGBValue(s),this.addEntity(L,g,t),L.color.copy(Zo)):this.addEntity(L,g,t),M){const B=g[0];t.basePoint=B.basePoint,M=!1}w=t.group(g),w&&o&&pe.name&&!pe.name.startsWith("*U")&&this.set(f,w),t.basePoint=x}return w&&h&&(w.applyMatrix(h),c&&(c.x!=0||c.y!=0||c.z!=1)&&(h.setFromExtrusionDirection(c),w.applyMatrix(h))),w}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 Zo=new $r;var ka=(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))(ka||{});const Ec=["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"],Il=i=>Ec[i],ai="Continuous",Js="ByLayer",Pl="ByBlock",ye=["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 Ma=Math.PI/180,Ta=180/Math.PI;function El(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(ye[i&255]+ye[i>>8&255]+ye[i>>16&255]+ye[i>>24&255]+"-"+ye[t&255]+ye[t>>8&255]+"-"+ye[t>>16&15|64]+ye[t>>24&255]+"-"+ye[e&63|128]+ye[e>>8&255]+"-"+ye[e>>16&255]+ye[e>>24&255]+ye[s&255]+ye[s>>8&255]+ye[s>>16&255]+ye[s>>24&255]).toLowerCase()}function Tr(i,t,e){return Math.max(t,Math.min(e,i))}function Na(i,t){return(i%t+t)%t}function kl(i,t,e,s,o){return s+(i-t)*(o-s)/(e-t)}function Ml(i,t,e){return i!==t?(e-i)/(t-i):0}function Ca(i,t,e){return(1-e)*i+e*t}function Tl(i,t,e,s){return Ca(i,t,1-Math.exp(-e*s))}function Nl(i,t=1){return t-Math.abs(Na(i,t*2)-t)}function Cl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Ll(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Ol(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Bl(i,t){return i+Math.random()*(t-i)}function zl(i){return i*(.5-Math.random())}function Rl(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 Fl(i){return i*Ma}function Dl(i){return i*Ta}function Ul(i){return(i&i-1)===0&&i!==0}function Vl(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Gl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Cs(i){const t=Math.PI*2;return(i%t+t)%t}function jl(i,t,e){return i>t&&i<e||i>e&&i<t}function Wl(i,t,e,s=!1){return i=Cs(i),t=Cs(t),e=Cs(e),s?t>e?i<=t&&i>=e:i<=t||i>=e:t<e?i>=t&&i<=e:i>=t||i<=e}function La(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Hl(i,t=1e-7){const e=La(i);return Math.max(Math.pow(10,e)*t,t)}const kt={DEG2RAD:Ma,RAD2DEG:Ta,generateUUID:El,clamp:Tr,euclideanModulo:Na,mapLinear:kl,inverseLerp:Ml,lerp:Ca,damp:Tl,pingpong:Nl,smoothstep:Cl,smootherstep:Ll,randInt:Ol,randFloat:Bl,randFloatSpread:zl,seededRandom:Rl,degToRad:Fl,radToDeg:Dl,isPowerOfTwo:Ul,ceilPowerOfTwo:Vl,floorPowerOfTwo:Gl,normalizeAngle:Cs,isBetween:jl,isBetweenAngle:Wl,intPartLength:La,relativeEps:Hl},fa=class Yl{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 We.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 Yl(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(kt.relativeEps(this.x,t),kt.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};fa.EMPTY=Object.freeze(new fa(0,0));let Zt=fa;const _a=class ql{constructor(t,e,s,o,h,c,g,b,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&&b!=null&&f!=null&&this.set(t,e,s,o,h,c,g,b,f)}set(t,e,s,o,h,c,g,b,f){const w=this.elements;return w[0]=t,w[1]=o,w[2]=g,w[3]=e,w[4]=h,w[5]=b,w[6]=s,w[7]=c,w[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],b=s[6],f=s[1],w=s[4],x=s[7],E=s[2],M=s[5],L=s[8],B=o[0],D=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*B+g*dt+b*W,h[3]=c*D+g*vt+b*ut,h[6]=c*F+g*ot+b*st,h[1]=f*B+w*dt+x*W,h[4]=f*D+w*vt+x*ut,h[7]=f*F+w*ot+x*st,h[2]=E*B+M*dt+L*W,h[5]=E*D+M*vt+L*ut,h[8]=E*F+M*ot+L*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],b=t[6],f=t[7],w=t[8];return e*c*w-e*g*f-s*h*w+s*g*b+o*h*f-o*c*b}invert(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],c=t[4],g=t[5],b=t[6],f=t[7],w=t[8],x=w*c-g*f,E=g*b-w*h,M=f*h-c*b,L=e*x+s*E+o*M;if(L===0)return this.set(0,0,0,0,0,0,0,0,0);const B=1/L;return t[0]=x*B,t[1]=(o*f-w*s)*B,t[2]=(g*s-o*c)*B,t[3]=E*B,t[4]=(w*e-o*b)*B,t[5]=(o*h-g*e)*B,t[6]=M*B,t[7]=(s*b-f*e)*B,t[8]=(c*e-s*h)*B,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 b=Math.cos(h),f=Math.sin(h);return this.set(s*b,s*f,-s*(b*c+f*g)+c+t,-o*f,o*b,-o*(-f*c+b*g)+g+e,0,0,1),this}scale(t,e){return this.premultiply(ea.makeScale(t,e)),this}rotate(t){return this.premultiply(ea.makeRotation(-t)),this}translate(t,e){return this.premultiply(ea.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof Zt?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 ql().fromArray(this.elements)}};_a.IDENTITY=Object.freeze(new _a);let Fi=_a;const ea=new Fi,gn=1e-6,se=2*Math.PI,kc={x:0,y:0},Oa={x:0,y:0,z:0};class Ba{constructor(){this.equalPointTol=gn,this.equalVectorTol=gn}equalPoint2d(t,e){return new Zt(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new Z(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=gn){return t<e&&t>-e}static equal(t,e,s=gn){return Math.abs(t-e)<s}static great(t,e,s=gn){return t-e>s}static less(t,e,s=gn){return t-e<s}}const za=new Ba;function Ra(i,t,e=!1){const s=i.x,o=i.y;let h=!1;const c=t.length;for(let g=0,b=c-1;g<c;b=g++){const f=t[g].x,w=t[g].y,x=t[b].x,E=t[b].y;let M=w>o!=E>o;e&&(M=w>=o!=E>=o),M&&s<(x-f)*(o-w)/(E-w)+f&&(h=!h)}return h}function Xl(i,t){if(i.length===0||t.length===0)return!1;const e=new ve().setFromPoints(i),s=new ve().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let o=0;o<i.length;){if(Ra(i[o],t,!0))return!0;o<i.length-1&&za.equalPoint2d(i[o+1],i[o])&&++o,++o}return!1}const Kl={isPointInPolygon:Ra,isPolygonIntersect:Xl};function $l(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 Zl(i,t){const e=t.length-1,s=i,o=[0];let h=0;for(let g=1;g<=e;g++){const b=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],w=t[g][2]-t[g-1][2],x=Math.sqrt(b*b+f*f+w*w);h+=x,o.push(h)}const c=[];for(let g=0;g<=s;g++)c.push(0);for(let g=1;g<=e-s;g++){const b=o[g]/h;c.push(b*(e-s+1))}for(let g=0;g<=s;g++)c.push(e-s+1);return c}function Ql(i,t){const e=t.length-1,s=i,o=[0];let h=0;for(let g=1;g<=e;g++){const b=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],w=t[g][2]-t[g-1][2],x=Math.sqrt(b*b+f*f+w*w),E=Math.sqrt(x);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 b=o[g]/h;c.push(b*(e-s+1))}for(let g=0;g<=s;g++)c.push(e-s+1);return c}function oi(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*oi(i,t-1,e,s)+g*oi(i+1,t-1,e,s)}function Ls(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 b=0;for(let f=0;f<=h;f++){const w=oi(f,c,i,e),x=o[f]*w;g[0]+=s[f][0]*x,g[1]+=s[f][1]*x,g[2]+=s[f][2]*x,b+=x}if(b<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 b>1e-10&&(g[0]/=b,g[1]/=b,g[2]/=b),g}function Jl(i,t,e,s){const o=i,h=t[o],c=t[t.length-o-1];let g=0;const b=1e3,f=(c-h)/b;let w=Ls(h,i,t,e,s);for(let B=1;B<=b;B++){const D=h+B*f,F=Ls(D,i,t,e,s),dt=F[0]-w[0],vt=F[1]-w[1],ot=F[2]-w[2];g+=Math.sqrt(dt*dt+vt*vt+ot*ot),w=F}const x=Ls(c,i,t,e,s),E=x[0]-w[0],M=x[1]-w[1],L=x[2]-w[2];return g+=Math.sqrt(E*E+M*M+L*L),g}function Mc(i){return i.map(t=>[...t])}class qr{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 b=s[o+0],f=s[o+1],w=s[o+2],x=s[o+3];const E=h[c+0],M=h[c+1],L=h[c+2],B=h[c+3];if(g===0){t[e+0]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x;return}if(g===1){t[e+0]=E,t[e+1]=M,t[e+2]=L,t[e+3]=B;return}if(x!==B||b!==E||f!==M||w!==L){let D=1-g;const F=b*E+f*M+w*L+x*B,dt=F>=0?1:-1,vt=1-F*F;if(vt>Number.EPSILON){const W=Math.sqrt(vt),ut=Math.atan2(W,F*dt);D=Math.sin(D*ut)/W,g=Math.sin(g*ut)/W}const ot=g*dt;if(b=b*D+E*ot,f=f*D+M*ot,w=w*D+L*ot,x=x*D+B*ot,D===1-g){const W=1/Math.sqrt(b*b+f*f+w*w+x*x);b*=W,f*=W,w*=W,x*=W}}t[e]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x}static multiplyQuaternionsFlat(t,e,s,o,h,c){const g=s[o],b=s[o+1],f=s[o+2],w=s[o+3],x=h[c],E=h[c+1],M=h[c+2],L=h[c+3];return t[e]=g*L+w*x+b*M-f*E,t[e+1]=b*L+w*E+f*x-g*M,t[e+2]=f*L+w*M+g*E-b*x,t[e+3]=w*L-g*x-b*E-f*M,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 qr(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,b=Math.sin,f=g(s/2),w=g(o/2),x=g(h/2),E=b(s/2),M=b(o/2),L=b(h/2);switch(c){case"XYZ":this._x=E*w*x+f*M*L,this._y=f*M*x-E*w*L,this._z=f*w*L+E*M*x,this._w=f*w*x-E*M*L;break;case"YXZ":this._x=E*w*x+f*M*L,this._y=f*M*x-E*w*L,this._z=f*w*L-E*M*x,this._w=f*w*x+E*M*L;break;case"ZXY":this._x=E*w*x-f*M*L,this._y=f*M*x+E*w*L,this._z=f*w*L+E*M*x,this._w=f*w*x-E*M*L;break;case"ZYX":this._x=E*w*x-f*M*L,this._y=f*M*x+E*w*L,this._z=f*w*L-E*M*x,this._w=f*w*x+E*M*L;break;case"YZX":this._x=E*w*x+f*M*L,this._y=f*M*x+E*w*L,this._z=f*w*L-E*M*x,this._w=f*w*x-E*M*L;break;case"XZY":this._x=E*w*x-f*M*L,this._y=f*M*x-E*w*L,this._z=f*w*L+E*M*x,this._w=f*w*x+E*M*L;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],b=e[9],f=e[2],w=e[6],x=e[10],E=s+g+x;if(E>0){const M=.5/Math.sqrt(E+1);this._w=.25/M,this._x=(w-b)*M,this._y=(h-f)*M,this._z=(c-o)*M}else if(s>g&&s>x){const M=2*Math.sqrt(1+s-g-x);this._w=(w-b)/M,this._x=.25*M,this._y=(o+c)/M,this._z=(h+f)/M}else if(g>x){const M=2*Math.sqrt(1+g-s-x);this._w=(h-f)/M,this._x=(o+c)/M,this._y=.25*M,this._z=(b+w)/M}else{const M=2*Math.sqrt(1+x-s-g);this._w=(c-o)/M,this._x=(h+f)/M,this._y=(b+w)/M,this._z=.25*M}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(Tr(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,b=e._y,f=e._z,w=e._w;return this._x=s*w+c*g+o*f-h*b,this._y=o*w+c*b+h*g-s*f,this._z=h*w+c*f+s*b-o*g,this._w=c*w-s*g-o*b-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 b=1-g*g;if(b<=Number.EPSILON){const M=1-e;return this._w=M*c+e*this._w,this._x=M*s+e*this._x,this._y=M*o+e*this._y,this._z=M*h+e*this._z,this.normalize(),this}const f=Math.sqrt(b),w=Math.atan2(f,g),x=Math.sin((1-e)*w)/f,E=Math.sin(e*w)/f;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(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 je=class th{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 We.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 th(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,b=t.w,f=2*(c*o-g*s),w=2*(g*e-h*o),x=2*(h*s-c*e);return this.x=e+b*f+c*x-g*w,this.y=s+b*w+g*f-h*x,this.z=o+b*x+h*w-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,b=e.z;return this.x=o*b-h*g,this.y=h*c-s*b,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 ra.copy(this).projectOnVector(t),this.sub(ra)}reflect(t){return this.sub(ra.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}};je.X_AXIS=Object.freeze(new je(1,0,0)),je.NEGATIVE_X_AXIS=Object.freeze(new je(-1,0,0)),je.Y_AXIS=Object.freeze(new je(0,1,0)),je.NEGATIVE_Y_AXIS=Object.freeze(new je(0,-1,0)),je.Z_AXIS=Object.freeze(new je(0,0,1)),je.NEGATIVE_Z_AXIS=Object.freeze(new je(0,0,-1));let Z=je;const ra=new Z,Jo=new qr,ya=class eh{constructor(t,e,s,o,h,c,g,b,f,w,x,E,M,L,B,D){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&&b!=null&&f!=null&&w!=null&&x!=null&&E!=null&&M!=null&&L!=null&&B!=null&&D!=null&&this.set(t,e,s,o,h,c,g,b,f,w,x,E,M,L,B,D)}set(t,e,s,o,h,c,g,b,f,w,x,E,M,L,B,D){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]=b,F[2]=f,F[6]=w,F[10]=x,F[14]=E,F[3]=M,F[7]=L,F[11]=B,F[15]=D,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 eh().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(za.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/zn.setFromMatrixColumn(t,0).length(),h=1/zn.setFromMatrixColumn(t,1).length(),c=1/zn.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(Tc,t,Nc)}lookAt(t,e,s){const o=this.elements;return ze.subVectors(t,e),ze.lengthSq()===0&&(ze.z=1),ze.normalize(),jr.crossVectors(s,ze),jr.lengthSq()===0&&(Math.abs(s.z)===1?ze.x+=1e-4:ze.z+=1e-4,ze.normalize(),jr.crossVectors(s,ze)),jr.normalize(),qs.crossVectors(ze,jr),o[0]=jr.x,o[4]=qs.x,o[8]=ze.x,o[1]=jr.y,o[5]=qs.y,o[9]=ze.y,o[2]=jr.z,o[6]=qs.z,o[10]=ze.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],b=s[8],f=s[12],w=s[1],x=s[5],E=s[9],M=s[13],L=s[2],B=s[6],D=s[10],F=s[14],dt=s[3],vt=s[7],ot=s[11],W=s[15],ut=o[0],st=o[4],Gt=o[8],Xt=o[12],Ht=o[1],wt=o[5],Bt=o[9],me=o[13],ge=o[2],Ne=o[6],te=o[10],oe=o[14],Q=o[3],Ct=o[7],le=o[11],cr=o[15];return h[0]=c*ut+g*Ht+b*ge+f*Q,h[4]=c*st+g*wt+b*Ne+f*Ct,h[8]=c*Gt+g*Bt+b*te+f*le,h[12]=c*Xt+g*me+b*oe+f*cr,h[1]=w*ut+x*Ht+E*ge+M*Q,h[5]=w*st+x*wt+E*Ne+M*Ct,h[9]=w*Gt+x*Bt+E*te+M*le,h[13]=w*Xt+x*me+E*oe+M*cr,h[2]=L*ut+B*Ht+D*ge+F*Q,h[6]=L*st+B*wt+D*Ne+F*Ct,h[10]=L*Gt+B*Bt+D*te+F*le,h[14]=L*Xt+B*me+D*oe+F*cr,h[3]=dt*ut+vt*Ht+ot*ge+W*Q,h[7]=dt*st+vt*wt+ot*Ne+W*Ct,h[11]=dt*Gt+vt*Bt+ot*te+W*le,h[15]=dt*Xt+vt*me+ot*oe+W*cr,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],b=t[9],f=t[13],w=t[2],x=t[6],E=t[10],M=t[14],L=t[3],B=t[7],D=t[11],F=t[15];return L*(+h*b*x-o*f*x-h*g*E+s*f*E+o*g*M-s*b*M)+B*(+e*b*M-e*f*E+h*c*E-o*c*M+o*f*w-h*b*w)+D*(+e*f*x-e*g*M-h*c*x+s*c*M+h*g*w-s*f*w)+F*(-o*g*w-e*b*x+e*g*E+o*c*x-s*c*E+s*b*w)}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],b=t[6],f=t[7],w=t[8],x=t[9],E=t[10],M=t[11],L=t[12],B=t[13],D=t[14],F=t[15],dt=x*D*f-B*E*f+B*b*M-g*D*M-x*b*F+g*E*F,vt=L*E*f-w*D*f-L*b*M+c*D*M+w*b*F-c*E*F,ot=w*B*f-L*x*f+L*g*M-c*B*M-w*g*F+c*x*F,W=L*x*b-w*B*b-L*g*E+c*B*E+w*g*D-c*x*D,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]=(B*E*h-x*D*h-B*o*M+s*D*M+x*o*F-s*E*F)*st,t[2]=(g*D*h-B*b*h+B*o*f-s*D*f-g*o*F+s*b*F)*st,t[3]=(x*b*h-g*E*h-x*o*f+s*E*f+g*o*M-s*b*M)*st,t[4]=vt*st,t[5]=(w*D*h-L*E*h+L*o*M-e*D*M-w*o*F+e*E*F)*st,t[6]=(L*b*h-c*D*h-L*o*f+e*D*f+c*o*F-e*b*F)*st,t[7]=(c*E*h-w*b*h+w*o*f-e*E*f-c*o*M+e*b*M)*st,t[8]=ot*st,t[9]=(L*x*h-w*B*h-L*s*M+e*B*M+w*s*F-e*x*F)*st,t[10]=(c*B*h-L*g*h+L*s*f-e*B*f-c*s*F+e*g*F)*st,t[11]=(w*g*h-c*x*h-w*s*f+e*x*f+c*s*M-e*g*M)*st,t[12]=W*st,t[13]=(w*B*o-L*x*o+L*s*E-e*B*E-w*s*D+e*x*D)*st,t[14]=(L*g*o-c*B*o-L*s*b+e*B*b+c*s*D-e*g*D)*st,t[15]=(c*x*o-w*g*o+w*s*b-e*x*b-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,b=t.z,f=h*c,w=h*g;return this.set(f*c+s,f*g-o*b,f*b+o*g,0,f*g+o*b,w*g+s,w*b-o*c,0,f*b-o*g,w*b+o*c,h*b*b+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,b=e.w,f=h+h,w=c+c,x=g+g,E=h*f,M=h*w,L=h*x,B=c*w,D=c*x,F=g*x,dt=b*f,vt=b*w,ot=b*x,W=s.x,ut=s.y,st=s.z;return o[0]=(1-(B+F))*W,o[1]=(M+ot)*W,o[2]=(L-vt)*W,o[3]=0,o[4]=(M-ot)*ut,o[5]=(1-(E+F))*ut,o[6]=(D+dt)*ut,o[7]=0,o[8]=(L+vt)*st,o[9]=(D-dt)*st,o[10]=(1-(E+B))*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=zn.set(o[0],o[1],o[2]).length();const c=zn.set(o[4],o[5],o[6]).length(),g=zn.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],er.copy(this);const b=1/h,f=1/c,w=1/g;return er.elements[0]*=b,er.elements[1]*=b,er.elements[2]*=b,er.elements[4]*=f,er.elements[5]*=f,er.elements[6]*=f,er.elements[8]*=w,er.elements[9]*=w,er.elements[10]*=w,e.setFromRotationMatrix(er),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}};ya.IDENTITY=Object.freeze(new ya);let Xr=ya;const zn=new Z,er=new Xr,Tc=new Z(0,0,0),Nc=new Z(1,1,1),jr=new Z,qs=new Z,ze=new Z;class Nt{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(na.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=na.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Nt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new 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,na).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:(fr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),fr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),fr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),fr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),fr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),fr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),fr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),fr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(fr),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 fr=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],na=new Z,tl=new Zt;class ve{constructor(t=void 0,e=void 0){this.min=t==null?new Zt(1/0,1/0):new Zt(t.x,t.y),this.max=e==null?new Zt(-1/0,-1/0):new Zt(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 ve().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new Zt(0,0):new Zt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Zt(0,0):new Zt(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,Cc=new Z,Lc=new Fi;class Gs{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(Cc.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||Lc.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 Gs().copy(this)}}class Tt extends Zt{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,o)=>{s.toArray(e,o*2)}),e}}class Y 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 Xr,nl=new qr,rh=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],b=o[1],f=o[5],w=o[9],x=o[2],E=o[6],M=o[10];switch(e){case"XYZ":this._y=Math.asin(Tr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-w,M),this._z=Math.atan2(-c,h)):(this._x=Math.atan2(E,f),this._z=0);break;case"YXZ":this._x=Math.asin(-Tr(w,-1,1)),Math.abs(w)<.9999999?(this._y=Math.atan2(g,M),this._z=Math.atan2(b,f)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(Tr(E,-1,1)),Math.abs(E)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-c,f)):(this._y=0,this._z=Math.atan2(b,h));break;case"ZYX":this._y=Math.asin(-Tr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(E,M),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-c,f));break;case"YZX":this._z=Math.asin(Tr(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-w,f),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(g,M));break;case"XZY":this._z=Math.asin(-Tr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(E,f),this._y=Math.atan2(g,h)):(this._x=Math.atan2(-w,M),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}};rh.DEFAULT_ORDER="XYZ";let nh=rh;class sh{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}let Fa=class extends sh{translate(t){return this.transform(new Fi().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}};class Di extends Fa{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new ve}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const 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 b=0;b<c;b++)h.set(o[b],{index:o[b],children:[]});const g={index:-1,children:[]};for(let b=0;b<c;b++){const f=o[b],w=e[f],x=s[f];let E=b+1;for(;E<c;E++){const M=o[E],L=e[M];if(s[M].containsBox(x)&&Kl.isPointInPolygon(w[kt.randInt(0,w.length-1)],L)){(t=h.get(M))==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 ve().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 Wn extends Fa{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,b=h-1,f;for(;g<=b;)if(o=Math.floor(g+(b-g)/2),f=s[o]-c,f<0)g=o+1;else if(f>0)b=o-1;else{b=o;break}if(o=b,s[o]===c)return o/(h-1);const w=s[o],x=s[o+1]-w,E=(c-w)/x;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 Vn extends Wn{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(kt.normalizeAngle(s)):kt.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(kt.normalizeAngle(o)):kt.normalizeAngle(o)}else throw We.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const o=(st,Gt)=>({x:(st.x+Gt.x)/2,y:(st.y+Gt.y)/2}),h=(st,Gt)=>(Gt.y-st.y)/(Gt.x-st.x),c=st=>-1/st,g=o(t,e),b=o(e,s),f=h(t,e),w=h(e,s),x=c(f),E=c(w),M=(st,Gt,Xt,Ht)=>{const wt=(Ht-Gt)/(st-Xt),Bt=st*wt+Gt;return{x:wt,y:Bt}},L=g.y-x*g.x,B=b.y-E*b.x,D=M(x,L,E,B),F=Math.sqrt(Math.pow(t.x-D.x,2)+Math.pow(t.y-D.y,2)),dt=(st,Gt)=>Math.atan2(st.y-Gt.y,st.x-Gt.x),vt=dt(t,D),ot=dt(e,D),W=dt(s,D),ut=W>vt&&W<ot||vt>W&&vt<ot||ot>W&&ot<vt;this.center=D,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 Zt(t),c=new Zt(e)):(o=Math.atan(s)*4,h=new Zt(e),c=new Zt(t));const g=new Zt().subVectors(c,h),b=g.length(),f=new Zt().addVectors(h,g.multiplyScalar(.5)),w=Math.abs(b/2/Math.tan(o/2)),x=g.normalize();let E;if(o<Math.PI){const M=new Zt(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=f.add(M.multiplyScalar(-w))}else{const M=new Zt(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=f.add(M.multiplyScalar(w))}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(kt.normalizeAngle(t)):kt.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==se?t:kt.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?kt.normalizeAngle(t-e):kt.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=kt.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);kt.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 ve(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 Vn(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=se,o=0),this.clockwise)for(let h=0;h<=t;h++){const c=o-s*(h/t),g=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}else for(let h=0;h<=t;h++){const c=o+s*(h/t),g=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}return e}}class Oc extends sh{translate(t){return this.transform(new Xr().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 js extends Oc{}let li=class ih extends js{constructor(t,e){super(),this._start=new Y(t),this._end=new Y(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 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(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(nn).normalize();return new Y(this._start).addScaledVector(s,t)}else{const s=this.delta(nn).normalize();return new Y(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=nn.subVectors(this._start,this._end).normalize();this._start=new Y(this._start).addScaledVector(s,t)}else{const s=this.delta(nn).normalize();this._end=new Y(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){sl.subVectors(t,this._start),Xs.subVectors(this.endPoint,this.startPoint);const s=Xs.dot(Xs);let o=Xs.dot(sl)/s;return e&&(o=kt.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=nn.subVectors(t,this.startPoint).dot(e);return new Y().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,o=nn.subVectors(t,s).dot(e),h=nn.copy(e).multiplyScalar(o);return new Y().addVectors(s,h)}calculateBoundingBox(){const t=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)),e=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 Nt(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ih(this._start.clone(),this._end.clone())}};const nn=new Z,sl=new Z,Xs=new Z;let Da=class ti extends js{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),b=new Z().crossVectors(c,g).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new Z().crossVectors(c,b).normalize(),w=new Z().crossVectors(g,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=w.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),M=new li(o,o.clone().add(x)),L=new li(h,h.clone().add(E)),B=new Z;return M.closestPointToPoint(L.startPoint,!0,B)?B:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const o=ti.computeCenterPoint(t,e,s);if(o){const h=o.distanceTo(t),c=new Z().subVectors(t,o),g=new Z().subVectors(e,o),b=Math.atan2(c.y,c.x),f=Math.atan2(g.y,g.x);return new ti(o,h,b,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)%se==0?(this.startAngle=0,this.endAngle=se):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw We.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==se?t:kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return kt.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 b=0;b<2*Math.PI;b+=Math.PI/2)kt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const b of t){const f=this.getPointAtAngle(b);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 Nt({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=se,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=sa.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=sa.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 ti(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(sa.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 Y(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(Oa);return new Gs(this.normal,t)}};const sa=new Z;class Ui extends Wn{constructor(t,e,s,o=0,h=se,c=!1,g=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(h-o)%se==0?(this.startAngle=0,this.endAngle=se):(this.startAngle=o,this.endAngle=h),this.clockwise=c,this.rotation=g}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw We.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw We.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==se?t:kt.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 kt.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 ve({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 b=Math.cos(this.rotation),f=Math.sin(this.rotation),w=c-this.center.x,x=g-this.center.y;c=w*b-x*f+this.center.x,g=w*f+x*b+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 Ui(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Vi extends js{constructor(t,e,s,o,h,c=0,g=se){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(g-c);Math.abs(b-se)<1e-10||Math.abs(b-2*se)<1e-10?(this.startAngle=0,this.endAngle=se):(this.startAngle=c,this.endAngle=g)}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw We.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw We.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==se?t:kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-se)<1e-10?se:kt.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 Ba.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),b=g.x-o.x,f=g.y-o.y,w=g.z-o.z;s+=Math.sqrt(b*b+f*f+w*w),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 b=0;b<2*Math.PI;b+=Math.PI/2)kt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const b of t){const f=this.getPointAtAngle(b);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 Nt({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 b=this.startAngle+this.deltaAngle*(g/100),f=this.getPointAtAngle(b);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 Nt({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=se,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 Y(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 Vi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new Z(this.center).distanceTo(Oa);return new Gs(this.normal,t)}}class bn extends Wn{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 Vn(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 ve().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(o=>s.push(new Y().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 Vn(h,c,h.bulge).getPoints(t),b=g.length;for(let f=0;f<b;++f){const w=g[f];e.push(new Tt(w.x,w.y))}}}else e.push(new Tt(h.x,h.y)),o==s-1&&this.closed&&e.push(e[0])}return e}}let Os=class ah extends Wn{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 ve(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ah(this._start.clone(),this._end.clone())}},Ua=class extends Wn{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 ve;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(o=>{e.push(new Tt(o.x,o.y))})}),e}};function Bc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var oh={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(b,f){var w=s;return b.split(".").forEach(function(x){w&&(w=w[x])}),w?w[f]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var f=g(b.data.className,b.data.methodName);if(!f)return console.error("could not find "+b.data.className+"."+b.data.methodName);postMessage({result:f.apply(null,b.data.args),id:b.data.id})}}}}return function(b,f,w){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var x={},E=function(){return Ct.__string_rec(this,"")};function M(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 L=function(){};x.HxOverrides=L,L.__name__=["HxOverrides"],L.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(" "),m=d[0].split("-"),_=d[1].split(":");return new Date(m[0],m[1]-1,m[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},L.cca=function(r,n){var a=r.charCodeAt(n);if(a==a)return a},L.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))},L.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var B=function(){};x.Lambda=B,B.__name__=["Lambda"],B.fold=function(r,n,a){for(var l=$e(r)();l.hasNext();){var u=l.next();a=n(u,a)}return a};var D=function(){this.length=0};x.List=D,D.__name__=["List"],D.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__:D},Math.__name__=["Math"];var F=function(){};x.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(){};x.Std=dt,dt.__name__=["Std"],dt.string=function(r){return Ct.__string_rec(r,"")},dt.parseFloat=function(r){return parseFloat(r)};var vt=function(){this.b=""};x.StringBuf=vt,vt.__name__=["StringBuf"],vt.prototype={add:function(r){this.b+=dt.string(r)},__class__:vt};var ot=function(){};x.StringTools=ot,ot.__name__=["StringTools"],ot.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 ut=function(){};x.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=x[r];return n==null||!n.__name__?null:n},ut.resolveEnum=function(r){var n=x[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=Ct.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(){};x["haxe.IMap"]=st,st.__name__=["haxe","IMap"];var Gt=function(r,n){this.high=r,this.low=n};x["haxe._Int64.___Int64"]=Gt,Gt.__name__=["haxe","_Int64","___Int64"],Gt.prototype={__class__:Gt};var Xt=function(){this.buf=new vt,this.cache=[],this.useCache=Xt.USE_CACHE,this.useEnumIndex=Xt.USE_ENUM_INDEX,this.shash=new ge,this.scount=0};x["haxe.Serializer"]=Xt,Xt.__name__=["haxe","Serializer"],Xt.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 m=r.length,_=0;_<m;){var y=_++;r[y]==null?d++:(d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d),d=0),this.serialize(r[y]))}d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d)),this.buf.b+="h";break;case D:this.buf.b+="l";for(var A=r,I=A.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 ge:this.buf.b+="b";for(var T=r,O=T.keys();O.hasNext();){var C=O.next();this.serializeString(C),this.serialize(Xi[C]!=null?T.getReserved(C):T.h[C])}this.buf.b+="h";break;case wt:this.buf.b+="q";for(var R=r,z=R.keys();z.hasNext();){var U=z.next();this.buf.b+=":",U==null?this.buf.b+="null":this.buf.b+=""+U,this.serialize(R.h[U])}this.buf.b+="h";break;case Bt:this.buf.b+="M";for(var V=r,q=V.keys();q.hasNext();){var J=q.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 Ne:for(var G=r,K=0,tt=G.length-2,et=new vt,it=Xt.BASE64;K<tt;){var ht=G.get(K++),at=G.get(K++),ct=G.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=G.get(K++),pt=G.get(K++);et.add(it.charAt(nt>>2)),et.add(it.charAt((nt<<4|pt>>4)&63)),et.add(it.charAt(pt<<2&63))}else if(K==tt+1){var X=G.get(K++);et.add(it.charAt(X>>2)),et.add(it.charAt(X<<4&63))}var ft=et.b;this.buf.b+="s",ft.length==null?this.buf.b+="null":this.buf.b+=""+ft.length,this.buf.b+=":",ft==null?this.buf.b+="null":this.buf.b+=""+ft;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(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(Ct.__instanceof(r,zo)){var Pt=ut.getClassName(r);this.buf.b+="A",this.serializeString(Pt)}else if(Ct.__instanceof(r,Ro))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 Wt=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(Wt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=dt.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Kt=r.length;this.buf.b+=dt.string(Kt-2);for(var Ut=2;Ut<Kt;){var $t=Ut++;this.serialize(r[$t])}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__:Xt};var Ht=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=Ht.DEFAULT_RESOLVER;n==null&&(n=ut,Ht.DEFAULT_RESOLVER=n),this.setResolver(n)};x["haxe.Unserializer"]=Ht,Ht.__name__=["haxe","Unserializer"],Ht.initCodes=function(){for(var r=[],n=0,a=Ht.BASE64.length;n<a;){var l=n++;r[Ht.BASE64.charCodeAt(l)]=l}return r},Ht.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(L.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var 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=L.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 m={};return this.cache.push(m),this.unserializeObject(m),m;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var y=this.readDigits();if(y<0||y>=this.scache.length)throw new Q("Invalid string reference");return this.scache[y];case 120:throw new Q(this.unserialize());case 99:var A=this.unserialize(),I=this.resolver.resolveClass(A);if(I==null)throw new Q("Class not found "+A);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 T=this.unserializeEnum(k,this.unserialize());return this.cache.push(T),T;case 106:var O=this.unserialize(),C=this.resolver.resolveEnum(O);if(C==null)throw new Q("Enum not found "+O);this.pos++;var R=this.readDigits(),z=ut.getEnumConstructs(C)[R];if(z==null)throw new Q("Unknown enum index "+O+"@"+R);var U=this.unserializeEnum(C,z);return this.cache.push(U),U;case 108:var V=new D;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 ge;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 wt;this.cache.push(H),this.buf;for(var G=this.get(this.pos++);G==58;){var K=this.readDigits();H.set(K,this.unserialize()),G=this.get(this.pos++)}if(G!=104)throw new Q("Invalid IntMap format");return H;case 77:var tt=new Bt;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var 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=L.substr(this.buf,this.pos,19);it=L.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(),pt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var X=Ht.CODES;X==null&&(X=Ht.initCodes(),Ht.CODES=X);var ft=this.pos,Pt=nt&3,Wt;Wt=(nt>>2)*3+(Pt>=2?Pt-1:0);for(var Kt=ft+(nt-Pt),Ut=Ne.alloc(Wt),$t=0;ft<Kt;){var ke=X[ot.fastCodeAt(pt,ft++)],qe=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,ke<<2|qe>>4);var be=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,qe<<4|be>>2);var _e=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,be<<6|_e)}if(Pt>=2){var Me=X[ot.fastCodeAt(pt,ft++)],Be=X[ot.fastCodeAt(pt,ft++)];if(Ut.set($t++,Me<<2|Be>>4),Pt==3){var Ze=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,Be<<4|Ze>>2)}}return this.pos+=nt,this.cache.push(Ut),Ut;case 67:var hr=this.unserialize(),Qe=this.resolver.resolveClass(hr);if(Qe==null)throw new Q("Class not found "+hr);var Je=ut.createEmptyInstance(Qe);if(this.cache.push(Je),Je.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Je;case 65:var tr=this.unserialize(),mr=this.resolver.resolveClass(tr);if(mr==null)throw new Q("Class not found "+tr);return mr;case 66:var On=this.unserialize(),tn=this.resolver.resolveEnum(On);if(tn==null)throw new Q("Enum not found "+On);return tn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Ht};var wt=function(){this.h={}};x["haxe.ds.IntMap"]=wt,wt.__name__=["haxe","ds","IntMap"],wt.__interfaces__=[st],wt.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 L.iter(r)},__class__:wt};var Bt=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Bt,Bt.__name__=["haxe","ds","ObjectMap"],Bt.__interfaces__=[st],Bt.prototype={set:function(r,n){var a=r.__id__||(r.__id__=++Bt.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 L.iter(r)},__class__:Bt};var me=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};me.Some=function(r){var n=["Some",0,r];return n.__enum__=me,n.toString=E,n},me.None=["None",1],me.None.toString=E,me.None.__enum__=me;var ge=function(){this.h={}};x["haxe.ds.StringMap"]=ge,ge.__name__=["haxe","ds","StringMap"],ge.__interfaces__=[st],ge.prototype={set:function(r,n){Xi[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return Xi[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 L.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__:ge};var Ne=function(r){this.length=r.byteLength,this.b=new Ki(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Ne,Ne.__name__=["haxe","io","Bytes"],Ne.alloc=function(r){return new Ne(new Ys(r))},Ne.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:Ne};var te=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};te.Blocked=["Blocked",0],te.Blocked.toString=E,te.Blocked.__enum__=te,te.Overflow=["Overflow",1],te.Overflow.toString=E,te.Overflow.__enum__=te,te.OutsideBounds=["OutsideBounds",2],te.OutsideBounds.toString=E,te.OutsideBounds.__enum__=te,te.Custom=function(r){var n=["Custom",3,r];return n.__enum__=te,n.toString=E,n};var oe=function(){};x["haxe.io.FPHelper"]=oe,oe.__name__=["haxe","io","FPHelper"],oe.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)},oe.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},oe.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)},oe.doubleToI64=function(r){var n=oe.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 m=u|0,_=u/4294967296|0;n.low=m,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=M(Error.prototype,{__class__:Q});var Ct=function(){};x["js.Boot"]=Ct,Ct.__name__=["js","Boot"],Ct.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var a=Ct.__nativeClassName(r);return a!=null?Ct.__resolveNativeClass(a):null},Ct.__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 m=u++;m!=2?l+=","+Ct.__string_rec(r[m],n):l+=Ct.__string_rec(r[m],n)}return l+")"}var _=r.length,y="[";n+=" ";for(var A=0;A<_;){var I=A++;y+=(I>0?",":"")+Ct.__string_rec(r[I],n)}return y+="]",y}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,T=`{
2
- `;n+=" ";var O=r.hasOwnProperty!=null;for(var k in r)O&&!r.hasOwnProperty(k)||k=="prototype"||k=="__class__"||k=="__super__"||k=="__interfaces__"||k=="__properties__"||(T.length!=2&&(T+=`,
3
- `),T+=n+k+" : "+Ct.__string_rec(r[k],n));return n=n.substring(1),T+=`
4
- `+n+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Ct.__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++,m=a[d];if(m==n||Ct.__interfLoop(m,n))return!0}return Ct.__interfLoop(r.__super__,n)},Ct.__instanceof=function(r,n){if(n==null)return!1;switch(n){case ec:return(r|0)===r;case Oo:return typeof r=="number";case Bo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case rc:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||Ct.__interfLoop(Ct.getClass(r),n))return!0}else if(typeof n=="object"&&Ct.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==zo&&r.__name__!=null||n==Ro&&r.__ename__!=null?!0:r.__enum__==n}},Ct.__nativeClassName=function(r){var n=Ct.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},Ct.__isNativeObj=function(r){return Ct.__nativeClassName(r)!=null},Ct.__resolveNativeClass=function(r){return w[r]};var le=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"]=le,le.__name__=["js","html","compat","ArrayBuffer"],le.sliceImpl=function(r,n){var a=new Ki(this,r,n==null?null:n-r),l=new Ys(a.byteLength),u=new Ki(l);return u.set(a),l},le.prototype={slice:function(r,n){return new le(this.a.slice(r,n))},__class__:le};var cr=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(te.OutsideBounds)};x["js.html.compat.DataView"]=cr,cr.__name__=["js","html","compat","DataView"],cr.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++],m=this.buf.a[a++];return n?l|u<<8|d<<16|m<<24:m|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 oe.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var a=this.getInt32(r,n),l=this.getInt32(r+4,n);return oe.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,oe.floatToI32(n),a)},setFloat64:function(r,n,a){var l=oe.doubleToI64(n);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:cr};var ir=function(){};x["js.html.compat.Uint8Array"]=ir,ir.__name__=["js","html","compat","Uint8Array"],ir._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 le(l)}else if(Ct.__instanceof(r,le)){var m=r;n==null&&(n=0),a==null&&(a=m.byteLength-n),n==0?l=m.a:l=m.a.slice(n,n+a),l.byteLength=l.length,l.byteOffset=n,l.buffer=m}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new le(l);else throw new Q("TODO "+dt.string(r));return l.subarray=ir._subarray,l.set=ir._set,l},ir._set=function(r,n){var a=this;if(Ct.__instanceof(r.buffer,le)){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 m=u++;a[m+n]=l[m]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>a.byteLength)throw new Q("set() outside of range");for(var y=0,A=_.length;y<A;){var I=y++;a[I+n]=_[I]}}else throw new Q("TODO")},ir._subarray=function(r,n){var a=this,l=ir._new(a.slice(r,n));return l.byteOffset=r,l};var Mt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&Mt.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=Mt,Mt.__name__=["promhx","base","AsyncBase"],Mt.link=function(r,n,a){r._update.push({async:n,linkf:function(l){n.handleResolve(a(l))}}),Mt.immediateLinkUpdate(r,n,a)},Mt.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)}},Mt.linkAll=function(r,n){for(var a=function(d,m,_){if(d.length==0||Mt.allFulfilled(d)){for(var y,A=[],I=$e(r)();I.hasNext();){var S=I.next();A.push(S==m?_:S._val)}y=A,n.handleResolve(y)}},l=$e(r)();l.hasNext();){var u=l.next();u._update.push({async:n,linkf:function(d,m,_){return function(y){d(m,_,y)}}(a,function(d){for(var m,_=[],y=$e(r)();y.hasNext();){var A=y.next();A!=u&&_.push(A)}return m=_,m}(),u)})}Mt.allFulfilled(r)&&n.handleResolve(function(d){for(var m,_=[],y=$e(r)();y.hasNext();){var A=y.next();_.push(A._val)}return m=_,m}())},Mt.pipeLink=function(r,n,a){var l=!1,u=function(d){if(!l){l=!0;var m=a(d);m._update.push({async:n,linkf:Oe(n,n.handleResolve)}),Mt.immediateLinkUpdate(m,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)}},Mt.allResolved=function(r){for(var n=$e(r)();n.hasNext();){var a=n.next();if(!a._resolved)return!1}return!0},Mt.allFulfilled=function(r){for(var n=$e(r)();n.hasNext();){var a=n.next();if(!a._fulfilled)return!1}return!0},Mt.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?It.enqueue(function(a,l){return function(){a(l)}}(Oe(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,It.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}),It.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 m=d[u];++u,m(l)}else if(n._update.length>0)for(var _=0,y=n._update;_<y.length;){var A=y[_];++_,A.async.handleError(l)}else throw new Q(l);n._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,It.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)}),It.continueOnNextLoop())},then:function(r){var n=new Mt(null);return Mt.link(this,n,r),n},unlink:function(r){var n=this;It.queue.add(function(){n._update=n._update.filter(function(a){return a.async!=r})}),It.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__:Mt};var An=f.promhx.Deferred=function(){Mt.call(this)};x["promhx.Deferred"]=An,An.__name__=["promhx","Deferred"],An.__super__=Mt,An.prototype=M(Mt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new fe(this)},stream:function(){return new Yt(this)},publicStream:function(){return new Lr(this)},__class__:An});var fe=f.promhx.Promise=function(r){Mt.call(this,r),this._rejected=!1};x["promhx.Promise"]=fe,fe.__name__=["promhx","Promise"],fe.whenAll=function(r){var n=new fe(null);return Mt.linkAll(r,n),n},fe.promise=function(r){var n=new fe;return n.handleResolve(r),n},fe.__super__=Mt,fe.prototype=M(Mt.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(Sn.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new fe(null);return Mt.link(this,n,r),n},unlink:function(r){var n=this;It.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(Sn.DownstreamNotFullfilled(a))}}),It.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new fe(null);return Mt.pipeLink(this,n,r),n},errorPipe:function(r){var n=new fe;return this.catchError(function(a){var l=r(a);l.then(Oe(n,n._resolve))}),this.then(Oe(n,n._resolve)),n},__class__:fe});var Yt=f.promhx.Stream=function(r){Mt.call(this,r),this._end_promise=new fe};x["promhx.Stream"]=Yt,Yt.__name__=["promhx","Stream"],Yt.foreach=function(r){for(var n=new Yt(null),a=$e(r)();a.hasNext();){var l=a.next();n.handleResolve(l)}return n.end(),n},Yt.wheneverAll=function(r){var n=new Yt(null);return Mt.linkAll(r,n),n},Yt.concatAll=function(r){for(var n=new Yt(null),a=$e(r)();a.hasNext();){var l=a.next();n.concat(l)}return n},Yt.mergeAll=function(r){for(var n=new Yt(null),a=$e(r)();a.hasNext();){var l=a.next();n.merge(l)}return n},Yt.stream=function(r){var n=new Yt(null);return n.handleResolve(r),n},Yt.__super__=Mt,Yt.prototype=M(Mt.prototype,{then:function(r){var n=new Yt(null);return Mt.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(m){return m.async!=r._end_promise}),a=!0):n.push(d)}return this._update=n,a},first:function(){var r=new fe(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 Yt(null);return Mt.pipeLink(this,n,r),this._end_promise.then(function(a){n.end()}),n},errorPipe:function(r){var n=new Yt(null);return this.catchError(function(a){var l=r(a);l.then(Oe(n,n._resolve)),l._end_promise.then((qi=n._end_promise,Oe(qi,qi._resolve)))}),this.then(Oe(n,n._resolve)),this._end_promise.then(function(a){n.end()}),n},handleEnd:function(){if(this._pending)It.queue.add(Oe(this,this.handleEnd)),It.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=me.Some(this._val):r=me.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return It.queue.add(Oe(this,this.handleEnd)),It.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new Yt(null);return this._update.push({async:n,linkf:function(a){r(a)&&n.handleResolve(a)}}),Mt.immediateLinkUpdate(this,n,function(a){return a}),n},concat:function(r){var n=new Yt(null);return this._update.push({async:n,linkf:Oe(n,n.handleResolve)}),Mt.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 Yt(null);return this._update.push({async:n,linkf:Oe(n,n.handleResolve)}),r._update.push({async:n,linkf:Oe(n,n.handleResolve)}),Mt.immediateLinkUpdate(this,n,function(a){return a}),Mt.immediateLinkUpdate(r,n,function(a){return a}),n},__class__:Yt});var Lr=f.promhx.PublicStream=function(r){Yt.call(this,r)};x["promhx.PublicStream"]=Lr,Lr.__name__=["promhx","PublicStream"],Lr.publicstream=function(r){var n=new Lr(null);return n.handleResolve(r),n},Lr.__super__=Yt,Lr.prototype=M(Yt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Lr});var It=function(){};x["promhx.base.EventLoop"]=It,It.__name__=["promhx","base","EventLoop"],It.enqueue=function(r){It.queue.add(r),It.continueOnNextLoop()},It.set_nextLoop=function(r){if(It.nextLoop!=null)throw new Q("nextLoop has already been set");return It.nextLoop=r,It.nextLoop},It.queueEmpty=function(){return It.queue.isEmpty()},It.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=It.queue.pop())!=null;)n();return It.queue.isEmpty()},It.clear=function(){It.queue=new D},It.f=function(){var r=It.queue.pop();r!=null&&r(),It.queue.isEmpty()||It.continueOnNextLoop()},It.continueOnNextLoop=function(){It.nextLoop!=null?It.nextLoop(It.f):setImmediate(It.f)};var Sn=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};Sn.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=Sn,n.toString=E,n},Sn.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=Sn,n.toString=E,n};var Ws=function(){};x["verb.Verb"]=Ws,Ws.__name__=["verb","Verb"],Ws.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 m=a[d];if(++d,n(l,m)){u=!1;break}}u&&a.push(l)}return a};var Ft=function(){};x["verb.core.Binomial"]=Ft,Ft.__name__=["verb","core","Binomial"],Ft.get=function(r,n){if(n==0)return 1;if(r==0||n>r)return 0;if(n>r-n&&(n=r-n),Ft.memo_exists(r,n))return Ft.get_memo(r,n);for(var a=1,l=r,u=1,d=n+1;u<d;){var m=u++;if(Ft.memo_exists(l,m)){r--,a=Ft.get_memo(l,m);continue}a*=r--,a/=m,Ft.memoize(l,m,a)}return a},Ft.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},Ft.memo_exists=function(r,n){return Ft.memo.h.hasOwnProperty(r)&&Ft.memo.h[r].h.hasOwnProperty(n)},Ft.get_memo=function(r,n){return Ft.memo.h[r].h[n]},Ft.memoize=function(r,n,a){Ft.memo.h.hasOwnProperty(r)||Ft.memo.set(r,new wt),Ft.memo.h[r].h[n]=a};var Ce=f.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"]=Ce,Ce.__name__=["verb","core","BoundingBox"],Ce.intervalsOverlap=function(r,n,a,l,u){u==null&&(u=-1);var d;u<-.5?d=rt.TOLERANCE:d=u;var m=Math.min(r,n)-d,_=Math.max(r,n)+d,y=Math.min(a,l)-d,A=Math.max(a,l)+d;return m>=y&&m<=A||_>=y&&_<=A||y>=m&&y<=_||A>=m&&A<=_},Ce.prototype={fromPoint:function(r){return new Ce([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 Ce([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,m=0,_=this.dim;m<_;){var y=m++;if(!Ce.intervalsOverlap(a[y],l[y],u[y],d[y],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 m=[],_=[],y=0,A=this.dim;y<A;){var I=y++;m.push(Math.min(l[I],d[I])),_.push(Math.max(a[I],u[I]))}return new Ce([_,m])},__class__:Ce};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var Qt=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Qt,Qt.__name__=["verb","core","SerializableBase"],Qt.prototype={serialize:function(){var r=new Xt;return r.serialize(this),r.toString()},__class__:Qt};var Yn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=Yn,Yn.__name__=["verb","core","Plane"],Yn.__super__=Qt,Yn.prototype=M(Qt.prototype,{__class__:Yn});var In=f.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=In,In.__name__=["verb","core","Ray"],In.__super__=Qt,In.prototype=M(Qt.prototype,{__class__:In});var jt=f.core.NurbsCurveData=function(r,n,a){this.degree=r,this.controlPoints=a,this.knots=n};x["verb.core.NurbsCurveData"]=jt,jt.__name__=["verb","core","NurbsCurveData"],jt.__super__=Qt,jt.prototype=M(Qt.prototype,{__class__:jt});var ee=f.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"]=ee,ee.__name__=["verb","core","NurbsSurfaceData"],ee.__super__=Qt,ee.prototype=M(Qt.prototype,{__class__:ee});var Xe=f.core.MeshData=function(r,n,a,l){this.faces=r,this.points=n,this.normals=a,this.uvs=l};x["verb.core.MeshData"]=Xe,Xe.__name__=["verb","core","MeshData"],Xe.empty=function(){return new Xe([],[],[],[])},Xe.__super__=Qt,Xe.prototype=M(Qt.prototype,{__class__:Xe});var qn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=qn,qn.__name__=["verb","core","PolylineData"],qn.__super__=Qt,qn.prototype=M(Qt.prototype,{__class__:qn});var Xn=f.core.VolumeData=function(r,n,a,l,u,d,m){this.degreeU=r,this.degreeV=n,this.degreeW=a,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=m};x["verb.core.VolumeData"]=Xn,Xn.__name__=["verb","core","VolumeData"],Xn.__super__=Qt,Xn.prototype=M(Qt.prototype,{__class__:Xn});var re=f.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=re,re.__name__=["verb","core","Pair"],re.prototype={__class__:re};var Ee=f.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=Ee,Ee.__name__=["verb","core","Interval"],Ee.prototype={__class__:Ee};var Qr=f.core.CurveCurveIntersection=function(r,n,a,l){this.point0=r,this.point1=n,this.u0=a,this.u1=l};x["verb.core.CurveCurveIntersection"]=Qr,Qr.__name__=["verb","core","CurveCurveIntersection"],Qr.prototype={__class__:Qr};var Kn=f.core.CurveSurfaceIntersection=function(r,n,a,l){this.u=r,this.uv=n,this.curvePoint=a,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=Kn,Kn.__name__=["verb","core","CurveSurfaceIntersection"],Kn.prototype={__class__:Kn};var Or=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};x["verb.core.MeshIntersectionPoint"]=Or,Or.__name__=["verb","core","MeshIntersectionPoint"],Or.prototype={__class__:Or};var $n=f.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"]=$n,$n.__name__=["verb","core","PolylineMeshIntersection"],$n.prototype={__class__:$n};var Zn=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,a,l){this.uv0=r,this.uv1=n,this.point=a,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=Zn,Zn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Zn.prototype={__class__:Zn};var Qn=f.core.TriSegmentIntersection=function(r,n,a,l){this.point=r,this.s=n,this.t=a,this.p=l};x["verb.core.TriSegmentIntersection"]=Qn,Qn.__name__=["verb","core","TriSegmentIntersection"],Qn.prototype={__class__:Qn};var Pn=f.core.CurveTriPoint=function(r,n,a){this.u=r,this.point=n,this.uv=a};x["verb.core.CurveTriPoint"]=Pn,Pn.__name__=["verb","core","CurveTriPoint"],Pn.prototype={__class__:Pn};var He=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"]=He,He.__name__=["verb","core","SurfacePoint"],He.fromUv=function(r,n){return new He(null,null,[r,n])},He.prototype={__class__:He};var Hs=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=Hs,Hs.__name__=["verb","core","CurvePoint"],Hs.prototype={__class__:Hs};var Jn=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)};x["verb.core.KdTree"]=Jn,Jn.__name__=["verb","core","KdTree"],Jn.prototype={buildTree:function(r,n,a){var l=n%this.dim,u,d;return r.length==0?null:r.length==1?new kn(r[0],l,a):(r.sort(function(m,_){var y=m.point[l]-_.point[l];return y==0?0:y>0?1:-1}),u=Math.floor(r.length/2),d=new kn(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 ts(function(S){return-S.item1}),d,m=null;m=function(S){for(var P,k=S.dimension,T=l.distanceFunction(r,S.kdPoint.point),O,C=[],R=0,z=l.dim;R<z;)R++,C.push(0);O=C;for(var U,V,q=function(K,tt){u.push(new re(K,tt)),u.size()>n&&u.pop()},J=0,H=l.dim;J<H;){var G=J++;G==S.dimension?O[G]=r[G]:O[G]=S.kdPoint.point[G]}if(U=l.distanceFunction(O,S.kdPoint.point),S.right==null&&S.left==null){(u.size()<n||T<u.peek().item1)&&q(S,T);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,m(P),(u.size()<n||T<u.peek().item1)&&q(S,T),(u.size()<n||Math.abs(U)<u.peek().item1)&&(P==S.left?V=S.right:V=S.left,V!=null&&m(V))},d=m;for(var _=0;_<n;)_++,u.push(new re(null,a));d(this.root);for(var y=[],A=0;A<n;){var I=A++;u.content[I].item0!=null&&y.push(new re(u.content[I].item0.kdPoint,u.content[I].item1))}return y},__class__:Jn};var ts=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=ts,ts.__name__=["verb","core","BinaryHeap"],ts.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,m=-1,_=0;if(d<n){var y=this.content[d];_=this.scoreFunction(y),_<l&&(m=d)}if(u<n){var A=this.content[u],I=this.scoreFunction(A);I<(m==-1?l:_)&&(m=u)}if(m!=-1)this.content[r]=this.content[m],this.content[m]=a,r=m;else break}},__class__:ts};var En=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=En,En.__name__=["verb","core","KdPoint"],En.prototype={__class__:En};var kn=f.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"]=kn,kn.__name__=["verb","core","KdNode"],kn.prototype={__class__:kn};var dr=function(){};x["verb.eval.IBoundingBoxTree"]=dr,dr.__name__=["verb","eval","IBoundingBoxTree"],dr.prototype={__class__:dr};var ar=function(r,n){this._boundingBox=null,this._curve=r,n==null&&(n=p.domain(this._curve.knots)/64),this._knotTol=n};x["verb.core.LazyCurveBoundingBoxTree"]=ar,ar.__name__=["verb","core","LazyCurveBoundingBoxTree"],ar.__interfaces__=[dr],ar.prototype={split:function(){var r=$.first(this._curve.knots),n=$.last(this._curve.knots),a=n-r,l=he.curveSplit(this._curve,(n+r)/2+a*.1*Math.random());return new re(new ar(l[0],this._knotTol),new ar(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ce(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return p.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:ar};var or=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"]=or,or.__name__=["verb","core","LazyMeshBoundingBoxTree"],or.__interfaces__=[dr],or.prototype={split:function(){var r=ne.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=$.left(r),a=$.right(r);return new re(new or(this._mesh,n),new or(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=ne.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__:or};var lr=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new Ee(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=lr,lr.__name__=["verb","core","LazyPolylineBoundingBoxTree"],lr.__interfaces__=[dr],lr.prototype={split:function(){var r=this._interval.min,n=this._interval.max,a=r+Math.ceil((n-r)/2),l=new Ee(r,a),u=new Ee(a,n);return new re(new lr(this._polyline,l),new lr(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ce(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__:lr};var Br=function(r,n,a,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,a==null&&(a=p.domain(r.knotsU)/16),l==null&&(l=p.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Br,Br.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Br.__interfaces__=[dr],Br.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=he.surfaceSplit(this._surface,a,this._splitV);return new re(new Br(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Br(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Ce;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 p.domain(this._surface.knotsV)<this._knotTolV&&p.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Br};var Ot=f.core.Mat=function(){};x["verb.core.Mat"]=Ot,Ot.__name__=["verb","core","Mat"],Ot.mul=function(r,n){for(var a=[],l=0,u=n.length;l<u;){var d=l++;a.push(p.mul(r,n[d]))}return a},Ot.mult=function(r,n){var a,l,u,d,m,_,y,A;a=r.length,l=n.length,u=n[0].length,d=[];for(var I=a-1,S=0,P=0;I>=0;){for(m=[],_=r[I],P=u-1;P>=0;){for(y=_[l-1]*n[l-1][P],S=l-2;S>=1;)A=S-1,y+=_[S]*n[S][P]+_[A]*n[A][P],S-=2;S==0&&(y+=_[0]*n[0][P]),m[P]=y,P--}d[I]=m,I--}return d},Ot.add=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.add(r[d],n[d]))}return a},Ot.div=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.div(r[d],n))}return a},Ot.sub=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.sub(r[d],n[d]))}return a},Ot.dot=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.dot(r[d],n))}return a},Ot.identity=function(r){for(var n=p.zeros2d(r,r),a=0;a<r;){var l=a++;n[l][l]=1}return n},Ot.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 m,_=[],y=0,A=r.length;y<A;){var I=y++;_.push(r[I][u])}return m=_,m}())}return n},Ot.solve=function(r,n){return Ot.LUsolve(Ot.LU(r),n)},Ot.LUsolve=function(r,n){var a,l,u=r.LU,d=u.length,m=n.slice(),_=r.P,y,A,I;for(a=d-1;a!=-1;)m[a]=n[a],--a;for(a=0;a<d;){for(y=_[a],_[a]!=a&&(I=m[a],m[a]=m[y],m[y]=I),A=u[a],l=0;l<a;)m[a]-=m[l]*A[l],++l;++a}for(a=d-1;a>=0;){for(A=u[a],l=a+1;l<d;)m[a]-=m[l]*A[l],++l;m[a]/=A[a],--a}return m},Ot.LU=function(r){for(var n,a,l,u,d,m,_,y,A,I=[],S=0,P=r.length;S<P;){var k=S++;I.push(r[k].slice())}r=I;var T=r.length,O=T-1,C=[];for(l=0;l<T;){for(_=l,m=r[l],A=Math.abs(m[l]),a=l+1;a<T;)u=Math.abs(r[a][l]),A<u&&(A=u,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=m,m=r[l]),d=m[l],n=l+1;n<T;)r[n][l]/=d,++n;for(n=l+1;n<T;){for(y=r[n],a=l+1;a<O;)y[a]-=y[l]*m[a],++a,y[a]-=y[l]*m[a],++a;a==O&&(y[a]-=y[l]*m[a]),++n}++l}return new es(r,C)};var es=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=es,es.__name__=["verb","core","_Mat","LUDecomp"],es.prototype={__class__:es};var ne=f.core.Mesh=function(){};x["verb.core.Mesh"]=ne,ne.__name__=["verb","core","Mesh"],ne.getTriangleNorm=function(r,n){var a=r[n[0]],l=r[n[1]],u=r[n[2]],d=p.sub(l,a),m=p.sub(u,a),_=p.cross(d,m);return p.mul(1/p.norm(_),_)},ne.makeMeshAabb=function(r,n){for(var a=new Ce,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},ne.sortTrianglesOnLongestAxis=function(r,n,a){for(var l=r.getLongestAxis(),u=[],d=0;d<a.length;){var m=a[d];++d;var _=ne.getMinCoordOnAxis(n.points,n.faces[m],l);u.push(new re(_,m))}u.sort(function(P,k){var T=P.item0,O=k.item0;return T==O?0:T>O?1:-1});for(var y=[],A=0,I=u.length;A<I;){var S=A++;y.push(u[S].item1)}return y},ne.getMinCoordOnAxis=function(r,n,a){for(var l=1/0,u=0;u<3;){var d=u++,m=r[n[d]][a];m<l&&(l=m)}return l},ne.getTriangleCentroid=function(r,n){for(var a=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var m=d++;a[m]+=r[n[u]][m]}for(var _=0;_<3;){var y=_++;a[y]/=3}return a},ne.triangleUVFromPoint=function(r,n,a){var l=r.faces[n],u=r.points[l[0]],d=r.points[l[1]],m=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],A=r.uvs[l[2]],I=p.sub(u,a),S=p.sub(d,a),P=p.sub(m,a),k=p.norm(p.cross(p.sub(u,d),p.sub(u,m))),T=p.norm(p.cross(S,P))/k,O=p.norm(p.cross(P,I))/k,C=p.norm(p.cross(I,S))/k;return p.add(p.mul(T,_),p.add(p.mul(O,y),p.mul(C,A)))};var zr=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=ne.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var m=ne.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=$.left(m),y=$.right(m);this._children=new re(new zr(r,_),new zr(r,y))};x["verb.core.MeshBoundingBoxTree"]=zr,zr.__name__=["verb","core","MeshBoundingBoxTree"],zr.__interfaces__=[dr],zr.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__:zr};var Ke=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=Ke,Ke.__name__=["verb","core","Minimizer"],Ke.uncmin=function(r,n,a,l,u){a==null&&(a=1e-8),l==null&&(l=function(J){return Ke.numericalGradient(r,J)}),u==null&&(u=1e3),n=n.slice(0);var d=n.length,m=r(n),_=m,y;if(isNaN(m))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,rt.EPSILON);var A,I,S,P=Ot.identity(d),k=0,T=[],O,C,R,z,U,V,q="";for(I=l(n);k<u;){if(!p.all(p.finite(I))){q="Gradient has Infinity or NaN";break}if(A=p.neg(Ot.dot(P,I)),!p.all(p.finite(A))){q="Search direction has Infinity or NaN";break}if(V=p.norm(A),V<a){q="Newton step smaller than tol";break}for(U=1,y=p.dot(I,A),O=n;k<u&&!(U*V<a);){if(T=p.mul(U,A),O=p.add(n,T),_=r(O),_-m>=.1*U*y||isNaN(_)){U*=.5,++k;continue}break}if(U*V<a){q="Line search step size smaller than tol";break}if(k==u){q="maxit reached during line search";break}S=l(O),C=p.sub(S,I),z=p.dot(C,T),R=Ot.dot(P,C),P=Ot.sub(Ot.add(P,Ot.mul((z+p.dot(C,R))/(z*z),Ke.tensor(T,T))),Ot.div(Ot.add(Ke.tensor(R,T),Ke.tensor(T,R)),z)),n=O,m=_,I=S,++k}return new rs(n,m,I,P,k,q)},Ke.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,m,_=[],y,A=.001,I,S,P,k=0,T,O,C,R=0;R<a;)for(var z=R++,U=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(u[z]=n[z]+U,d=r(u),u[z]=n[z]-U,m=r(u),u[z]=n[z],isNaN(d)||isNaN(m)){U/=16;continue}if(_[z]=(d-m)/(2*U),I=n[z]-U,S=n[z],P=n[z]+U,T=(d-l)/U,O=(l-m)/U,C=p.max([Math.abs(_[z]),Math.abs(l),Math.abs(d),Math.abs(m),Math.abs(I),Math.abs(S),Math.abs(P),1e-8]),y=Math.min(p.max([Math.abs(T-_[z]),Math.abs(O-_[z]),Math.abs(T-O)])/C,U/C),y>A)U/=16;else break}return _},Ke.tensor=function(r,n){for(var a=r.length,l=n.length,u=[],d,m,_=a-1;_>=0;){d=[],m=r[_];for(var y=l-1;y>=3;)d[y]=m*n[y],--y,d[y]=m*n[y],--y,d[y]=m*n[y],--y,d[y]=m*n[y],--y;for(;y>=0;)d[y]=m*n[y],--y;u[_]=d,_--}return u};var rs=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"]=rs,rs.__name__=["verb","core","MinimizationResult"],rs.prototype={__class__:rs};var Mn=function(){};x["verb.core.ISerializable"]=Mn,Mn.__name__=["verb","core","ISerializable"],Mn.prototype={__class__:Mn};var Yi=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Yi,Yi.__name__=["verb","core","Deserializer"],Yi.deserialize=function(r){var n=new Ht(r),a=n.unserialize();return a};var Le=f.core.Trig=function(){};x["verb.core.Trig"]=Le,Le.__name__=["verb","core","Trig"],Le.isPointInPlane=function(r,n,a){return Math.abs(p.dot(p.sub(r,n.origin),n.normal))<a},Le.distToSegment=function(r,n,a){var l=Le.segmentClosestPoint(n,r,a,0,1);return p.dist(n,l.pt)},Le.rayClosestPoint=function(r,n,a){var l=p.sub(r,n),u=p.dot(l,a),d=p.add(n,p.mul(u,a));return d},Le.distToRay=function(r,n,a){var l=Le.rayClosestPoint(r,n,a),u=p.sub(l,r);return p.norm(u)},Le.threePointsAreFlat=function(r,n,a,l){var u=p.sub(n,r),d=p.sub(a,r),m=p.cross(u,d),_=p.dot(m,m);return _<l},Le.segmentClosestPoint=function(r,n,a,l,u){var d=p.sub(a,n),m=p.norm(d);if(m<rt.EPSILON)return{u:l,pt:n};var _=n,y=p.mul(1/m,d),A=p.sub(r,_),I=p.dot(A,y);return I<0?{u:l,pt:n}:I>m?{u,pt:a}:{u:l+(u-l)*I/m,pt:p.add(_,p.mul(I,y))}};var p=f.core.Vec=function(){};x["verb.core.Vec"]=p,p.__name__=["verb","core","Vec"],p.angleBetween=function(r,n){return Math.acos(p.dot(r,n)/(p.norm(r)*p.norm(n)))},p.positiveAngleBetween=function(r,n,a){var l=p.cross(r,n),u=p.norm(r),d=p.norm(n),m=u*d,_=p.dot(r,n),y=p.norm(l)/m,A=_/m,I=Math.atan2(y,A),S=p.dot(a,l);return Math.abs(S)<rt.EPSILON||S>0?I:-I},p.signedAngleBetween=function(r,n,a){var l=p.cross(r,n),u=p.norm(r),d=p.norm(n),m=u*d,_=p.dot(r,n),y=p.norm(l)/m,A=_/m,I=Math.atan2(y,A),S=p.dot(a,l);return S>0?I:2*Math.PI-I},p.angleBetweenNormalized2d=function(r,n){var a=r[0]*n[1]-r[1]*n[0];return Math.atan2(a,p.dot(r,n))},p.domain=function(r){return $.last(r)-$.first(r)},p.range=function(r){for(var n=[],a=0,l=0;l<r;)l++,n.push(a),a+=1;return n},p.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},p.neg=function(r){return r.map(function(n){return-n})},p.min=function(r){return B.fold(r,function(n,a){return Math.min(n,a)},1/0)},p.max=function(r){return B.fold(r,function(n,a){return Math.max(n,a)},-1/0)},p.all=function(r){return B.fold(r,function(n,a){return a&&n},!0)},p.finite=function(r){return r.map(function(n){return isFinite(n)})},p.onRay=function(r,n,a){return p.add(r,p.mul(a,n))},p.lerp=function(r,n,a){return p.add(p.mul(r,n),p.mul(1-r,a))},p.normalized=function(r){return p.div(r,p.norm(r))},p.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]]},p.dist=function(r,n){return p.norm(p.sub(r,n))},p.distSquared=function(r,n){return p.normSquared(p.sub(r,n))},p.sum=function(r){return B.fold(r,function(n,a){return a+n},0)},p.addAll=function(r){var n=$e(r)();if(!n.hasNext())return null;var a=n.next().length;return B.fold(r,function(l,u){return p.add(u,l)},p.rep(a,0))},p.addAllMutate=function(r){for(var n=r[0],a=1,l=r.length;a<l;){var u=a++;p.addMutate(n,r[u])}},p.addMulMutate=function(r,n,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+n*a[d]}},p.subMulMutate=function(r,n,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-n*a[d]}},p.addMutate=function(r,n){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]+n[u]}},p.subMutate=function(r,n){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]-n[u]}},p.mulMutate=function(r,n){for(var a=0,l=n.length;a<l;){var u=a++;n[u]=n[u]*r}},p.norm=function(r){var n=p.normSquared(r);return n!=0?Math.sqrt(n):n},p.normSquared=function(r){return B.fold(r,function(n,a){return a+n*n},0)},p.rep=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(n);return a},p.zeros1d=function(r){for(var n=[],a=0;a<r;)a++,n.push(0);return n},p.zeros2d=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(p.zeros1d(n));return a},p.zeros3d=function(r,n,a){for(var l=[],u=0;u<r;)u++,l.push(p.zeros2d(n,a));return l},p.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},p.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},p.mul=function(r,n){for(var a=[],l=0,u=n.length;l<u;){var d=l++;a.push(r*n[d])}return a},p.div=function(r,n){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]/n)}return a},p.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},p.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},p.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},p.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 bt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=bt,bt.__name__=["verb","eval","Analyze"],bt.knotMultiplicities=function(r){for(var n=[new Tn(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 Tn(u,0),n.push(a)),a.inc()}return n},bt.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var a;n?a=r.controlPoints:a=Ot.transpose(r.controlPoints);for(var l=0,u=a[0].length;l<u;){var d=l++,m=p.dist($.first(a)[d],$.last(a)[d])<rt.EPSILON;if(!m)return!1}return!0},bt.rationalSurfaceClosestPoint=function(r,n){var a=bt.rationalSurfaceClosestParam(r,n);return N.rationalSurfacePoint(r,a[0],a[1])},bt.rationalSurfaceClosestParam=function(r,n){for(var a=5,l=0,u,d=1e-4,m=5e-4,_,y=r.knotsU[0],A=$.last(r.knotsU),I=r.knotsV[0],S=$.last(r.knotsV),P=bt.isRationalSurfaceClosed(r),k=bt.isRationalSurfaceClosed(r,!1),T,O=zt.rationalSurfaceAdaptive(r,new Rr),C=1/0,R=0,z=O.points.length;R<z;){var U=R++,V=O.points[U],q=p.normSquared(p.sub(n,V));q<C&&(C=q,T=O.uvs[U])}for(var J=function(Wt){return N.rationalSurfaceDerivatives(r,Wt[0],Wt[1],2)},H=function(Wt,Kt,Ut){var $t=Kt[1][0],ke=Kt[0][1],qe=Kt[2][0],be=Kt[0][2],_e=Kt[1][1],Me=Kt[1][1],Be=p.dot($t,Ut),Ze=p.dot(ke,Ut),hr=[-Be,-Ze],Qe=p.dot($t,$t)+p.dot(qe,Ut),Je=p.dot($t,ke)+p.dot(_e,Ut),tr=p.dot($t,ke)+p.dot(Me,Ut),mr=p.dot(ke,ke)+p.dot(be,Ut),On=[[Qe,Je],[tr,mr]],tn=Ot.solve(On,hr);return p.add(tn,Wt)};l<a;){u=J(T),_=p.sub(u[0][0],n);var G=p.norm(_),K=p.dot(u[1][0],_),tt=p.norm(u[1][0])*G,et=p.dot(u[0][1],_),it=p.norm(u[0][1])*G,ht=K/tt,at=et/it,ct=G<d,nt=ht<m,pt=at<m;if(ct&&nt&&pt)return T;var X=H(T,u,_);X[0]<y?P?X=[A-(X[0]-y),X[1]]:X=[y+rt.EPSILON,X[1]]:X[0]>A&&(P?X=[y+(X[0]-A),X[1]]:X=[A-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 ft=p.norm(p.mul(X[0]-T[0],u[1][0])),Pt=p.norm(p.mul(X[1]-T[1],u[0][1]));if(ft+Pt<d)return T;T=X,l++}return T},bt.rationalCurveClosestPoint=function(r,n){return N.rationalCurvePoint(r,bt.rationalCurveClosestParam(r,n))},bt.rationalCurveClosestParam=function(r,n){for(var a=1/0,l=0,u=zt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,m=u.length-1;d<m;){var _=d++,y=u[_][0],A=u[_+1][0],I=u[_].slice(1),S=u[_+1].slice(1),P=Le.segmentClosestPoint(n,I,S,y,A),k=p.norm(p.sub(n,P.pt));k<a&&(a=k,l=P.u)}for(var T=5,O=0,C,R=1e-4,z=5e-4,U,V=r.knots[0],q=$.last(r.knots),J=p.normSquared(p.sub(r.controlPoints[0],$.last(r.controlPoints)))<rt.EPSILON,H=l,G=function(X){return N.rationalCurveDerivatives(r,X,2)},K=function(X,ft,Pt){var Wt=p.dot(ft[1],Pt),Kt=p.dot(ft[2],Pt),Ut=p.dot(ft[1],ft[1]),$t=Kt+Ut;return X-Wt/$t};O<T;){C=G(H),U=p.sub(C[0],n);var tt=p.norm(U),et=p.dot(C[1],U),it=p.norm(C[1])*tt,ht=et/it,at=tt<R,ct=Math.abs(ht)<z;if(at&&ct)return H;var nt=K(H,C,U);nt<V?J?nt=q-(nt-V):nt=V:nt>q&&(J?nt=V+(nt-q):nt=q);var pt=p.norm(p.mul(nt-H,C[1]));if(pt<R)return H;H=nt,O++}return H},bt.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=_t.decomposeCurveIntoBeziers(r);var m=0;d[m];var _=-rt.EPSILON,y;for(u!=null?y=u:y=[];_<n&&m<d.length;){if(m<y.length?y[m]=y[m]:y[m]=bt.rationalBezierCurveArcLength(r),_+=y[m],n<_+rt.EPSILON)return bt.rationalBezierCurveParamAtArcLength(r,n,a,y[m]);m++}return-1},bt.rationalBezierCurveParamAtArcLength=function(r,n,a,l){if(n<0)return r.knots[0];var u;if(l!=null?u=l:u=bt.rationalBezierCurveArcLength(r),n>u)return $.last(r.knots);var d=r.knots[0],m=0,_=$.last(r.knots),y=u,A=0,I=0,S;for(a!=null?S=a:S=rt.TOLERANCE*2;y-m>S;)A=(d+_)/2,I=bt.rationalBezierCurveArcLength(r,A),I>n?(_=A,y=I):(d=A,m=I);return(d+_)/2},bt.rationalCurveArcLength=function(r,n,a){a==null&&(a=16),n==null?n=$.last(r.knots):n=n;for(var l=_t.decomposeCurveIntoBeziers(r),u=0,d=l[0],m=0;u<l.length&&d.knots[0]+rt.EPSILON<n;){var _=Math.min($.last(d.knots),n);m+=bt.rationalBezierCurveArcLength(d,_,a),d=l[++u]}return m},bt.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,m=r.degree+a,_,y,A=0;A<m;){var I=A++;_=u*bt.Tvalues[m][I]+u+r.knots[0],y=N.rationalCurveDerivatives(r,_,1),d+=bt.Cvalues[m][I]*p.norm(y[1])}return u*d};var Tn=f.eval.KnotMultiplicity=function(r,n){this.knot=r,this.mult=n};x["verb.eval.KnotMultiplicity"]=Tn,Tn.__name__=["verb","eval","KnotMultiplicity"],Tn.prototype={inc:function(){this.mult++},__class__:Tn};var Ye=f.eval.Check=function(){};x["verb.eval.Check"]=Ye,Ye.__name__=["verb","eval","Check"],Ye.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 m=r.length-n-1,_=r.length;m<_;){var y=m++;if(Math.abs(r[y]-a)>rt.EPSILON)return!1}return Ye.isNonDecreasing(r)},Ye.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},Ye.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(!Ye.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},Ye.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(!Ye.isValidKnotVector(r.knotsU,r.degreeU)||!Ye.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 he=f.eval.Divide=function(){};x["verb.eval.Divide"]=he,he.__name__=["verb","eval","Divide"],he.surfaceSplit=function(r,n,a){a==null&&(a=!1);var l,u,d;a?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Ot.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var m,_=[],y=0,A=u+1;y<A;)y++,_.push(n);m=_;for(var I=[],S=[],P=N.knotSpan(u,n,l),k=null,T=0;T<d.length;){var O=d[T];++T,k=_t.curveKnotRefine(new jt(u,l,O),m),I.push(k.controlPoints.slice(0,P+1)),S.push(k.controlPoints.slice(P+1))}var C=k.knots.slice(0,P+u+2),R=k.knots.slice(P+1);return a?[new ee(r.degreeU,u,r.knotsU.slice(),C,I),new ee(r.degreeU,u,r.knotsU.slice(),R,S)]:(I=Ot.transpose(I),S=Ot.transpose(S),[new ee(u,r.degreeV,C,r.knotsV.slice(),I),new ee(u,r.degreeV,R,r.knotsV.slice(),S)])},he.curveSplit=function(r,n){var a=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],m=0,_=a+1;m<_;)m++,d.push(n);u=d;var y=_t.curveKnotRefine(r,u),A=N.knotSpan(a,n,l),I=y.knots.slice(0,A+a+2),S=y.knots.slice(A+1),P=y.controlPoints.slice(0,A+1),k=y.controlPoints.slice(A+1);return[new jt(a,I,P),new jt(a,S,k)]},he.rationalCurveByEqualArcLength=function(r,n){var a=bt.rationalCurveArcLength(r),l=a/n;return he.rationalCurveByArcLength(r,l)},he.rationalCurveByArcLength=function(r,n){var a=_t.decomposeCurveIntoBeziers(r),l=a.map(function(P){return bt.rationalBezierCurveArcLength(P)}),u=p.sum(l),d=[new Nn(r.knots[0],0)];if(n>u)return d;for(var m=n,_=0,y=m,A=0,I=0,S;_<a.length;){for(A+=l[_];y<A+rt.EPSILON;)S=bt.rationalBezierCurveParamAtArcLength(a[_],y-I,rt.TOLERANCE,l[_]),d.push(new Nn(S,y)),y+=m;I+=l[_],_++}return d};var Nn=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=Nn,Nn.__name__=["verb","eval","CurveLengthSample"],Nn.prototype={__class__:Nn};var N=f.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 p.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),m=N.weight2d(u),_=[],y=d[0][0].length,A=0,I=l+1;A<I;){var S=A++;_.push([]);for(var P=0,k=l-S+1;P<k;){for(var T=P++,O=d[S][T],C=1,R=T+1;C<R;){var z=C++;p.subMulMutate(O,Ft.get(T,z)*m[0][z],_[S][T-z])}for(var U=1,V=S+1;U<V;){var q=U++;p.subMulMutate(O,Ft.get(S,q)*m[q][0],_[S-q][T]);for(var J=p.zeros1d(y),H=1,G=T+1;H<G;){var K=H++;p.addMulMutate(J,Ft.get(T,K)*m[q][K],_[S-q][T-K])}p.subMulMutate(O,Ft.get(S,q),J)}p.mulMutate(1/m[0][0],O),_[S].push(O)}}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),m=[],_=0,y=a+1;_<y;){for(var A=_++,I=u[A],S=1,P=A+1;S<P;){var k=S++;p.subMulMutate(I,Ft.get(A,k)*d[k],m[A-k])}p.mulMutate(1/d[0],I),m.push(I)}return m},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 m=a.degreeU,_=a.degreeV,y=a.controlPoints,A=a.knotsU,I=a.knotsV;if(!N.areValidRelations(m,y.length,A.length)||!N.areValidRelations(_,y[0].length,I.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=y[0][0].length,P;d<m?P=d:P=m;var k;d<_?k=d:k=_;for(var T=p.zeros3d(d+1,d+1,S),O=N.knotSpanGivenN(r,m,l,A),C=N.knotSpanGivenN(n,_,u,I),R=N.derivativeBasisFunctionsGivenNI(O,l,m,r,A),z=N.derivativeBasisFunctionsGivenNI(C,u,_,n,I),U=p.zeros2d(_+1,S),V=0,q=0,J=P+1;q<J;){for(var H=q++,G=0,K=_+1;G<K;){var tt=G++;U[tt]=p.zeros1d(S);for(var et=0,it=m+1;et<it;){var ht=et++;p.addMulMutate(U[tt],R[H][ht],y[O-m+ht][C-_+tt])}}var at=d-H;at<k?V=at:V=k;for(var ct=0,nt=V+1;ct<nt;){var pt=ct++;T[H][pt]=p.zeros1d(S);for(var X=0,ft=_+1;X<ft;){var Pt=X++;p.addMulMutate(T[H][pt],z[pt][Pt],U[Pt])}}}return T},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,m=a.degreeV,_=a.controlPoints,y=a.knotsU,A=a.knotsV;if(!N.areValidRelations(d,_.length,y.length)||!N.areValidRelations(m,_[0].length,A.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,y),P=N.knotSpanGivenN(n,m,u,A),k=N.basisFunctionsGivenKnotSpanIndex(S,l,d,y),T=N.basisFunctionsGivenKnotSpanIndex(P,u,m,A),O=S-d,C=P,R=p.zeros1d(I),z=p.zeros1d(I),U=0,V=m+1;U<V;){var q=U++;z=p.zeros1d(I),C=P-m+q;for(var J=0,H=d+1;J<H;){var G=J++;p.addMulMutate(z,k[G],_[O+G][C])}p.addMulMutate(R,T[q],z)}return R},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],m=p.mul(l,a[1]),_=p.mul(u*.5,a[2]),y=p.mul(u*l*.5,a[3]),A=p.add(_,_),I=p.add(y,y),S=p.mul(.3333333333333333,y),P=[],k=0,T=n+1;k<T;)k++,P.push(N.dehomogenize(d)),p.addAllMutate([d,m,_,S]),p.addAllMutate([m,A,y]),p.addAllMutate([A,I]),p.addAllMutate([_,y]);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],m=p.mul(l,a[1]),_=p.mul(u*.5,a[2]),y=p.mul(u*l*.5,a[3]),A=p.add(_,_),I=p.add(y,y),S=p.mul(.3333333333333333,y),P=[],k=0,T=n+1;k<T;)k++,P.push(N.dehomogenize(d)),p.addAllMutate([d,m,_,S]),p.addAllMutate([m,A,y]),p.addAllMutate([A,I]),p.addAllMutate([_,y]);return P},N.rationalSurfaceRegularSampleDerivatives=function(r,n,a,l){for(var u=N.surfaceRegularSampleDerivatives(r,n,a,l),d=[],m=n+1,_=a+1,y=l+1,A=0;A<m;){var I=A++,S=[];d.push(S);for(var P=0;P<_;){for(var k=P++,T=u[I][k],O=N.rational2d(T),C=N.weight2d(T),R=[],z=O[0][0].length,U=0;U<y;){var V=U++;R.push([]);for(var q=0,J=y-V;q<J;){for(var H=q++,G=O[V][H],K=1,tt=H+1;K<tt;){var et=K++;p.subMulMutate(G,Ft.get(H,et)*C[0][et],R[V][H-et])}for(var it=1,ht=V+1;it<ht;){var at=it++;p.subMulMutate(G,Ft.get(V,at)*C[at][0],R[V-at][H]);for(var ct=p.zeros1d(z),nt=1,pt=H+1;nt<pt;){var X=nt++;p.addMulMutate(ct,Ft.get(H,X)*C[at][X],R[V-at][H-X])}p.subMulMutate(G,Ft.get(V,at),ct)}p.mulMutate(1/C[0][0],G),R[V].push(G)}}S.push(R)}}return d},N.surfaceRegularSampleDerivatives=function(r,n,a,l){var u=r.degreeU,d=r.degreeV,m=r.controlPoints,_=r.knotsU,y=r.knotsV,A=m[0][0].length;($.last(_)-_[0])/n,($.last(y)-y[0])/a;for(var I=N.regularlySpacedDerivativeBasisFunctions(u,_,n),S=I.item0,P=I.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,y,a),T=k.item0,O=k.item1,C=[],R=n+1,z=a+1,U=0;U<R;){var V=U++,q=[];C.push(q);for(var J=0;J<z;){var H=J++;q.push(N.surfaceDerivativesGivenBasesKnotSpans(u,d,m,S[V],T[H],P[V],O[H],A,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,m=r.knotsU,_=r.knotsV,y=d[0][0].length;($.last(m)-m[0])/n,($.last(_)-_[0])/a;for(var A=N.regularlySpacedBasisFunctions(l,m,n),I=A.item0,S=A.item1,P=N.regularlySpacedBasisFunctions(u,_,a),k=P.item0,T=P.item1,O=[],C=n+1,R=a+1,z=0;z<C;){var U=z++,V=[];O.push(V);for(var q=0;q<R;){var J=q++;V.push(N.surfacePointGivenBasesKnotSpans(l,u,d,I[U],k[J],S[U],T[J],y))}}return O},N.regularlySpacedBasisFunctions=function(r,n,a){for(var l=n.length-r-2,u=($.last(n)-n[0])/a,d=[],m=[],_=n[0],y=N.knotSpanGivenN(l,r,_,n),A=a+1,I=0;I<A;){for(I++;_>=n[y+1];)y++;m.push(y),d.push(N.basisFunctionsGivenKnotSpanIndex(y,_,r,n)),_+=u}return new re(m,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,n,a){for(var l=n.length-r-2,u=($.last(n)-n[0])/a,d=[],m=[],_=n[0],y=N.knotSpanGivenN(l,r,_,n),A=a+1,I=0;I<A;){for(I++;_>=n[y+1];)y++;m.push(y),d.push(N.derivativeBasisFunctionsGivenNI(y,_,r,l,n)),_+=u}return new re(m,d)},N.surfacePointGivenBasesKnotSpans=function(r,n,a,l,u,d,m,_){for(var y=p.zeros1d(_),A,I=l-r,S=u-n,P=0,k=n+1;P<k;){var T=P++;A=p.zeros1d(_);for(var O=0,C=r+1;O<C;){var R=O++;p.addMulMutate(A,d[R],a[I+R][S])}S++,p.addMulMutate(y,m[T],A)}return y},N.surfaceDerivativesGivenBasesKnotSpans=function(r,n,a,l,u,d,m,_,y){var A=a[0][0].length,I;y<r?I=y:I=r;var S;y<n?S=y:S=n;for(var P=p.zeros3d(I+1,S+1,A),k=p.zeros2d(n+1,A),T=0,O=0,C=I+1;O<C;){for(var R=O++,z=0,U=n+1;z<U;){var V=z++;k[V]=p.zeros1d(A);for(var q=0,J=r+1;q<J;){var H=q++;p.addMulMutate(k[V],d[R][H],a[l-r+H][u-n+V])}}var G=y-R;G<S?T=G:T=S;for(var K=0,tt=T+1;K<tt;){var et=K++;P[R][et]=p.zeros1d(A);for(var it=0,ht=n+1;it<ht;){var at=it++;p.addMulMutate(P[R][et],m[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,m=n.knots;if(!N.areValidRelations(u,d.length,m.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<u?y=l:y=u;for(var A=p.zeros2d(l+1,_),I=N.knotSpanGivenN(r,u,a,m),S=N.derivativeBasisFunctionsGivenNI(I,a,u,y,m),P=0,k=y+1;P<k;)for(var T=P++,O=0,C=u+1;O<C;){var R=O++;p.addMulMutate(A[T],S[T][R],d[I-u+R])}return A},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 m=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(m,a,l,d),y=p.zeros1d(u[0].length),A=0,I=l+1;A<I;){var S=A++;p.addMulMutate(y,_[S],u[m-l+S])}return y},N.volumePoint=function(r,n,a,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,m=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,u,d,m,n,a,l)},N.volumePointGivenNML=function(r,n,a,l,u,d,m){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,y=r.degreeU,A=r.degreeV,I=r.degreeW,S=r.knotsU,P=r.knotsV,k=r.knotsW,T=_[0][0][0].length,O=N.knotSpanGivenN(n,y,u,S),C=N.knotSpanGivenN(a,A,d,P),R=N.knotSpanGivenN(l,I,m,k),z=N.basisFunctionsGivenKnotSpanIndex(O,u,y,S),U=N.basisFunctionsGivenKnotSpanIndex(C,d,A,P),V=N.basisFunctionsGivenKnotSpanIndex(R,m,I,k),q=O-y,J=p.zeros1d(T),H=p.zeros1d(T),G=p.zeros1d(T),K=0,tt=I+1;K<tt;){var et=K++;G=p.zeros1d(T);for(var it=R-I+et,ht=0,at=A+1;ht<at;){var ct=ht++;H=p.zeros1d(T);for(var nt=C-A+ct,pt=0,X=y+1;pt<X;){var ft=pt++;p.addMulMutate(H,z[ft],_[q+ft][nt][it])}p.addMulMutate(G,U[ct],H)}p.addMulMutate(J,V[et],G)}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=p.zeros2d(a+1,a+1),m=p.zeros1d(a+1),_=p.zeros1d(a+1),y=0,A=0;d[0][0]=1;for(var I=1,S=a+1;I<S;){var P=I++;m[P]=n-u[r+1-P],_[P]=u[r+P]-n,y=0;for(var k=0;k<P;){var T=k++;d[P][T]=_[T+1]+m[P-T],A=d[T][P-1]/d[P][T],d[T][P]=y+_[T+1]*A,y=m[P-T]*A}d[P][P]=y}for(var O=p.zeros2d(l+1,a+1),C=p.zeros2d(2,a+1),R=0,z=1,U=0,V=0,q=0,J=0,H=0,G=0,K=a+1;G<K;){var tt=G++;O[0][tt]=d[tt][a]}for(var et=0,it=a+1;et<it;){var ht=et++;R=0,z=1,C[0][0]=1;for(var at=1,ct=l+1;at<ct;){var nt=at++;U=0,V=ht-nt,q=a-nt,ht>=nt&&(C[z][0]=C[R][0]/d[q+1][V],U=C[z][0]*d[V][q]),V>=-1?J=1:J=-V,ht-1<=q?H=nt-1:H=a-ht;for(var pt=J,X=H+1;pt<X;){var ft=pt++;C[z][ft]=(C[R][ft]-C[R][ft-1])/d[q+1][V+ft],U+=C[z][ft]*d[V+ft][q]}ht<=q&&(C[z][nt]=-C[R][nt-1]/d[q+1][ht],U+=C[z][nt]*d[ht][q]),O[nt][ht]=U;var Pt=R;R=z,z=Pt}}for(var Wt=a,Kt=1,Ut=l+1;Kt<Ut;){for(var $t=Kt++,ke=0,qe=a+1;ke<qe;){var be=ke++;O[$t][be]*=Wt}Wt*=a-$t}return O},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=p.zeros1d(a+1),d=p.zeros1d(a+1),m=p.zeros1d(a+1),_=0,y=0;u[0]=1;for(var A=1,I=a+1;A<I;){var S=A++;d[S]=n-l[r+1-S],m[S]=l[r+S]-n,_=0;for(var P=0;P<S;){var k=P++;y=u[k]/(m[k+1]+d[S-k]),u[k]=_+m[k+1]*y,_=d[S-k]*y}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,m=Math.floor((u+d)/2);a<l[m]||a>=l[m+1];)a<l[m]?d=m:u=m,m=Math.floor((u+d)/2);return m},N.dehomogenize=function(r){for(var n=r.length,a=[],l=r[n-1],u=r.length-1,d=0;d<u;){var m=d++;a.push(r[m]/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,m=[],_;n!=null?_=n:_=p.rep(r.length,1);for(var y=0;y<a;){var A=y++,I=[];m=r[A],d=_[A];for(var S=0;S<l;){var P=S++;I.push(m[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=[],m=0;m<a;)m++,d.push(p.rep(r[0].length,1));u=d}for(var _=0;_<a;){var y=_++;l.push(N.homogenize1d(r[y],u[y]))}return l};var lt=f.eval.Intersect=function(){};x["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),m=d.map(function(_){return _.map(function(y){return lt.surfacesAtPointWithEstimate(r,n,y.uv0,y.uv1,a)})});return m.map(function(_){return gt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},lt.surfacesAtPointWithEstimate=function(r,n,a,l,u){var d,m,_,y,A,I,S,P,k,T,O,C,R,z=5,U=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),m=d[0][0],y=d[1][0],A=d[0][1],_=p.normalized(p.cross(y,A)),I=p.dot(_,m),S=N.rationalSurfaceDerivatives(n,l[0],l[1],1),P=S[0][0],T=S[1][0],O=S[0][1],k=p.normalized(p.cross(T,O)),C=p.dot(k,P),R=p.distSquared(m,P),R<u*u)break;var V=p.normalized(p.cross(_,k)),q=p.dot(V,m),J=lt.threePlanes(_,I,k,C,V,q);if(J==null)throw new Q("panic!");var H=p.sub(J,m),G=p.sub(J,P),K=p.cross(y,_),tt=p.cross(A,_),et=p.cross(T,k),it=p.cross(O,k),ht=p.dot(tt,H)/p.dot(tt,y),at=p.dot(K,H)/p.dot(K,A),ct=p.dot(it,G)/p.dot(it,T),nt=p.dot(et,G)/p.dot(et,O);a=p.add([ht,at],a),l=p.add([ct,nt],l),U++}while(U<z);return new Zn(a,l,m,R)},lt.meshes=function(r,n,a,l){a==null&&(a=new or(r)),l==null&&(l=new or(n));var u=lt.boundingBoxTrees(a,l,0),d=$.unique(u.map(function(m){return lt.triangles(r,m.item0,n,m.item1)}).filter(function(m){return m!=null}).filter(function(m){return p.distSquared(m.min.point,m.max.point)>rt.EPSILON}),function(m,_){var y=p.sub(m.min.uv0,_.min.uv0),A=p.dot(y,y),I=p.sub(m.max.uv0,_.max.uv0),S=p.dot(I,I),P=p.sub(m.min.uv0,_.max.uv0),k=p.dot(P,P),T=p.sub(m.max.uv0,_.min.uv0),O=p.dot(T,T);return A<rt.EPSILON&&S<rt.EPSILON||k<rt.EPSILON&&O<rt.EPSILON});return lt.makeMeshIntersectionPolylines(d)},lt.meshSlices=function(r,n,a,l){for(var u=new zr(r),d=u.boundingBox(),m=d.min[0],_=d.min[1],y=d.max[0],A=d.max[1],I=p.span(n,a,l),S=[],P=0;P<I.length;){var k=I[P];++P;var T=[[m,_,k],[y,_,k],[y,A,k],[m,A,k]],O=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],R=new Xe(C,T,null,O);S.push(lt.meshes(r,R,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 m=r[d];++d,u.push(m.min),u.push(m.max)}for(var _=0;_<u.length;){var y=u[_];if(++_,y.adj==null){var A=lt.lookupAdjacentSegment(y,l,r.length);A!=null&&A.adj==null&&(y.adj=A,A.adj=y)}}var I=u.filter(function(z){return z.adj==null});I.length==0&&(I=u);for(var S=[],P=0,k=!1;I.length!=0;){var T=I.pop();if(!T.visited){for(var O=[],C=T;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,O.push(C),P+=2,C=C.opp.adj,C==T)););O.length>0&&(O.push(O[O.length-1].opp),S.push(O))}if(I.length==0&&u.length>0&&(k||P<u.length)){k=!0;var R=u.pop();I.push(R)}}return S},lt.kdTreeFromSegments=function(r){for(var n=[],a=0;a<r.length;){var l=r[a];++a,n.push(new En(l.min.point,l.min)),n.push(new En(l.max.point,l.max))}return new Jn(n,p.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 ar(r),u!=null?u=u:u=new Br(n);var d=lt.boundingBoxTrees(l,u,a);return $.unique(d.map(function(m){var _=m.item0,y=m.item1,A=$.first(_.knots),I=$.last(_.knots),S=(A+I)/2,P=$.first(y.knotsU),k=$.last(y.knotsU),T=$.first(y.knotsV),O=$.last(y.knotsV),C=[(P+k)/2,(T+O)/2];return lt.curveAndSurfaceWithEstimate(_,y,[S].concat(C),a)}).filter(function(m){return p.distSquared(m.curvePoint,m.surfacePoint)<a*a}),function(m,_){return Math.abs(m.u-_.u)<.5*a})},lt.curveAndSurfaceWithEstimate=function(r,n,a,l){l==null&&(l=.001);var u=function(y){var A=N.rationalCurvePoint(r,y[0]),I=N.rationalSurfacePoint(n,y[1],y[2]),S=p.sub(A,I);return p.dot(S,S)},d=function(y){var A=N.rationalCurveDerivatives(r,y[0],1),I=N.rationalSurfaceDerivatives(n,y[1],y[2],1),S=p.sub(I[0][0],A[0]),P=p.mul(-1,A[1]),k=I[1][0],T=I[0][1];return[2*p.dot(P,S),2*p.dot(k,S),2*p.dot(T,S)]},m=Ke.uncmin(u,a,l*l,d),_=m.solution;return new Kn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(n,_[1],_[2]))},lt.polylineAndMesh=function(r,n,a){for(var l=lt.boundingBoxTrees(new lr(r),new or(n),a),u=[],d=0;d<l.length;){var m=l[d];++d;var _=m.item0,y=m.item1,A=lt.segmentWithTriangle(r.points[_],r.points[_+1],n.points,n.faces[y]);if(A!=null){var I=A.point,S=p.lerp(A.p,[r.params[_]],[r.params[_+1]])[0],P=ne.triangleUVFromPoint(n,y,I);u.push(new $n(I,S,P,_,y))}}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 m=l.pop(),_=u.pop();if(!(m.empty()||_.empty())&&m.boundingBox().intersects(_.boundingBox(),a)){var y=m.indivisible(a),A=_.indivisible(a);if(y&&A){d.push(new re(m.yield(),_.yield()));continue}else if(y&&!A){var I=_.split();l.push(m),u.push(I.item1),l.push(m),u.push(I.item0);continue}else if(!y&&A){var S=m.split();l.push(S.item1),u.push(_),l.push(S.item0),u.push(_);continue}var P=m.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 ar(r),new ar(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 p.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]),T=N.rationalCurvePoint(n,P[1]),O=p.sub(k,T);return p.dot(O,O)},m=function(P){var k=N.rationalCurveDerivatives(r,P[0],1),T=N.rationalCurveDerivatives(n,P[1],1),O=p.sub(k[0],T[0]),C=k[1],R=p.mul(-1,T[1]);return[2*p.dot(C,O),2*p.dot(R,O)]},_=Ke.uncmin(d,[a,l],u*u,m),y=_.solution[0],A=_.solution[1],I=N.rationalCurvePoint(r,y),S=N.rationalCurvePoint(n,A);return new Qr(I,S,y,A)},lt.triangles=function(r,n,a,l){var u=r.faces[n],d=a.faces[l],m=ne.getTriangleNorm(r.points,u),_=ne.getTriangleNorm(a.points,d),y=r.points[u[0]],A=a.points[d[0]],I=lt.planes(y,m,A,_);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 Ee(new Or(k.min.uv0,k.min.uv1,k.min.point,n,l),new Or(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]]],m=[p.sub(d[1],d[0]),p.sub(d[2],d[1]),p.sub(d[0],d[2])],_=[p.sub(u[1],u[0]),p.sub(u[2],u[1]),p.sub(u[0],u[2])],y=_.map(p.normalized),A=_.map(p.norm),I=null,S=null,P=0;P<3;){var k=P++,T=u[k],O=y[k],C=lt.rays(T,O,r.origin,r.dir);if(C!=null){var R=C.u0,z=C.u1;R<-rt.EPSILON||R>A[k]+rt.EPSILON||((I==null||z<I.u)&&(I=new Pn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],m[k],R/A[k]))),(S==null||z>S.u)&&(S=new Pn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],m[k],R/A[k]))))}}return S==null||I==null?null:new Ee(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 m;r.min.u>n.min.u?m=new re(r.min,0):m=new re(n.min,1);var _;r.max.u<n.max.u?_=new re(r.max,0):_=new re(n.max,1);var y=new Ee(new Or(null,null,m.item0.point,l,d),new Or(null,null,_.item0.point,l,d));return m.item1==0?(y.min.uv0=m.item0.uv,y.min.uv1=ne.triangleUVFromPoint(u,d,m.item0.point)):(y.min.uv0=ne.triangleUVFromPoint(a,l,m.item0.point),y.min.uv1=m.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=ne.triangleUVFromPoint(u,d,_.item0.point)):(y.max.uv0=ne.triangleUVFromPoint(a,l,_.item0.point),y.max.uv1=_.item0.uv),y},lt.planes=function(r,n,a,l){var u=p.cross(n,l);if(p.dot(u,u)<rt.EPSILON)return null;var d=0,m=Math.abs(u[0]),_=Math.abs(u[1]),y=Math.abs(u[2]);_>m&&(d=1,m=_),y>m&&(d=2,m=y);var A,I,S,P;d==0?(A=n[1],I=n[2],S=l[1],P=l[2]):d==1?(A=n[0],I=n[2],S=l[0],P=l[2]):(A=n[0],I=n[1],S=l[0],P=l[1]);var k=-p.dot(r,n),T=-p.dot(a,l),O=A*P-I*S,C=(I*T-k*P)/O,R=(k*S-A*T)/O,z;return d==0?z=[0,C,R]:d==1?z=[C,0,R]:z=[C,R,0],new In(z,p.normalized(u))},lt.threePlanes=function(r,n,a,l,u,d){var m=p.cross(a,u),_=p.dot(r,m);if(Math.abs(_)<rt.EPSILON)return null;var y=p.sub(p.mul(d,a),p.mul(l,u)),A=p.add(p.mul(n,m),p.cross(r,y));return p.mul(1/_,A)},lt.polylines=function(r,n,a){for(var l=lt.boundingBoxTrees(new lr(r),new lr(n),a),u=[],d=0;d<l.length;){var m=l[d];++d;var _=m.item0,y=m.item1,A=lt.segments(r.points[_],r.points[_+1],n.points[y],n.points[y+1],a);A!=null&&(A.u0=p.lerp(A.u0,[r.params[_]],[r.params[_+1]])[0],A.u1=p.lerp(A.u1,[n.params[y]],[n.params[y+1]])[0],u.push(A))}return u},lt.segments=function(r,n,a,l,u){var d=p.sub(n,r),m=Math.sqrt(p.dot(d,d)),_=p.mul(1/m,d),y=p.sub(l,a),A=Math.sqrt(p.dot(y,y)),I=p.mul(1/A,y),S=lt.rays(r,_,a,I);if(S!=null){var P=Math.min(Math.max(0,S.u0/m),1),k=Math.min(Math.max(0,S.u1/A),1),T=p.onRay(r,d,P),O=p.onRay(a,y,k),C=p.distSquared(T,O);if(C<u*u)return new Qr(T,O,P,k)}return null},lt.rays=function(r,n,a,l){var u=p.dot(n,l),d=p.dot(n,a),m=p.dot(n,r),_=p.dot(l,a),y=p.dot(l,r),A=p.dot(n,n),I=p.dot(l,l),S=A*I-u*u;if(Math.abs(S)<rt.EPSILON)return null;var P=u*(d-m)-A*(_-y),k=P/S,T=(d-m+k*u)/A,O=p.onRay(r,n,T),C=p.onRay(a,l,k);return new Qr(O,C,T,k)},lt.segmentWithTriangle=function(r,n,a,l){var u=a[l[0]],d=a[l[1]],m=a[l[2]],_=p.sub(d,u),y=p.sub(m,u),A=p.cross(_,y),I=p.sub(n,r),S=p.sub(r,u),P=-p.dot(A,S),k=p.dot(A,I);if(Math.abs(k)<rt.EPSILON)return null;var T=P/k;if(T<0||T>1)return null;var O=p.add(r,p.mul(T,I)),C=p.dot(_,y),R=p.dot(_,_),z=p.dot(y,y),U=p.sub(O,u),V=p.dot(U,_),q=p.dot(U,y),J=C*C-R*z;if(Math.abs(J)<rt.EPSILON)return null;var H=(C*q-z*V)/J,G=(C*V-R*q)/J;return H>1+rt.EPSILON||G>1+rt.EPSILON||G<-rt.EPSILON||H<-rt.EPSILON||H+G>1+rt.EPSILON?null:new Qn(O,H,G,T)},lt.segmentAndPlane=function(r,n,a,l){var u=p.dot(l,p.sub(n,r));if(Math.abs(u)<rt.EPSILON)return null;var d=p.dot(l,p.sub(a,r)),m=d/u;return m>1+rt.EPSILON||m<-rt.EPSILON?null:{p:m}};var gt=f.eval.Make=function(){};x["verb.eval.Make"]=gt,gt.__name__=["verb","eval","Make"],gt.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,m=(u-l)/(d-1),_=[],y=0;y<d;){var A=y++,I=p.sub(N.rationalCurvePoint(n,l+A*m),a),S=_t.rationalCurveTransform(r,[[1,0,0,I[0]],[0,1,0,I[1]],[0,0,1,I[2]],[0,0,0,1]]);_.push(S)}return gt.loftedSurface(_)},gt.surfaceBoundaryCurves=function(r){var n=gt.surfaceIsocurve(r,$.first(r.knotsU),!1),a=gt.surfaceIsocurve(r,$.last(r.knotsU),!1),l=gt.surfaceIsocurve(r,$.first(r.knotsV),!0),u=gt.surfaceIsocurve(r,$.last(r.knotsV),!0);return[n,a,l,u]},gt.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=bt.knotMultiplicities(l),m=-1,_=0,y=d.length;_<y;){var A=_++;if(Math.abs(n-d[A].knot)<rt.EPSILON){m=A;break}}var I=u+1;m>=0&&(I=I-d[m].mult);var S;I>0?S=_t.surfaceKnotRefine(r,p.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 T,O=[],C=0,R=S.controlPoints;C<R.length;){var z=R[C];++C,O.push(z[P])}return T=O,T}()):new jt(S.degreeV,S.knotsV,S.controlPoints[P])},gt.loftedSurface=function(r,n){r=_t.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=[],m=0,_=r[0].controlPoints.length;m<_;){var y=[m++],A=r.map(function(S){return function(P){return P.controlPoints[S[0]]}}(y)),I=gt.rationalInterpCurve(A,n,!0);d.push(I.controlPoints),u=I.knots}return new ee(a,n,l,u,d)},gt.clonedCurve=function(r){return new jt(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},gt.rationalBezierCurve=function(r,n){for(var a=r.length-1,l=[],u=0,d=a+1;u<d;)u++,l.push(0);for(var m=0,_=a+1;m<_;)m++,l.push(1);return n==null&&(n=p.rep(r.length,1)),new jt(a,l,N.homogenize1d(r,n))},gt.fourPointSurface=function(r,n,a,l,u){u==null&&(u=3);for(var d=u,m=[],_=0,y=u+1;_<y;){for(var A=_++,I=[],S=0,P=u+1;S<P;){var k=S++,T=1-A/d,O=p.lerp(T,r,n),C=p.lerp(T,l,a),R=p.lerp(1-k/d,O,C);R.push(1),I.push(R)}m.push(I)}var z=p.rep(u+1,0),U=p.rep(u+1,1);return new ee(u,u,z.concat(U),z.concat(U),m)},gt.ellipseArc=function(r,n,a,l,u){var d=p.norm(n),m=p.norm(a);n=p.normalized(n),a=p.normalized(a),u<l&&(u=2*Math.PI+l);var _=u-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var A=_/y,I=Math.cos(A/2),S=p.add(r,p.add(p.mul(d*Math.cos(l),n),p.mul(m*Math.sin(l),a))),P=p.sub(p.mul(Math.cos(l),a),p.mul(Math.sin(l),n)),k=[],T=p.zeros1d(2*y+3),O=0,C=l,R=p.zeros1d(y*2);k[0]=S,R[0]=1;for(var z=1,U=y+1;z<U;){var V=z++;C+=A;var q=p.add(r,p.add(p.mul(d*Math.cos(C),n),p.mul(m*Math.sin(C),a)));R[O+2]=1,k[O+2]=q;var J=p.sub(p.mul(Math.cos(C),a),p.mul(Math.sin(C),n)),H=lt.rays(S,p.mul(1/p.norm(P),P),q,p.mul(1/p.norm(J),J)),G=p.add(S,p.mul(H.u0,P));R[O+1]=I,k[O+1]=G,O+=2,V<y&&(S=q,P=J)}for(var K=2*y+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+K]=1}switch(y){case 2:T[3]=T[4]=.5;break;case 3:T[3]=T[4]=.3333333333333333,T[5]=T[6]=.6666666666666666;break;case 4:T[3]=T[4]=.25,T[5]=T[6]=.5,T[7]=T[8]=.75;break}return new jt(2,T,N.homogenize1d(k,R))},gt.arc=function(r,n,a,l,u,d){return gt.ellipseArc(r,p.mul(l,p.normalized(n)),p.mul(l,p.normalized(a)),u,d)},gt.polyline=function(r){for(var n=[0,0],a=0,l=0,u=r.length-1;l<u;){var d=l++;a+=p.dist(r[d],r[d+1]),n.push(a)}n.push(a),n=p.mul(1/a,n);for(var m,_=[],y=0,A=r.length;y<A;)y++,_.push(1);return m=_,new jt(1,n,N.homogenize1d(r.slice(0),m))},gt.extrudedSurface=function(r,n,a){for(var l=[[],[],[]],u=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),m=N.weight1d(a.controlPoints),_=p.mul(n,r),y=p.mul(.5*n,r),A=0,I=d.length;A<I;){var S=A++;l[2][S]=d[S],l[1][S]=p.add(y,d[S]),l[0][S]=p.add(_,d[S]),u[0][S]=m[S],u[1][S]=m[S],u[2][S]=m[S]}return new ee(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,u))},gt.cylindricalSurface=function(r,n,a,l,u){var d=p.cross(r,n),m=gt.arc(a,n,d,u,0,2*Math.PI);return gt.extrudedSurface(r,l,m)},gt.revolvedSurface=function(r,n,a,l){var u=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),m,_;l<=Math.PI/2?(m=1,_=p.zeros1d(6+2*(m-1))):l<=Math.PI?(m=2,_=p.zeros1d(6+2*(m-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(m=3,_=p.zeros1d(6+2*(m-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(m=4,_=p.zeros1d(6+2*(m-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/m,A=3+2*(m-1),I=0;I<3;){var S=I++;_[S]=0,_[A+S]=1}for(var P=Math.cos(y/2),k=0,T=p.zeros1d(m+1),O=p.zeros1d(m+1),C=p.zeros3d(2*m+1,u.length,3),R=p.zeros2d(2*m+1,u.length),z=1,U=m+1;z<U;){var V=z++;k+=y,O[V]=Math.cos(k),T[V]=Math.sin(k)}for(var q=0,J=u.length;q<J;){var H=q++,G=Le.rayClosestPoint(u[H],n,a),K=p.sub(u[H],G),tt=p.norm(K),et=p.cross(a,K);tt>rt.EPSILON&&(K=p.mul(1/tt,K),et=p.mul(1/tt,et)),C[0][H]=u[H];var it=u[H];R[0][H]=d[H];for(var ht=et,at=0,ct=1,nt=m+1;ct<nt;){var pt=ct++,X;tt==0?X=G:X=p.add(G,p.add(p.mul(tt*O[pt],K),p.mul(tt*T[pt],et))),C[at+2][H]=X,R[at+2][H]=d[H];var ft=p.sub(p.mul(O[pt],et),p.mul(T[pt],K));if(tt==0)C[at+1][H]=G;else{var Pt=lt.rays(it,p.mul(1/p.norm(ht),ht),X,p.mul(1/p.norm(ft),ft)),Wt=p.add(it,p.mul(Pt.u0,ht));C[at+1][H]=Wt}R[at+1][H]=P*d[H],at+=2,pt<m&&(it=X,ht=ft)}}return new ee(2,r.degree,_,r.knots,N.homogenize2d(C,R))},gt.sphericalSurface=function(r,n,a,l){var u=gt.arc(r,p.mul(-1,n),a,l,0,Math.PI);return gt.revolvedSurface(u,r,n,2*Math.PI)},gt.conicalSurface=function(r,n,a,l,u){var d=2*Math.PI,m=1,_=[p.add(a,p.mul(l,r)),p.add(a,p.mul(u,n))],y=[0,0,1,1],A=[1,1],I=new jt(m,y,N.homogenize1d(_,A));return gt.revolvedSurface(I,a,r,d)},gt.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],m=1,_=r.length;m<_;){var y=m++,A=p.norm(p.sub(r[y],r[y-1])),I=d[d.length-1];d.push(I+A)}for(var S=d[d.length-1],P=0,k=d.length;P<k;){var T=P++;d[T]=d[T]/S}var O=p.rep(n+1,0),C=l!=null&&u!=null,R;C?R=0:R=1;var z;C?z=d.length-n+1:z=d.length-n;for(var U=R;U<z;){for(var V=U++,q=0,J=0;J<n;){var H=J++;q+=d[V+H]}O.push(1/n*q)}var G=O.concat(p.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,G),ct=N.basisFunctionsGivenKnotSpanIndex(at,ht,n,G),nt=at-n,pt=p.zeros1d(nt),X=p.zeros1d(et-nt);K.push(pt.concat(ct).concat(X))}if(C){var ft=K[0].length-2,Pt=[-1,1].concat(p.zeros1d(ft)),Wt=p.zeros1d(ft).concat([-1,1]);$.spliceAndInsert(K,1,0,Pt),$.spliceAndInsert(K,K.length-1,0,Wt)}for(var Kt=r[0].length,Ut=[],$t=(1-G[G.length-n-2])/n,ke=G[n+1]/n,qe=0;qe<Kt;){var be=[qe++],_e;if(!C)_e=r.map(function(tr){return function(mr){return mr[tr[0]]}}(be));else{_e=[r[0][be[0]]],_e.push(ke*l[be[0]]);for(var Me=1,Be=r.length-1;Me<Be;){var Ze=Me++;_e.push(r[Ze][be[0]])}_e.push($t*u[be[0]]),_e.push($.last(r)[be[0]])}var hr=Ot.solve(K,_e);Ut.push(hr)}var Qe=Ot.transpose(Ut);if(!a){var Je=p.rep(Qe.length,1);Qe=N.homogenize1d(Qe,Je)}return new jt(n,G,Qe)};var _t=f.eval.Modify=function(){};x["verb.eval.Modify"]=_t,_t.__name__=["verb","eval","Modify"],_t.curveReverse=function(r){return new jt(r.degree,_t.knotsReverse(r.knots),$.reversed(r.controlPoints))},_t.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new ee(r.degreeU,r.degreeV,r.knotsU,_t.knotsReverse(r.knotsV),function(a){for(var l,u=[],d=0,m=r.controlPoints;d<m.length;){var _=m[d];++d,u.push($.reversed(_))}return l=u,l}()):new ee(r.degreeU,r.degreeV,_t.knotsReverse(r.knotsU),r.knotsV,$.reversed(r.controlPoints))},_t.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},_t.unifyCurveKnotVectors=function(r){r=r.map(gt.clonedCurve);for(var n=B.fold(r,function(G,K){return _t.imax(G.degree,K)},0),a=0,l=r.length;a<l;){var u=a++;r[u].degree<n&&(r[u]=_t.curveElevateDegree(r[u],n))}for(var d,m=[],_=0;_<r.length;){var y=r[_];++_,m.push(new Ee($.first(y.knots),$.last(y.knots)))}d=m;for(var A=0,I=r.length;A<I;){var S=A++,P=[d[S].min];r[S].knots=r[S].knots.map(function(G){return function(K){return K-G[0]}}(P))}for(var k=d.map(function(G){return G.max-G.min}),T=B.fold(k,function(G,K){return Math.max(G,K)},0),O=0,C=r.length;O<C;){var R=O++,z=[T/k[R]];r[R].knots=r[R].knots.map(function(G){return function(K){return K*G[0]}}(z))}for(var U=B.fold(r,function(G,K){return p.sortedSetUnion(G.knots,K)},[]),V=0,q=r.length;V<q;){var J=V++,H=p.sortedSetSub(U,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=_t.curveKnotRefine(r[J],H)}return r},_t.imin=function(r,n){return r<n?r:n},_t.imax=function(r,n){return r>n?r:n},_t.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,m=n-r.degree,_=r.controlPoints[0].length,y=p.zeros2d(l+m+1,l+1),A=[],I=[],S=[],P=a+l+1,k=n,T=Math.floor(k/2),O=[],C=[];y[0][0]=1,y[k][l]=1;for(var R=1,z=T+1;R<z;)for(var U=R++,V=1/Ft.get(k,U),q=_t.imin(l,U),J=_t.imax(0,U-m),H=q+1;J<H;){var G=J++;y[U][G]=V*Ft.get(l,G)*Ft.get(m,U-G)}for(var K=T+1;K<k;)for(var tt=K++,et=_t.imin(l,tt),it=_t.imax(0,tt-m),ht=et+1;it<ht;){var at=it++;y[tt][at]=y[k-tt][l-at]}var ct=k+1,nt=-1,pt=l,X=l+1,ft=1,Pt=u[0];O[0]=d[0];for(var Wt=0,Kt=k+1;Wt<Kt;){var Ut=Wt++;C[Ut]=Pt}for(var $t=0,ke=l+1;$t<ke;){var qe=$t++;A[qe]=d[qe]}for(;X<P;){for(var be=X;X<P&&u[X]==u[X+1];)X=X+1;var _e=X-be+1,Me=u[X],Be=nt;nt=l-_e;var Ze;Be>0?Ze=Math.floor((Be+2)/2):Ze=1;var hr;if(nt>0?hr=Math.floor(k-(nt+1)/2):hr=k,nt>0){for(var Qe=Me-Pt,Je=[],tr=l;tr>_e;)Je[tr-_e-1]=Qe/(u[pt+tr]-Pt),tr--;for(var mr=1,On=nt+1;mr<On;){for(var tn=mr++,nc=nt-tn,$i=_e+tn,en=l;en>=$i;)A[en]=p.add(p.mul(Je[en-$i],A[en]),p.mul(1-Je[en-$i],A[en-1])),en--;S[nc]=A[l]}}for(var Fo=Ze,sc=k+1;Fo<sc;){var Bn=Fo++;I[Bn]=p.zeros1d(_);for(var ic=_t.imin(l,Bn),Do=_t.imax(0,Bn-m),ac=ic+1;Do<ac;){var Uo=Do++;I[Bn]=p.add(I[Bn],p.mul(y[Bn][Uo],A[Uo]))}}if(Be>1)for(var Zi=ct-2,Qi=ct,Vo=Me-Pt,oc=(Me-C[ct-1])/Vo,Go=1;Go<Be;){for(var Ji=Go++,gr=Zi,rn=Qi,Gr=rn-ct+1;rn-gr>Ji;){if(gr<ft){var lc=(Me-C[gr])/(Pt-C[gr]);O[gr]=p.lerp(lc,O[gr],O[gr-1])}if(rn>=Ze){if(rn-Ji<=ct-k+Be){var hc=(Me-C[rn-Ji])/Vo;I[Gr]=p.lerp(hc,I[Gr],I[Gr+1])}}else I[Gr]=p.lerp(oc,I[Gr],I[Gr+1]);gr=gr+1,rn=rn-1,Gr=Gr-1}Zi=Zi-1,Qi=Qi+1}if(pt!=l)for(var jo=0,uc=k-Be;jo<uc;)jo++,C[ct]=Pt,ct=ct+1;for(var Wo=Ze,cc=hr+1;Wo<cc;){var dc=Wo++;O[ft]=I[dc],ft=ft+1}if(X<P){for(var Ho=0;Ho<nt;){var Yo=Ho++;A[Yo]=S[Yo]}for(var qo=nt,pc=l+1;qo<pc;){var Xo=qo++;A[Xo]=d[X-l+Xo]}pt=X,X=X+1,Pt=Me}else for(var Ko=0,mc=k+1;Ko<mc;){var gc=Ko++;C[ct+gc]=Me}}return new jt(n,C,O)},_t.rationalSurfaceTransform=function(r,n){for(var a=N.dehomogenize2d(r.controlPoints),l=0,u=a.length;l<u;)for(var d=l++,m=0,_=a[d].length;m<_;){var y=m++,A=a[d][y];A.push(1),a[d][y]=Ot.dot(n,A).slice(0,A.length-1)}return new ee(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},_t.rationalCurveTransform=function(r,n){for(var a=N.dehomogenize1d(r.controlPoints),l=0,u=a.length;l<u;){var d=l++,m=a[d];m.push(1),a[d]=Ot.dot(n,m).slice(0,m.length-1)}return new jt(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},_t.surfaceKnotRefine=function(r,n,a){var l=[],u,d,m;a?(m=r.controlPoints,u=r.knotsV,d=r.degreeV):(m=Ot.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<m.length;){var A=m[y];++y,_=_t.curveKnotRefine(new jt(d,u,A),n),l.push(_.controlPoints)}var I=_.knots;return a?new ee(r.degreeU,r.degreeV,r.knotsU.slice(),I,l):(l=Ot.transpose(l),new ee(r.degreeU,r.degreeV,I,r.knotsV.slice(),l))},_t.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,a=r.controlPoints,l=r.knots,u=bt.knotMultiplicities(l),d=n+1,m=0;m<u.length;){var _=u[m];if(++m,_.mult<d){var y=p.rep(d-_.mult,_.knot),A=_t.curveKnotRefine(new jt(n,l,a),y);l=A.knots,a=A.controlPoints}}l.length/d-1;for(var I=d*2,S=[],P=0;P<a.length;){var k=l.slice(P,P+I),T=a.slice(P,P+d);S.push(new jt(n,k,T)),P+=d}return S},_t.curveKnotRefine=function(r,n){if(n.length==0)return gt.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,m=d+a+1,_=n.length-1,y=N.knotSpan(a,n[0],u),A=N.knotSpan(a,n[_],u),I=[],S=[],P=0,k=y-a+1;P<k;){var T=P++;I[T]=l[T]}for(var O=A-1,C=d+1;O<C;){var R=O++;I[R+_+1]=l[R]}for(var z=0,U=y+1;z<U;){var V=z++;S[V]=u[V]}for(var q=A+a,J=m+1;q<J;){var H=q++;S[H+_+1]=u[H]}for(var G=A+a-1,K=A+a+_,tt=_;tt>=0;){for(;n[tt]<=u[G]&&G>y;)I[K-a-1]=l[G-a-1],S[K]=u[G],K=K-1,G=G-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[G-a+ht]),I[at-1]=p.add(p.mul(ct,I[at-1]),p.mul(1-ct,I[at])))}S[K]=n[tt],K=K-1,tt--}return new jt(a,S,I)},_t.curveKnotInsert=function(r,n,a){for(var l=r.degree,u=r.controlPoints,d=r.knots,m=0,_=u.length,y=N.knotSpan(l,n,d),A=[],I=[],S=[],P=1,k=y+1;P<k;){var T=P++;I[T]=d[T]}for(var O=1,C=a+1;O<C;){var R=O++;I[y+R]=n}for(var z=y+1,U=d.length;z<U;){var V=z++;I[V+a]=d[V]}for(var q=0,J=y-l+1;q<J;){var H=q++;S[H]=u[H]}for(var G=y-m;G<_;){var K=G++;S[K+a]=u[K]}for(var tt=0,et=l-m+1;tt<et;){var it=tt++;A[it]=u[y-l+it]}for(var ht=0,at=0,ct=1,nt=a+1;ct<nt;){var pt=ct++;ht=y-l+pt;for(var X=0,ft=l-pt-m+1;X<ft;){var Pt=X++;at=(n-d[ht+Pt])/(d[Pt+y+1]-d[ht+Pt]),A[Pt]=p.add(p.mul(at,A[Pt+1]),p.mul(1-at,A[Pt]))}S[ht]=A[0],S[y+a-pt-m]=A[l-pt-m]}for(var Wt=ht+1,Kt=y-m;Wt<Kt;){var Ut=Wt++;S[Ut]=A[Ut-ht]}return new jt(l,I,S)};var zt=f.eval.Tess=function(){};x["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=[],m=(a-n)/(l-1),_=0,y=0;y<l;){var A=y++;_=n+m*A,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 m=u++;l.push([r.knots[m+1]].concat(N.dehomogenize(r.controlPoints[m])))}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),m=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),y=n+(a-n)*_,A=N.rationalCurvePoint(r,y),I=p.sub(d,m),S=p.sub(d,A);if(p.dot(I,I)<l&&p.dot(S,S)>l||!Le.threePointsAreFlat(d,A,m,l)){var P=n+(a-n)*.5,k=zt.rationalCurveAdaptiveSampleRange(r,n,P,l,u),T=zt.rationalCurveAdaptiveSampleRange(r,P,a,l,u);return k.slice(0,-1).concat(T)}else return u?[[n].concat(d),[a].concat(m)]:[d,m]},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],m=$.last(u)-u[0],_=d/n,y=m/a,A=[],I=[],S=[],P=0,k=n+1;P<k;)for(var T=P++,O=0,C=a+1;O<C;){var R=O++,z=T*_,U=R*y;I.push([z,U]);var V=N.rationalSurfaceDerivatives(r,z,U,1),q=V[0][0];A.push(q);var J=p.normalized(p.cross(V[1][0],V[0][1]));S.push(J)}for(var H=[],G=0;G<n;)for(var K=G++,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],pt=[it,at,ct];H.push(nt),H.push(pt)}return new Xe(H,A,S,I)},zt.divideRationalSurfaceAdaptive=function(r,n){n==null&&(n=new Rr),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 m=$.last(r.knotsU),_=r.knotsU[0],y=$.last(r.knotsV),A=r.knotsV[0],I=(m-_)/u,S=(y-A)/d,P=[],k=[],T=0,O=d+1;T<O;){for(var C=T++,R=[],z=0,U=u+1;z<U;){var V=z++,q=_+I*V,J=A+S*C,H=N.rationalSurfaceDerivatives(r,q,J,1),G=p.normalized(p.cross(H[0][1],H[1][0]));R.push(new He(H[0][0],G,[q,J],-1,p.isZero(G)))}k.push(R)}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 pr(r,ht))}if(!n.refine)return P;for(var at=0;at<d;)for(var ct=at++,nt=0;nt<u;){var pt=nt++,X=ct*u+pt,ft=zt.north(X,ct,pt,u,d,P),Pt=zt.east(X,ct,pt,u,d,P),Wt=zt.south(X,ct,pt,u,d,P),Kt=zt.west(X,ct,pt,u,d,P);P[X].neighbors=[Wt,Pt,ft,Kt],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=Xe.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 Rr;var a=zt.divideRationalSurfaceAdaptive(r,n);return zt.triangulateAdaptiveRefinementNodeTree(a)};var Rr=f.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"]=Rr,Rr.__name__=["verb","eval","AdaptiveRefinementOptions"],Rr.prototype={__class__:Rr};var pr=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],m=$.last(r.knotsV);this.corners=[He.fromUv(l,d),He.fromUv(u,d),He.fromUv(u,m),He.fromUv(l,m)]}};x["verb.eval.AdaptiveRefinementNode"]=pr,pr.__name__=["verb","eval","AdaptiveRefinementNode"],pr.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=p.cross(l[0][1],l[1][0]),m=p.isZero(d);return m||(d=p.normalized(d)),a!=null?(a.degen=m,a.point=u,a.normal=d,a):new He(u,d,[r,n],-1,m)},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,m=[function(y){return y.uv[0]>d.corners[0].uv[0]+u&&y.uv[0]<d.corners[2].uv[0]-u},function(y){return y.uv[1]>d.corners[0].uv[1]+u&&y.uv[1]<d.corners[2].uv[1]-u}],_=a.filter(m[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=p.normSquared(p.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=p.normSquared(p.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return p.normSquared(p.sub(a.normal,this.corners[0].normal))>r.normTol||p.normSquared(p.sub(a.normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(a.normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Rr),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 pr(this.srf,l),new pr(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]],m=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new pr(this.srf,d),new pr(this.srf,m)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var A=y[_];++_,A._divide(r,n,!a)}}},triangulate:function(r){if(r==null&&(r=Xe.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 m=d++,_=this.getAllCorners(m);_.length==2&&(u=m+1);for(var y=0,A=_.length;y<A;){var I=y++;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 T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var O=r.points.length-1,C=0,R=a.length-1;C<a.length;)r.faces.push([O,l[C],l[R]]),R=C++;return r},__class__:pr};var At=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=At,At.__name__=["verb","exe","Dispatcher"],At.init=function(){At._init||(At._workerPool=new Fr(At.THREADS),At._init=!0)},At.dispatchMethod=function(r,n,a){At.init();var l=new An,u=function(d){l.resolve(d)};return At._workerPool.addWork(ut.getClassName(r),n,a,u),new fe(l)};var Fr=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new wt,this._working=new wt,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(Fr.basePath+n)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(Fr.basePath+n.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=Fr,Fr.__name__=["verb","exe","WorkerPool"],Fr.prototype={addWork:function(r,n,a,l){var u=new Jr(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(m){r._working.remove(d[0]),r._pool.push(u[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](m.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,a),l[0].postMessage(n)}},__class__:Fr};var Jr=function(r,n,a){this.className=r,this.methodName=n,this.args=a,this.id=Jr.uuid++};x["verb.exe._WorkerPool.Work"]=Jr,Jr.__name__=["verb","exe","_WorkerPool","Work"],Jr.prototype={__class__:Jr};var Cn=function(){};x["verb.geom.ICurve"]=Cn,Cn.__name__=["verb","geom","ICurve"],Cn.__interfaces__=[Mn],Cn.prototype={__class__:Cn};var Lt=f.geom.NurbsCurve=function(r){this._data=Ye.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Lt,Lt.__name__=["verb","geom","NurbsCurve"],Lt.__interfaces__=[Cn],Lt.byKnotsControlPointsWeights=function(r,n,a,l){return new Lt(new jt(r,n.slice(),N.homogenize1d(a,l)))},Lt.byPoints=function(r,n){return n==null&&(n=3),new Lt(gt.rationalInterpCurve(r,n))},Lt.__super__=Qt,Lt.prototype=M(Qt.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 Lt(this._data)},domain:function(){return new Ee($.first(this._data.knots),$.last(this._data.knots))},transform:function(r){return new Lt(_t.rationalCurveTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(_t,"rationalCurveTransform",[this._data,r]).then(function(n){return new Lt(n)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return At.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return At.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),At.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return bt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return bt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestParam",[this._data,r])},length:function(){return bt.rationalCurveArcLength(this._data)},lengthAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return bt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return bt.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return At.dispatchMethod(bt,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return he.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return At.dispatchMethod(he,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return he.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return At.dispatchMethod(he,"rationalCurveByArcLength",[this._data,r])},split:function(r){return he.curveSplit(this._data,r).map(function(n){return new Lt(n)})},splitAsync:function(r){return At.dispatchMethod(he,"curveSplit",[this._data,r]).then(function(n){return n.map(function(a){return new Lt(a)})})},reverse:function(){return new Lt(_t.curveReverse(this._data))},reverseAsync:function(){return At.dispatchMethod(_t,"curveReverse",[this._data]).then(function(r){return new Lt(r)})},tessellate:function(r){return zt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Lt});var Dr=f.geom.Arc=function(r,n,a,l,u,d){Lt.call(this,gt.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"]=Dr,Dr.__name__=["verb","geom","Arc"],Dr.__super__=Lt,Dr.prototype=M(Lt.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__:Dr});var ns=f.geom.BezierCurve=function(r,n){Lt.call(this,gt.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=ns,ns.__name__=["verb","geom","BezierCurve"],ns.__super__=Lt,ns.prototype=M(Lt.prototype,{__class__:ns});var ss=f.geom.Circle=function(r,n,a,l){Dr.call(this,r,n,a,l,0,Math.PI*2)};x["verb.geom.Circle"]=ss,ss.__name__=["verb","geom","Circle"],ss.__super__=Dr,ss.prototype=M(Dr.prototype,{__class__:ss});var Ln=function(){};x["verb.geom.ISurface"]=Ln,Ln.__name__=["verb","geom","ISurface"],Ln.__interfaces__=[Mn],Ln.prototype={__class__:Ln};var Et=f.geom.NurbsSurface=function(r){this._data=Ye.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Et,Et.__name__=["verb","geom","NurbsSurface"],Et.__interfaces__=[Ln],Et.byKnotsControlPointsWeights=function(r,n,a,l,u,d){return new Et(new ee(r,n,a,l,N.homogenize2d(u,d)))},Et.byCorners=function(r,n,a,l){return new Et(gt.fourPointSurface(r,n,a,l))},Et.byLoftingCurves=function(r,n){return new Et(gt.loftedSurface(function(a){for(var l,u=[],d=0;d<r.length;){var m=r[d];++d,u.push(m.asNurbs())}return l=u,l}(),n))},Et.__super__=Qt,Et.prototype=M(Qt.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 ee(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Et(this.asNurbs())},domainU:function(){return new Ee($.first(this._data.knotsU),$.last(this._data.knotsU))},domainV:function(){return new Ee($.first(this._data.knotsV),$.last(this._data.knotsV))},point:function(r,n){return N.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return At.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return N.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return At.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),At.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,n,a])},closestParam:function(r){return bt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return bt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),he.surfaceSplit(this._data,r,n).map(function(a){return new Et(a)})},splitAsync:function(r,n){return n==null&&(n=!1),At.dispatchMethod(he,"surfaceSplit",[this._data,r,n]).then(function(a){return a.map(function(l){return new Et(l)})})},reverse:function(r){return r==null&&(r=!1),new Et(_t.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),At.dispatchMethod(_t,"surfaceReverse",[this._data,r]).then(function(n){return new Et(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Lt(gt.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),At.dispatchMethod(gt,"surfaceIsocurve",[this._data,r,n]).then(function(a){return new Lt(a)})},boundaries:function(r){return gt.surfaceBoundaryCurves(this._data).map(function(n){return new Lt(n)})},boundariesAsync:function(r){return At.dispatchMethod(gt,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(a){return new Lt(a)})})},tessellate:function(r){return zt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Et(_t.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(_t,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new Et(n)})},__class__:Et});var is=f.geom.ConicalSurface=function(r,n,a,l,u){Et.call(this,gt.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"]=is,is.__name__=["verb","geom","ConicalSurface"],is.__super__=Et,is.prototype=M(Et.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__:is});var as=f.geom.CylindricalSurface=function(r,n,a,l,u){Et.call(this,gt.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"]=as,as.__name__=["verb","geom","CylindricalSurface"],as.__super__=Et,as.prototype=M(Et.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__:as});var Ur=f.geom.EllipseArc=function(r,n,a,l,u){Lt.call(this,gt.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"]=Ur,Ur.__name__=["verb","geom","EllipseArc"],Ur.__super__=Lt,Ur.prototype=M(Lt.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__:Ur});var os=f.geom.Ellipse=function(r,n,a){Ur.call(this,r,n,a,0,Math.PI*2)};x["verb.geom.Ellipse"]=os,os.__name__=["verb","geom","Ellipse"],os.__super__=Ur,os.prototype=M(Ur.prototype,{__class__:os});var ls=f.geom.ExtrudedSurface=function(r,n){Et.call(this,gt.extrudedSurface(p.normalized(n),p.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=ls,ls.__name__=["verb","geom","ExtrudedSurface"],ls.__super__=Et,ls.prototype=M(Et.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:ls});var Vr=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Vr,Vr.__name__=["verb","geom","Intersect"],Vr.curves=function(r,n,a){return a==null&&(a=.001),lt.curves(r.asNurbs(),n.asNurbs(),a)},Vr.curvesAsync=function(r,n,a){return a==null&&(a=.001),At.dispatchMethod(lt,"curves",[r.asNurbs(),n.asNurbs(),a])},Vr.curveAndSurface=function(r,n,a){return a==null&&(a=.001),lt.curveAndSurface(r.asNurbs(),n.asNurbs(),a)},Vr.curveAndSurfaceAsync=function(r,n,a){return a==null&&(a=.001),At.dispatchMethod(lt,"curveAndSurface",[r.asNurbs(),n.asNurbs(),a])},Vr.surfaces=function(r,n,a){return a==null&&(a=.001),lt.surfaces(r.asNurbs(),n.asNurbs(),a).map(function(l){return new Lt(l)})},Vr.surfacesAsync=function(r,n,a){return a==null&&(a=.001),At.dispatchMethod(lt,"surfaces",[r.asNurbs(),n.asNurbs(),a]).then(function(l){return l.map(function(u){return new Lt(u)})})};var hs=f.geom.Line=function(r,n){Lt.call(this,gt.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=hs,hs.__name__=["verb","geom","Line"],hs.__super__=Lt,hs.prototype=M(Lt.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:hs});var us=f.geom.RevolvedSurface=function(r,n,a,l){Et.call(this,gt.revolvedSurface(r.asNurbs(),n,a,l)),this._profile=r,this._center=n,this._axis=a,this._angle=l};x["verb.geom.RevolvedSurface"]=us,us.__name__=["verb","geom","RevolvedSurface"],us.__super__=Et,us.prototype=M(Et.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:us});var cs=f.geom.SphericalSurface=function(r,n){Et.call(this,gt.sphericalSurface(r,[0,0,1],[1,0,0],n)),this._center=r,this._radius=n};x["verb.geom.SphericalSurface"]=cs,cs.__name__=["verb","geom","SphericalSurface"],cs.__super__=Et,cs.prototype=M(Et.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:cs});var ds=f.geom.SweptSurface=function(r,n){Et.call(this,gt.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=ds,ds.__name__=["verb","geom","SweptSurface"],ds.__super__=Et,ds.prototype=M(Et.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:ds});function $e(r){return r instanceof Array?function(){return L.iter(r)}:typeof r.iterator=="function"?Oe(r,r.iterator):r.iterator}var qi,tc=0;function Oe(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=tc++);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 ec=x.Int={__name__:["Int"]},rc=x.Dynamic={__name__:["Dynamic"]},Oo=x.Float=Number;Oo.__name__=["Float"];var Bo=x.Bool=Boolean;Bo.__ename__=["Bool"];var zo=x.Class={__name__:["Class"]},Ro={};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 Xi={},Ys=w.ArrayBuffer||le;Ys.prototype.slice==null&&(Ys.prototype.slice=le.sliceImpl),w.DataView;var Ki=w.Uint8Array||ir._new;(function(r,n){if(r.setImmediate)return;var a=1,l={},u=!1,d=r.document,m;function _(z){return l[a]=y.apply(n,z),a++}function y(z){var U=[].slice.call(arguments,1);return function(){typeof z=="function"?z.apply(n,U):new Function(""+z)()}}function A(z){if(u)setTimeout(y(A,z),0);else{var U=l[z];if(U){u=!0;try{U()}finally{I(z),u=!1}}}}function I(z){delete l[z]}function S(){m=function(){var z=_(arguments);return process.nextTick(y(A,z)),z}}function P(){if(r.postMessage&&!r.importScripts){var z=!0,U=r.onmessage;return r.onmessage=function(){z=!1},r.postMessage("","*"),r.onmessage=U,z}}function k(){var z="setImmediate$"+Math.random()+"$",U=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(z)===0&&A(+V.data.slice(z.length))};r.addEventListener?r.addEventListener("message",U,!1):r.attachEvent("onmessage",U),m=function(){var V=_(arguments);return r.postMessage(z+V,"*"),V}}function T(){var z=new MessageChannel;z.port1.onmessage=function(U){var V=U.data;A(V)},m=function(){var U=_(arguments);return z.port2.postMessage(U),U}}function O(){var z=d.documentElement;m=function(){var U=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){A(U),V.onreadystatechange=null,z.removeChild(V),V=null},z.appendChild(V),U}}function C(){m=function(){var z=_(arguments);return setTimeout(y(A,z),0),z}}var R=Object.getPrototypeOf&&Object.getPrototypeOf(r);R=R&&R.setTimeout?R:r,{}.toString.call(r.process)==="[object process]"?S():P()?k():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?O():C(),R.setImmediate=m,R.clearImmediate=I})(new Function("return this")()),Xt.USE_CACHE=!1,Xt.USE_ENUM_INDEX=!1,Xt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Ht.DEFAULT_RESOLVER=ut,Ht.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Bt.count=0,oe.i64tmp=function(r){var n,a=new Gt(0,0);return n=a,n}(),Ct.__toStr={}.toString,ir.BYTES_PER_ELEMENT=1,It.queue=new D,Ft.memo=new wt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",bt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],bt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],At.THREADS=1,At._init=!1,Fr.basePath="",Jr.uuid=0,Ws.main()}(typeof console<"u"?console:{log:function(){}},e,typeof c<"u"?c:typeof s<"u"?s:typeof self<"u"?self:this),e})})(oh);var zc=oh.exports;const Rn=Bc(zc);class ia{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 b=(e-t)/h-(s-t)/(h+c)+(s-e)/c,f=(s-e)/c-(o-e)/(c+g)+(o-s)/g;b*=c,f*=c,this.init(e,s,b,f)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}let lh=class extends js{constructor(t=[],e=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new Z,this._px=new ia,this._py=new ia,this._pz=new ia,this._points=t.map(h=>new Y(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 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 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 Y){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),b=c-g;this._closed?g+=g>0?0:(Math.floor(Math.abs(g)/h)+1)*h:b===0&&g===h-1&&(g=h-2,b=1);let f,w;this._closed||g>0?f=o[(g-1)%h]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),f=new Y(this._tmp.x,this._tmp.y,this._tmp.z));const x=o[g%h],E=o[(g+1)%h];if(this._closed||g+2<h?w=o[(g+2)%h]:(this._tmp.subVectors(o[h-1],o[h-2]).add(o[h-1]),w=new Y(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let L=Math.pow(f.distanceToSquared(x),M),B=Math.pow(x.distanceToSquared(E),M),D=Math.pow(E.distanceToSquared(w),M);B<1e-4&&(B=1),L<1e-4&&(L=B),D<1e-4&&(D=B),this._px.initNonuniformCatmullRom(f.x,x.x,E.x,w.x,L,B,D),this._py.initNonuniformCatmullRom(f.y,x.y,E.y,w.y,L,B,D),this._pz.initNonuniformCatmullRom(f.z,x.z,E.z,w.z,L,B,D)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,E.x,w.x,this._tension),this._py.initCatmullRom(f.y,x.y,E.y,w.y,this._tension),this._pz.initCatmullRom(f.z,x.z,E.z,w.z,this._tension));return s.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),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 Y(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 Y;return s.copy(e),s.applyMatrix4(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Nt;const t=new Nt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}};class yn{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 Ls(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Jl(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,o){return new yn(t,e,s,o)}static byPoints(t,e,s="Uniform"){let o;switch(s){case"Chord":o=Zl(e,t);break;case"SqrtChord":o=Ql(e,t);break;case"Uniform":default:o=$l(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 yn(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],b=o[2]-h[2];return Math.sqrt(c*c+g*g+b*b)<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 lh(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 yn.byPoints(o,e,s)}}class Kr extends js{constructor(t,e,s,o,h){super();const c=arguments.length;if(c<2||c>5)throw We.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let g,b=3,f=!1;if(c>=3&&(Array.isArray(s)?(g=s,c>=4&&(b=o||3),c>=5&&(f=h)):s!==void 0&&(b=s||3,c>=4&&(f=o))),s===void 0&&c>=4&&(b=o||3,c>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw We.ILLEGAL_PARAMETERS;const w=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Rn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,w,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 We.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Rn.geom.NurbsCurve.byPoints(g,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=yn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Rn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Rn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=yn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Rn.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=Rn.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 Y(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 Y(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],b=(g-c)/(t-1);for(let f=0;f<t;f++){const w=f===t-1?g:c+f*b,x=e.point(w);s.push(new Y(x[0],x[1],x[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 b=h+g*c;s.push(t.point(b))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Nt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,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 Kr(t,e,s,!0)}}var _n=256,hh=[],il=256,Ks;for(;_n--;)hh[_n]=(_n+256).toString(16).substring(1);function Rc(i){var t=0,e=11;if(!Ks||_n+e>il*2)for(Ks="",_n=0;t<il;t++)Ks+=hh[Math.random()*256|0];return Ks.substring(_n,_n+++e)}class Zr{constructor(t,e){t=t||{},jn(t,{objectId:Rc()}),this._attrs=new vl(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:Ja().workingDatabase}set database(t){this._database=t}close(){}}const to=class to extends Zr{constructor(){super(...arguments),this._layer="0",this._color=new $r,this._lineType=Js,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 s=this.getLayerColor();s&&s.RGB!=null&&(t=s)}else this.color.isByBlock||this.color.RGB!=null&&(t=this.color);const e=t.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Js}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}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,o){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:t=>{this.layer=t}}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:t=>{this.color.copy(t)}}}]}}get lineStyle(){var o;const{type:t,name:e}=this.getLineType(),s=(o=this.database)==null?void 0:o.tables.linetypeTable.getAt(e);return s?{type:t,...s.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Js){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Pl?{type:"ByBlock",name:ai}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:ai}}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}attachEntityInfo(t){t&&(t.objectId=this.objectId,this.attrs.has("ownerId")&&(t.ownerId=this.ownerId),t.layerName=this.layer,t.visible=this.visibility)}};to.typeName="Entity";let Ie=to;const eo=class eo extends Ie{};eo.typeName="Curve";let Pe=eo;var Dn=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(Dn||{});const ro=class ro extends Pe{constructor(t,e,s=0,o=!1,h=0,c=0,g=null){super(),this._polyType=t,this._elevation=s;const b=g&&(g==null?void 0:g.length)===e.length,f=e.map((w,x)=>({x:w.x,y:w.y,bulge:b?g[x]:void 0}));this._geo=new bn(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 Nt({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 Y().set(o.x,o.y,this.elevation))),t.lines(e)}};ro.typeName="2dPolyline";let hi=ro;var uh=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(uh||{});const no=class no extends Ie{constructor(){super(),this._position=new Y,this._bulge=0,this._startWidth=0,this._endWidth=0,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get bulge(){return this._bulge}set bulge(t){this._bulge=t}get startWidth(){return this._startWidth}set startWidth(t){this._startWidth=t}get endWidth(){return this._endWidth}set endWidth(t){this._endWidth=t}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};no.typeName="2dVertex";let ba=no;var Bs=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(Bs||{});const so=class so extends Pe{constructor(t,e,s=!1){super(),this._polyType=t,this._geo=new bn(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 Nt({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 Y().set(o.x,o.y,0))),t.lines(e)}};so.typeName="3dPolyline";let ui=so;var ch=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(ch||{});const io=class io extends Ie{constructor(){super(),this._position=new Y,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};io.typeName="3dVertex";let xa=io;const ao=class ao extends Pe{constructor(t,e,s,o,h=Z.Z_AXIS){super(),this._geo=new Da(t,e,s,o,h,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 normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}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)}};ao.typeName="Arc";let ci=ao;const oo=class oo extends Ie{constructor(t){super(),this._blockName=t,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(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 properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:t=>{this.scaleFactors.x=t}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:t=>{this.scaleFactors.y=t}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:t=>{this.scaleFactors.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}get geometricExtents(){const t=new Nt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const c of h)t.union(c.geometricExtents)}const s=new qr().setFromEuler(new nh(this.rotation,0,0)),o=new Xr;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=Yr.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 qr;return t.setFromAxisAngle(Z.Z_AXIS,this.rotation),new Xr().compose(this._position,t,this._scaleFactors)}};oo.typeName="BlockReference";let Fs=oo;const lo=class lo extends Pe{constructor(t,e,s=Z.Z_AXIS){super(),this._geo=new Da(t,e,0,se,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}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}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)}};lo.typeName="Circle";let di=lo;const ho=class ho extends Pe{constructor(t,e,s,o,h,c,g){super(),this._geo=new Vi(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 startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}draw(t){return t.ellipticalArc(this._geo)}};ho.typeName="Ellipse";let pi=ho;const uo=class uo extends Ie{constructor(){super(),this._vertices=[new Y,new Y,new Y],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 Y),this._vertices[3].copy(e);this._vertices[t].copy(e)}setEdgeInvisibilities(t){this._edgeInvisibilities=t}isEdgeVisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<t)===0}makeEdgeInvisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<t}get geometricExtents(){return new Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;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)}};uo.typeName="Face";let mi=uo;var dh=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(dh||{}),ph=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(ph||{});const co=class co extends Ie{constructor(){super(),this._elevation=0,this._geo=new Di,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(t){this._isSolidFill=t}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){const e=t.subEntityTraits;return e.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,patternLines:this.definitionLines},t.area(this._geo)}};co.typeName="Hatch";let Ds=co;var mh=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(mh||{});const po=class po extends Pe{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 Y().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Nt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e)}else return t.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Kr(this._vertices,"Uniform"),this._updated=!1)}};po.typeName="Leader";let gi=po;var fn=(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))(fn||{});const mo=class mo extends Pe{constructor(t,e){super(),this._geo=new li(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,o){const h=this.startPoint,c=this.endPoint;switch(t){case fn.EndPoint:o.push(h),o.push(c);break;case fn.MidPoint:o.push(this.midPoint);break;case fn.Nearest:{const g=this._geo.project(e);o.push(g)}break;case fn.Perpendicular:{const g=this._geo.perpPoint(e);o.push(g)}break;case fn.Tangent:o.push(h);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,s=this.endPoint,o=[new Y(e.x,e.y,0),new Y(s.x,s.y,0)];return t.lines(o)}};mo.typeName="Line";let fi=mo;var Va=(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))(Va||{}),Nr=(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))(Nr||{}),Se=(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))(Se||{}),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||{}),ja=(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))(ja||{}),Wa=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Wa||{});let gh=class fh{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(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new ve;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new ve;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new fh;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 go=class go extends Ie{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=Se.TopLeft,this._direction=new Z(1,0,0),this._drawingDirection=Nr.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Nt}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:Se[1],value:1},{label:Se[2],value:2},{label:Se[3],value:3},{label:Se[4],value:4},{label:Se[5],value:5},{label:Se[6],value:6},{label:Se[7],value:7},{label:Se[8],value:8},{label:Se[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Nr[1],value:1},{label:Nr[2],value:2},{label:Nr[3],value:3},{label:Nr[4],value:4},{label:Nr[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("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()};return t.mtext(s,o,e)}};go.typeName="MText";let _i=go;const fo=class fo extends Pe{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 We.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Kr(t,e,s,o):this._geo=new Kr(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)}};fo.typeName="Spline";let Us=fo;const Fc=new Z,_o=class _o extends Fs{constructor(t,e,s){super(t),this._attachmentPoint=Se.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Nt}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 M=0;M<=this.numColumns;M++)s+=M>0?this.columnWidth(M-1):0,h[c++]=s,h[c++]=e,h[c++]=0}const g=[],b=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 M=0;M<this.numRows;M++){e+=M>0?this.rowHeight(M-1):0;const L=this.cell(M*this.numColumns+E);if(f=M*this.numColumns+E,L&&!b[f]){const B=L.borderWidth??1,D=L.borderHeight??1;this.fillVisited(b,f,this.numColumns,B,D),o[c++]=E+M*(this.numColumns+1),o[c++]=E+M*(this.numColumns+1)+B;const F=h[o[c-1]*3]-s,dt=E+(M+D)*(this.numColumns+1)+B;E+B==this.numColumns&&(o[c++]=E+M*(this.numColumns+1)+B,o[c++]=dt);const vt=-h[dt*3+1]-e;if(M+D==this.numRows&&(o[c++]=E+(M+D)*(this.numColumns+1)+D,o[c++]=E+(M+D)*(this.numColumns+1)),o[c++]=E+(M+D)*(this.numColumns+1),o[c++]=E+M*(this.numColumns+1),L.text){const ot=L.attachmentPoint||this.attachmentPoint||Se.MiddleCenter,W=this.getTableTextOffset(ot,F,vt),ut={text:L.text,height:L.textHeight,width:F,position:Fc.set(s,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ot},st=this.getTextStyle(L);g.push(t.mtext(ut,st))}}}}g.push(t.lineSegments(h,3,o));const w=t.group(g),x=new qr;return x.setFromAxisAngle(Z.Z_AXIS,this.rotation),al.compose(this.position,x,this.scaleFactors),w.applyMatrix(al),this.attachEntityInfo(w),w}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}};_o.typeName="Table";let yi=_o;const al=new Xr;var _h=(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))(_h||{}),yh=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(yh||{});const yo=class yo extends Ie{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(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new Nt}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("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:Nr.BOTTOM_TO_TOP,attachmentPoint:Se.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return t.mtext(s,o,e)}};yo.typeName="Text";let vi=yo;const vo=class vo extends Pe{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(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new bn(this._vertices,!0),s=new Di;s.add(e);const o=t.subEntityTraits;return o.fillType={solidFill:!0,patternAngle:0,patternLines:[]},t.area(s)}};vo.typeName="Trace";let bi=vo;const bo=class bo extends Pe{constructor(){super(),this._elevation=0,this._geo=new bn}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,b={x:e.x,y:e.y,bulge:s,startWidth:c,endWidth:g};this._geo.addVertexAt(t,b)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new Y(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,this.elevation))),t.lines(e)}};bo.typeName="Polyline";let xi=bo;const xo=class xo extends Ie{constructor(){super(),this._geo=new Y}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Nt().expandByPoint(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}};xo.typeName="Point";let wi=xo;var vh=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(vh||{}),bh=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(bh||{});const wo=class wo extends Ie{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new Y,this._scale=new Zt(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 Nt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,o=new ve;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,b=c.y*s+h.y;t.push(new Y(g,b,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++)$s.copy(t[e]),$s.rotateAround(ol,this._rotation),t[e].setX($s.x),t[e].setY($s.y)}t.push(t[0])}return t}};wo.typeName="RasterImage";let Vs=wo;const ol=new Tt,$s=new Tt,Ao=class Ao extends Pe{constructor(){super(),this._basePoint=new Y,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 Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}};Ao.typeName="Ray";let Ai=Ao;const So=class So extends Ie{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(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new Nt}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 gh;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 Y(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new Y(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),s.push(e.lines([new Y(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new Y(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new Y(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new Y(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new Y(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new Y(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),s}};So.typeName="Viewport";let Si=So;const Io=class Io extends Vs{draw(t){const e=this.boundaryPath(),s=new Di;return s.add(new bn(e)),t.area(s)}};Io.typeName="Wipeout";let Ii=Io;const Po=class Po extends Pe{constructor(){super(),this._basePoint=new Y,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 Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}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)}};Po.typeName="Xline";let Pi=Po;var xh=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(xh||{});const Eo=class Eo extends Ie{constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new Y,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new Y,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 Gn),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 Xr().makeTranslation(this.dimBlockPosition),h=Yr.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 Yr.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Yr.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 Y().subVectors(e,t).normalize();return new Y(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():Va.Closed}};Eo.typeName="Dimension";let Cr=Eo;const ko=class ko extends Cr{constructor(t,e,s,o,h=null,c=null){super(),this._centerPoint=new Y().copy(t),this._xLine1Point=new Y().copy(e),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(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Nt}};ko.typeName="3PointAngularDimension";let Ei=ko;const Mo=class Mo extends Cr{constructor(t,e,s,o=null,h=null){super(),this._dimLinePoint=new Y().copy(s),this._xLine1Point=new Y().copy(t),this._xLine2Point=new Y().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 Nt}get isAppendArrow(){return!1}};Mo.typeName="AlignedDimension";let ki=Mo;const To=class To extends Cr{constructor(t,e,s,o,h=null,c=null){super(),this._arcPoint=new Y().copy(o),this._xLine1Point=new Y().copy(e),this._xLine2Point=new Y().copy(s),this._centerPoint=new Y().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 Nt}};To.typeName="ArcDimension";let wa=To;const No=class No extends Cr{constructor(t,e,s=0,o=null,h=null){super(),this._chordPoint=new Y().copy(t),this._farChordPoint=new Y().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 Nt}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)}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)})}};No.typeName="DiametricDimension";let Mi=No;const Co=class Co extends Cr{constructor(t,e,s=null,o=null){super(),this._definingPoint=new Y().copy(t),this._leaderEndPoint=new Y().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 Nt}get arrowLineCount(){return 0}};Co.typeName="OrdinateDimension";let Ti=Co;const Lo=class Lo extends Cr{constructor(t,e,s,o=null,h=null){super(),this._center=new Y().copy(t),this._chordPoint=new Y().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 Nt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};Lo.typeName="RadialDimension";let Ni=Lo;class Gi extends Zr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new ve,this._extents=new Nt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class Ha extends Zr{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 ji(this._recordsByName)}}class wh extends Ha{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 Ah extends Zr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class Sh{constructor(t){this.db=t}createDefaultLayer(){const t=new $r;return t.colorIndex=7,this.db.tables.layerTable.add(new Hi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new Rs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Rs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Rs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Qa({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Gn({name:"Standard",dimtxsty:"Standard"}))}createDefaultLayout(){const t=new Gi;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this.db.tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.dictionaries.layouts.setAt(t.layoutName,t),this.db.tables.blockTable.modelSpace.layoutId=t.objectId}createArrowBlock(){if(!this.db.tables.blockTable.getAt("_CAXARROW")){const e=new Ds;e.patternName="SOLID";const s=new Ua;s.add(new Os({x:0,y:0},{x:-1,y:.125})),s.add(new Os({x:-1,y:.125},{x:-1,y:-.125})),s.add(new Os({x:-1,y:-.125},{x:0,y:0})),e.add(s);const o=new pe;o.name="_CAXARROW",o.appendEntity(e),this.db.tables.blockTable.add(o)}}}var 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 Dc(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function Uc(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}var Ih=(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))(Ih||{});class ji{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 Ph="Load Database";class Te extends xl{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Ia.getInstance().getEntry(Ph),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 qa{constructor(t={}){this.config=t}async read(t,e,s,o){const h={name:Ph,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(w=>{w!=="total"&&(f+=`- ${w}: ${this.data[w]} ms
5
- `)}),f+=`- total: ${this.data.total} ms`,f}};Ia.getInstance().collect(h),this.progress=o;const c={value:0},g=new wl;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new Te({stage:"START",step:1,progress:c,task:async f=>f},o)),g.addTask(new Te({stage:"PARSE",step:5,progress:c,task:async f=>await this.parse(f)},o)),g.addTask(new Te({stage:"FONT",step:5,progress:c,task:async f=>{const w=this.getFonts(f.model);return{model:f.model,data:w}}},o)),g.addTask(new Te({stage:"LTYPE",step:1,progress:c,task:async f=>(this.processLineTypes(f.model,e),f)},o)),g.addTask(new Te({stage:"STYLE",step:1,progress:c,task:async f=>(this.processTextStyles(f.model,e),f)},o)),g.addTask(new Te({stage:"DIMSTYLE",step:1,progress:c,task:async f=>(this.processDimStyles(f.model,e),f)},o)),g.addTask(new Te({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 Te({stage:"VPORT",step:1,progress:c,task:async f=>(this.processViewports(f.model,e),f)},o)),g.addTask(new Te({stage:"HEADER",step:1,progress:c,task:async f=>(this.processHeader(f.model,e),f)},o)),g.addTask(new Te({stage:"BLOCK_RECORD",step:5,progress:c,task:async f=>(this.processBlockTables(f.model,e),f)},o)),g.addTask(new Te({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 Te({stage:"BLOCK",step:5,progress:c,task:async f=>(await this.processBlocks(f.model,e),f)},o)),g.addTask(new Te({stage:"ENTITY",step:100,progress:c,task:async f=>(await this.processEntities(f.model,e,s,c,o),f)},o)),g.addTask(new Te({stage:"END",step:0,progress:c,task:async f=>f},o));const b=Date.now();await g.run(t),h.data.total=Date.now()-b}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"),Yr.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 ue,ps,Jt,ie,ms,rr,xe,_r,nr,sn,gs,fs,an,on,_s,ys,vs,Re,yr,qt,ln,bs,yt,we,xs,Ae,ws,vr,br,sr,As,hn,Fe,xr,un,aa,oa,wr,Ar,Ss,Is,Sr,Ps,la,ha,ce,Ir,de,De,ua,ca,da,pa,Pr,Ue,cn,Es,dn,Ve,Er,Ge,kr;(ue={})[ue.None=0]="None",ue[ue.Anonymous=1]="Anonymous",ue[ue.NonConstant=2]="NonConstant",ue[ue.Xref=4]="Xref",ue[ue.XrefOverlay=8]="XrefOverlay",ue[ue.ExternallyDependent=16]="ExternallyDependent",ue[ue.ResolvedOrDependent=32]="ResolvedOrDependent",ue[ue.ReferencedXref=64]="ReferencedXref";(ps={})[ps.BYBLOCK=0]="BYBLOCK",ps[ps.BYLAYER=256]="BYLAYER";(Jt={})[Jt.Rotated=0]="Rotated",Jt[Jt.Aligned=1]="Aligned",Jt[Jt.Angular=2]="Angular",Jt[Jt.Diameter=3]="Diameter",Jt[Jt.Radius=4]="Radius",Jt[Jt.Angular3Point=5]="Angular3Point",Jt[Jt.Ordinate=6]="Ordinate",Jt[Jt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Jt[Jt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Jt[Jt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(ie={})[ie.TopLeft=1]="TopLeft",ie[ie.TopCenter=2]="TopCenter",ie[ie.TopRight=3]="TopRight",ie[ie.MiddleLeft=4]="MiddleLeft",ie[ie.MiddleCenter=5]="MiddleCenter",ie[ie.MiddleRight=6]="MiddleRight",ie[ie.BottomLeft=7]="BottomLeft",ie[ie.BottomCenter=8]="BottomCenter",ie[ie.BottomRight=9]="BottomRight";(ms={})[ms.AtLeast=1]="AtLeast",ms[ms.Exact=2]="Exact";var ll=((rr={})[rr.Center=0]="Center",rr[rr.Above=1]="Above",rr[rr.Outside=2]="Outside",rr[rr.JIS=3]="JIS",rr[rr.Below=4]="Below",rr),Fn=((xe={})[xe.Feet=0]="Feet",xe[xe.None=1]="None",xe[xe.Inch=2]="Inch",xe[xe.FeetAndInch=3]="FeetAndInch",xe[xe.Leading=4]="Leading",xe[xe.Trailing=8]="Trailing",xe[xe.LeadingAndTrailing=12]="LeadingAndTrailing",xe),Vc=((_r={})[_r.None=0]="None",_r[_r.Leading=1]="Leading",_r[_r.Trailing=2]="Trailing",_r[_r.LeadingAndTrailing=3]="LeadingAndTrailing",_r),Gc=((nr={})[nr.Center=0]="Center",nr[nr.Left=1]="Left",nr[nr.Right=2]="Right",nr[nr.OverFirst=3]="OverFirst",nr[nr.OverSecond=4]="OverSecond",nr),jc=((sn={})[sn.Bottom=0]="Bottom",sn[sn.Center=1]="Center",sn[sn.Top=2]="Top",sn),Wc=((gs={})[gs.PatternFill=0]="PatternFill",gs[gs.SolidFill=1]="SolidFill",gs);(fs={})[fs.NonAssociative=0]="NonAssociative",fs[fs.Associative=1]="Associative";(an={})[an.Normal=0]="Normal",an[an.Outer=1]="Outer",an[an.Ignore=2]="Ignore";(on={})[on.UserDefined=0]="UserDefined",on[on.Predefined=1]="Predefined",on[on.Custom=2]="Custom";(_s={})[_s.NotAnnotated=0]="NotAnnotated",_s[_s.Annotated=1]="Annotated";(ys={})[ys.Solid=0]="Solid",ys[ys.Gradient=1]="Gradient";(vs={})[vs.TwoColor=0]="TwoColor",vs[vs.OneColor=1]="OneColor";var Hc=((Re={})[Re.Default=0]="Default",Re[Re.External=1]="External",Re[Re.Polyline=2]="Polyline",Re[Re.Derived=4]="Derived",Re[Re.Textbox=8]="Textbox",Re[Re.Outermost=16]="Outermost",Re),Zs=((yr={})[yr.Line=1]="Line",yr[yr.Circular=2]="Circular",yr[yr.Elliptic=3]="Elliptic",yr[yr.Spline=4]="Spline",yr),Yc=((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);Yc.Off;(ln={})[ln.Standard=-3]="Standard",ln[ln.ByLayer=-2]="ByLayer",ln[ln.ByBlock=-1]="ByBlock";(bs={})[bs.English=0]="English",bs[bs.Metric=1]="Metric";(yt={})[yt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",yt[yt.FRONT_CLIPPING=2]="FRONT_CLIPPING",yt[yt.BACK_CLIPPING=4]="BACK_CLIPPING",yt[yt.UCS_FOLLOW=8]="UCS_FOLLOW",yt[yt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",yt[yt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",yt[yt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",yt[yt.FAST_ZOOM=128]="FAST_ZOOM",yt[yt.SNAP_MODE=256]="SNAP_MODE",yt[yt.GRID_MODE=512]="GRID_MODE",yt[yt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",yt[yt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",yt[yt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",yt[yt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",yt[yt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",yt[yt.UNUSED=32768]="UNUSED",yt[yt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",yt[yt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",yt[yt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",yt[yt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",yt[yt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",yt[yt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(we={})[we.OPTIMIZED_2D=0]="OPTIMIZED_2D",we[we.WIREFRAME=1]="WIREFRAME",we[we.HIDDEN_LINE=2]="HIDDEN_LINE",we[we.FLAT_SHADED=3]="FLAT_SHADED",we[we.GOURAUD_SHADED=4]="GOURAUD_SHADED",we[we.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",we[we.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";(Ae={})[Ae.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",Ae[Ae.TOP=1]="TOP",Ae[Ae.BOTTOM=2]="BOTTOM",Ae[Ae.FRONT=3]="FRONT",Ae[Ae.BACK=4]="BACK",Ae[Ae.LEFT=5]="LEFT",Ae[Ae.RIGHT=6]="RIGHT";(ws={})[ws.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ws[ws.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(vr={})[vr.ByLayer=0]="ByLayer",vr[vr.ByBlock=1]="ByBlock",vr[vr.ByDictionaryDefault=2]="ByDictionaryDefault",vr[vr.ByObject=3]="ByObject";function St(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 Xa=Symbol();function xt(i,t){return(e,s,o)=>{let h=function(b,f=!1){return b.reduce((w,x)=>{x.pushContext&&w.push({});let E=w[w.length-1];for(let M of typeof x.code=="number"?[x.code]:x.code){let L=E[M]??(E[M]=[]);x.isMultiple&&L.length&&f&&console.warn(`Snippet ${L[L.length-1].name} for code(${M}) is shadowed by ${x.name}`),L.push(x)}return w},[{}])}(i,s.debug),c=!1,g=h.length-1;for(;!St(e,0,"EOF");){let b=function(D,F,dt){return D.find((vt,ot)=>{var W;return ot>=dt&&((W=vt[F])==null?void 0:W.length)})}(h,e.code,g),f=b==null?void 0:b[e.code],w=f==null?void 0:f[f.length-1];if(!b||!w){s.rewind();break}w.isMultiple||b[e.code].pop();let{name:x,parser:E,isMultiple:M,isReducible:L}=w,B=E==null?void 0:E(e,s,o);if(B===Xa){s.rewind();break}if(x){let[D,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=ma(ot[ut]),Gt=ma(ot[ut+1]);Object.prototype.hasOwnProperty.call(W,st)||(typeof Gt=="number"?W[st]=[]:W[st]={}),W=W[st]}return[W,ma(ot[ot.length-1])]}(o,x);M&&!L?(Object.prototype.hasOwnProperty.call(D,F)||(D[F]=[]),D[F].push(B)):D[F]=B}w.pushContext&&(g-=1),c=!0,e=s.next()}return t&&Object.setPrototypeOf(o,t),c}}function ma(i){let t=Number.parseInt(i);return Number.isNaN(t)?i:t}function v({value:i}){return i}function j(i,t){return Rt(t)}function Dt({value:i}){return!!i}let qc=[{code:1001,name:"xdata",parser:Eh}];function Eh(i,t){var o;if(!St(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let s=[e.value];for(;!St(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:Mr(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Mr(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Mr(i.code),value:i.value});break;case 1010:h.push({type:Mr(i.code),value:Rt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Mr(i.code),value:Rt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Mr(i.code),value:Rt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Mr(i.code),value:Rt(t)});break;case 1041:h.push({name:"distance",type:Mr(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Mr(i.code),value:i.value})}i=t.next()}return t.rewind(),e}function Mr(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 vn(i,t,e){for(;St(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(;!St(c,102)&&!St(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,b){for(;!St(c,102,"}")&&!St(c,0,"EOF");)b.push(c),c=g.next()}(i,t,e.extensions[h]),i=t.next()}t.rewind()}let Xc=0;function kh(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=Xc++)}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 Mh(i){return Kc[i]}(br={})[br.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",br[br.CAST=1]="CAST",br[br.RECEIVE=2]="RECEIVE",br[br.IGNORE=3]="IGNORE";let Vt=[...qc,{code:284,name:"shadowMode",parser:v},{code:390,name:"plotStyleHardId",parser:v},{code:380,name:"plotStyleType",parser:v},{code:440,name:"transparency",parser:v},{code:430,name:"colorName",parser:v},{code:420,name:"color",parser:v},{code:310,name:"proxyEntity",isMultiple:!0,parser:v},{code:92,name:"proxyByte",parser:v},{code:60,name:"isVisible",parser:Dt},{code:48,name:"lineTypeScale",parser:v},{code:370,name:"lineweight",parser:v},{code:62,name:"colorIndex",parser(i,t,e){let s=i.value;return s>0&&s<256&&(e.color=Mh(Math.abs(s))),s}},{code:347,name:"materialObjectHardId",parser:v},{code:6,name:"lineType",parser:v},{code:8,name:"layer",parser:v},{code:410,name:"layoutTabName",parser:v},{code:67,name:"isInPaperSpace",parser:Dt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:v},{code:102,parser:vn},{code:102,parser:vn},{code:102,parser:vn},{code:5,name:"handle",parser:v}];function Wi(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 Th(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let $c={extrusionDirection:{x:0,y:0,z:1}},Zc=[{code:210,name:"extrusionDirection",parser:j},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:100,name:"subclassMarker",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j},{code:39,name:"thickness",parser:v},{code:100},...Vt];class Nh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Th(this,"parser",xt(Zc,$c))}}Th(Nh,"ForEntityName","ARC");(sr={})[sr.NONE=0]="NONE",sr[sr.INVISIBLE=1]="INVISIBLE",sr[sr.CONSTANT=2]="CONSTANT",sr[sr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",sr[sr.PRESET=8]="PRESET";(As={})[As.MULTILINE=2]="MULTILINE",As[As.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(hn={})[hn.NONE=0]="NONE",hn[hn.MIRRORED_X=2]="MIRRORED_X",hn[hn.MIRRORED_Y=4]="MIRRORED_Y";var Qc=((Fe={})[Fe.LEFT=0]="LEFT",Fe[Fe.CENTER=1]="CENTER",Fe[Fe.RIGHT=2]="RIGHT",Fe[Fe.ALIGNED=3]="ALIGNED",Fe[Fe.MIDDLE=4]="MIDDLE",Fe[Fe.FIT=5]="FIT",Fe),Jc=((xr={})[xr.BASELINE=0]="BASELINE",xr[xr.BOTTOM=1]="BOTTOM",xr[xr.MIDDLE=2]="MIDDLE",xr[xr.TOP=3]="TOP",xr);function Ch(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Lh={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Qc.LEFT,valign:Jc.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Oh=[{code:73,name:"valign",parser:v},{code:100},{code:210,name:"extrusionDirection",parser:j},{code:11,name:"endPoint",parser:j},{code:72,name:"valign",parser:v},{code:72,name:"halign",parser:v},{code:71,name:"generationFlag",parser:v},{code:7,name:"styleName",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"xScale",parser:v},{code:50,name:"rotation",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:j},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Bh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ch(this,"parser",xt(Oh,Lh))}}function zh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ch(Bh,"ForEntityName","TEXT");let td={...Lh},ed=[{code:2},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:j},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedRecord",parser:Dt},{code:100},{code:280,name:"isLocked",parser:Dt},{code:74,name:"valign",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:3,name:"prompt",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},...Oh.slice(2)];class Rh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){zh(this,"parser",xt(ed,td))}}zh(Rh,"ForEntityName","ATTDEF");(un={})[un.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",un[un.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",un[un.BY_STYLE=5]="BY_STYLE";function rd(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*Ci(i,t=1/0,e=1){for(let s=i;s!==t;s+=e)yield s}function Wr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function Ka(i,t,e){if(St(t,102))return vn(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=Mh(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=Eh(t,e);break;default:return!1}return!0}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}let nd={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},ei=[{code:46,name:"annotationHeight",parser:v},{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:v},{code:49,name:"columnGutter",parser:v},{code:48,name:"columnWidth",parser:v},{code:79,name:"columnAutoHeight",parser:v},{code:78,name:"columnFlowReversed",parser:v},{code:76,name:"columnCount",parser:v},{code:75,name:"columnType",parser:v},{code:441,name:"backgroundFillTransparency",parser:v},{code:63,name:"backgroundFillColor",parser:v},{code:45,name:"fillBoxScale",parser:v},{code:[...Ci(430,440)],name:"backgroundColor",parser:v},{code:[...Ci(420,430)],name:"backgroundColor",parser:v},{code:90,name:"backgroundFill",parser:v},{code:44,name:"lineSpacing",parser:v},{code:73,name:"lineSpacingStyle",parser:v},{code:50,name:"rotation",parser:v},{code:43},{code:42},{code:11,name:"direction",parser:j},{code:210,name:"extrusionDirection",parser:j},{code:7,name:"styleName",parser:v},...Wi("text"),{code:72,name:"drawingDirection",parser:v},{code:71,name:"attachmentPoint",parser:v},{code:41,name:"width",parser:v},{code:40,name:"height",parser:v},{code:10,name:"insertionPoint",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Dh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Fh(this,"parser",xt(ei,nd))}}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}Fh(Dh,"ForEntityName","MTEXT");let sd={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},id=[...ei.slice(ei.findIndex(({name:i})=>i==="columnType"),ei.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!St(i,0,"MTEXT"))return Xa}},{code:2,name:"definitionTag",parser:v},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:j},{code:340,name:"secondaryAttributesHardId",parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedEntriesKeep",parser:Dt},{code:100},{code:280,name:"lockPositionFlag",parser:Dt},{code:210,name:"extrusionDirection",parser:j},{code:11,name:"alignmentPoint",parser:j},{code:74,name:"verticalJustification",parser:v},{code:72,name:"horizontalJustification",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:7,name:"textStyle",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"scale",parser:v},{code:50,name:"rotation",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:j},{code:39,name:"thickness",parser:v},{code:100},...Vt];class Vh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Uh(this,"parser",xt(id,sd))}}function Gh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Uh(Vh,"ForEntityName","ATTRIB");let ad=[...Wi("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class jh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gh(this,"parser",xt(ad))}}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}Gh(jh,"ForEntityName","BODY");let od={thickness:0,extrusionDirection:{x:0,y:0,z:1}},ld=[{code:210,name:"extrusionDirection",parser:j},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Hh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wh(this,"parser",xt(ld,od))}}Wh(Hh,"ForEntityName","CIRCLE");class ri{parseEntity(t,e){let s={};for(;!St(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:Ka(o,h,c)}})(s,e,t),e=t.next()}return s}}function Yh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}oa="DIMENSION",(aa="ForEntityName")in ri?Object.defineProperty(ri,aa,{value:oa,enumerable:!0,configurable:!0,writable:!0}):ri[aa]=oa;let hd={extrusionDirection:{x:0,y:0,z:1}},ud=[{code:42,name:"endAngle",parser:v},{code:41,name:"startAngle",parser:v},{code:40,name:"axisRatio",parser:v},{code:210,name:"extrusionDirection",parser:j},{code:11,name:"majorAxisEndPoint",parser:j},{code:10,name:"center",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class qh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Yh(this,"parser",xt(ud,hd))}}Yh(qh,"ForEntityName","ELLIPSE");(wr={})[wr.First=1]="First",wr[wr.Second=2]="Second",wr[wr.Third=4]="Third",wr[wr.Fourth=8]="Fourth";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}let cd=[{code:13,name:"vertices.3",parser:j},{code:12,name:"vertices.2",parser:j},{code:11,name:"vertices.1",parser:j},{code:10,name:"vertices.0",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Kh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Xh(this,"parser",xt(cd))}}Xh(Kh,"ForEntityName","3DFACE");let $h=[{code:330,name:"sourceBoundaryObjects",parser:v,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:v}],dd=[{code:11,name:"end",parser:j},{code:10,name:"start",parser:j}],pd=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j}],md=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"lengthOfMinorAxis",parser:v},{code:11,name:"end",parser:j},{code:10,name:"center",parser:j}],gd=[{code:13,name:"endTangent",parser:j},{code:12,name:"startTangent",parser:j},{code:11,name:"fitDatum",isMultiple:!0,parser:j},{code:97,name:"numberOfFitData",parser:v},{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:v},{code:96,name:"numberOfControlPoints",parser:v},{code:95,name:"numberOfKnots",parser:v},{code:74,name:"isPeriodic",parser:Dt},{code:73,name:"splineFlag",parser:v},{code:94,name:"degree",parser:v}],fd={[Zs.Line]:dd,[Zs.Circular]:pd,[Zs.Elliptic]:md,[Zs.Spline]:gd},_d=[...$h,{code:72,name:"edges",parser(i,t){let e={type:i.value},s=xt(fd[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:v}],yd=[...$h,{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:v},{code:73,name:"isClosed",parser:Dt},{code:72,name:"hasBulge",parser:Dt}],vd=[{code:49,name:"dashLengths",parser:v,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:v},{code:45,name:"offset",parser:hl},{code:43,name:"base",parser:hl},{code:53,name:"angle",parser:v}];function hl(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 Zh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let bd={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},xd=[{code:470},{code:463},{code:462,name:"colorTint",parser:v},{code:461,name:"gradientDefinition",parser:v},{code:460,name:"gradientRotation",parser:v},{code:453,name:"numberOfColors",parser:v},{code:452,name:"gradientColorFlag",parser:v},{code:451},{code:450,name:"gradientFlag",parser:v},{code:10,name:"seedPoints",parser:j,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:j},{code:98,name:"numberOfSeedPoints",parser:v},{code:47,name:"pixelSize",parser:v},{code:53,name:"definitionLines",parser:function(i,t){let e={};return xt(vd)(i,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:v},{code:77,name:"isDouble",parser:Dt},{code:73,name:"isAnnotated",parser:Dt},{code:41,name:"patternScale",parser:v},{code:52,name:"patternAngle",parser:v},{code:76,name:"patternType",parser:v},{code:75,name:"hatchStyle",parser:v},{code:92,name:"boundaryPaths",parser:function(i,t){let e={boundaryPathTypeFlag:i.value},s=e.boundaryPathTypeFlag&Hc.Polyline;return i=t.next(),s?xt(yd)(i,t,e):xt(_d)(i,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:v},{code:71,name:"associativity",parser:v},{code:63,name:"patternFillColor",parser:v},{code:70,name:"solidFill",parser:v},{code:2,name:"patternName",parser:v},{code:210,name:"extrusionDirection",parser:j},{code:10,name:"elevationPoint",parser:j},{code:100,name:"subclassMarker",parser:v,pushContext:!0},...Vt];class Qh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zh(this,"parser",xt(xd,bd))}}Zh(Qh,"ForEntityName","HATCH");(Ar={})[Ar.ShowImage=1]="ShowImage",Ar[Ar.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",Ar[Ar.UseClippingBoundary=4]="UseClippingBoundary",Ar[Ar.TransparencyIsOn=8]="TransparencyIsOn";(Ss={})[Ss.Rectangular=1]="Rectangular",Ss[Ss.Polygonal=2]="Polygonal";(Is={})[Is.Outside=0]="Outside",Is[Is.Inside=1]="Inside";function Jh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let wd={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Ad=[{code:290,name:"clipMode",parser:v},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:j},{code:91,name:"countBoundaryPoints",parser:v},{code:71,name:"clippingBoundaryType",parser:v},{code:360,name:"imageDefReactorHandle",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipped",parser:Dt},{code:70,name:"flags",parser:v},{code:340,name:"imageDefHandle",parser:v},{code:13,name:"imageSize",parser:j},{code:12,name:"vPixel",parser:j},{code:11,name:"uPixel",parser:j},{code:10,name:"position",parser:j},{code:90,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class tu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Jh(this,"parser",xt(Ad,wd))}}function eu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Jh(tu,"ForEntityName","IMAGE");let Sd={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Id=[{code:210,name:"extrusionDirection",parser:j},{code:45,name:"rowSpacing",parser:v},{code:44,name:"columnSpacing",parser:v},{code:71,name:"rowCount",parser:v},{code:70,name:"columnCount",parser:v},{code:50,name:"rotation",parser:v},{code:43,name:"zScale",parser:v},{code:42,name:"yScale",parser:v},{code:41,name:"xScale",parser:v},{code:10,name:"insertionPoint",parser:j},{code:2,name:"name",parser:v},{code:66,name:"isVariableAttributes",parser:Dt},{code:100,name:"subclassMarker",parser:v},...Vt];class ru{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){eu(this,"parser",xt(Id,Sd))}}function nu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}eu(ru,"ForEntityName","INSERT");let Pd={isArrowheadEnabled:!0},Ed=[{code:213,name:"offsetFromAnnotation",parser:j},{code:212,name:"offsetFromBlock",parser:j},{code:211,name:"horizontalDirection",parser:j},{code:210,name:"normal",parser:j},{code:340,name:"associatedAnnotation",parser:v},{code:77,name:"byBlockColor",parser:v},{code:10,name:"vertices",parser:j,isMultiple:!0},{code:76,name:"numberOfVertices",parser:v},{code:41,name:"textWidth",parser:v},{code:40,name:"textHeight",parser:v},{code:75,name:"isHooklineExists",parser:Dt},{code:74,name:"isHooklineSameDirection",parser:Dt},{code:73,name:"leaderCreationFlag",parser:v},{code:72,name:"isSpline",parser:Dt},{code:71,name:"isArrowheadEnabled",parser:Dt},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class su{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nu(this,"parser",xt(Ed,Pd))}}nu(su,"ForEntityName","LEADER");(Sr={})[Sr.TextAnnotation=0]="TextAnnotation",Sr[Sr.ToleranceAnnotation=1]="ToleranceAnnotation",Sr[Sr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Sr[Sr.NoAnnotation=3]="NoAnnotation";function iu(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={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Md=[{code:210,name:"extrusionDirection",parser:j},{code:11,name:"endPoint",parser:j},{code:10,name:"startPoint",parser:j},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class au{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){iu(this,"parser",xt(Md,kd))}}iu(au,"ForEntityName","LINE");(Ps={})[Ps.IS_CLOSED=1]="IS_CLOSED",Ps[Ps.PLINE_GEN=128]="PLINE_GEN";let Td={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Nd={bulge:0},Cd=[{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:91,name:"id",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v}],Ld=[{code:210,name:"extrusionDirection",parser:j},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return xt(Cd,Nd)(i,t,e),e}},{code:39,name:"thickness",parser:v},{code:38,name:"elevation",parser:v},{code:43,name:"constantWidth",parser:v},{code:70,name:"flag",parser:v},{code:90,name:"numberOfVertices",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class ni{parseEntity(t,e){let s={};return xt(Ld,Td)(e,t,s),s}}function ou(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ha="LWPOLYLINE",(la="ForEntityName")in ni?Object.defineProperty(ni,la,{value:ha,enumerable:!0,configurable:!0,writable:!0}):ni[la]=ha;let Od=[{code:90,name:"overridenSubEntityCount",parser:v},{code:140,name:"edgeCreaseWeights",parser:v,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:v},{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&&!St(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:j,isMultiple:!0},{code:92,name:"verticesCount",parser:v},{code:91,name:"subdivisionLevel",parser:v},{code:40,name:"blendCrease",parser:v},{code:72,name:"isBlendCreased",parser:Dt},{code:71,name:"version",parser:v},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Vt];class lu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ou(this,"parser",xt(Od))}}function hu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ou(lu,"ForEntityName","MESH");let Bd={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},zd=[{code:50,name:"angle",parser:v},{code:210,name:"extrusionDirection",parser:j},{code:39,name:"thickness",parser:v},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class uu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){hu(this,"parser",xt(zd,Bd))}}hu(uu,"ForEntityName","POINT");(ce={})[ce.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ce[ce.CURVE_FIT=2]="CURVE_FIT",ce[ce.SPLINE_FIT=4]="SPLINE_FIT",ce[ce.POLYLINE_3D=8]="POLYLINE_3D",ce[ce.POLYGON_3D=16]="POLYGON_3D",ce[ce.CLOSED_POLYGON=32]="CLOSED_POLYGON",ce[ce.POLYFACE=64]="POLYFACE",ce[ce.CONTINUOUS=128]="CONTINUOUS";var Qs=((Ir={})[Ir.NONE=0]="NONE",Ir[Ir.QUADRATIC=5]="QUADRATIC",Ir[Ir.CUBIC=6]="CUBIC",Ir[Ir.BEZIER=8]="BEZIER",Ir),Rd=((de={})[de.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",de[de.TANGENT_DEFINED=2]="TANGENT_DEFINED",de[de.NOT_USED=4]="NOT_USED",de[de.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",de[de.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",de[de.FOR_POLYLINE=32]="FOR_POLYLINE",de[de.FOR_POLYGON=64]="FOR_POLYGON",de[de.POLYFACE=128]="POLYFACE",de);function cu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Fd={startWidth:0,endWidth:0,bulge:0},Dd=[{code:91,name:"id",parser:v},{code:[...Ci(71,75)],name:"faces",isMultiple:!0,parser:v},{code:50,name:"tangentDirection",parser:v},{code:70,name:"flag",parser:v},{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:30,name:"z",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...Vt];class $a{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){cu(this,"parser",xt(Dd,Fd))}}function du(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}cu($a,"ForEntityName","VERTEX");let Ud={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:[]},Vd=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>St(i,0,"VERTEX")?(i=t.next(),new $a().parseEntity(t,i)):Xa},{code:210,name:"extrusionDirection",parser:j},{code:75,name:"smoothType",parser:v},{code:74,name:"surfaceNDensity",parser:v},{code:73,name:"surfaceMDensity",parser:v},{code:72,name:"meshNVertexCount",parser:v},{code:71,name:"meshMVertexCount",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:70,name:"flag",parser:v},{code:39,name:"thickness",parser:v},{code:30,name:"elevation",parser:v},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:v},...Vt];class pu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){du(this,"parser",xt(Vd,Ud))}}function mu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}du(pu,"ForEntityName","POLYLINE");let Gd=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class gu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){mu(this,"parser",xt(Gd))}}function fu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}mu(gu,"ForEntityName","RAY");let jd=[...Wi("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class _u{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){fu(this,"parser",xt(jd))}}function yu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}fu(_u,"ForEntityName","REGION");let Wd={vertices:[],backLineVertices:[]},Hd=[{code:360,name:"geometrySettingHardId",parser:v},{code:12,name:"backLineVertices",isMultiple:!0,parser:j},{code:93,name:"numberOfBackLineVertices",parser:v},{code:11,name:"vertices",isMultiple:!0,parser:j},{code:92,name:"verticesCount",parser:v},{code:[63,411],name:"indicatorColor",parser:v},{code:70,name:"indicatorTransparency",parser:v},{code:41,name:"bottomHeight",parser:v},{code:40,name:"topHeight",parser:v},{code:10,name:"verticalDirection",parser:j},{code:1,name:"name",parser:v},{code:91,name:"flag",parser:v},{code:90,name:"state",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class vu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){yu(this,"parser",xt(Hd,Wd))}}function bu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}yu(vu,"ForEntityName","SECTION");let Yd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},qd=[{code:210,name:"extrusionDirection",parser:j},{code:39,name:"thickness",parser:v},{code:[...Ci(10,14)],name:"points",isMultiple:!0,parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class xu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){bu(this,"parser",xt(qd,Yd))}}function wu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}bu(xu,"ForEntityName","SOLID");let Xd=[{code:350,name:"historyObjectSoftId",parser:v},{code:100,name:"subclassMarker",parser:v},...Wi("data"),{code:70,name:"version",parser:v},{code:100},...Vt];class Au{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){wu(this,"parser",xt(Xd))}}wu(Au,"ForEntityName","3DSOLID");(De={})[De.NONE=0]="NONE",De[De.CLOSED=1]="CLOSED",De[De.PERIODIC=2]="PERIODIC",De[De.RATIONAL=4]="RATIONAL",De[De.PLANAR=8]="PLANAR",De[De.LINEAR=16]="LINEAR";function Su(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:[]},$d=[{code:11,name:"fitPoints",isMultiple:!0,parser:j},{code:10,name:"controlPoints",isMultiple:!0,parser:j},{code:41,name:"weights",isMultiple:!0,parser:v},{code:40,name:"knots",isMultiple:!0,parser:v},{code:13,name:"endTangent",parser:j},{code:12,name:"startTangent",parser:j},{code:44,name:"fitTolerance",parser:v},{code:43,name:"controlTolerance",parser:v},{code:42,name:"knotTolerance",parser:v},{code:74,name:"numberOfFitPoints",parser:v},{code:73,name:"numberOfControlPoints",parser:v},{code:72,name:"numberOfKnots",parser:v},{code:71,name:"degree",parser:v},{code:70,name:"flag",parser:v},{code:210,name:"normal",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Iu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Su(this,"parser",xt($d,Kd))}}Su(Iu,"ForEntityName","SPLINE");class si{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=Wr(Rt(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Wr(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,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(c){g=!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(f,w,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=w.next();break;case 1:f.text=x.value,x=w.next();break;case 300:f.attrText=x.value,x=w.next();break;case 302:f.text=x.value?x.value:f.text,x=w.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=w.next()}})(b,o,h),h=o.next();break;default:return b}return c=!1,g=!1,b}(t,e)),e=t.lastReadGroup;break;default:Ka(s,e,t),e=t.next()}}return s}}function Pu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ca="ACAD_TABLE",(ua="ForEntityName")in si?Object.defineProperty(si,ua,{value:ca,enumerable:!0,configurable:!0,writable:!0}):si[ua]=ca;let Zd=[{code:11,name:"xAxisDirection",parser:j},{code:210,name:"extrusionDirection",parser:j},{code:1,name:"text",parser:v},{code:10,name:"position",parser:j},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Eu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Pu(this,"parser",xt(Zd))}}Pu(Eu,"ForEntityName","TOLERANCE");class ii{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=Wr(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=Wr(Rt(h));break;case 17:o.targetPoint=Wr(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=Wr(Rt(h));break;case 111:o.ucsXAxis=Wr(Rt(h));break;case 112:o.ucsYAxis=Wr(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)&&Ka(s,e,t),e=t.next()}return s}}pa="VIEWPORT",(da="ForEntityName")in ii?Object.defineProperty(ii,da,{value:pa,enumerable:!0,configurable:!0,writable:!0}):ii[da]=pa;(Pr={})[Pr.ShowImage=1]="ShowImage",Pr[Pr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Pr[Pr.UseClippingBoundary=4]="UseClippingBoundary",Pr[Pr.Transparency=8]="Transparency";function ku(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Qd={brightness:50,constrast:50,fade:0},Jd=[{code:14,name:"boundary",isMultiple:!0,parser:j},{code:91,name:"numberOfVertices",parser:v},{code:71,name:"boundaryType",parser:v},{code:360,name:"imageDefReactorHardId",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipping",parser:Dt},{code:70,name:"displayFlag",parser:v},{code:340,name:"imageDefHardId",parser:v},{code:13,name:"imageSize",parser:j},{code:12,name:"vDirection",parser:j},{code:11,name:"uDirection",parser:j},{code:10,name:"position",parser:j},{code:90,name:"classVersion",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Mu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ku(this,"parser",xt(Jd,Qd))}}function Tu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ku(Mu,"ForEntityName","WIPEOUT");let t0=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Nu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Tu(this,"parser",xt(t0))}}function Cu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Tu(Nu,"ForEntityName","XLINE");let e0={},r0=[{code:170,name:"multileaderType",parser:v},{code:291,name:"doglegEnabled",parser:Dt},{code:40,name:"doglegLength",parser:v},{code:172,name:"contentType",parser:v},{code:3,name:"textContent",parser:v},{code:12,name:"textAnchor",parser:j},{code:344,name:"blockHandle",parser:v},{code:15,name:"blockPosition",parser:j},{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 b,f={vertices:[]};for(;c.hasNext()&&(b=c.next()).code!==305;)b.code===10&&f.vertices.push((b.value,Rt(c)));return f}(0,t))}return o},isMultiple:!0},...Vt];class Lu{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Cu(this,"parser",xt(r0,e0))}}Cu(Lu,"ForEntityName","MULTILEADER");let n0=Object.fromEntries([Nh,Rh,Vh,jh,Hh,ri,qh,Kh,tu,ru,su,au,ni,lu,Dh,Lu,uu,pu,gu,_u,vu,xu,Au,Iu,si,Bh,Eu,Qh,$a,ii,Mu,Nu].map(i=>[i.ForEntityName,new i]));function Ou(i,t){let e=[];for(;!St(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let s=n0[i.value];if(s){let o=i.value;i=t.next();let h=s.parseEntity(t,i);h.type=o,kh(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=t.next()}return e}function s0(i,t){let e={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");){if(St(i,0,"BLOCK")){let s=i0(i=t.next(),t);kh(s),s.name&&(e[s.name]=s)}i=t.next()}return e}function i0(i,t){let e={};for(;!St(i,0,"EOF");){if(St(i,0,"ENDBLK")){for(i=t.next();!St(i,0,"EOF");){if(St(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=Ou(i,t)}i=t.next()}return e}function a0(i,t){let e=null,s={};for(;!St(i,0,"EOF")&&!St(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}(Ue={})[Ue.NOT_APPLICABLE=0]="NOT_APPLICABLE",Ue[Ue.KEEP_EXISTING=1]="KEEP_EXISTING",Ue[Ue.USE_CLONE=2]="USE_CLONE",Ue[Ue.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Ue[Ue.VALUE_NAME=4]="VALUE_NAME",Ue[Ue.UNMANGLE_NAME=5]="UNMANGLE_NAME";let Za=[{code:330,name:"ownerObjectId",parser:v},{code:102,parser:vn},{code:102,parser:vn},{code:102,parser:vn},{code:5,name:"handle",parser:v}],o0=[{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:v},{code:280,name:"isHardOwned",parser:Dt},{code:100,name:"subclassMarker",parser:v},...Za],l0=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:v},{code:90,name:"version",parser:v},{code:1,name:"fileName",parser:v},{code:10,name:"size",parser:j},{code:11,name:"sizeOfOnePixel",parser:j},{code:280,name:"isLoaded",parser:v},{code:281,name:"resolutionUnits",parser:v},{code:100,name:"subclassMarker",parser:v}];(cn={})[cn.NOUNIT=0]="NOUNIT",cn[cn.CENTIMETERS=2]="CENTIMETERS",cn[cn.INCH=5]="INCH";(Es={})[Es.PSLTSCALE=1]="PSLTSCALE",Es[Es.LIMCHECK=2]="LIMCHECK";(dn={})[dn.INCHES=0]="INCHES",dn[dn.MILLIMETERS=1]="MILLIMETERS",dn[dn.PIXELS=2]="PIXELS";(Ve={})[Ve.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",Ve[Ve.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",Ve[Ve.DRAWING_LIMITS=2]="DRAWING_LIMITS",Ve[Ve.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",Ve[Ve.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",Ve[Ve.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Er={})[Er.AS_DISPLAYED=0]="AS_DISPLAYED",Er[Er.WIREFRAME=1]="WIREFRAME",Er[Er.HIDDEN=2]="HIDDEN",Er[Er.RENDERED=3]="RENDERED";(Ge={})[Ge.DRAFT=0]="DRAFT",Ge[Ge.PREVIEW=1]="PREVIEW",Ge[Ge.NORMAL=2]="NORMAL",Ge[Ge.PRESENTATION=3]="PRESENTATION",Ge[Ge.MAXIMUM=4]="MAXIMUM",Ge[Ge.CUSTOM=5]="CUSTOM";let Bu=[{code:333,name:"shadePlotId",parser:v},{code:149,name:"imageOriginY",parser:v},{code:148,name:"imageOriginX",parser:v},{code:147,name:"scaleFactor",parser:v},{code:78,name:"shadePlotCustomDPI",parser:v},{code:77,name:"shadePlotResolution",parser:v},{code:76,name:"shadePlotMode",parser:v},{code:75,name:"standardScaleType",parser:v},{code:7,name:"currentStyleSheet",parser:v},{code:74,name:"plotType",parser:v},{code:73,name:"plotRotation",parser:v},{code:72,name:"plotPaperUnit",parser:v},{code:70,name:"layoutFlag",parser:v},{code:143,name:"printScaleDenominator",parser:v},{code:142,name:"printScaleNumerator",parser:v},{code:141,name:"windowAreaYMax",parser:v},{code:140,name:"windowAreaXMax",parser:v},{code:49,name:"windowAreaYMin",parser:v},{code:48,name:"windowAreaXMin",parser:v},{code:47,name:"plotOriginY",parser:v},{code:46,name:"plotOriginX",parser:v},{code:45,name:"paperHeight",parser:v},{code:44,name:"paperWidth",parser:v},{code:43,name:"marginTop",parser:v},{code:42,name:"marginRight",parser:v},{code:41,name:"marginBottom",parser:v},{code:40,name:"marginLeft",parser:v},{code:6,name:"plotViewName",parser:v},{code:4,name:"paperSize",parser:v},{code:2,name:"configName",parser:v},{code:1,name:"pageSetupName",parser:v},{code:100,name:"subclassMarker",parser:v},...Za],h0=[{code:346,name:"orthographicUcsId",parser:v},{code:345,name:"namedUcsId",parser:v},{code:331,name:"viewportId",parser:v},{code:330,name:"paperSpaceTableId",parser:v},{code:76,name:"orthographicType",parser:v},{code:17,name:"ucsYAxis",parser:j},{code:16,name:"ucsXAxis",parser:j},{code:13,name:"ucsOrigin",parser:j},{code:146,name:"elevation",parser:v},{code:15,name:"maxExtent",parser:j},{code:14,name:"minExtent",parser:j},{code:12,name:"insertionPoint",parser:j},{code:11,name:"maxLimit",parser:j},{code:10,name:"minLimit",parser:j},{code:71,name:"tabOrder",parser:v},{code:70,name:"controlFlag",parser:v},{code:1,name:"layoutName",parser:v},{code:100,name:"subclassMarker",parser:v},...Bu],u0=[{code:40,name:"wcsToOCSTransform",parser:ul},{code:40,name:"ocsToWCSTransform",parser:ul},{code:41,name:"backClippingDistance",parser:v},{code:73,name:"isBackClipping",parser:Dt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:v},{code:72,name:"isFrontClipping",parser:Dt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Dt},{code:11,name:"position",parser:j},{code:210,name:"normal",parser:j},{code:10,name:"boundaryVertices",parser:j,isMultiple:!0},{code:70,name:"boundaryCount",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...Za];function ul(i,t){let e=[];for(let s=0;s<3&&St(i,40);++s){let o=[];for(let h=0;h<4&&St(i,40);++h)o.push(i.value),i=t.next();e.push(o)}return t.rewind(),e}let c0={LAYOUT:h0,PLOTSETTINGS:Bu,DICTIONARY:o0,SPATIAL_FILTER:u0,IMAGEDEF:l0};function d0(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,o=c0[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:rd(e,({name:s})=>s)}}let Hn=[{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102,parser(i,t){for(;!St(i,0,"EOF")&&!St(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:v}],p0=xt([{code:310,name:"bmpPreview",parser:v},{code:281,name:"scalability",parser:v},{code:280,name:"explodability",parser:v},{code:70,name:"insertionUnits",parser:v},{code:340,name:"layoutObjects",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Hn]),m0=[{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:ll.Above,defaultValueImperial:ll.Center},{name:"DIMZIN",code:78,defaultValue:Fn.Trailing,defaultValueImperial:Fn.Feet},{name:"DIMAZIN",code:79,defaultValue:Vc.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:Gc.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:jc.Center},{name:"DIMTZIN",code:284,defaultValue:Fn.Trailing,defaultValueImperial:Fn.Feet},{name:"DIMALTZ",code:285,defaultValue:Fn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Fn.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}],g0=xt([...m0.map(i=>({...i,parser:v})),{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},{code:105,name:"handle",parser:v},...Hn.filter(i=>i.code!==5)]),f0=xt([{code:347,name:"materialObjectId",parser:v},{code:390,name:"plotStyleNameObjectId",parser:v},{code:370,name:"lineweight",parser:v},{code:290,name:"isPlotting",parser:Dt},{code:6,name:"lineType",parser:v},{code:62,name:"colorIndex",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Hn]);(kr={})[kr.NONE=0]="NONE",kr[kr.AbsoluteRotation=1]="AbsoluteRotation",kr[kr.TextEmbedded=2]="TextEmbedded",kr[kr.ShapeEmbedded=4]="ShapeEmbedded";let _0=xt([{code:9,name:"text",parser:v},{code:45,name:"offsetY",parser:v},{code:44,name:"offsetX",parser:v},{code:50,name:"rotation",parser:v},{code:46,name:"scale",parser:v},{code:340,name:"styleObjectId",parser:v},{code:75,name:"shapeNumber",parser:v},{code:74,name:"elementTypeFlag",parser:v},{code:49,name:"elementLength",parser:v}],{elementTypeFlag:0,elementLength:0}),y0=xt([{code:49,name:"pattern",parser(i,t){let e={};return _0(i,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:v},{code:73,name:"numberOfLineTypes",parser:v},{code:72,parser:v},{code:3,name:"description",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Hn]),v0=xt([{code:1e3,name:"extendedFont",parser:v},{code:1001},{code:4,name:"bigFont",parser:v},{code:3,name:"font",parser:v},{code:42,name:"lastHeight",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:50,name:"obliqueAngle",parser:v},{code:41,name:"widthFactor",parser:v},{code:40,name:"fixedTextHeight",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Hn]),b0=xt([{code:[63,421,431],name:"ambientColor",parser:v},{code:142,name:"contrast",parser:v},{code:141,name:"brightness",parser:v},{code:282,name:"defaultLightingType",parser:v},{code:292,name:"isDefaultLightingOn",parser:Dt},{code:348,name:"visualStyleObjectId",parser:v},{code:333,name:"shadePlotObjectId",parser:v},{code:332,name:"backgroundObjectId",parser:v},{code:61,name:"majorGridLines",parser:v},{code:170,name:"shadePlotSetting",parser:v},{code:146,name:"elevation",parser:v},{code:79,name:"orthographicType",parser:v},{code:112,name:"ucsYAxis",parser:j},{code:111,name:"ucsXAxis",parser:j},{code:110,name:"ucsOrigin",parser:j},{code:74,name:"ucsIconSetting",parser:v},{code:71,name:"viewMode",parser:v},{code:281,name:"renderMode",parser:v},{code:1,name:"styleSheet",parser:v},{code:[331,441],name:"frozenLayers",parser:v,isMultiple:!0},{code:72,name:"circleSides",parser:v},{code:51,name:"viewTwistAngle",parser:v},{code:50,name:"snapRotationAngle",parser:v},{code:45,name:"viewHeight",parser:v},{code:44,name:"backClippingPlane",parser:v},{code:43,name:"frontClippingPlane",parser:v},{code:42,name:"lensLength",parser:v},{code:17,name:"viewTarget",parser:j},{code:16,name:"viewDirectionFromTarget",parser:j},{code:15,name:"gridSpacing",parser:j},{code:14,name:"snapSpacing",parser:j},{code:13,name:"snapBasePoint",parser:j},{code:12,name:"center",parser:j},{code:11,name:"upperRightCorner",parser:j},{code:10,name:"lowerLeftCorner",parser:j},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...Hn]),x0={BLOCK_RECORD:p0,DIMSTYLE:g0,LAYER:f0,LTYPE:y0,STYLE:v0,VPORT:b0},w0=xt([{code:70,name:"maxNumberOfEntries",parser:v},{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:v},{code:2,name:"name",parser:v}]);function A0(i,t){var s;let e={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");){if(St(i,0,"TABLE")){i=t.next();let o={entries:[]};w0(i,t,o),e[o.name]=o}if(St(i,0)&&!St(i,0,"ENDTAB")){let o=i.value;i=t.next();let h=x0[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 ks(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class cl{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=dl(t,this._data[this._pointer++],this.debug),s={code:t,value:e};return St(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=dl(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){ks(this,"_data",void 0),ks(this,"debug",void 0),ks(this,"_pointer",void 0),ks(this,"_eof",void 0),ks(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function dl(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 Aa(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class S0{constructor(){Aa(this,"encoding","utf-8"),Aa(this,"encodingFailureFatal",!1)}}class I0 extends EventTarget{parseSync(t,e=!1){let s=new cl(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 cl(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(;!St(s,0,"EOF");)St(s,0,"SECTION")&&(St(s=t.next(),2,"HEADER")?(s=t.next(),e.header=a0(s,t)):St(s,2,"BLOCKS")?(s=t.next(),e.blocks=s0(s,t)):St(s,2,"ENTITIES")?(s=t.next(),e.entities=Ou(s,t)):St(s,2,"TABLES")?(s=t.next(),e.tables=A0(s,t)):St(s,2,"OBJECTS")&&(s=t.next(),e.objects=d0(s,t))),s=t.next();return e}constructor(t=new S0){super(),Aa(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}const pl=[{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 Li{constructor(t){if(typeof t=="string"){const e=pl.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=pl.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 P0{parse(t){const e=new I0,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,w,x;const s=new TextDecoder("utf-8");let o=0,h="",c=null,g=null,b=!1;for(;o<t.byteLength;){const E=Math.min(o+65536,t.byteLength),M=t.slice(o,E);o=E;const B=(h+s.decode(M,{stream:!0})).split(/\r?\n/);h=B.pop()??"";for(let D=0;D<B.length;D++){const F=B[D].trim();if(F==="SECTION"&&((f=B[D+2])==null?void 0:f.trim())==="HEADER")b=!0;else if(F==="ENDSEC"&&b)return{version:c,encoding:g};if(b&&F==="$ACADVER"){const dt=(w=B[D+2])==null?void 0:w.trim();dt&&(c=new Li(dt))}else if(b&&F==="$DWGCODEPAGE"){const dt=(x=B[D+2])==null?void 0:x.trim();if(dt){const vt=ka[dt];g=Il(vt)}}if(c&&g)return{version:c,encoding:g}}}return{version:c,encoding:g}}}class ml{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 mi;return t.vertices.forEach((s,o)=>e.setVertexAt(o,s)),e}convertArc(t){return new ci(t.center,t.radius,kt.degToRad(t.startAngle),kt.degToRad(t.endAngle),t.extrusionDirection??Z.Z_AXIS)}convertCirle(t){return new di(t.center,t.radius,t.extrusionDirection??Z.Z_AXIS)}convertEllipse(t){const e=new Z(t.majorAxisEndPoint),s=e.length();return new pi(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 fi(new Y(e.x,e.y,e.z||0),new Y(s.x,s.y,s.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Us(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 Us(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 wi;return e.position=t.position,e}convertSolid(t){const e=new bi;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&Rd.SPLINE_CONTROL_POINT||(o.push({x:c.x,y:c.y,z:c.z}),h.push(c.bulge??0))}),s){let c=Bs.SimplePoly;return t.flag&4&&(t.smoothType==Qs.CUBIC?c=Bs.CubicSplinePoly:t.smoothType==Qs.QUADRATIC&&(c=Bs.QuadSplinePoly)),new ui(c,o,e)}else{let c=Dn.SimplePoly;return t.flag&2?c=Dn.FitCurvePoly:t.flag&4&&(t.smoothType==Qs.CUBIC?c=Dn.CubicSplinePoly:t.smoothType==Qs.QUADRATIC&&(c=Dn.QuadSplinePoly)),new hi(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 Ds;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.isSolidFill=t.solidFill==Wc.SolidFill,e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new bn;b.closed=g.isClosed,g.vertices.forEach((f,w)=>{b.addVertexAt(w,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(b)}else{const g=h,b=new Ua;g.edges.forEach(f=>{if(f.type==1){const w=f;b.add(new Os(w.start,w.end))}else if(f.type==2){const w=f;b.add(new Vn(w.center,w.radius,kt.degToRad(w.startAngle||0),kt.degToRad(w.endAngle||0),!w.isCCW))}else if(f.type==3){const w=f;new Zt().subVectors(w.end,w.center);const E=Math.sqrt(Math.pow(w.end.x,2)+Math.pow(w.end.y,2)),M=E*w.lengthOfMinorAxis;let L=kt.degToRad(w.startAngle||0),B=kt.degToRad(w.endAngle||0);const D=Math.atan2(w.end.y,w.end.x);w.isCCW||(L=Math.PI*2-L,B=Math.PI*2-B),b.add(new Ui({...w.center,z:0},E,M,L,B,!w.isCCW,D))}else if(f.type==4){const w=f;if(w.numberOfControlPoints>0&&w.numberOfKnots>0){const x=w.controlPoints.map(L=>({x:L.x,y:L.y,z:0}));let E=!0;const M=w.controlPoints.map(L=>(L.weight==null&&(E=!1),L.weight||1));b.add(new Kr(x,w.knots,E?M:void 0))}else if(w.numberOfFitData>0){const x=w.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new Kr(x,"Uniform"))}}}),e.add(b)}}),e}convertTable(t){const e=new yi(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=kt.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 _i;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=kt.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 gi;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 ki(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(s.dimBlockPosition={...e.insertionPoint,z:0}),s.rotation=kt.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new Ei(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 Ni(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new Mi(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 Vs;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 Ii;return this.processWipeout(t,e),e}convertViewport(t){const e=new Si;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 Ai;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Pi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Fs(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?kt.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&e.color.setRGBValue(t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=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 xn extends Zr{constructor(t,e){t=t||{},jn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const Hr=class Hr extends xn{static isModelSapceName(t){return t.toLowerCase()==Hr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(Hr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new Y,this._layoutId="",this._entities=new Map}get isModelSapce(){return Hr.isModelSapceName(this.name)}get isPaperSapce(){return Hr.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 ji(this._entities)}getIdAt(t){return this._entities.get(t)}};Hr.MODEL_SPACE_NAME="*MODEL_SPACE",Hr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let pe=Hr;class E0{convertLayout(t,e){var o,h;const s=new Gi;if(s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,t.layoutName==="Model"){const c=pe.MODEL_SPACE_NAME;(o=e.tables.BLOCK_RECORD)==null||o.entries.some(g=>g.name.toUpperCase()===c?(s.blockTableRecordId=g.handle,!0):!1)}else(h=e.tables.BLOCK_RECORD)==null||h.entries.some(c=>c.layoutObjects===t.handle?(s.blockTableRecordId=c.handle,!0):!1),s.blockTableRecordId||(s.blockTableRecordId=t.paperSpaceTableId);return s.limits.min.copy(t.minLimit),s.limits.max.copy(t.maxLimit),s.extents.min.copy(t.minExtent),s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new Ah;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class zu{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),b=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:x=>{clearTimeout(b),this.releaseWorker(g),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(g),c(x)},timeout:b});const f=x=>{const{id:E,success:M,data:L,error:B}=x.data;if(E!==t)return;this.cleanupTask(t);const D=Date.now()-o;h(M?{success:!0,data:L,duration:D}:{success:!1,error:B,duration:D})},w=x=>{this.cleanupTask(t),c(new Error(`Worker error: ${x.message}`))};g.addEventListener("message",f),g.addEventListener("error",w),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 Ru{constructor(t){this.framework=new zu(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Fu(i){return new Ru(i)}class k0{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 Du extends qa{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=Fu({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 P0().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 b=s(c.font);b&&g.push(b)}if(c.bigFont){const b=s(c.bigFont);b&&g.push(b)}if(c.extendedFont){const b=s(c.extendedFont);b&&g.push(b)}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(w=>{o.add(w[1].toLowerCase())});const f=s.get(g.styleName);f==null||f.forEach(w=>o.add(w))}else if(c.type=="TEXT"){const g=c,b=s.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(c.type=="INSERT"){const b=e[c.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,s,o)}})}async processEntities(t,e,s,o,h){const c=new ml;let g=t.entities;const b=g.length,f=new Pa(b,100-o.value,s);this.config.convertByEntityType&&(g=this.groupAndFlattenByType(g));const w=e.tables.blockTable.modelSpace;await f.processChunk(async(x,E)=>{let M=[],L=x<E?g[x].type:"";for(let B=x;B<E;B++){const D=g[B],F=c.convert(D);F&&(this.config.convertByEntityType&&D.type!==L&&(w.appendEntity(M),M=[],L=D.type),M.push(F))}if(w.appendEntity(M),h){let B=o.value+E/b*(100-o.value);B>100&&(B=100),await h(B,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e){const s=new ml,o=t.length,h=[];for(let c=0;c<o;c++){const g=t[c],b=s.convert(g);b&&h.push(b)}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 pe,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 pe;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 E0;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 Qu;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 $r;g.colorIndex=c.colorIndex;const b=new Hi({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:g,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,b),e.tables.layerTable.add(b)})}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 Rs(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 Qa(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 Gn(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 Uu extends qa{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,b=new Pa(g,100-o.value,s);this.config.convertByEntityType&&(c=this.groupAndFlattenByType(c));const f=e.tables.blockTable.modelSpace;await b.processChunk(async(w,x)=>{let E=[],M=w<x?c[w].type:"";for(let L=w;L<x;L++){const B=c[L];this.config.convertByEntityType&&B.type!==M&&(this.triggerEvents(f,E),E=[],M=B.type),E.push(B)}if(this.triggerEvents(f,E),h){let L=o.value+x/g*(100-o.value);L>100&&(L=100),await h(L,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const s=e.newIterator().toArray();this.triggerEvents(e,s)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.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 zs=(i=>(i.DXF="dxf",i.DWG="dwg",i))(zs||{});class ur{constructor(){this.events={registered:new ae,unregistered:new ae},this._converters=new Map,this.register("dxf",new Du)}static createInstance(){return ur._instance==null&&(ur._instance=new ur),this._instance}static get instance(){return ur._instance||(ur._instance=new ur),ur._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 wn extends Zr{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 ji(this._recordsByName)}normalizeName(t){return t}}class Vu extends wn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(pe.MODEL_SPACE_NAME);return t||(t=new pe,t.name=pe.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(pe.isModelSapceName(t))e=pe.MODEL_SPACE_NAME;else if(pe.isPaperSapceName(t)){const s=pe.PAPER_SPACE_NAME_PREFIX,o=t.substring(s.length);e=s+o}return e}}class Gu extends wn{constructor(t){super(t)}}class Hi extends xn{constructor(t,e){t=t||{},jn(t,{color:new $r,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 lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class ju extends wn{constructor(t){super(t);const e=new $r,s=new Hi({name:"0",standardFlags:0,linetype:ai,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 Wu extends wn{constructor(t){super(t)}}class Hu extends wn{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 Yu extends wn{constructor(t){super(t)}}class M0 extends Zr{constructor(){super(),this.events={dictObjetSet:new ae,dictObjectErased:new ae,entityAppended:new ae,entityModified:new ae,layerAppended:new ae,layerModified:new ae,layerErased:new ae,openProgress:new ae,headerSysVarChanged:new ae},this._version=new Li("AC1014"),this._angBase=0,this._angDir=0,this._aunits=Ea.DecimalDegrees,this._celtscale=1,this._cecolor=new $r,this._extents=new Nt,this._insunits=Ya.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Vu(this),dimStyleTable:new Gu(this),linetypeTable:new Wu(this),textStyleTable:new Hu(this),layerTable:new ju(this),viewportTable:new Yu(this)},this._dictionaries={layouts:new wh(this),imageDefs:new Ha(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 Li(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=zs.DXF){const o=ur.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,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,subStageStatus:g,data:b}),e&&e.fontLoader&&c=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var M;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=(M=s.body)==null?void 0:M.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:L,value:B}=await g.read();if(L)break;if(b.push(B),c+=B.length,h!==null){const D=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:D,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(c);let w=0;for(const L of b)f.set(L,w),w+=L.length;this.getFileNameFromUri(t).toLowerCase().split(".").pop()==="dwg"?await this.read(f.buffer,e,zs.DWG):await this.read(f.buffer,e,zs.DXF),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}async regen(){await new Uu(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}){const e=new Sh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}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})}getFileNameFromUri(t){try{const s=new URL(t).pathname.split("/");return s[s.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}var qu=(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))(qu||{}),Xu=(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))(Xu||{}),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||{}),$u=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))($u||{}),Zu=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(Zu||{});const Bi=class Bi extends xn{constructor(t,e){t=t||{},jn(t,Bi.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)}};Bi.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 Gn=Bi;class Rs extends xn{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}}const zi=class zi{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new ae},this.registerVar({name:"PICKBOX",type:"number",defaultValue:0})}static instance(){return this._instance||(this._instance=new zi),this._instance}registerVar(t){this.registry.set(t.name.toUpperCase(),t)}registerMany(t){t.forEach(e=>this.registerVar(e))}getVar(t){if(t=t.toUpperCase(),this.cache.has(t))return this.cache.get(t)}setVar(t,e){t=t.toUpperCase();const s=this.getDescriptor(t);if(s){const o=this.getVar(t);if(this.cache.set(t,e),s.type!=="string"&&(typeof e=="string"||e instanceof String))if(s.type==="number"){const h=Number(e);if(Number.isNaN(h))throw new Error("Invalid input!");e=h}else s.type==="boolean"&&(e=this.parseBoolean(e));this.events.sysVarChanged.dispatch({name:t,newVal:e,oldVal:o})}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(t.toUpperCase())}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),s=new Set(["true","t","1","yes","y"]),o=new Set(["false","f","0","no","n"]);return s.has(e)?!0:(o.has(e),!1)}};zi._instance=null;let Sa=zi;class Qa extends xn{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}const T0={center:new Tt,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:Ga.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:ja.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Wa.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Qu extends xn{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=T0}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 Ju{constructor(){this.events={layoutCreated:new ae,layoutRemoved:new ae,layoutRenamed:new ae,layoutSwitched:new ae}}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 pe;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||Ja().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function Ja(){return Oi.instance}const Ri=class Ri{constructor(){this._workingDatabase=null,this._layoutManager=new Ju}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}};Ri.instance=new Ri;let Oi=Ri;exports.AcCmColor=$r;exports.AcCmColorMethod=mt;exports.AcCmColorUtil=pn;exports.AcCmEntityColor=_c;exports.AcCmErrors=We;exports.AcCmEventDispatcher=yc;exports.AcCmEventManager=ae;exports.AcCmLoader=Pc;exports.AcCmLoadingManager=Al;exports.AcCmObject=vl;exports.AcCmPerformanceCollector=Ia;exports.AcCmTask=xl;exports.AcCmTaskScheduler=wl;exports.AcDb2dPolyline=hi;exports.AcDb2dVertex=ba;exports.AcDb2dVertexType=uh;exports.AcDb3PointAngularDimension=Ei;exports.AcDb3dPolyline=ui;exports.AcDb3dVertex=xa;exports.AcDb3dVertexType=ch;exports.AcDbAlignedDimension=ki;exports.AcDbAngleUnits=Ea;exports.AcDbArc=ci;exports.AcDbArcDimension=wa;exports.AcDbBaseWorker=k0;exports.AcDbBatchProcessing=Pa;exports.AcDbBlockReference=Fs;exports.AcDbBlockTable=Vu;exports.AcDbBlockTableRecord=pe;exports.AcDbCircle=di;exports.AcDbCodePage=ka;exports.AcDbCurve=Pe;exports.AcDbDataGenerator=Sh;exports.AcDbDatabase=M0;exports.AcDbDatabaseConverter=qa;exports.AcDbDatabaseConverterManager=ur;exports.AcDbDiametricDimension=Mi;exports.AcDbDictionary=Ha;exports.AcDbDimArrowType=Ih;exports.AcDbDimStyleTable=Gu;exports.AcDbDimStyleTableRecord=Gn;exports.AcDbDimTextHorizontal=qu;exports.AcDbDimTextVertical=Xu;exports.AcDbDimVerticalJustification=Zu;exports.AcDbDimZeroSuppression=Ku;exports.AcDbDimZeroSuppressionAngular=$u;exports.AcDbDimension=Cr;exports.AcDbDwgVersion=Li;exports.AcDbDxfConverter=Du;exports.AcDbEllipse=pi;exports.AcDbEntity=Ie;exports.AcDbFace=mi;exports.AcDbFileType=zs;exports.AcDbHatch=Ds;exports.AcDbHatchPatternType=dh;exports.AcDbHatchStyle=ph;exports.AcDbHostApplicationServices=Oi;exports.AcDbLayerTable=ju;exports.AcDbLayerTableRecord=Hi;exports.AcDbLayout=Gi;exports.AcDbLayoutDictionary=wh;exports.AcDbLayoutManager=Ju;exports.AcDbLeader=gi;exports.AcDbLeaderAnnotationType=mh;exports.AcDbLine=fi;exports.AcDbLineSpacingStyle=xh;exports.AcDbLinetypeTable=Wu;exports.AcDbLinetypeTableRecord=Rs;exports.AcDbMText=_i;exports.AcDbObject=Zr;exports.AcDbObjectIterator=ji;exports.AcDbOrdinateDimension=Ti;exports.AcDbOsnapMode=fn;exports.AcDbPoint=wi;exports.AcDbPoly2dType=Dn;exports.AcDbPoly3dType=Bs;exports.AcDbPolyline=xi;exports.AcDbRadialDimension=Ni;exports.AcDbRasterImage=Vs;exports.AcDbRasterImageClipBoundaryType=vh;exports.AcDbRasterImageDef=Ah;exports.AcDbRasterImageImageDisplayOpt=bh;exports.AcDbRay=Ai;exports.AcDbRegenerator=Uu;exports.AcDbRenderingCache=Yr;exports.AcDbSpline=Us;exports.AcDbSymbolTable=wn;exports.AcDbSymbolTableRecord=xn;exports.AcDbSysVarManager=Sa;exports.AcDbTable=yi;exports.AcDbText=vi;exports.AcDbTextHorizontalMode=_h;exports.AcDbTextStyleTable=Hu;exports.AcDbTextStyleTableRecord=Qa;exports.AcDbTextVerticalMode=yh;exports.AcDbTrace=bi;exports.AcDbUnitsValue=Ya;exports.AcDbViewport=Si;exports.AcDbViewportTable=Yu;exports.AcDbViewportTableRecord=Qu;exports.AcDbWipeout=Ii;exports.AcDbWorkerApi=Ru;exports.AcDbWorkerManager=zu;exports.AcDbXline=Pi;exports.AcGeArea2d=Di;exports.AcGeBox2d=ve;exports.AcGeBox3d=Nt;exports.AcGeCatmullRomCurve3d=lh;exports.AcGeCircArc2d=Vn;exports.AcGeCircArc3d=Da;exports.AcGeCurve2d=Wn;exports.AcGeEllipseArc2d=Ui;exports.AcGeEllipseArc3d=Vi;exports.AcGeEuler=nh;exports.AcGeGeometryUtil=Kl;exports.AcGeLine2d=Os;exports.AcGeLine3d=li;exports.AcGeLoop2d=Ua;exports.AcGeMathUtil=kt;exports.AcGeMatrix2d=Fi;exports.AcGeMatrix3d=Xr;exports.AcGeNurbsCurve=yn;exports.AcGePlane=Gs;exports.AcGePoint2d=Tt;exports.AcGePoint3d=Y;exports.AcGePolyline2d=bn;exports.AcGeQuaternion=qr;exports.AcGeShape2d=Fa;exports.AcGeSpline3d=Kr;exports.AcGeTol=Ba;exports.AcGeVector2d=Zt;exports.AcGeVector3d=Z;exports.AcGiArrowType=Va;exports.AcGiDefaultLightingType=Wa;exports.AcGiMTextAttachmentPoint=Se;exports.AcGiMTextFlowDirection=Nr;exports.AcGiOrthographicType=ja;exports.AcGiRenderMode=Ga;exports.AcGiViewport=gh;exports.AcTrStringUtil=Ic;exports.ByBlock=Pl;exports.ByLayer=Js;exports.DEBUG_MODE=Ac;exports.DEFAULT_LINE_TYPE=ai;exports.DEFAULT_TOL=za;exports.DEG2RAD=Ma;exports.DefaultLoadingManager=Sl;exports.FLOAT_TOL=gn;exports.ORIGIN_POINT_2D=kc;exports.ORIGIN_POINT_3D=Oa;exports.RAD2DEG=Ta;exports.TAU=se;exports.acdbHostApplicationServices=Ja;exports.basisFunction=oi;exports.calculateCurveLength=Jl;exports.ceilPowerOfTwo=Vl;exports.clamp=Tr;exports.clone=Ms;exports.createWorkerApi=Fu;exports.damp=Tl;exports.deepClone=ga;exports.defaults=jn;exports.degToRad=Fl;exports.dwgCodePageToEncoding=Il;exports.euclideanModulo=Na;exports.evaluateNurbsPoint=Ls;exports.floorPowerOfTwo=Gl;exports.generateChordKnots=Zl;exports.generateSqrtChordKnots=Ql;exports.generateUUID=El;exports.generateUniformKnots=$l;exports.has=_l;exports.intPartLength=La;exports.interpolateControlPoints=Mc;exports.inverseLerp=Ml;exports.isBetween=jl;exports.isBetweenAngle=Wl;exports.isEmpty=yl;exports.isEqual=Un;exports.isImperialUnits=Uc;exports.isMetricUnits=Dc;exports.isPointInPolygon=Ra;exports.isPolygonIntersect=Xl;exports.isPowerOfTwo=Ul;exports.lerp=Ca;exports.log=Ns;exports.mapLinear=kl;exports.normalizeAngle=Cs;exports.pingpong=Nl;exports.radToDeg=Dl;exports.randFloat=Bl;exports.randFloatSpread=zl;exports.randInt=Ol;exports.relativeEps=Hl;exports.seededRandom=Rl;exports.setLogLevel=Sc;exports.smootherstep=Ll;exports.smoothstep=Cl;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function vc(i,t){for(var e=0;e<t.length;e++){const n=t[e];if(typeof n!="string"&&!Array.isArray(n)){for(const o in n)if(o!=="default"&&!(o in i)){const h=Object.getOwnPropertyDescriptor(n,o);h&&Object.defineProperty(i,o,h.get?h:{enumerable:!0,get:()=>n[o]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var mt=(i=>(i[i.ByColor=1]="ByColor",i[i.ByACI=2]="ByACI",i[i.ByLayer=3]="ByLayer",i[i.ByBlock=4]="ByBlock",i[i.None=0]="None",i))(mt||{});const Jo={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},na=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];let gn=class{static getColorByIndex(t){return na[t]}static getIndexByColor(t){const e=na.length-1;for(let n=1;n<e;++n)if(na[n]===t)return n}static getColorByName(t){return Jo[t.toLowerCase()]}static getNameByColor(t){for(const[e,n]of Object.entries(Jo))if(n===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},Qr=class fn{constructor(t=mt.ByLayer,e){this._colorMethod=t,this._colorMethod==mt.ByColor&&e==null?this._value=16777215:this._colorMethod==mt.ByACI?e==null?this._value=8:e===0?this._colorMethod=mt.ByBlock:e===256?this._colorMethod=mt.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}get colorMethod(){return this._colorMethod}set colorMethod(t){this._colorMethod=t}get red(){const t=this.RGB;return t!=null?t>>16&255:void 0}get green(){const t=this.RGB;return t!=null?t>>8&255:void 0}get blue(){const t=this.RGB;return t!=null?t&255:void 0}get RGB(){switch(this._colorMethod){case mt.ByColor:case mt.ByBlock:case mt.ByLayer:return this._value;case mt.ByACI:return this._value?gn.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,n){const o=Math.max(0,Math.min(255,Math.round(t))),h=Math.max(0,Math.min(255,Math.round(e))),c=Math.max(0,Math.min(255,Math.round(n)));return this._value=o<<16|h<<8|c,this._colorMethod=mt.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?(console.warn("Invalid RGB value:",t),this):(this._value=t&16777215,this._colorMethod=mt.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let h=0,c=0,g=0;if(e.length===7)h=parseInt(e.substr(1,2),16),c=parseInt(e.substr(3,2),16),g=parseInt(e.substr(5,2),16);else if(e.length===4)h=parseInt(e[1]+e[1],16),c=parseInt(e[2]+e[2],16),g=parseInt(e[3]+e[3],16);else return console.warn("Invalid hex color:",t),this;return this.setRGB(h,c,g)}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n){const h=parseInt(n[1],10),c=parseInt(n[2],10),g=parseInt(n[3],10);return this.setRGB(h,c,g)}const o=gn.getColorByName(t);return o!==void 0?this.setRGBValue(o):(console.warn("Unknown CSS color string:",t),this)}setScalar(t){return this.setRGB(t,t,t)}get hexColor(){const t=this.RGB;return t==null?void 0:"0x"+t.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const t=this.RGB;if(t!=null)return`rgb(${t>>16&255},${t>>8&255},${t&255})`}get colorIndex(){return this._colorMethod===mt.ByACI?this._value:this._colorMethod===mt.ByLayer?256:this._colorMethod===mt.ByBlock?0:void 0}set colorIndex(t){if(t==null)return;const e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=mt.ByBlock,this._value=void 0):e===256?(this._colorMethod=mt.ByLayer,this._value=void 0):(this._colorMethod=mt.ByACI,this._value=e)}get isByColor(){return this._colorMethod===mt.ByColor}get isByACI(){return this._colorMethod===mt.ByACI}get isByLayer(){return this._colorMethod===mt.ByLayer}setByLayer(t){return this._colorMethod=mt.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===mt.ByBlock}setByBlock(t){return this._colorMethod=mt.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case mt.ByLayer:return"ByLayer";case mt.ByBlock:return"ByBlock";case mt.ByColor:return this._value?gn.getNameByColor(this._value):"";case mt.ByACI:return this._value?gn.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=gn.getColorByName(t);e!==void 0?(this._value=e,this._colorMethod=mt.ByColor):console.warn("Unknown color name:",t)}clone(){const t=new fn;return t._colorMethod=this._colorMethod,t._value=this._value,t}copy(t){return this._colorMethod=t._colorMethod,this._value=t._value,this}equals(t){return this._colorMethod===t._colorMethod&&this._value===t._value}toString(){switch(this._colorMethod){case mt.ByLayer:return"ByLayer";case mt.ByBlock:return"ByBlock";case mt.ByACI:return this._value!==void 0?String(this._value):"";case mt.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(t){if(!t)return;const e=t.trim();if(/^bylayer$/i.test(e))return new fn(mt.ByLayer);if(/^byblock$/i.test(e))return new fn(mt.ByBlock);if(/^\d{1,3},\d{1,3},\d{1,3}$/i.test(e)){const[o,h,c]=e.split(",").map(Number),g=new fn(mt.ByColor);return g.setRGB(o,h,c),g}if(/^\d+$/.test(e)){const o=parseInt(e,10);return new fn(mt.ByACI,o)}const n=gn.getColorByName(e);if(n!=null)return new fn(mt.ByColor,n);console.warn("Unknown color name:",t)}};class bc{constructor(t=mt.ByColor,e=0){this._colorMethod=t,this._value=e}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(t){this._colorMethod=mt.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=mt.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=mt.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,n){this._colorMethod=mt.ByColor,this._value=(t&255)<<16|(e&255)<<8|n&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=mt.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=mt.ByLayer,this._value=t}isByColor(){return this._colorMethod===mt.ByColor}isByLayer(){return this._colorMethod===mt.ByLayer}isByBlock(){return this._colorMethod===mt.ByBlock}isByACI(){return this._colorMethod===mt.ByACI}isNone(){return this._colorMethod===mt.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const He={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class xc{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const n=this._listeners[t];if(n!==void 0){const o=n.indexOf(e);o!==-1&&n.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 n=e.slice(0);for(let o=0,h=n.length;o<h;o++)n[o].call(this,t)}}}let ae=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 n of this.listeners)n.call(null,t,...e)}};function Ns(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function ya(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(Array.isArray(i))return i.map(ya);const t={};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=ya(i[e]));return t}function Hn(i,...t){for(const e of t)if(e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&i[n]===void 0&&(i[n]=e[n]);return i}function yl(i,t){return i!=null&&Object.prototype.hasOwnProperty.call(i,t)}function vl(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 Gn(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(!Gn(i[o],t[o]))return!1;return!0}const e=Object.keys(i),n=Object.keys(t);if(e.length!==n.length)return!1;for(const o of e)if(!Object.prototype.hasOwnProperty.call(t,o)||!Gn(i[o],t[o]))return!1;return!0}var wc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ac(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var bl={exports:{}};(function(i){(function(t,e){i.exports?i.exports=e():t.log=e()})(wc,function(){var t=function(){},e="undefined",n=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],h={},c=null;function g(B,D){var F=B[D];if(typeof F.bind=="function")return F.bind(B);try{return Function.prototype.bind.call(F,B)}catch{return function(){return Function.prototype.apply.apply(F,[B,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 f(B){return B==="debug"&&(B="log"),typeof console===e?!1:B==="trace"&&n?b:console[B]!==void 0?g(console,B):console.log!==void 0?g(console,"log"):t}function w(){for(var B=this.getLevel(),D=0;D<o.length;D++){var F=o[D];this[F]=D<B?t:this.methodFactory(F,B,this.name)}if(this.log=this.debug,typeof console===e&&B<this.levels.SILENT)return"No console available for logging"}function x(B){return function(){typeof console!==e&&(w.call(this),this[B].apply(this,arguments))}}function E(B,D,F){return f(B)||x.apply(this,arguments)}function M(B,D){var F=this,dt,vt,ot,W="loglevel";typeof B=="string"?W+=":"+B:typeof B=="symbol"&&(W=void 0);function ut(wt){var Bt=(o[wt]||"silent").toUpperCase();if(!(typeof window===e||!W)){try{window.localStorage[W]=Bt;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Bt+";"}catch{}}}function st(){var wt;if(!(typeof window===e||!W)){try{wt=window.localStorage[W]}catch{}if(typeof wt===e)try{var Bt=window.document.cookie,me=encodeURIComponent(W),ge=Bt.indexOf(me+"=");ge!==-1&&(wt=/^([^;]+)/.exec(Bt.slice(ge+me.length+1))[1])}catch{}return F.levels[wt]===void 0&&(wt=void 0),wt}}function Gt(){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 Xt(wt){var Bt=wt;if(typeof Bt=="string"&&F.levels[Bt.toUpperCase()]!==void 0&&(Bt=F.levels[Bt.toUpperCase()]),typeof Bt=="number"&&Bt>=0&&Bt<=F.levels.SILENT)return Bt;throw new TypeError("log.setLevel() called with invalid level: "+wt)}F.name=B,F.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},F.methodFactory=D||E,F.getLevel=function(){return ot??vt??dt},F.setLevel=function(wt,Bt){return ot=Xt(wt),Bt!==!1&&ut(ot),w.call(F)},F.setDefaultLevel=function(wt){vt=Xt(wt),st()||F.setLevel(wt,!1)},F.resetLevel=function(){ot=null,Gt(),w.call(F)},F.enableAll=function(wt){F.setLevel(F.levels.TRACE,wt)},F.disableAll=function(wt){F.setLevel(F.levels.SILENT,wt)},F.rebuild=function(){if(c!==F&&(dt=Xt(c.getLevel())),w.call(F),c===F)for(var wt in h)h[wt].rebuild()},dt=Xt(c?c.getLevel():"WARN");var Ht=st();Ht!=null&&(ot=Xt(Ht)),w.call(F)}c=new M,c.getLogger=function(B){if(typeof B!="symbol"&&typeof B!="string"||B==="")throw new TypeError("You must supply a name when creating a logger.");var D=h[B];return D||(D=h[B]=new M(B,c.methodFactory)),D};var L=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=L),c},c.getLoggers=function(){return h},c.default=c,c})})(bl);var xl=bl.exports;const Sc=Ac(xl),Ic=vc({__proto__:null,default:Sc},[xl]),Pc=!0,Ls=Ic;Ls.setLevel("debug");const Ec=i=>{try{Ls.setLevel(i)}catch(t){Ls.setLevel("error"),Ls.error(t)}};let wl=class Al{constructor(t,e){this.events={attrChanged:new ae,modelChanged:new ae},this._changing=!1,this._previousAttributes={},this._pending=!1;const n=t||{};e&&Hn(n,e),this.attributes=n,this.changed={}}get(t){return this.attributes[t]}set(t,e,n){if(t==null)return this;let o;typeof t=="object"?(o=t,n=e):(o={},o[t]=e),n||(n={});const h=n.unset,c=n.silent,g=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=Ns(this.attributes),this.changed={});const f=this.attributes,w=this.changed,x=this._previousAttributes;for(const E in o)e=o[E],Gn(f[E],e)||g.push(E),Gn(x[E],e)?delete w[E]:w[E]=e,h?delete f[E]:f[E]=e;if(!c){g.length&&(this._pending=n);for(let E=0;E<g.length;E++)this.events.attrChanged.dispatch({object:this,attrName:g[E],attrValue:f[g[E]],options:n})}if(b)return this;if(!c)for(;this._pending;)n=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:n});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!vl(this.changed):yl(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?Ns(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,n={};for(const o in t){const h=t[o];Gn(e[o],h)||(n[o]=h)}return n}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return Ns(this._previousAttributes)}clone(){const t=Ns(this.attributes);return new Al(t)}},ka=class Cs{constructor(){this.entries=new Map}static getInstance(){return Cs.instance||(Cs.instance=new Cs),Cs.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 kc{static formatBytes(t,e=2){if(t===0)return"0 B";const n=1024,o=Math.max(0,e),h=["B","KB","MB","GB","TB"],c=Math.floor(Math.log(t)/Math.log(n)),g=t/Math.pow(n,c);return`${parseFloat(g.toFixed(o))} ${h[c]}`}}var Se=(i=>(i[i.ByLayer=0]="ByLayer",i[i.ByBlock=1]="ByBlock",i[i.ByAlpha=2]="ByAlpha",i[i.ErrorValue=3]="ErrorValue",i))(Se||{});let Ui=class cr{constructor(t){t!==void 0?(this._method=Se.ByAlpha,this._alpha=cr.clampAlpha(t)):(this._method=Se.ByLayer,this._alpha=255)}get method(){return this._method}set method(t){this._method=t}get alpha(){return this._alpha}set alpha(t){this._alpha=cr.clampAlpha(t),this._method=Se.ByAlpha}get percentage(){if(this._method===Se.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),n=Math.round(255*(1-e/100));this.alpha=n}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===Se.ByAlpha}get isByBlock(){return this._method===Se.ByBlock}get isByLayer(){return this._method===Se.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===Se.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new cr;return t._method=this._method,t._alpha=this._alpha,t}equals(t){return this._method===t._method&&this._alpha===t._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(t){const e=t.trim();if(/^bylayer$/i.test(e)){const h=new cr;return h._method=Se.ByLayer,h}if(/^byblock$/i.test(e)){const h=new cr;return h._method=Se.ByBlock,h}const n=Number(e);if(Number.isInteger(n)&&n>=0&&n<=255)return new cr(n);const o=new cr;return o._method=Se.ErrorValue,o}static deserialize(t){const e=t>>>24&255,n=t&255,o=Object.values(Se)[e]??Se.ErrorValue,h=new cr;return h._method=o,h._alpha=cr.clampAlpha(n),h}};class Sl{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}let Il=class{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,n)=>{const o=()=>{Promise.resolve(t()).then(e).catch(n)};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 n=t;for(let o=0;o<e;o++){const h=this.tasks[o];try{n=await this.scheduleTask(async()=>{const c=await h.run(n);return this.onProgress((o+1)/e,h),c})}catch(c){if(this.onError({error:c,taskIndex:o,task:h}))break}}this.onComplete(n)}},Pl=class{constructor(t,e,n){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=n}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,n=this.handlers.length;e<n;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 El=new Pl;class Mc{constructor(t){this.manager=t!==void 0?t:El,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((n,o)=>{this.load(t,n,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 Ma{constructor(t,e,n){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=n,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,n)=>{const o=()=>{Promise.resolve(t()).then(e).catch(n)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(t){let e=0;const n=async()=>{const o=e,h=Math.min(e+this._chunkSize,this._count);await t(o,h),e=h,e<this._count&&await this.scheduleTask(n)};await n()}}var Ta=(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))(Ta||{});class Xr{static get instance(){return this._instance||(this._instance=new Xr),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,n,o=!0,h,c){var b;const g=[];if(e!=null){const f=this.createKey(e.name,n);let w;if(this.has(f))w=this.get(f);else{const x=(b=t.basePoint)==null?void 0:b.clone();t.basePoint=void 0;const E=e.newIterator();let M=!0;for(const L of E)if(L.color.isByBlock&&n?(tl.copy(L.color),L.color.setRGBValue(n),this.addEntity(L,g,t),L.color.copy(tl)):this.addEntity(L,g,t),M){const B=g[0];t.basePoint=B.basePoint,M=!1}w=t.group(g),w&&o&&pe.name&&!pe.name.startsWith("*U")&&this.set(f,w),t.basePoint=x}return w&&h&&(w.applyMatrix(h),c&&(c.x!=0||c.y!=0||c.z!=1)&&(h.setFromExtrusionDirection(c),w.applyMatrix(h))),w}else return t.group(g)}addEntity(t,e,n){const o=t.draw(n);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 tl=new Qr;var Na=(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))(Na||{});const Tc=["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"],kl=i=>Tc[i],li="Continuous",ei="ByLayer",Ml="ByBlock",ye=["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 el=1234567;const Ca=Math.PI/180,La=180/Math.PI;function Tl(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ye[i&255]+ye[i>>8&255]+ye[i>>16&255]+ye[i>>24&255]+"-"+ye[t&255]+ye[t>>8&255]+"-"+ye[t>>16&15|64]+ye[t>>24&255]+"-"+ye[e&63|128]+ye[e>>8&255]+"-"+ye[e>>16&255]+ye[e>>24&255]+ye[n&255]+ye[n>>8&255]+ye[n>>16&255]+ye[n>>24&255]).toLowerCase()}function Cr(i,t,e){return Math.max(t,Math.min(e,i))}function Oa(i,t){return(i%t+t)%t}function Nl(i,t,e,n,o){return n+(i-t)*(o-n)/(e-t)}function Cl(i,t,e){return i!==t?(e-i)/(t-i):0}function Ba(i,t,e){return(1-e)*i+e*t}function Ll(i,t,e,n){return Ba(i,t,1-Math.exp(-e*n))}function Ol(i,t=1){return t-Math.abs(Oa(i,t*2)-t)}function Bl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function zl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Rl(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Fl(i,t){return i+Math.random()*(t-i)}function Dl(i){return i*(.5-Math.random())}function Ul(i){i!==void 0&&(el=i);let t=el+=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 Vl(i){return i*Ca}function Gl(i){return i*La}function jl(i){return(i&i-1)===0&&i!==0}function Wl(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Hl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Os(i){const t=Math.PI*2;return(i%t+t)%t}function Yl(i,t,e){return i>t&&i<e||i>e&&i<t}function ql(i,t,e,n=!1){return i=Os(i),t=Os(t),e=Os(e),n?t>e?i<=t&&i>=e:i<=t||i>=e:t<e?i>=t&&i<=e:i>=t||i<=e}function za(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Xl(i,t=1e-7){const e=za(i);return Math.max(Math.pow(10,e)*t,t)}const kt={DEG2RAD:Ca,RAD2DEG:La,generateUUID:Tl,clamp:Cr,euclideanModulo:Oa,mapLinear:Nl,inverseLerp:Cl,lerp:Ba,damp:Ll,pingpong:Ol,smoothstep:Bl,smootherstep:zl,randInt:Rl,randFloat:Fl,randFloatSpread:Dl,seededRandom:Ul,degToRad:Vl,radToDeg:Gl,isPowerOfTwo:jl,ceilPowerOfTwo:Wl,floorPowerOfTwo:Hl,normalizeAngle:Os,isBetween:Yl,isBetweenAngle:ql,intPartLength:za,relativeEps:Xl},va=class Kl{constructor(t,e){this.x=0,this.y=0;const n=+(t!==void 0)+ +(e!==void 0);if(n!==0){if(n===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(n===1){const{x:o,y:h}=t;this.x=o,this.y=h;return}if(n===2){this.x=t,this.y=e;return}throw He.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 Kl(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,n=this.y,o=t.elements;return this.x=o[0]*e+o[3]*n+o[6],this.y=o[1]*e+o[4]*n+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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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 n=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,n)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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 n=Math.cos(e),o=Math.sin(e),h=this.x-t.x,c=this.y-t.y;return this.x=h*n-c*o+t.x,this.y=h*o+c*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(kt.relativeEps(this.x,t),kt.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};va.EMPTY=Object.freeze(new va(0,0));let Zt=va;const ba=class $l{constructor(t,e,n,o,h,c,g,b,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&n!=null&&o!=null&&h!=null&&c!=null&&g!=null&&b!=null&&f!=null&&this.set(t,e,n,o,h,c,g,b,f)}set(t,e,n,o,h,c,g,b,f){const w=this.elements;return w[0]=t,w[1]=o,w[2]=g,w[3]=e,w[4]=h,w[5]=b,w[6]=n,w[7]=c,w[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.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 n=t.elements,o=e.elements,h=this.elements,c=n[0],g=n[3],b=n[6],f=n[1],w=n[4],x=n[7],E=n[2],M=n[5],L=n[8],B=o[0],D=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*B+g*dt+b*W,h[3]=c*D+g*vt+b*ut,h[6]=c*F+g*ot+b*st,h[1]=f*B+w*dt+x*W,h[4]=f*D+w*vt+x*ut,h[7]=f*F+w*ot+x*st,h[2]=E*B+M*dt+L*W,h[5]=E*D+M*vt+L*ut,h[8]=E*F+M*ot+L*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],n=t[1],o=t[2],h=t[3],c=t[4],g=t[5],b=t[6],f=t[7],w=t[8];return e*c*w-e*g*f-n*h*w+n*g*b+o*h*f-o*c*b}invert(){const t=this.elements,e=t[0],n=t[1],o=t[2],h=t[3],c=t[4],g=t[5],b=t[6],f=t[7],w=t[8],x=w*c-g*f,E=g*b-w*h,M=f*h-c*b,L=e*x+n*E+o*M;if(L===0)return this.set(0,0,0,0,0,0,0,0,0);const B=1/L;return t[0]=x*B,t[1]=(o*f-w*n)*B,t[2]=(g*n-o*c)*B,t[3]=E*B,t[4]=(w*e-o*b)*B,t[5]=(o*h-g*e)*B,t[6]=M*B,t[7]=(n*b-f*e)*B,t[8]=(c*e-n*h)*B,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,n,o,h,c,g){const b=Math.cos(h),f=Math.sin(h);return this.set(n*b,n*f,-n*(b*c+f*g)+c+t,-o*f,o*b,-o*(-f*c+b*g)+g+e,0,0,1),this}scale(t,e){return this.premultiply(sa.makeScale(t,e)),this}rotate(t){return this.premultiply(sa.makeRotation(-t)),this}translate(t,e){return this.premultiply(sa.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof Zt?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),n=Math.sin(t);return this.set(e,-n,0,n,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,n=t.elements;for(let o=0;o<9;o++)if(e[o]!==n[o])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new $l().fromArray(this.elements)}};ba.IDENTITY=Object.freeze(new ba);let Vi=ba;const sa=new Vi,_n=1e-6,se=2*Math.PI,Nc={x:0,y:0},Ra={x:0,y:0,z:0};class Fa{constructor(){this.equalPointTol=_n,this.equalVectorTol=_n}equalPoint2d(t,e){return new Zt(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new Z(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=_n){return t<e&&t>-e}static equal(t,e,n=_n){return Math.abs(t-e)<n}static great(t,e,n=_n){return t-e>n}static less(t,e,n=_n){return t-e<n}}const Da=new Fa;function Ua(i,t,e=!1){const n=i.x,o=i.y;let h=!1;const c=t.length;for(let g=0,b=c-1;g<c;b=g++){const f=t[g].x,w=t[g].y,x=t[b].x,E=t[b].y;let M=w>o!=E>o;e&&(M=w>=o!=E>=o),M&&n<(x-f)*(o-w)/(E-w)+f&&(h=!h)}return h}function Zl(i,t){if(i.length===0||t.length===0)return!1;const e=new ve().setFromPoints(i),n=new ve().setFromPoints(t);if(!e.intersectsBox(n))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 Ql={isPointInPolygon:Ua,isPolygonIntersect:Zl};function Jl(i,t){const e=[],n=t-1,o=i;for(let h=0;h<=o;h++)e.push(0);for(let h=1;h<=n-o;h++)e.push(h);for(let h=0;h<=o;h++)e.push(n-o+1);return e}function th(i,t){const e=t.length-1,n=i,o=[0];let h=0;for(let g=1;g<=e;g++){const b=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],w=t[g][2]-t[g-1][2],x=Math.sqrt(b*b+f*f+w*w);h+=x,o.push(h)}const c=[];for(let g=0;g<=n;g++)c.push(0);for(let g=1;g<=e-n;g++){const b=o[g]/h;c.push(b*(e-n+1))}for(let g=0;g<=n;g++)c.push(e-n+1);return c}function eh(i,t){const e=t.length-1,n=i,o=[0];let h=0;for(let g=1;g<=e;g++){const b=t[g][0]-t[g-1][0],f=t[g][1]-t[g-1][1],w=t[g][2]-t[g-1][2],x=Math.sqrt(b*b+f*f+w*w),E=Math.sqrt(x);h+=E,o.push(h)}const c=[];for(let g=0;g<=n;g++)c.push(0);for(let g=1;g<=e-n;g++){const b=o[g]/h;c.push(b*(e-n+1))}for(let g=0;g<=n;g++)c.push(e-n+1);return c}function hi(i,t,e,n){if(t===0)return e>=n[i]&&e<n[i+1]?1:0;const o=n[i+t]-n[i],h=n[i+t+1]-n[i+1],c=o>1e-10?(e-n[i])/o:0,g=h>1e-10?(n[i+t+1]-e)/h:0;return c*hi(i,t-1,e,n)+g*hi(i+1,t-1,e,n)}function Bs(i,t,e,n,o){const h=n.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[...n[h]];if(Math.abs(i-e[c])<1e-8)return[...n[0]];const g=[0,0,0];let b=0;for(let f=0;f<=h;f++){const w=hi(f,c,i,e),x=o[f]*w;g[0]+=n[f][0]*x,g[1]+=n[f][1]*x,g[2]+=n[f][2]*x,b+=x}if(b<1e-10){const f=e[e.length-c-1];if(Math.abs(i-f)<1e-8)return[...n[h]];if(Math.abs(i-e[c])<1e-8)return[...n[0]]}return b>1e-10&&(g[0]/=b,g[1]/=b,g[2]/=b),g}function rh(i,t,e,n){const o=i,h=t[o],c=t[t.length-o-1];let g=0;const b=1e3,f=(c-h)/b;let w=Bs(h,i,t,e,n);for(let B=1;B<=b;B++){const D=h+B*f,F=Bs(D,i,t,e,n),dt=F[0]-w[0],vt=F[1]-w[1],ot=F[2]-w[2];g+=Math.sqrt(dt*dt+vt*vt+ot*ot),w=F}const x=Bs(c,i,t,e,n),E=x[0]-w[0],M=x[1]-w[1],L=x[2]-w[2];return g+=Math.sqrt(E*E+M*M+L*L),g}function Cc(i){return i.map(t=>[...t])}class Kr{constructor(t=0,e=0,n=0,o=1){this._x=t,this._y=e,this._z=n,this._w=o}static slerpFlat(t,e,n,o,h,c,g){let b=n[o+0],f=n[o+1],w=n[o+2],x=n[o+3];const E=h[c+0],M=h[c+1],L=h[c+2],B=h[c+3];if(g===0){t[e+0]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x;return}if(g===1){t[e+0]=E,t[e+1]=M,t[e+2]=L,t[e+3]=B;return}if(x!==B||b!==E||f!==M||w!==L){let D=1-g;const F=b*E+f*M+w*L+x*B,dt=F>=0?1:-1,vt=1-F*F;if(vt>Number.EPSILON){const W=Math.sqrt(vt),ut=Math.atan2(W,F*dt);D=Math.sin(D*ut)/W,g=Math.sin(g*ut)/W}const ot=g*dt;if(b=b*D+E*ot,f=f*D+M*ot,w=w*D+L*ot,x=x*D+B*ot,D===1-g){const W=1/Math.sqrt(b*b+f*f+w*w+x*x);b*=W,f*=W,w*=W,x*=W}}t[e]=b,t[e+1]=f,t[e+2]=w,t[e+3]=x}static multiplyQuaternionsFlat(t,e,n,o,h,c){const g=n[o],b=n[o+1],f=n[o+2],w=n[o+3],x=h[c],E=h[c+1],M=h[c+2],L=h[c+3];return t[e]=g*L+w*x+b*M-f*E,t[e+1]=b*L+w*E+f*x-g*M,t[e+2]=f*L+w*M+g*E-b*x,t[e+3]=w*L-g*x-b*E-f*M,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,n,o){return this._x=t,this._y=e,this._z=n,this._w=o,this._onChangeCallback(),this}clone(){return new Kr(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 n=t.x,o=t.y,h=t.z,c=t.order,g=Math.cos,b=Math.sin,f=g(n/2),w=g(o/2),x=g(h/2),E=b(n/2),M=b(o/2),L=b(h/2);switch(c){case"XYZ":this._x=E*w*x+f*M*L,this._y=f*M*x-E*w*L,this._z=f*w*L+E*M*x,this._w=f*w*x-E*M*L;break;case"YXZ":this._x=E*w*x+f*M*L,this._y=f*M*x-E*w*L,this._z=f*w*L-E*M*x,this._w=f*w*x+E*M*L;break;case"ZXY":this._x=E*w*x-f*M*L,this._y=f*M*x+E*w*L,this._z=f*w*L+E*M*x,this._w=f*w*x-E*M*L;break;case"ZYX":this._x=E*w*x-f*M*L,this._y=f*M*x+E*w*L,this._z=f*w*L-E*M*x,this._w=f*w*x+E*M*L;break;case"YZX":this._x=E*w*x+f*M*L,this._y=f*M*x+E*w*L,this._z=f*w*L-E*M*x,this._w=f*w*x-E*M*L;break;case"XZY":this._x=E*w*x-f*M*L,this._y=f*M*x-E*w*L,this._z=f*w*L+E*M*x,this._w=f*w*x+E*M*L;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+c)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,o=Math.sin(n);return this._x=t.x*o,this._y=t.y*o,this._z=t.z*o,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],o=e[4],h=e[8],c=e[1],g=e[5],b=e[9],f=e[2],w=e[6],x=e[10],E=n+g+x;if(E>0){const M=.5/Math.sqrt(E+1);this._w=.25/M,this._x=(w-b)*M,this._y=(h-f)*M,this._z=(c-o)*M}else if(n>g&&n>x){const M=2*Math.sqrt(1+n-g-x);this._w=(w-b)/M,this._x=.25*M,this._y=(o+c)/M,this._z=(h+f)/M}else if(g>x){const M=2*Math.sqrt(1+g-n-x);this._w=(h-f)/M,this._x=(o+c)/M,this._y=.25*M,this._z=(b+w)/M}else{const M=2*Math.sqrt(1+x-n-g);this._w=(c-o)/M,this._x=(h+f)/M,this._y=(b+w)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Cr(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const o=Math.min(1,e/n);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 n=t._x,o=t._y,h=t._z,c=t._w,g=e._x,b=e._y,f=e._z,w=e._w;return this._x=n*w+c*g+o*f-h*b,this._y=o*w+c*b+h*g-n*f,this._z=h*w+c*f+n*b-o*g,this._w=c*w-n*g-o*b-h*f,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,o=this._y,h=this._z,c=this._w;let g=c*t._w+n*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=n,this._y=o,this._z=h,this;const b=1-g*g;if(b<=Number.EPSILON){const M=1-e;return this._w=M*c+e*this._w,this._x=M*n+e*this._x,this._y=M*o+e*this._y,this._z=M*h+e*this._z,this.normalize(),this}const f=Math.sqrt(b),w=Math.atan2(f,g),x=Math.sin((1-e)*w)/f,E=Math.sin(e*w)/f;return this._w=c*x+this._w*E,this._x=n*x+this._x*E,this._y=o*x+this._y*E,this._z=h*x+this._z*E,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),o=Math.sqrt(1-n),h=Math.sqrt(n);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 We=class nh{constructor(t,e,n){this.x=0,this.y=0,this.z=0;const o=+(t!==void 0)+ +(e!==void 0)+ +(n!==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=n;return}throw He.ILLEGAL_PARAMETERS}}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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 nh(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(rl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(rl.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,o=this.z,h=t.elements;return this.x=h[0]*e+h[3]*n+h[6]*o,this.y=h[1]*e+h[4]*n+h[7]*o,this.z=h[2]*e+h[5]*n+h[8]*o,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,o=this.z,h=t.elements,c=1/(h[3]*e+h[7]*n+h[11]*o+h[15]);return this.x=(h[0]*e+h[4]*n+h[8]*o+h[12])*c,this.y=(h[1]*e+h[5]*n+h[9]*o+h[13])*c,this.z=(h[2]*e+h[6]*n+h[10]*o+h[14])*c,this}applyQuaternion(t){const e=this.x,n=this.y,o=this.z,h=t.x,c=t.y,g=t.z,b=t.w,f=2*(c*o-g*n),w=2*(g*e-h*o),x=2*(h*n-c*e);return this.x=e+b*f+c*x-g*w,this.y=n+b*w+g*f-h*x,this.z=o+b*x+h*w-c*f,this}transformDirection(t){const e=this.x,n=this.y,o=this.z,h=t.elements;return this.x=h[0]*e+h[4]*n+h[8]*o,this.y=h[1]*e+h[5]*n+h[9]*o,this.z=h[2]*e+h[6]*n+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 n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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),n=this.length(),o=t.length();return Math.abs(e)===n*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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,o=t.y,h=t.z,c=e.x,g=e.y,b=e.z;return this.x=o*b-h*g,this.y=h*c-n*b,this.z=n*g-o*c,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ia.copy(this).projectOnVector(t),this.sub(ia)}reflect(t){return this.sub(ia.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 n=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,n)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,o=this.z-t.z;return e*e+n*n+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(),n=this.setFromMatrixColumn(t,1).length(),o=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,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,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};We.X_AXIS=Object.freeze(new We(1,0,0)),We.NEGATIVE_X_AXIS=Object.freeze(new We(-1,0,0)),We.Y_AXIS=Object.freeze(new We(0,1,0)),We.NEGATIVE_Y_AXIS=Object.freeze(new We(0,-1,0)),We.Z_AXIS=Object.freeze(new We(0,0,1)),We.NEGATIVE_Z_AXIS=Object.freeze(new We(0,0,-1));let Z=We;const ia=new Z,rl=new Kr,xa=class sh{constructor(t,e,n,o,h,c,g,b,f,w,x,E,M,L,B,D){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&n!=null&&o!=null&&h!=null&&c!=null&&g!=null&&b!=null&&f!=null&&w!=null&&x!=null&&E!=null&&M!=null&&L!=null&&B!=null&&D!=null&&this.set(t,e,n,o,h,c,g,b,f,w,x,E,M,L,B,D)}set(t,e,n,o,h,c,g,b,f,w,x,E,M,L,B,D){const F=this.elements;return F[0]=t,F[4]=e,F[8]=n,F[12]=o,F[1]=h,F[5]=c,F[9]=g,F[13]=b,F[2]=f,F[6]=w,F[10]=x,F[14]=E,F[3]=M,F[7]=L,F[11]=B,F[15]=D,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 sh().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[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 n=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,n.x,n.y,n.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,o=1/Fn.setFromMatrixColumn(t,0).length(),h=1/Fn.setFromMatrixColumn(t,1).length(),c=1/Fn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*o,e[1]=n[1]*o,e[2]=n[2]*o,e[3]=0,e[4]=n[4]*h,e[5]=n[5]*h,e[6]=n[6]*h,e[7]=0,e[8]=n[8]*c,e[9]=n[9]*c,e[10]=n[10]*c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Lc,t,Oc)}lookAt(t,e,n){const o=this.elements;return Re.subVectors(t,e),Re.lengthSq()===0&&(Re.z=1),Re.normalize(),Hr.crossVectors(n,Re),Hr.lengthSq()===0&&(Math.abs(n.z)===1?Re.x+=1e-4:Re.z+=1e-4,Re.normalize(),Hr.crossVectors(n,Re)),Hr.normalize(),Ks.crossVectors(Re,Hr),o[0]=Hr.x,o[4]=Ks.x,o[8]=Re.x,o[1]=Hr.y,o[5]=Ks.y,o[9]=Re.y,o[2]=Hr.z,o[6]=Ks.z,o[10]=Re.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,o=e.elements,h=this.elements,c=n[0],g=n[4],b=n[8],f=n[12],w=n[1],x=n[5],E=n[9],M=n[13],L=n[2],B=n[6],D=n[10],F=n[14],dt=n[3],vt=n[7],ot=n[11],W=n[15],ut=o[0],st=o[4],Gt=o[8],Xt=o[12],Ht=o[1],wt=o[5],Bt=o[9],me=o[13],ge=o[2],Ce=o[6],te=o[10],oe=o[14],Q=o[3],Ct=o[7],le=o[11],pr=o[15];return h[0]=c*ut+g*Ht+b*ge+f*Q,h[4]=c*st+g*wt+b*Ce+f*Ct,h[8]=c*Gt+g*Bt+b*te+f*le,h[12]=c*Xt+g*me+b*oe+f*pr,h[1]=w*ut+x*Ht+E*ge+M*Q,h[5]=w*st+x*wt+E*Ce+M*Ct,h[9]=w*Gt+x*Bt+E*te+M*le,h[13]=w*Xt+x*me+E*oe+M*pr,h[2]=L*ut+B*Ht+D*ge+F*Q,h[6]=L*st+B*wt+D*Ce+F*Ct,h[10]=L*Gt+B*Bt+D*te+F*le,h[14]=L*Xt+B*me+D*oe+F*pr,h[3]=dt*ut+vt*Ht+ot*ge+W*Q,h[7]=dt*st+vt*wt+ot*Ce+W*Ct,h[11]=dt*Gt+vt*Bt+ot*te+W*le,h[15]=dt*Xt+vt*me+ot*oe+W*pr,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],n=t[4],o=t[8],h=t[12],c=t[1],g=t[5],b=t[9],f=t[13],w=t[2],x=t[6],E=t[10],M=t[14],L=t[3],B=t[7],D=t[11],F=t[15];return L*(+h*b*x-o*f*x-h*g*E+n*f*E+o*g*M-n*b*M)+B*(+e*b*M-e*f*E+h*c*E-o*c*M+o*f*w-h*b*w)+D*(+e*f*x-e*g*M-h*c*x+n*c*M+h*g*w-n*f*w)+F*(-o*g*w-e*b*x+e*g*E+o*c*x-n*c*E+n*b*w)}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,n){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]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],o=t[2],h=t[3],c=t[4],g=t[5],b=t[6],f=t[7],w=t[8],x=t[9],E=t[10],M=t[11],L=t[12],B=t[13],D=t[14],F=t[15],dt=x*D*f-B*E*f+B*b*M-g*D*M-x*b*F+g*E*F,vt=L*E*f-w*D*f-L*b*M+c*D*M+w*b*F-c*E*F,ot=w*B*f-L*x*f+L*g*M-c*B*M-w*g*F+c*x*F,W=L*x*b-w*B*b-L*g*E+c*B*E+w*g*D-c*x*D,ut=e*dt+n*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]=(B*E*h-x*D*h-B*o*M+n*D*M+x*o*F-n*E*F)*st,t[2]=(g*D*h-B*b*h+B*o*f-n*D*f-g*o*F+n*b*F)*st,t[3]=(x*b*h-g*E*h-x*o*f+n*E*f+g*o*M-n*b*M)*st,t[4]=vt*st,t[5]=(w*D*h-L*E*h+L*o*M-e*D*M-w*o*F+e*E*F)*st,t[6]=(L*b*h-c*D*h-L*o*f+e*D*f+c*o*F-e*b*F)*st,t[7]=(c*E*h-w*b*h+w*o*f-e*E*f-c*o*M+e*b*M)*st,t[8]=ot*st,t[9]=(L*x*h-w*B*h-L*n*M+e*B*M+w*n*F-e*x*F)*st,t[10]=(c*B*h-L*g*h+L*n*f-e*B*f-c*n*F+e*g*F)*st,t[11]=(w*g*h-c*x*h-w*n*f+e*x*f+c*n*M-e*g*M)*st,t[12]=W*st,t[13]=(w*B*o-L*x*o+L*n*E-e*B*E-w*n*D+e*x*D)*st,t[14]=(L*g*o-c*B*o-L*n*b+e*B*b+c*n*D-e*g*D)*st,t[15]=(c*x*o-w*g*o+w*n*b-e*x*b-c*n*E+e*g*E)*st,this}scale(t){const e=this.elements,n=t.x,o=t.y,h=t.z;return e[0]*=n,e[4]*=o,e[8]*=h,e[1]*=n,e[5]*=o,e[9]*=h,e[2]*=n,e[6]*=o,e[10]*=h,e[3]*=n,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],n=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,n,o))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),o=Math.sin(e),h=1-n,c=t.x,g=t.y,b=t.z,f=h*c,w=h*g;return this.set(f*c+n,f*g-o*b,f*b+o*g,0,f*g+o*b,w*g+n,w*b-o*c,0,f*b-o*g,w*b+o*c,h*b*b+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,o,h,c){return this.set(1,n,h,0,t,1,c,0,e,o,1,0,0,0,0,1),this}compose(t,e,n){const o=this.elements,h=e.x,c=e.y,g=e.z,b=e.w,f=h+h,w=c+c,x=g+g,E=h*f,M=h*w,L=h*x,B=c*w,D=c*x,F=g*x,dt=b*f,vt=b*w,ot=b*x,W=n.x,ut=n.y,st=n.z;return o[0]=(1-(B+F))*W,o[1]=(M+ot)*W,o[2]=(L-vt)*W,o[3]=0,o[4]=(M-ot)*ut,o[5]=(1-(E+F))*ut,o[6]=(D+dt)*ut,o[7]=0,o[8]=(L+vt)*st,o[9]=(D-dt)*st,o[10]=(1-(E+B))*st,o[11]=0,o[12]=t.x,o[13]=t.y,o[14]=t.z,o[15]=1,this}decompose(t,e,n){const o=this.elements;let h=Fn.set(o[0],o[1],o[2]).length();const c=Fn.set(o[4],o[5],o[6]).length(),g=Fn.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 b=1/h,f=1/c,w=1/g;return rr.elements[0]*=b,rr.elements[1]*=b,rr.elements[2]*=b,rr.elements[4]*=f,rr.elements[5]*=f,rr.elements[6]*=f,rr.elements[8]*=w,rr.elements[9]*=w,rr.elements[10]*=w,e.setFromRotationMatrix(rr),n.x=h,n.y=c,n.z=g,this}equals(t){const e=this.elements,n=t.elements;for(let o=0;o<16;o++)if(e[o]!==n[o])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};xa.IDENTITY=Object.freeze(new xa);let $r=xa;const Fn=new Z,rr=new $r,Lc=new Z(0,0,0),Oc=new Z(1,1,1),Hr=new Z,Ks=new Z,Re=new Z;class Nt{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,n=t.length;e<n;e+=3)this.expandByPoint(aa.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=aa.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new Nt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new 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,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,aa).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:(yr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),yr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),yr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),yr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),yr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),yr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),yr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),yr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(yr),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 yr=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],aa=new Z,nl=new Zt;class ve{constructor(t=void 0,e=void 0){this.min=t==null?new Zt(1/0,1/0):new Zt(t.x,t.y),this.max=e==null?new Zt(-1/0,-1/0):new Zt(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,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=nl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new ve().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new Zt(0,0):new Zt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new Zt(0,0):new Zt(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,nl).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 sl=new Z,Bc=new Z,zc=new Vi;class Ws{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,n,o){return this.normal.set(t,e,n),this.constant=o,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const o=sl.subVectors(n,e).cross(Bc.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 n=e||zc.getNormalMatrix(t),o=this.coplanarPoint(sl).applyMatrix4(t),h=this.normal.applyMatrix3(n).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 Ws().copy(this)}}class Tt extends Zt{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((n,o)=>{n.toArray(e,o*2)}),e}}class Y extends Z{static pointArrayToNumberArray(t,e=!0){const n=e?3:2,o=new Array(t.length*n);return t.forEach((h,c)=>{h.toArray(o,c*n)}),o}}const il=new $r,al=new Kr,ih=class wa{constructor(t=0,e=0,n=0,o=wa.DEFAULT_ORDER){this._x=t,this._y=e,this._z=n,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,n,o=this._order){return this._x=t,this._y=e,this._z=n,this._order=o,this._onChangeCallback(),this}clone(){return new wa(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,n=!0){const o=t.elements,h=o[0],c=o[4],g=o[8],b=o[1],f=o[5],w=o[9],x=o[2],E=o[6],M=o[10];switch(e){case"XYZ":this._y=Math.asin(Cr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-w,M),this._z=Math.atan2(-c,h)):(this._x=Math.atan2(E,f),this._z=0);break;case"YXZ":this._x=Math.asin(-Cr(w,-1,1)),Math.abs(w)<.9999999?(this._y=Math.atan2(g,M),this._z=Math.atan2(b,f)):(this._y=Math.atan2(-x,h),this._z=0);break;case"ZXY":this._x=Math.asin(Cr(E,-1,1)),Math.abs(E)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-c,f)):(this._y=0,this._z=Math.atan2(b,h));break;case"ZYX":this._y=Math.asin(-Cr(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(E,M),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-c,f));break;case"YZX":this._z=Math.asin(Cr(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-w,f),this._y=Math.atan2(-x,h)):(this._x=0,this._y=Math.atan2(g,M));break;case"XZY":this._z=Math.asin(-Cr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(E,f),this._y=Math.atan2(g,h)):(this._x=Math.atan2(-w,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n=!0){return il.makeRotationFromQuaternion(t),this.setFromRotationMatrix(il,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return al.setFromEuler(this),this.setFromQuaternion(al,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}};ih.DEFAULT_ORDER="XYZ";let ah=ih;class oh{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}let Va=class extends oh{translate(t){return this.transform(new Vi().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}};class Gi 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 ve}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let n=0;n<this.loops.length;++n){const o=this.loops[n].getPoints(t);e.push(o)}return e}buildHierarchy(){var t;const e=this.getPoints(100),n=this.calculateBoundaryBoxes(e),o=this.sortBoundaryBoxesByAreas(n),h=new Map,c=o.length;for(let b=0;b<c;b++)h.set(o[b],{index:o[b],children:[]});const g={index:-1,children:[]};for(let b=0;b<c;b++){const f=o[b],w=e[f],x=n[f];let E=b+1;for(;E<c;E++){const M=o[E],L=e[M];if(n[M].containsBox(x)&&Ql.isPointInPolygon(w[kt.randInt(0,w.length-1)],L)){(t=h.get(M))==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(n=>{e.push(new ve().setFromPoints(n))}),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 n=[];return e.forEach(o=>{n.push(o.index)}),n}}class Yn 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 n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let n,o=this.getPoint(0),h=0;e.push(0);for(let c=1;c<=t;c++)n=this.getPoint(c/t),h+=n.distanceTo(o),e.push(h),o=n;return e}getUtoTmapping(t,e){const n=this.getLengths();let o=0;const h=n.length;let c;e?c=e:c=t*n[h-1];let g=0,b=h-1,f;for(;g<=b;)if(o=Math.floor(g+(b-g)/2),f=n[o]-c,f<0)g=o+1;else if(f>0)b=o-1;else{b=o;break}if(o=b,n[o]===c)return o/(h-1);const w=n[o],x=n[o+1]-w,E=(c-w)/x;return(o+E)/(h-1)}getTangent(t){let e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);const o=this.getPoint(e),h=this.getPoint(n),c=new Tt;return c.copy(h).sub(o).normalize(),c}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class jn extends Yn{constructor(t,e,n,o,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c==3)typeof t=="object"&&typeof e=="object"&&typeof n=="object"?this.createByThreePoints(t,e,n):this.createByStartEndPointsAndBulge(t,e,n);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(kt.normalizeAngle(n)):kt.normalizeAngle(n),this._endAngle=this._clockwise?this._mirrorAngle(kt.normalizeAngle(o)):kt.normalizeAngle(o)}else throw He.ILLEGAL_PARAMETERS}createByThreePoints(t,e,n){const o=(st,Gt)=>({x:(st.x+Gt.x)/2,y:(st.y+Gt.y)/2}),h=(st,Gt)=>(Gt.y-st.y)/(Gt.x-st.x),c=st=>-1/st,g=o(t,e),b=o(e,n),f=h(t,e),w=h(e,n),x=c(f),E=c(w),M=(st,Gt,Xt,Ht)=>{const wt=(Ht-Gt)/(st-Xt),Bt=st*wt+Gt;return{x:wt,y:Bt}},L=g.y-x*g.x,B=b.y-E*b.x,D=M(x,L,E,B),F=Math.sqrt(Math.pow(t.x-D.x,2)+Math.pow(t.y-D.y,2)),dt=(st,Gt)=>Math.atan2(st.y-Gt.y,st.x-Gt.x),vt=dt(t,D),ot=dt(e,D),W=dt(n,D),ut=W>vt&&W<ot||vt>W&&vt<ot||ot>W&&ot<vt;this.center=D,this.radius=F,this._clockwise=!ut,this._startAngle=vt,this._endAngle=W}createByStartEndPointsAndBulge(t,e,n){let o,h,c;n<0?(o=Math.atan(-n)*4,h=new Zt(t),c=new Zt(e)):(o=Math.atan(n)*4,h=new Zt(e),c=new Zt(t));const g=new Zt().subVectors(c,h),b=g.length(),f=new Zt().addVectors(h,g.multiplyScalar(.5)),w=Math.abs(b/2/Math.tan(o/2)),x=g.normalize();let E;if(o<Math.PI){const M=new Zt(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=f.add(M.multiplyScalar(-w))}else{const M=new Zt(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=f.add(M.multiplyScalar(w))}n<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=n<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(kt.normalizeAngle(t)):kt.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==se?t:kt.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?kt.normalizeAngle(t-e):kt.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),n=kt.normalizeAngle((t+e)/2),o=this._clockwise?this._mirrorAngle(n):n;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);kt.isBetweenAngle(c,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const n=t.map(h=>h.x),o=t.map(h=>h.y);return new ve(new Tt(Math.min(...n),Math.min(...o)),new Tt(Math.max(...n),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new jn(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),n=this.center.x+this.radius*Math.cos(e),o=this.center.y+this.radius*Math.sin(e);return new Tt(n,o)}getPoints(t=100){const e=[];let n=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(n=se,o=0),this.clockwise)for(let h=0;h<=t;h++){const c=o-n*(h/t),g=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}else for(let h=0;h<=t;h++){const c=o+n*(h/t),g=this._clockwise?this._mirrorAngle(c):c,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}return e}}class Rc extends oh{translate(t){return this.transform(new $r().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 Hs extends Rc{}let ui=class lh extends Hs{constructor(t,e){super(),this._start=new Y(t),this._end=new Y(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 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(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 n=this.delta(an).normalize();return new Y(this._start).addScaledVector(n,t)}else{const n=this.delta(an).normalize();return new Y(this._end).addScaledVector(n,t)}}extend(t,e=!1){if(e){const n=an.subVectors(this._start,this._end).normalize();this._start=new Y(this._start).addScaledVector(n,t)}else{const n=this.delta(an).normalize();this._end=new Y(this._end).addScaledVector(n,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){ol.subVectors(t,this._start),$s.subVectors(this.endPoint,this.startPoint);const n=$s.dot($s);let o=$s.dot(ol)/n;return e&&(o=kt.clamp(o,0,1)),o}closestPointToPoint(t,e,n){const o=this.closestPointToPointParameter(t,e);return this.delta(n).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,n=an.subVectors(t,this.startPoint).dot(e);return new Y().copy(e).multiplyScalar(n).add(this.startPoint)}perpPoint(t){const e=this.direction,n=this.startPoint,o=an.subVectors(t,n).dot(e),h=an.copy(e).multiplyScalar(o);return new Y().addVectors(n,h)}calculateBoundingBox(){const t=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)),e=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 Nt(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new lh(this._start.clone(),this._end.clone())}};const an=new Z,ol=new Z,$s=new Z;let Ga=class ri extends Hs{static computeCenterPoint(t,e,n){const o=new Z().addVectors(t,e).multiplyScalar(.5),h=new Z().addVectors(t,n).multiplyScalar(.5),c=new Z().subVectors(e,t),g=new Z().subVectors(n,t),b=new Z().crossVectors(c,g).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new Z().crossVectors(c,b).normalize(),w=new Z().crossVectors(g,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=w.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),M=new ui(o,o.clone().add(x)),L=new ui(h,h.clone().add(E)),B=new Z;return M.closestPointToPoint(L.startPoint,!0,B)?B:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,n){const o=ri.computeCenterPoint(t,e,n);if(o){const h=o.distanceTo(t),c=new Z().subVectors(t,o),g=new Z().subVectors(e,o),b=Math.atan2(c.y,c.x),f=Math.atan2(g.y,g.x);return new ri(o,h,b,f,Z.Z_AXIS)}}constructor(t,e,n,o,h,c=Z.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=n,this.endAngle=o,this.normal=h,this.refVec=c,(o-n)%se==0?(this.startAngle=0,this.endAngle=se):(this.startAngle=n,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw He.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==se?t:kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return kt.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 b=0;b<2*Math.PI;b+=Math.PI/2)kt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,n=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<n&&(n=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 Nt({x:e,y:n,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 n=this.deltaAngle,o=this.startAngle;this.closed&&(n=se,o=0);for(let h=0;h<=t;h++){const c=o+n*(h/t),g=this.getPointAtAngle(c);e.push(g)}return e}transform(t){const e=oa.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),n=oa.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),n.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(n),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 ri(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(oa.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,n=this.refVec,o={x:e.y*n.z-e.z*n.y,y:e.z*n.x-e.x*n.z,z:e.x*n.y-e.y*n.x},h=this.center,c=this.radius;return new Y(h.x+c*(n.x*Math.cos(t)+o.x*Math.sin(t)),h.y+c*(n.y*Math.cos(t)+o.y*Math.sin(t)),h.z+c*(n.z*Math.cos(t)+o.z*Math.sin(t)))}get plane(){const t=new Z(this.center).distanceTo(Ra);return new Ws(this.normal,t)}};const oa=new Z;class ji extends Yn{constructor(t,e,n,o=0,h=se,c=!1,g=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=n,(h-o)%se==0?(this.startAngle=0,this.endAngle=se):(this.startAngle=o,this.endAngle=h),this.clockwise=c,this.rotation=g}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw He.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw He.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==se?t:kt.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 kt.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,n=-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),n=Math.max(n,c.x),o=Math.max(o,c.y)}return new ve({x:t,y:e},{x:n,y:o})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=e;for(;n>e;)n-=e;n<Number.EPSILON&&(o?n=0:n=e),this.clockwise===!0&&!o&&(n===e?n=-e:n=n-e);const h=this.startAngle+t*n;let c=this.center.x+this.majorAxisRadius*Math.cos(h),g=this.center.y+this.minorAxisRadius*Math.sin(h);if(this.rotation!==0){const b=Math.cos(this.rotation),f=Math.sin(this.rotation),w=c-this.center.x,x=g-this.center.y;c=w*b-x*f+this.center.x,g=w*f+x*b+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 ji(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Wi extends Hs{constructor(t,e,n,o,h,c=0,g=se){super(),this.center=t,this.normal=e,this.majorAxis=n,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(g-c);Math.abs(b-se)<1e-10||Math.abs(b-2*se)<1e-10?(this.startAngle=0,this.endAngle=se):(this.startAngle=c,this.endAngle=g)}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw He.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw He.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==se?t:kt.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-se)<1e-10?se:kt.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 n=0,o=this.getPointAtAngle(this.startAngle);for(let h=1;h<=t;h++){const c=this.startAngle+h*e,g=this.getPointAtAngle(c),b=g.x-o.x,f=g.y-o.y,w=g.z-o.z;n+=Math.sqrt(b*b+f*f+w*w),o=g}return n}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 b=0;b<2*Math.PI;b+=Math.PI/2)kt.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,n=1/0,o=1/0,h=-1/0,c=-1/0,g=-1/0;for(const b of t){const f=this.getPointAtAngle(b);f.x<e&&(e=f.x),f.y<n&&(n=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 Nt({x:e,y:n,z:o},{x:h,y:c,z:g})}else{let t=1/0,e=1/0,n=1/0,o=-1/0,h=-1/0,c=-1/0;for(let g=0;g<=100;g++){const b=this.startAngle+this.deltaAngle*(g/100),f=this.getPointAtAngle(b);t=Math.min(t,f.x),e=Math.min(e,f.y),n=Math.min(n,f.z),o=Math.max(o,f.x),h=Math.max(h,f.y),c=Math.max(c,f.z)}return new Nt({x:t,y:e,z:n},{x:o,y:h,z:c})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let n=this.deltaAngle,o=this.startAngle;this.closed&&(n=se,o=0);for(let h=0;h<=t;h++){const c=o+n*(h/t),g=this.getPointAtAngle(c);e.push(g)}return e}getPointAtAngle(t){const e=Math.cos(t),n=Math.sin(t),o=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(n),h=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(o);return new Y(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),n=e.dot(this.majorAxis),o=e.dot(this.minorAxis),h=n/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 Wi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new Z(this.center).distanceTo(Ra);return new Ws(this.normal,t)}}class wn extends Yn{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 n=0;n<e;++n){const o=this._vertices[n];let h=null;if(n<e-1?h=this._vertices[n+1]:n==e-1&&this.closed&&(h=this._vertices[0]),h)if(o.bulge){const c=new jn(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 ve().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const n=[];return this.getPoints(t).forEach(o=>n.push(new Y().set(o.x,o.y,e))),n}getPoints(t){const e=[],n=this._vertices.length;for(let o=0;o<n;++o){const h=this._vertices[o];if(h.bulge){let c=null;if(o<n-1?c=this._vertices[o+1]:o==n-1&&this.closed&&(c=this._vertices[0]),c){const g=new jn(h,c,h.bulge).getPoints(t),b=g.length;for(let f=0;f<b;++f){const w=g[f];e.push(new Tt(w.x,w.y))}}}else e.push(new Tt(h.x,h.y)),o==n-1&&this.closed&&e.push(e[0])}return e}}let zs=class hh extends Yn{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 ve(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new hh(this._start.clone(),this._end.clone())}},ja=class extends Yn{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 ve;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(n=>{n.getPoints(t).forEach(o=>{e.push(new Tt(o.x,o.y))})}),e}};function Fc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var uh={exports:{}};(function(i,t){(function(e){i.exports=e()})(function(){var e={},n=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=n;if(h()){var g=function(b,f){var w=n;return b.split(".").forEach(function(x){w&&(w=w[x])}),w?w[f]:null};onmessage=function(b){if(!(!b.data.className||!b.data.methodName)){var f=g(b.data.className,b.data.methodName);if(!f)return console.error("could not find "+b.data.className+"."+b.data.methodName);postMessage({result:f.apply(null,b.data.args),id:b.data.id})}}}}return function(b,f,w){f.geom=f.geom||{},f.exe=f.exe||{},f.eval=f.eval||{},f.core=f.core||{},f.promhx=f.promhx||{};var x={},E=function(){return Ct.__string_rec(this,"")};function M(r,s){function a(){}a.prototype=r;var l=new a;for(var u in s)l[u]=s[u];return s.toString!==Object.prototype.toString&&(l.toString=s.toString),l}var L=function(){};x.HxOverrides=L,L.__name__=["HxOverrides"],L.strDate=function(r){var s=r.length;switch(s){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(" "),m=d[0].split("-"),_=d[1].split(":");return new Date(m[0],m[1]-1,m[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},L.cca=function(r,s){var a=r.charCodeAt(s);if(a==a)return a},L.substr=function(r,s,a){return s!=null&&s!=0&&a!=null&&a<0?"":(a==null&&(a=r.length),s<0?(s=r.length+s,s<0&&(s=0)):a<0&&(a=r.length+a-s),r.substr(s,a))},L.iter=function(r){return{cur:0,arr:r,hasNext:function(){return this.cur<this.arr.length},next:function(){return this.arr[this.cur++]}}};var B=function(){};x.Lambda=B,B.__name__=["Lambda"],B.fold=function(r,s,a){for(var l=Ze(r)();l.hasNext();){var u=l.next();a=s(u,a)}return a};var D=function(){this.length=0};x.List=D,D.__name__=["List"],D.prototype={add:function(r){var s=[r];this.h==null?this.h=s:this.q[1]=s,this.q=s,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__:D},Math.__name__=["Math"];var F=function(){};x.Reflect=F,F.__name__=["Reflect"],F.field=function(r,s){try{return r[s]}catch(a){return a instanceof Q&&(a=a.val),null}},F.callMethod=function(r,s,a){return s.apply(r,a)},F.fields=function(r){var s=[];if(r!=null){var a=Object.prototype.hasOwnProperty;for(var l in r)l!="__id__"&&l!="hx__closures__"&&a.call(r,l)&&s.push(l)}return s},F.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},F.deleteField=function(r,s){return Object.prototype.hasOwnProperty.call(r,s)?(delete r[s],!0):!1};var dt=function(){};x.Std=dt,dt.__name__=["Std"],dt.string=function(r){return Ct.__string_rec(r,"")},dt.parseFloat=function(r){return parseFloat(r)};var vt=function(){this.b=""};x.StringBuf=vt,vt.__name__=["StringBuf"],vt.prototype={add:function(r){this.b+=dt.string(r)},__class__:vt};var ot=function(){};x.StringTools=ot,ot.__name__=["StringTools"],ot.fastCodeAt=function(r,s){return r.charCodeAt(s)};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 s=["TClass",6,r];return s.__enum__=W,s.toString=E,s},W.TEnum=function(r){var s=["TEnum",7,r];return s.__enum__=W,s.toString=E,s},W.TUnknown=["TUnknown",8],W.TUnknown.toString=E,W.TUnknown.__enum__=W;var ut=function(){};x.Type=ut,ut.__name__=["Type"],ut.getClassName=function(r){var s=r.__name__;return s==null?null:s.join(".")},ut.getEnumName=function(r){var s=r.__ename__;return s.join(".")},ut.resolveClass=function(r){var s=x[r];return s==null||!s.__name__?null:s},ut.resolveEnum=function(r){var s=x[r];return s==null||!s.__ename__?null:s},ut.createEmptyInstance=function(r){function s(){}return s.prototype=r.prototype,new s},ut.createEnum=function(r,s,a){var l=F.field(r,s);if(l==null)throw new Q("No such constructor "+s);if(F.isFunction(l)){if(a==null)throw new Q("Constructor "+s+" need parameters");return F.callMethod(r,l,a)}if(a!=null&&a.length!=0)throw new Q("Constructor "+s+" does not need parameters");return l},ut.getEnumConstructs=function(r){var s=r.__constructs__;return s.slice()},ut.typeof=function(r){var s=typeof r;switch(s){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=Ct.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(){};x["haxe.IMap"]=st,st.__name__=["haxe","IMap"];var Gt=function(r,s){this.high=r,this.low=s};x["haxe._Int64.___Int64"]=Gt,Gt.__name__=["haxe","_Int64","___Int64"],Gt.prototype={__class__:Gt};var Xt=function(){this.buf=new vt,this.cache=[],this.useCache=Xt.USE_CACHE,this.useEnumIndex=Xt.USE_ENUM_INDEX,this.shash=new ge,this.scount=0};x["haxe.Serializer"]=Xt,Xt.__name__=["haxe","Serializer"],Xt.prototype={toString:function(){return this.buf.b},serializeString:function(r){var s=this.shash.get(r);if(s!=null){this.buf.b+="R",s==null?this.buf.b+="null":this.buf.b+=""+s;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 s=typeof r,a=0,l=this.cache.length;a<l;){var u=a++,d=this.cache[u];if(typeof d==s&&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 s=0,a=F.fields(r);s<a.length;){var l=a[s];++s,this.serializeString(l),this.serialize(F.field(r,l))}this.buf.b+="g"},serialize:function(r){{var s=ut.typeof(r);switch(s[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=s[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 m=r.length,_=0;_<m;){var y=_++;r[y]==null?d++:(d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d),d=0),this.serialize(r[y]))}d>0&&(d==1?this.buf.b+="n":(this.buf.b+="u",d==null?this.buf.b+="null":this.buf.b+=""+d)),this.buf.b+="h";break;case D:this.buf.b+="l";for(var A=r,I=A.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 ge:this.buf.b+="b";for(var T=r,O=T.keys();O.hasNext();){var C=O.next();this.serializeString(C),this.serialize(Zi[C]!=null?T.getReserved(C):T.h[C])}this.buf.b+="h";break;case wt:this.buf.b+="q";for(var R=r,z=R.keys();z.hasNext();){var U=z.next();this.buf.b+=":",U==null?this.buf.b+="null":this.buf.b+=""+U,this.serialize(R.h[U])}this.buf.b+="h";break;case Bt:this.buf.b+="M";for(var V=r,q=V.keys();q.hasNext();){var J=q.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 Ce:for(var G=r,K=0,tt=G.length-2,et=new vt,it=Xt.BASE64;K<tt;){var ht=G.get(K++),at=G.get(K++),ct=G.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=G.get(K++),pt=G.get(K++);et.add(it.charAt(nt>>2)),et.add(it.charAt((nt<<4|pt>>4)&63)),et.add(it.charAt(pt<<2&63))}else if(K==tt+1){var X=G.get(K++);et.add(it.charAt(X>>2)),et.add(it.charAt(X<<4&63))}var ft=et.b;this.buf.b+="s",ft.length==null?this.buf.b+="null":this.buf.b+=""+ft.length,this.buf.b+=":",ft==null?this.buf.b+="null":this.buf.b+=""+ft;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(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(Ct.__instanceof(r,Do)){var Pt=ut.getClassName(r);this.buf.b+="A",this.serializeString(Pt)}else if(Ct.__instanceof(r,Uo))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 Wt=s[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(Wt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=dt.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Kt=r.length;this.buf.b+=dt.string(Kt-2);for(var Ut=2;Ut<Kt;){var $t=Ut++;this.serialize(r[$t])}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__:Xt};var Ht=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var s=Ht.DEFAULT_RESOLVER;s==null&&(s=ut,Ht.DEFAULT_RESOLVER=s),this.setResolver(s)};x["haxe.Unserializer"]=Ht,Ht.__name__=["haxe","Unserializer"],Ht.initCodes=function(){for(var r=[],s=0,a=Ht.BASE64.length;s<a;){var l=s++;r[Ht.BASE64.charCodeAt(l)]=l}return r},Ht.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(s){return null},resolveEnum:function(s){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,s=!1,a=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=a)break;s=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return s&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var s=this.buf.charCodeAt(this.pos);if(s>=43&&s<58||s==101||s==69)this.pos++;else break}return dt.parseFloat(L.substr(this.buf,r,this.pos-r))},unserializeObject:function(r){for(;;){if(this.pos>=this.length)throw new Q("Invalid object");if(this.buf.charCodeAt(this.pos)==103)break;var s=this.unserialize();if(typeof s!="string")throw new Q("Invalid object key");var a=this.unserialize();r[s]=a}this.pos++},unserializeEnum:function(r,s){if(this.get(this.pos++)!=58)throw new Q("Invalid enum format");var a=this.readDigits();if(a==0)return ut.createEnum(r,s);for(var l=[];a-- >0;)l.push(this.unserialize());return ut.createEnum(r,s,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 s=this.readDigits();if(this.get(this.pos++)!=58||this.length-this.pos<s)throw new Q("Invalid string length");var a=L.substr(this.buf,this.pos,s);return this.pos+=s,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 m={};return this.cache.push(m),this.unserializeObject(m),m;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var y=this.readDigits();if(y<0||y>=this.scache.length)throw new Q("Invalid string reference");return this.scache[y];case 120:throw new Q(this.unserialize());case 99:var A=this.unserialize(),I=this.resolver.resolveClass(A);if(I==null)throw new Q("Class not found "+A);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 T=this.unserializeEnum(k,this.unserialize());return this.cache.push(T),T;case 106:var O=this.unserialize(),C=this.resolver.resolveEnum(O);if(C==null)throw new Q("Enum not found "+O);this.pos++;var R=this.readDigits(),z=ut.getEnumConstructs(C)[R];if(z==null)throw new Q("Unknown enum index "+O+"@"+R);var U=this.unserializeEnum(C,z);return this.cache.push(U),U;case 108:var V=new D;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 ge;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 wt;this.cache.push(H),this.buf;for(var G=this.get(this.pos++);G==58;){var K=this.readDigits();H.set(K,this.unserialize()),G=this.get(this.pos++)}if(G!=104)throw new Q("Invalid IntMap format");return H;case 77:var tt=new Bt;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var 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=L.substr(this.buf,this.pos,19);it=L.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(),pt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var X=Ht.CODES;X==null&&(X=Ht.initCodes(),Ht.CODES=X);var ft=this.pos,Pt=nt&3,Wt;Wt=(nt>>2)*3+(Pt>=2?Pt-1:0);for(var Kt=ft+(nt-Pt),Ut=Ce.alloc(Wt),$t=0;ft<Kt;){var Me=X[ot.fastCodeAt(pt,ft++)],Xe=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,Me<<2|Xe>>4);var be=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,Xe<<4|be>>2);var _e=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,be<<6|_e)}if(Pt>=2){var Te=X[ot.fastCodeAt(pt,ft++)],ze=X[ot.fastCodeAt(pt,ft++)];if(Ut.set($t++,Te<<2|ze>>4),Pt==3){var Qe=X[ot.fastCodeAt(pt,ft++)];Ut.set($t++,ze<<4|Qe>>2)}}return this.pos+=nt,this.cache.push(Ut),Ut;case 67:var ur=this.unserialize(),Je=this.resolver.resolveClass(ur);if(Je==null)throw new Q("Class not found "+ur);var tr=ut.createEmptyInstance(Je);if(this.cache.push(tr),tr.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return tr;case 65:var er=this.unserialize(),fr=this.resolver.resolveClass(er);if(fr==null)throw new Q("Class not found "+er);return fr;case 66:var zn=this.unserialize(),rn=this.resolver.resolveEnum(zn);if(rn==null)throw new Q("Enum not found "+zn);return rn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Ht};var wt=function(){this.h={}};x["haxe.ds.IntMap"]=wt,wt.__name__=["haxe","ds","IntMap"],wt.__interfaces__=[st],wt.prototype={set:function(r,s){this.h[r]=s},remove:function(r){return this.h.hasOwnProperty(r)?(delete this.h[r],!0):!1},keys:function(){var r=[];for(var s in this.h)this.h.hasOwnProperty(s)&&r.push(s|0);return L.iter(r)},__class__:wt};var Bt=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Bt,Bt.__name__=["haxe","ds","ObjectMap"],Bt.__interfaces__=[st],Bt.prototype={set:function(r,s){var a=r.__id__||(r.__id__=++Bt.count);this.h[a]=s,this.h.__keys__[a]=r},keys:function(){var r=[];for(var s in this.h.__keys__)this.h.hasOwnProperty(s)&&r.push(this.h.__keys__[s]);return L.iter(r)},__class__:Bt};var me=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};me.Some=function(r){var s=["Some",0,r];return s.__enum__=me,s.toString=E,s},me.None=["None",1],me.None.toString=E,me.None.__enum__=me;var ge=function(){this.h={}};x["haxe.ds.StringMap"]=ge,ge.__name__=["haxe","ds","StringMap"],ge.__interfaces__=[st],ge.prototype={set:function(r,s){Zi[r]!=null?this.setReserved(r,s):this.h[r]=s},get:function(r){return Zi[r]!=null?this.getReserved(r):this.h[r]},setReserved:function(r,s){this.rh==null&&(this.rh={}),this.rh["$"+r]=s},getReserved:function(r){return this.rh==null?null:this.rh["$"+r]},keys:function(){var r=this.arrayKeys();return L.iter(r)},arrayKeys:function(){var r=[];for(var s in this.h)this.h.hasOwnProperty(s)&&r.push(s);if(this.rh!=null)for(var s in this.rh)s.charCodeAt(0)==36&&r.push(s.substr(1));return r},__class__:ge};var Ce=function(r){this.length=r.byteLength,this.b=new Qi(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Ce,Ce.__name__=["haxe","io","Bytes"],Ce.alloc=function(r){return new Ce(new Xs(r))},Ce.prototype={get:function(r){return this.b[r]},set:function(r,s){this.b[r]=s&255},__class__:Ce};var te=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};te.Blocked=["Blocked",0],te.Blocked.toString=E,te.Blocked.__enum__=te,te.Overflow=["Overflow",1],te.Overflow.toString=E,te.Overflow.__enum__=te,te.OutsideBounds=["OutsideBounds",2],te.OutsideBounds.toString=E,te.OutsideBounds.__enum__=te,te.Custom=function(r){var s=["Custom",3,r];return s.__enum__=te,s.toString=E,s};var oe=function(){};x["haxe.io.FPHelper"]=oe,oe.__name__=["haxe","io","FPHelper"],oe.i32ToFloat=function(r){var s=1-(r>>>31<<1),a=r>>>23&255,l=r&8388607;return l==0&&a==0?0:s*(1+Math.pow(2,-23)*l)*Math.pow(2,a-127)},oe.floatToI32=function(r){if(r==0)return 0;var s;r<0?s=-r:s=r;var a=Math.floor(Math.log(s)/.6931471805599453);a<-127?a=-127:a>128&&(a=128);var l=Math.round((s/Math.pow(2,a)-1)*8388608)&8388607;return(r<0?-2147483648:0)|a+127<<23|l},oe.i64ToDouble=function(r,s){var a=1-(s>>>31<<1),l=(s>>20&2047)-1023,u=(s&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return u==0&&l==-1023?0:a*(1+Math.pow(2,-52)*u)*Math.pow(2,l)},oe.doubleToI64=function(r){var s=oe.i64tmp;if(r==0)s.low=0,s.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 m=u|0,_=u/4294967296|0;s.low=m,s.high=(r<0?-2147483648:0)|l+1023<<20|_}return s};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=M(Error.prototype,{__class__:Q});var Ct=function(){};x["js.Boot"]=Ct,Ct.__name__=["js","Boot"],Ct.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var s=r.__class__;if(s!=null)return s;var a=Ct.__nativeClassName(r);return a!=null?Ct.__resolveNativeClass(a):null},Ct.__string_rec=function(r,s){if(r==null)return"null";if(s.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]+"(";s+=" ";for(var u=2,d=r.length;u<d;){var m=u++;m!=2?l+=","+Ct.__string_rec(r[m],s):l+=Ct.__string_rec(r[m],s)}return l+")"}var _=r.length,y="[";s+=" ";for(var A=0;A<_;){var I=A++;y+=(I>0?",":"")+Ct.__string_rec(r[I],s)}return y+="]",y}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,T=`{
2
+ `;s+=" ";var O=r.hasOwnProperty!=null;for(var k in r)O&&!r.hasOwnProperty(k)||k=="prototype"||k=="__class__"||k=="__super__"||k=="__interfaces__"||k=="__properties__"||(T.length!=2&&(T+=`,
3
+ `),T+=s+k+" : "+Ct.__string_rec(r[k],s));return s=s.substring(1),T+=`
4
+ `+s+"}",T;case"function":return"<function>";case"string":return r;default:return String(r)}},Ct.__interfLoop=function(r,s){if(r==null)return!1;if(r==s)return!0;var a=r.__interfaces__;if(a!=null)for(var l=0,u=a.length;l<u;){var d=l++,m=a[d];if(m==s||Ct.__interfLoop(m,s))return!0}return Ct.__interfLoop(r.__super__,s)},Ct.__instanceof=function(r,s){if(s==null)return!1;switch(s){case sc:return(r|0)===r;case Ro:return typeof r=="number";case Fo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case ic:return!0;default:if(r!=null){if(typeof s=="function"){if(r instanceof s||Ct.__interfLoop(Ct.getClass(r),s))return!0}else if(typeof s=="object"&&Ct.__isNativeObj(s)&&r instanceof s)return!0}else return!1;return s==Do&&r.__name__!=null||s==Uo&&r.__ename__!=null?!0:r.__enum__==s}},Ct.__nativeClassName=function(r){var s=Ct.__toStr.call(r).slice(8,-1);return s=="Object"||s=="Function"||s=="Math"||s=="JSON"?null:s},Ct.__isNativeObj=function(r){return Ct.__nativeClassName(r)!=null},Ct.__resolveNativeClass=function(r){return w[r]};var le=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var s=r;this.a=[];for(var a=0;a<s;){var l=a++;this.a[l]=0}this.byteLength=s}};x["js.html.compat.ArrayBuffer"]=le,le.__name__=["js","html","compat","ArrayBuffer"],le.sliceImpl=function(r,s){var a=new Qi(this,r,s==null?null:s-r),l=new Xs(a.byteLength),u=new Qi(l);return u.set(a),l},le.prototype={slice:function(r,s){return new le(this.a.slice(r,s))},__class__:le};var pr=function(r,s,a){if(this.buf=r,s==null?this.offset=0:this.offset=s,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(te.OutsideBounds)};x["js.html.compat.DataView"]=pr,pr.__name__=["js","html","compat","DataView"],pr.prototype={getInt8:function(r){var s=this.buf.a[this.offset+r];return s>=128?s-256:s},getUint8:function(r){return this.buf.a[this.offset+r]},getInt16:function(r,s){var a=this.getUint16(r,s);return a>=32768?a-65536:a},getUint16:function(r,s){return s?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,s){var a=this.offset+r,l=this.buf.a[a++],u=this.buf.a[a++],d=this.buf.a[a++],m=this.buf.a[a++];return s?l|u<<8|d<<16|m<<24:m|d<<8|u<<16|l<<24},getUint32:function(r,s){var a=this.getInt32(r,s);return a<0?a+4294967296:a},getFloat32:function(r,s){return oe.i32ToFloat(this.getInt32(r,s))},getFloat64:function(r,s){var a=this.getInt32(r,s),l=this.getInt32(r+4,s);return oe.i64ToDouble(s?a:l,s?l:a)},setInt8:function(r,s){s<0?this.buf.a[r+this.offset]=s+128&255:this.buf.a[r+this.offset]=s&255},setUint8:function(r,s){this.buf.a[r+this.offset]=s&255},setInt16:function(r,s,a){this.setUint16(r,s<0?s+65536:s,a)},setUint16:function(r,s,a){var l=r+this.offset;a?(this.buf.a[l]=s&255,this.buf.a[l++]=s>>8&255):(this.buf.a[l++]=s>>8&255,this.buf.a[l]=s&255)},setInt32:function(r,s,a){this.setUint32(r,s,a)},setUint32:function(r,s,a){var l=r+this.offset;a?(this.buf.a[l++]=s&255,this.buf.a[l++]=s>>8&255,this.buf.a[l++]=s>>16&255,this.buf.a[l++]=s>>>24):(this.buf.a[l++]=s>>>24,this.buf.a[l++]=s>>16&255,this.buf.a[l++]=s>>8&255,this.buf.a[l++]=s&255)},setFloat32:function(r,s,a){this.setUint32(r,oe.floatToI32(s),a)},setFloat64:function(r,s,a){var l=oe.doubleToI64(s);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:pr};var ar=function(){};x["js.html.compat.Uint8Array"]=ar,ar.__name__=["js","html","compat","Uint8Array"],ar._new=function(r,s,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 le(l)}else if(Ct.__instanceof(r,le)){var m=r;s==null&&(s=0),a==null&&(a=m.byteLength-s),s==0?l=m.a:l=m.a.slice(s,s+a),l.byteLength=l.length,l.byteOffset=s,l.buffer=m}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new le(l);else throw new Q("TODO "+dt.string(r));return l.subarray=ar._subarray,l.set=ar._set,l},ar._set=function(r,s){var a=this;if(Ct.__instanceof(r.buffer,le)){var l=r;if(r.byteLength+s>a.byteLength)throw new Q("set() outside of range");for(var u=0,d=r.byteLength;u<d;){var m=u++;a[m+s]=l[m]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+s>a.byteLength)throw new Q("set() outside of range");for(var y=0,A=_.length;y<A;){var I=y++;a[I+s]=_[I]}}else throw new Q("TODO")},ar._subarray=function(r,s){var a=this,l=ar._new(a.slice(r,s));return l.byteOffset=r,l};var Mt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&Mt.link(r,this,function(s){return s})};x["promhx.base.AsyncBase"]=Mt,Mt.__name__=["promhx","base","AsyncBase"],Mt.link=function(r,s,a){r._update.push({async:s,linkf:function(l){s.handleResolve(a(l))}}),Mt.immediateLinkUpdate(r,s,a)},Mt.immediateLinkUpdate=function(r,s,a){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&s.handleError(r._errorVal),r._resolved&&!r._pending)try{s.handleResolve(a(r._val))}catch(l){l instanceof Q&&(l=l.val),s.handleError(l)}},Mt.linkAll=function(r,s){for(var a=function(d,m,_){if(d.length==0||Mt.allFulfilled(d)){for(var y,A=[],I=Ze(r)();I.hasNext();){var S=I.next();A.push(S==m?_:S._val)}y=A,s.handleResolve(y)}},l=Ze(r)();l.hasNext();){var u=l.next();u._update.push({async:s,linkf:function(d,m,_){return function(y){d(m,_,y)}}(a,function(d){for(var m,_=[],y=Ze(r)();y.hasNext();){var A=y.next();A!=u&&_.push(A)}return m=_,m}(),u)})}Mt.allFulfilled(r)&&s.handleResolve(function(d){for(var m,_=[],y=Ze(r)();y.hasNext();){var A=y.next();_.push(A._val)}return m=_,m}())},Mt.pipeLink=function(r,s,a){var l=!1,u=function(d){if(!l){l=!0;var m=a(d);m._update.push({async:s,linkf:Be(s,s.handleResolve)}),Mt.immediateLinkUpdate(m,s,function(_){return _})}};if(r._update.push({async:s,linkf:u}),r._resolved&&!r._pending)try{u(r._val)}catch(d){d instanceof Q&&(d=d.val),s.handleError(d)}},Mt.allResolved=function(r){for(var s=Ze(r)();s.hasNext();){var a=s.next();if(!a._resolved)return!1}return!0},Mt.allFulfilled=function(r){for(var s=Ze(r)();s.hasNext();){var a=s.next();if(!a._fulfilled)return!1}return!0},Mt.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 s=this;this._pending?It.enqueue(function(a,l){return function(){a(l)}}(Be(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,It.queue.add(function(){s._val=r;for(var a=0,l=s._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)}}s._fulfilled=!0,s._pending=!1}),It.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var s=this,a=function(l){if(s._error.length>0)for(var u=0,d=s._error;u<d.length;){var m=d[u];++u,m(l)}else if(s._update.length>0)for(var _=0,y=s._update;_<y.length;){var A=y[_];++_,A.async.handleError(l)}else throw new Q(l);s._errorPending=!1};this._errorPending||(this._errorPending=!0,this._errored=!0,this._errorVal=r,It.queue.add(function(){if(s._errorMap!=null)try{s._resolve(s._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),a(l)}else a(r)}),It.continueOnNextLoop())},then:function(r){var s=new Mt(null);return Mt.link(this,s,r),s},unlink:function(r){var s=this;It.queue.add(function(){s._update=s._update.filter(function(a){return a.async!=r})}),It.continueOnNextLoop()},isLinked:function(r){for(var s=!1,a=0,l=this._update;a<l.length;){var u=l[a];if(++a,u.async==r)return!0}return s},__class__:Mt};var In=f.promhx.Deferred=function(){Mt.call(this)};x["promhx.Deferred"]=In,In.__name__=["promhx","Deferred"],In.__super__=Mt,In.prototype=M(Mt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new fe(this)},stream:function(){return new Yt(this)},publicStream:function(){return new Br(this)},__class__:In});var fe=f.promhx.Promise=function(r){Mt.call(this,r),this._rejected=!1};x["promhx.Promise"]=fe,fe.__name__=["promhx","Promise"],fe.whenAll=function(r){var s=new fe(null);return Mt.linkAll(r,s),s},fe.promise=function(r){var s=new fe;return s.handleResolve(r),s},fe.__super__=Mt,fe.prototype=M(Mt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var s="Promise has already been resolved";throw new Q(Pn.AlreadyResolved(s))}this._resolve(r)},then:function(r){var s=new fe(null);return Mt.link(this,s,r),s},unlink:function(r){var s=this;It.queue.add(function(){if(s._fulfilled)s._update=s._update.filter(function(l){return l.async!=r});else{var a="Downstream Promise is not fullfilled";s.handleError(Pn.DownstreamNotFullfilled(a))}}),It.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var s=new fe(null);return Mt.pipeLink(this,s,r),s},errorPipe:function(r){var s=new fe;return this.catchError(function(a){var l=r(a);l.then(Be(s,s._resolve))}),this.then(Be(s,s._resolve)),s},__class__:fe});var Yt=f.promhx.Stream=function(r){Mt.call(this,r),this._end_promise=new fe};x["promhx.Stream"]=Yt,Yt.__name__=["promhx","Stream"],Yt.foreach=function(r){for(var s=new Yt(null),a=Ze(r)();a.hasNext();){var l=a.next();s.handleResolve(l)}return s.end(),s},Yt.wheneverAll=function(r){var s=new Yt(null);return Mt.linkAll(r,s),s},Yt.concatAll=function(r){for(var s=new Yt(null),a=Ze(r)();a.hasNext();){var l=a.next();s.concat(l)}return s},Yt.mergeAll=function(r){for(var s=new Yt(null),a=Ze(r)();a.hasNext();){var l=a.next();s.merge(l)}return s},Yt.stream=function(r){var s=new Yt(null);return s.handleResolve(r),s},Yt.__super__=Mt,Yt.prototype=M(Mt.prototype,{then:function(r){var s=new Yt(null);return Mt.link(this,s,r),this._end_promise._update.push({async:s._end_promise,linkf:function(a){s.end()}}),s},detachStream:function(r){for(var s=[],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(m){return m.async!=r._end_promise}),a=!0):s.push(d)}return this._update=s,a},first:function(){var r=new fe(null);return this.then(function(s){r._resolved||r.handleResolve(s)}),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 s=new Yt(null);return Mt.pipeLink(this,s,r),this._end_promise.then(function(a){s.end()}),s},errorPipe:function(r){var s=new Yt(null);return this.catchError(function(a){var l=r(a);l.then(Be(s,s._resolve)),l._end_promise.then(($i=s._end_promise,Be($i,$i._resolve)))}),this.then(Be(s,s._resolve)),this._end_promise.then(function(a){s.end()}),s},handleEnd:function(){if(this._pending)It.queue.add(Be(this,this.handleEnd)),It.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=me.Some(this._val):r=me.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return It.queue.add(Be(this,this.handleEnd)),It.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:function(a){r(a)&&s.handleResolve(a)}}),Mt.immediateLinkUpdate(this,s,function(a){return a}),s},concat:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:Be(s,s.handleResolve)}),Mt.immediateLinkUpdate(this,s,function(a){return a}),this._end_promise.then(function(a){r.pipe(function(l){return s.handleResolve(l),s}),r._end_promise.then(function(l){s.end()})}),s},merge:function(r){var s=new Yt(null);return this._update.push({async:s,linkf:Be(s,s.handleResolve)}),r._update.push({async:s,linkf:Be(s,s.handleResolve)}),Mt.immediateLinkUpdate(this,s,function(a){return a}),Mt.immediateLinkUpdate(r,s,function(a){return a}),s},__class__:Yt});var Br=f.promhx.PublicStream=function(r){Yt.call(this,r)};x["promhx.PublicStream"]=Br,Br.__name__=["promhx","PublicStream"],Br.publicstream=function(r){var s=new Br(null);return s.handleResolve(r),s},Br.__super__=Yt,Br.prototype=M(Yt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Br});var It=function(){};x["promhx.base.EventLoop"]=It,It.__name__=["promhx","base","EventLoop"],It.enqueue=function(r){It.queue.add(r),It.continueOnNextLoop()},It.set_nextLoop=function(r){if(It.nextLoop!=null)throw new Q("nextLoop has already been set");return It.nextLoop=r,It.nextLoop},It.queueEmpty=function(){return It.queue.isEmpty()},It.finish=function(r){r==null&&(r=1e3);for(var s=null;r-- >0&&(s=It.queue.pop())!=null;)s();return It.queue.isEmpty()},It.clear=function(){It.queue=new D},It.f=function(){var r=It.queue.pop();r!=null&&r(),It.queue.isEmpty()||It.continueOnNextLoop()},It.continueOnNextLoop=function(){It.nextLoop!=null?It.nextLoop(It.f):setImmediate(It.f)};var Pn=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};Pn.AlreadyResolved=function(r){var s=["AlreadyResolved",0,r];return s.__enum__=Pn,s.toString=E,s},Pn.DownstreamNotFullfilled=function(r){var s=["DownstreamNotFullfilled",1,r];return s.__enum__=Pn,s.toString=E,s};var Ys=function(){};x["verb.Verb"]=Ys,Ys.__name__=["verb","Verb"],Ys.main=function(){b.log("verb 2.1.0")};var $=function(){};x["verb.core.ArrayExtensions"]=$,$.__name__=["verb","core","ArrayExtensions"],$.alloc=function(r,s){if(!(s<0))for(;r.length<s;)r.push(null)},$.reversed=function(r){var s=r.slice();return s.reverse(),s},$.last=function(r){return r[r.length-1]},$.first=function(r){return r[0]},$.spliceAndInsert=function(r,s,a,l){r.splice(s,a),r.splice(s,0,l)},$.left=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(0,s)},$.right=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(s)},$.rightWithPivot=function(r){if(r.length==0)return[];var s=Math.ceil(r.length/2);return r.slice(s-1)},$.unique=function(r,s){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 m=a[d];if(++d,s(l,m)){u=!1;break}}u&&a.push(l)}return a};var Ft=function(){};x["verb.core.Binomial"]=Ft,Ft.__name__=["verb","core","Binomial"],Ft.get=function(r,s){if(s==0)return 1;if(r==0||s>r)return 0;if(s>r-s&&(s=r-s),Ft.memo_exists(r,s))return Ft.get_memo(r,s);for(var a=1,l=r,u=1,d=s+1;u<d;){var m=u++;if(Ft.memo_exists(l,m)){r--,a=Ft.get_memo(l,m);continue}a*=r--,a/=m,Ft.memoize(l,m,a)}return a},Ft.get_no_memo=function(r,s){if(s==0)return 1;if(r==0||s>r)return 0;s>r-s&&(s=r-s);for(var a=1,l=1,u=s+1;l<u;){var d=l++;a*=r--,a/=d}return a},Ft.memo_exists=function(r,s){return Ft.memo.h.hasOwnProperty(r)&&Ft.memo.h[r].h.hasOwnProperty(s)},Ft.get_memo=function(r,s){return Ft.memo.h[r].h[s]},Ft.memoize=function(r,s,a){Ft.memo.h.hasOwnProperty(r)||Ft.memo.set(r,new wt),Ft.memo.h[r].h[s]=a};var Le=f.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"]=Le,Le.__name__=["verb","core","BoundingBox"],Le.intervalsOverlap=function(r,s,a,l,u){u==null&&(u=-1);var d;u<-.5?d=rt.TOLERANCE:d=u;var m=Math.min(r,s)-d,_=Math.max(r,s)+d,y=Math.min(a,l)-d,A=Math.max(a,l)+d;return m>=y&&m<=A||_>=y&&_<=A||y>=m&&y<=_||A>=m&&A<=_},Le.prototype={fromPoint:function(r){return new Le([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 s=0,a=this.dim;s<a;){var l=s++;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 s=r.length,a=0;a<s;){var l=a++;this.add(r[l])}return this},contains:function(r,s){return s==null&&(s=-1),this.initialized?this.intersects(new Le([r]),s):!1},intersects:function(r,s){if(s==null&&(s=-1),!this.initialized||!r.initialized)return!1;for(var a=this.min,l=this.max,u=r.min,d=r.max,m=0,_=this.dim;m<_;){var y=m++;if(!Le.intervalsOverlap(a[y],l[y],u[y],d[y],s))return!1}return!0},clear:function(){return this.initialized=!1,this},getLongestAxis:function(){for(var r=0,s=0,a=0,l=this.dim;a<l;){var u=a++,d=this.getAxisLength(u);d>r&&(r=d,s=u)}return s},getAxisLength:function(r){return r<0||r>this.dim-1?0:Math.abs(this.min[r]-this.max[r])},intersect:function(r,s){if(!this.initialized)return null;var a=this.min,l=this.max,u=r.min,d=r.max;if(!this.intersects(r,s))return null;for(var m=[],_=[],y=0,A=this.dim;y<A;){var I=y++;m.push(Math.min(l[I],d[I])),_.push(Math.max(a[I],u[I]))}return new Le([_,m])},__class__:Le};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var Qt=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Qt,Qt.__name__=["verb","core","SerializableBase"],Qt.prototype={serialize:function(){var r=new Xt;return r.serialize(this),r.toString()},__class__:Qt};var Xn=f.core.Plane=function(r,s){this.origin=r,this.normal=s};x["verb.core.Plane"]=Xn,Xn.__name__=["verb","core","Plane"],Xn.__super__=Qt,Xn.prototype=M(Qt.prototype,{__class__:Xn});var En=f.core.Ray=function(r,s){this.origin=r,this.dir=s};x["verb.core.Ray"]=En,En.__name__=["verb","core","Ray"],En.__super__=Qt,En.prototype=M(Qt.prototype,{__class__:En});var jt=f.core.NurbsCurveData=function(r,s,a){this.degree=r,this.controlPoints=a,this.knots=s};x["verb.core.NurbsCurveData"]=jt,jt.__name__=["verb","core","NurbsCurveData"],jt.__super__=Qt,jt.prototype=M(Qt.prototype,{__class__:jt});var ee=f.core.NurbsSurfaceData=function(r,s,a,l,u){this.degreeU=r,this.degreeV=s,this.knotsU=a,this.knotsV=l,this.controlPoints=u};x["verb.core.NurbsSurfaceData"]=ee,ee.__name__=["verb","core","NurbsSurfaceData"],ee.__super__=Qt,ee.prototype=M(Qt.prototype,{__class__:ee});var Ke=f.core.MeshData=function(r,s,a,l){this.faces=r,this.points=s,this.normals=a,this.uvs=l};x["verb.core.MeshData"]=Ke,Ke.__name__=["verb","core","MeshData"],Ke.empty=function(){return new Ke([],[],[],[])},Ke.__super__=Qt,Ke.prototype=M(Qt.prototype,{__class__:Ke});var Kn=f.core.PolylineData=function(r,s){this.points=r,this.params=s};x["verb.core.PolylineData"]=Kn,Kn.__name__=["verb","core","PolylineData"],Kn.__super__=Qt,Kn.prototype=M(Qt.prototype,{__class__:Kn});var $n=f.core.VolumeData=function(r,s,a,l,u,d,m){this.degreeU=r,this.degreeV=s,this.degreeW=a,this.knotsU=l,this.knotsV=u,this.knotsW=d,this.controlPoints=m};x["verb.core.VolumeData"]=$n,$n.__name__=["verb","core","VolumeData"],$n.__super__=Qt,$n.prototype=M(Qt.prototype,{__class__:$n});var re=f.core.Pair=function(r,s){this.item0=r,this.item1=s};x["verb.core.Pair"]=re,re.__name__=["verb","core","Pair"],re.prototype={__class__:re};var ke=f.core.Interval=function(r,s){this.min=r,this.max=s};x["verb.core.Interval"]=ke,ke.__name__=["verb","core","Interval"],ke.prototype={__class__:ke};var tn=f.core.CurveCurveIntersection=function(r,s,a,l){this.point0=r,this.point1=s,this.u0=a,this.u1=l};x["verb.core.CurveCurveIntersection"]=tn,tn.__name__=["verb","core","CurveCurveIntersection"],tn.prototype={__class__:tn};var Zn=f.core.CurveSurfaceIntersection=function(r,s,a,l){this.u=r,this.uv=s,this.curvePoint=a,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=Zn,Zn.__name__=["verb","core","CurveSurfaceIntersection"],Zn.prototype={__class__:Zn};var zr=f.core.MeshIntersectionPoint=function(r,s,a,l,u){this.visited=!1,this.adj=null,this.opp=null,this.uv0=r,this.uv1=s,this.point=a,this.faceIndex0,this.faceIndex1};x["verb.core.MeshIntersectionPoint"]=zr,zr.__name__=["verb","core","MeshIntersectionPoint"],zr.prototype={__class__:zr};var Qn=f.core.PolylineMeshIntersection=function(r,s,a,l,u){this.point=r,this.u=s,this.uv=a,this.polylineIndex=l,this.faceIndex=u};x["verb.core.PolylineMeshIntersection"]=Qn,Qn.__name__=["verb","core","PolylineMeshIntersection"],Qn.prototype={__class__:Qn};var Jn=f.core.SurfaceSurfaceIntersectionPoint=function(r,s,a,l){this.uv0=r,this.uv1=s,this.point=a,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=Jn,Jn.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],Jn.prototype={__class__:Jn};var ts=f.core.TriSegmentIntersection=function(r,s,a,l){this.point=r,this.s=s,this.t=a,this.p=l};x["verb.core.TriSegmentIntersection"]=ts,ts.__name__=["verb","core","TriSegmentIntersection"],ts.prototype={__class__:ts};var kn=f.core.CurveTriPoint=function(r,s,a){this.u=r,this.point=s,this.uv=a};x["verb.core.CurveTriPoint"]=kn,kn.__name__=["verb","core","CurveTriPoint"],kn.prototype={__class__:kn};var Ye=function(r,s,a,l,u){u==null&&(u=!1),l==null&&(l=-1),this.uv=a,this.point=r,this.normal=s,this.id=l,this.degen=u};x["verb.core.SurfacePoint"]=Ye,Ye.__name__=["verb","core","SurfacePoint"],Ye.fromUv=function(r,s){return new Ye(null,null,[r,s])},Ye.prototype={__class__:Ye};var qs=f.core.CurvePoint=function(r,s){this.u=r,this.pt=s};x["verb.core.CurvePoint"]=qs,qs.__name__=["verb","core","CurvePoint"],qs.prototype={__class__:qs};var es=f.core.KdTree=function(r,s){this.dim=3,this.points=r,this.distanceFunction=s,this.dim=r[0].point.length,this.root=this.buildTree(r,0,null)};x["verb.core.KdTree"]=es,es.__name__=["verb","core","KdTree"],es.prototype={buildTree:function(r,s,a){var l=s%this.dim,u,d;return r.length==0?null:r.length==1?new Tn(r[0],l,a):(r.sort(function(m,_){var y=m.point[l]-_.point[l];return y==0?0:y>0?1:-1}),u=Math.floor(r.length/2),d=new Tn(r[u],l,a),d.left=this.buildTree(r.slice(0,u),s+1,d),d.right=this.buildTree(r.slice(u+1),s+1,d),d)},nearest:function(r,s,a){var l=this,u=new rs(function(S){return-S.item1}),d,m=null;m=function(S){for(var P,k=S.dimension,T=l.distanceFunction(r,S.kdPoint.point),O,C=[],R=0,z=l.dim;R<z;)R++,C.push(0);O=C;for(var U,V,q=function(K,tt){u.push(new re(K,tt)),u.size()>s&&u.pop()},J=0,H=l.dim;J<H;){var G=J++;G==S.dimension?O[G]=r[G]:O[G]=S.kdPoint.point[G]}if(U=l.distanceFunction(O,S.kdPoint.point),S.right==null&&S.left==null){(u.size()<s||T<u.peek().item1)&&q(S,T);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,m(P),(u.size()<s||T<u.peek().item1)&&q(S,T),(u.size()<s||Math.abs(U)<u.peek().item1)&&(P==S.left?V=S.right:V=S.left,V!=null&&m(V))},d=m;for(var _=0;_<s;)_++,u.push(new re(null,a));d(this.root);for(var y=[],A=0;A<s;){var I=A++;u.content[I].item0!=null&&y.push(new re(u.content[I].item0.kdPoint,u.content[I].item1))}return y},__class__:es};var rs=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=rs,rs.__name__=["verb","core","BinaryHeap"],rs.prototype={push:function(r){this.content.push(r),this.bubbleUp(this.content.length-1)},pop:function(){var r=this.content[0],s=this.content.pop();return this.content.length>0&&(this.content[0]=s,this.sinkDown(0)),r},peek:function(){return this.content[0]},remove:function(r){for(var s=this.content.length,a=0;a<s;){var l=a++;if(this.content[l]==r){var u=this.content.pop();l!=s-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 s=this.content[r];r>0;){var a=Math.floor((r+1)/2)-1,l=this.content[a];if(this.scoreFunction(s)<this.scoreFunction(l))this.content[a]=s,this.content[r]=l,r=a;else break}},sinkDown:function(r){for(var s=this.content.length,a=this.content[r],l=this.scoreFunction(a);;){var u=(r+1)*2,d=u-1,m=-1,_=0;if(d<s){var y=this.content[d];_=this.scoreFunction(y),_<l&&(m=d)}if(u<s){var A=this.content[u],I=this.scoreFunction(A);I<(m==-1?l:_)&&(m=u)}if(m!=-1)this.content[r]=this.content[m],this.content[m]=a,r=m;else break}},__class__:rs};var Mn=f.core.KdPoint=function(r,s){this.point=r,this.obj=s};x["verb.core.KdPoint"]=Mn,Mn.__name__=["verb","core","KdPoint"],Mn.prototype={__class__:Mn};var Tn=f.core.KdNode=function(r,s,a){this.kdPoint=r,this.left=null,this.right=null,this.parent=a,this.dimension=s};x["verb.core.KdNode"]=Tn,Tn.__name__=["verb","core","KdNode"],Tn.prototype={__class__:Tn};var mr=function(){};x["verb.eval.IBoundingBoxTree"]=mr,mr.__name__=["verb","eval","IBoundingBoxTree"],mr.prototype={__class__:mr};var or=function(r,s){this._boundingBox=null,this._curve=r,s==null&&(s=p.domain(this._curve.knots)/64),this._knotTol=s};x["verb.core.LazyCurveBoundingBoxTree"]=or,or.__name__=["verb","core","LazyCurveBoundingBoxTree"],or.__interfaces__=[mr],or.prototype={split:function(){var r=$.first(this._curve.knots),s=$.last(this._curve.knots),a=s-r,l=he.curveSplit(this._curve,(s+r)/2+a*.1*Math.random());return new re(new or(l[0],this._knotTol),new or(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Le(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return p.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:or};var lr=function(r,s){if(this._boundingBox=null,this._mesh=r,s==null){for(var a=[],l=0,u=r.faces.length;l<u;){var d=l++;a.push(d)}s=a}this._faceIndices=s};x["verb.core.LazyMeshBoundingBoxTree"]=lr,lr.__name__=["verb","core","LazyMeshBoundingBoxTree"],lr.__interfaces__=[mr],lr.prototype={split:function(){var r=ne.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),s=$.left(r),a=$.right(r);return new re(new lr(this._mesh,s),new lr(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=ne.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__:lr};var hr=function(r,s){this._boundingBox=null,this._polyline=r,s==null&&(s=new ke(0,r.points.length!=0?r.points.length-1:0)),this._interval=s};x["verb.core.LazyPolylineBoundingBoxTree"]=hr,hr.__name__=["verb","core","LazyPolylineBoundingBoxTree"],hr.__interfaces__=[mr],hr.prototype={split:function(){var r=this._interval.min,s=this._interval.max,a=r+Math.ceil((s-r)/2),l=new ke(r,a),u=new ke(a,s);return new re(new hr(this._polyline,l),new hr(this._polyline,u))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Le(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__:hr};var Rr=function(r,s,a,l){s==null&&(s=!1),this._boundingBox=null,this._surface=r,this._splitV=s,a==null&&(a=p.domain(r.knotsU)/16),l==null&&(l=p.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Rr,Rr.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Rr.__interfaces__=[mr],Rr.prototype={split:function(){var r,s;this._splitV?(r=$.first(this._surface.knotsV),s=$.last(this._surface.knotsV)):(r=$.first(this._surface.knotsU),s=$.last(this._surface.knotsU));var a=(r+s)/2,l=he.surfaceSplit(this._surface,a,this._splitV);return new re(new Rr(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Rr(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Le;for(var r=0,s=this._surface.controlPoints;r<s.length;){var a=s[r];++r,this._boundingBox.addRange(N.dehomogenize1d(a))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return p.domain(this._surface.knotsV)<this._knotTolV&&p.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Rr};var Ot=f.core.Mat=function(){};x["verb.core.Mat"]=Ot,Ot.__name__=["verb","core","Mat"],Ot.mul=function(r,s){for(var a=[],l=0,u=s.length;l<u;){var d=l++;a.push(p.mul(r,s[d]))}return a},Ot.mult=function(r,s){var a,l,u,d,m,_,y,A;a=r.length,l=s.length,u=s[0].length,d=[];for(var I=a-1,S=0,P=0;I>=0;){for(m=[],_=r[I],P=u-1;P>=0;){for(y=_[l-1]*s[l-1][P],S=l-2;S>=1;)A=S-1,y+=_[S]*s[S][P]+_[A]*s[A][P],S-=2;S==0&&(y+=_[0]*s[0][P]),m[P]=y,P--}d[I]=m,I--}return d},Ot.add=function(r,s){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.add(r[d],s[d]))}return a},Ot.div=function(r,s){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.div(r[d],s))}return a},Ot.sub=function(r,s){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.sub(r[d],s[d]))}return a},Ot.dot=function(r,s){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(p.dot(r[d],s))}return a},Ot.identity=function(r){for(var s=p.zeros2d(r,r),a=0;a<r;){var l=a++;s[l][l]=1}return s},Ot.transpose=function(r){if(r.length==0)return[];for(var s=[],a=0,l=r[0].length;a<l;){var u=a++;s.push(function(d){for(var m,_=[],y=0,A=r.length;y<A;){var I=y++;_.push(r[I][u])}return m=_,m}())}return s},Ot.solve=function(r,s){return Ot.LUsolve(Ot.LU(r),s)},Ot.LUsolve=function(r,s){var a,l,u=r.LU,d=u.length,m=s.slice(),_=r.P,y,A,I;for(a=d-1;a!=-1;)m[a]=s[a],--a;for(a=0;a<d;){for(y=_[a],_[a]!=a&&(I=m[a],m[a]=m[y],m[y]=I),A=u[a],l=0;l<a;)m[a]-=m[l]*A[l],++l;++a}for(a=d-1;a>=0;){for(A=u[a],l=a+1;l<d;)m[a]-=m[l]*A[l],++l;m[a]/=A[a],--a}return m},Ot.LU=function(r){for(var s,a,l,u,d,m,_,y,A,I=[],S=0,P=r.length;S<P;){var k=S++;I.push(r[k].slice())}r=I;var T=r.length,O=T-1,C=[];for(l=0;l<T;){for(_=l,m=r[l],A=Math.abs(m[l]),a=l+1;a<T;)u=Math.abs(r[a][l]),A<u&&(A=u,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=m,m=r[l]),d=m[l],s=l+1;s<T;)r[s][l]/=d,++s;for(s=l+1;s<T;){for(y=r[s],a=l+1;a<O;)y[a]-=y[l]*m[a],++a,y[a]-=y[l]*m[a],++a;a==O&&(y[a]-=y[l]*m[a]),++s}++l}return new ns(r,C)};var ns=function(r,s){this.LU=r,this.P=s};x["verb.core._Mat.LUDecomp"]=ns,ns.__name__=["verb","core","_Mat","LUDecomp"],ns.prototype={__class__:ns};var ne=f.core.Mesh=function(){};x["verb.core.Mesh"]=ne,ne.__name__=["verb","core","Mesh"],ne.getTriangleNorm=function(r,s){var a=r[s[0]],l=r[s[1]],u=r[s[2]],d=p.sub(l,a),m=p.sub(u,a),_=p.cross(d,m);return p.mul(1/p.norm(_),_)},ne.makeMeshAabb=function(r,s){for(var a=new Le,l=0;l<s.length;){var u=s[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},ne.sortTrianglesOnLongestAxis=function(r,s,a){for(var l=r.getLongestAxis(),u=[],d=0;d<a.length;){var m=a[d];++d;var _=ne.getMinCoordOnAxis(s.points,s.faces[m],l);u.push(new re(_,m))}u.sort(function(P,k){var T=P.item0,O=k.item0;return T==O?0:T>O?1:-1});for(var y=[],A=0,I=u.length;A<I;){var S=A++;y.push(u[S].item1)}return y},ne.getMinCoordOnAxis=function(r,s,a){for(var l=1/0,u=0;u<3;){var d=u++,m=r[s[d]][a];m<l&&(l=m)}return l},ne.getTriangleCentroid=function(r,s){for(var a=[0,0,0],l=0;l<3;)for(var u=l++,d=0;d<3;){var m=d++;a[m]+=r[s[u]][m]}for(var _=0;_<3;){var y=_++;a[y]/=3}return a},ne.triangleUVFromPoint=function(r,s,a){var l=r.faces[s],u=r.points[l[0]],d=r.points[l[1]],m=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],A=r.uvs[l[2]],I=p.sub(u,a),S=p.sub(d,a),P=p.sub(m,a),k=p.norm(p.cross(p.sub(u,d),p.sub(u,m))),T=p.norm(p.cross(S,P))/k,O=p.norm(p.cross(P,I))/k,C=p.norm(p.cross(I,S))/k;return p.add(p.mul(T,_),p.add(p.mul(O,y),p.mul(C,A)))};var Fr=function(r,s){if(this._empty=!1,this._face=-1,s==null){for(var a=[],l=0,u=r.faces.length;l<u;){var d=l++;a.push(d)}s=a}if(this._boundingBox=ne.makeMeshAabb(r,s),s.length<1){this._empty=!0;return}else if(s.length<2){this._face=s[0];return}var m=ne.sortTrianglesOnLongestAxis(this._boundingBox,r,s),_=$.left(m),y=$.right(m);this._children=new re(new Fr(r,_),new Fr(r,y))};x["verb.core.MeshBoundingBoxTree"]=Fr,Fr.__name__=["verb","core","MeshBoundingBoxTree"],Fr.__interfaces__=[mr],Fr.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__:Fr};var $e=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=$e,$e.__name__=["verb","core","Minimizer"],$e.uncmin=function(r,s,a,l,u){a==null&&(a=1e-8),l==null&&(l=function(J){return $e.numericalGradient(r,J)}),u==null&&(u=1e3),s=s.slice(0);var d=s.length,m=r(s),_=m,y;if(isNaN(m))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,rt.EPSILON);var A,I,S,P=Ot.identity(d),k=0,T=[],O,C,R,z,U,V,q="";for(I=l(s);k<u;){if(!p.all(p.finite(I))){q="Gradient has Infinity or NaN";break}if(A=p.neg(Ot.dot(P,I)),!p.all(p.finite(A))){q="Search direction has Infinity or NaN";break}if(V=p.norm(A),V<a){q="Newton step smaller than tol";break}for(U=1,y=p.dot(I,A),O=s;k<u&&!(U*V<a);){if(T=p.mul(U,A),O=p.add(s,T),_=r(O),_-m>=.1*U*y||isNaN(_)){U*=.5,++k;continue}break}if(U*V<a){q="Line search step size smaller than tol";break}if(k==u){q="maxit reached during line search";break}S=l(O),C=p.sub(S,I),z=p.dot(C,T),R=Ot.dot(P,C),P=Ot.sub(Ot.add(P,Ot.mul((z+p.dot(C,R))/(z*z),$e.tensor(T,T))),Ot.div(Ot.add($e.tensor(R,T),$e.tensor(T,R)),z)),s=O,m=_,I=S,++k}return new ss(s,m,I,P,k,q)},$e.numericalGradient=function(r,s){var a=s.length,l=r(s);if(l==NaN)throw new Q("gradient: f(x) is a NaN!");for(var u=s.slice(0),d,m,_=[],y,A=.001,I,S,P,k=0,T,O,C,R=0;R<a;)for(var z=R++,U=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(u[z]=s[z]+U,d=r(u),u[z]=s[z]-U,m=r(u),u[z]=s[z],isNaN(d)||isNaN(m)){U/=16;continue}if(_[z]=(d-m)/(2*U),I=s[z]-U,S=s[z],P=s[z]+U,T=(d-l)/U,O=(l-m)/U,C=p.max([Math.abs(_[z]),Math.abs(l),Math.abs(d),Math.abs(m),Math.abs(I),Math.abs(S),Math.abs(P),1e-8]),y=Math.min(p.max([Math.abs(T-_[z]),Math.abs(O-_[z]),Math.abs(T-O)])/C,U/C),y>A)U/=16;else break}return _},$e.tensor=function(r,s){for(var a=r.length,l=s.length,u=[],d,m,_=a-1;_>=0;){d=[],m=r[_];for(var y=l-1;y>=3;)d[y]=m*s[y],--y,d[y]=m*s[y],--y,d[y]=m*s[y],--y,d[y]=m*s[y],--y;for(;y>=0;)d[y]=m*s[y],--y;u[_]=d,_--}return u};var ss=function(r,s,a,l,u,d){this.solution=r,this.value=s,this.gradient=a,this.invHessian=l,this.iterations=u,this.message=d};x["verb.core.MinimizationResult"]=ss,ss.__name__=["verb","core","MinimizationResult"],ss.prototype={__class__:ss};var Nn=function(){};x["verb.core.ISerializable"]=Nn,Nn.__name__=["verb","core","ISerializable"],Nn.prototype={__class__:Nn};var Ki=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Ki,Ki.__name__=["verb","core","Deserializer"],Ki.deserialize=function(r){var s=new Ht(r),a=s.unserialize();return a};var Oe=f.core.Trig=function(){};x["verb.core.Trig"]=Oe,Oe.__name__=["verb","core","Trig"],Oe.isPointInPlane=function(r,s,a){return Math.abs(p.dot(p.sub(r,s.origin),s.normal))<a},Oe.distToSegment=function(r,s,a){var l=Oe.segmentClosestPoint(s,r,a,0,1);return p.dist(s,l.pt)},Oe.rayClosestPoint=function(r,s,a){var l=p.sub(r,s),u=p.dot(l,a),d=p.add(s,p.mul(u,a));return d},Oe.distToRay=function(r,s,a){var l=Oe.rayClosestPoint(r,s,a),u=p.sub(l,r);return p.norm(u)},Oe.threePointsAreFlat=function(r,s,a,l){var u=p.sub(s,r),d=p.sub(a,r),m=p.cross(u,d),_=p.dot(m,m);return _<l},Oe.segmentClosestPoint=function(r,s,a,l,u){var d=p.sub(a,s),m=p.norm(d);if(m<rt.EPSILON)return{u:l,pt:s};var _=s,y=p.mul(1/m,d),A=p.sub(r,_),I=p.dot(A,y);return I<0?{u:l,pt:s}:I>m?{u,pt:a}:{u:l+(u-l)*I/m,pt:p.add(_,p.mul(I,y))}};var p=f.core.Vec=function(){};x["verb.core.Vec"]=p,p.__name__=["verb","core","Vec"],p.angleBetween=function(r,s){return Math.acos(p.dot(r,s)/(p.norm(r)*p.norm(s)))},p.positiveAngleBetween=function(r,s,a){var l=p.cross(r,s),u=p.norm(r),d=p.norm(s),m=u*d,_=p.dot(r,s),y=p.norm(l)/m,A=_/m,I=Math.atan2(y,A),S=p.dot(a,l);return Math.abs(S)<rt.EPSILON||S>0?I:-I},p.signedAngleBetween=function(r,s,a){var l=p.cross(r,s),u=p.norm(r),d=p.norm(s),m=u*d,_=p.dot(r,s),y=p.norm(l)/m,A=_/m,I=Math.atan2(y,A),S=p.dot(a,l);return S>0?I:2*Math.PI-I},p.angleBetweenNormalized2d=function(r,s){var a=r[0]*s[1]-r[1]*s[0];return Math.atan2(a,p.dot(r,s))},p.domain=function(r){return $.last(r)-$.first(r)},p.range=function(r){for(var s=[],a=0,l=0;l<r;)l++,s.push(a),a+=1;return s},p.span=function(r,s,a){if(a==null)return[];if(a<rt.EPSILON)return[];if(r>s&&a>0)return[];if(s>r&&a<0)return[];for(var l=[],u=r;u<=s;)l.push(u),u+=a;return l},p.neg=function(r){return r.map(function(s){return-s})},p.min=function(r){return B.fold(r,function(s,a){return Math.min(s,a)},1/0)},p.max=function(r){return B.fold(r,function(s,a){return Math.max(s,a)},-1/0)},p.all=function(r){return B.fold(r,function(s,a){return a&&s},!0)},p.finite=function(r){return r.map(function(s){return isFinite(s)})},p.onRay=function(r,s,a){return p.add(r,p.mul(a,s))},p.lerp=function(r,s,a){return p.add(p.mul(r,s),p.mul(1-r,a))},p.normalized=function(r){return p.div(r,p.norm(r))},p.cross=function(r,s){return[r[1]*s[2]-r[2]*s[1],r[2]*s[0]-r[0]*s[2],r[0]*s[1]-r[1]*s[0]]},p.dist=function(r,s){return p.norm(p.sub(r,s))},p.distSquared=function(r,s){return p.normSquared(p.sub(r,s))},p.sum=function(r){return B.fold(r,function(s,a){return a+s},0)},p.addAll=function(r){var s=Ze(r)();if(!s.hasNext())return null;var a=s.next().length;return B.fold(r,function(l,u){return p.add(u,l)},p.rep(a,0))},p.addAllMutate=function(r){for(var s=r[0],a=1,l=r.length;a<l;){var u=a++;p.addMutate(s,r[u])}},p.addMulMutate=function(r,s,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]+s*a[d]}},p.subMulMutate=function(r,s,a){for(var l=0,u=r.length;l<u;){var d=l++;r[d]=r[d]-s*a[d]}},p.addMutate=function(r,s){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]+s[u]}},p.subMutate=function(r,s){for(var a=0,l=r.length;a<l;){var u=a++;r[u]=r[u]-s[u]}},p.mulMutate=function(r,s){for(var a=0,l=s.length;a<l;){var u=a++;s[u]=s[u]*r}},p.norm=function(r){var s=p.normSquared(r);return s!=0?Math.sqrt(s):s},p.normSquared=function(r){return B.fold(r,function(s,a){return a+s*s},0)},p.rep=function(r,s){for(var a=[],l=0;l<r;)l++,a.push(s);return a},p.zeros1d=function(r){for(var s=[],a=0;a<r;)a++,s.push(0);return s},p.zeros2d=function(r,s){for(var a=[],l=0;l<r;)l++,a.push(p.zeros1d(s));return a},p.zeros3d=function(r,s,a){for(var l=[],u=0;u<r;)u++,l.push(p.zeros2d(s,a));return l},p.dot=function(r,s){for(var a=0,l=0,u=r.length;l<u;){var d=l++;a+=r[d]*s[d]}return a},p.add=function(r,s){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]+s[d])}return a},p.mul=function(r,s){for(var a=[],l=0,u=s.length;l<u;){var d=l++;a.push(r*s[d])}return a},p.div=function(r,s){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]/s)}return a},p.sub=function(r,s){for(var a=[],l=0,u=r.length;l<u;){var d=l++;a.push(r[d]-s[d])}return a},p.isZero=function(r){for(var s=0,a=r.length;s<a;){var l=s++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},p.sortedSetUnion=function(r,s){for(var a=[],l=0,u=0;l<r.length||u<s.length;){if(l>=r.length){a.push(s[u]),u++;continue}else if(u>=s.length){a.push(r[l]),l++;continue}var d=r[l]-s[u];if(Math.abs(d)<rt.EPSILON){a.push(r[l]),l++,u++;continue}if(d>0){a.push(s[u]),u++;continue}a.push(r[l]),l++}return a},p.sortedSetSub=function(r,s){for(var a=[],l=0,u=0;l<r.length;){if(u>=s.length){a.push(r[l]),l++;continue}if(Math.abs(r[l]-s[u])<rt.EPSILON){l++,u++;continue}a.push(r[l]),l++}return a};var bt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=bt,bt.__name__=["verb","eval","Analyze"],bt.knotMultiplicities=function(r){for(var s=[new Cn(r[0],0)],a=s[0],l=0;l<r.length;){var u=r[l];++l,Math.abs(u-a.knot)>rt.EPSILON&&(a=new Cn(u,0),s.push(a)),a.inc()}return s},bt.isRationalSurfaceClosed=function(r,s){s==null&&(s=!0);var a;s?a=r.controlPoints:a=Ot.transpose(r.controlPoints);for(var l=0,u=a[0].length;l<u;){var d=l++,m=p.dist($.first(a)[d],$.last(a)[d])<rt.EPSILON;if(!m)return!1}return!0},bt.rationalSurfaceClosestPoint=function(r,s){var a=bt.rationalSurfaceClosestParam(r,s);return N.rationalSurfacePoint(r,a[0],a[1])},bt.rationalSurfaceClosestParam=function(r,s){for(var a=5,l=0,u,d=1e-4,m=5e-4,_,y=r.knotsU[0],A=$.last(r.knotsU),I=r.knotsV[0],S=$.last(r.knotsV),P=bt.isRationalSurfaceClosed(r),k=bt.isRationalSurfaceClosed(r,!1),T,O=zt.rationalSurfaceAdaptive(r,new Dr),C=1/0,R=0,z=O.points.length;R<z;){var U=R++,V=O.points[U],q=p.normSquared(p.sub(s,V));q<C&&(C=q,T=O.uvs[U])}for(var J=function(Wt){return N.rationalSurfaceDerivatives(r,Wt[0],Wt[1],2)},H=function(Wt,Kt,Ut){var $t=Kt[1][0],Me=Kt[0][1],Xe=Kt[2][0],be=Kt[0][2],_e=Kt[1][1],Te=Kt[1][1],ze=p.dot($t,Ut),Qe=p.dot(Me,Ut),ur=[-ze,-Qe],Je=p.dot($t,$t)+p.dot(Xe,Ut),tr=p.dot($t,Me)+p.dot(_e,Ut),er=p.dot($t,Me)+p.dot(Te,Ut),fr=p.dot(Me,Me)+p.dot(be,Ut),zn=[[Je,tr],[er,fr]],rn=Ot.solve(zn,ur);return p.add(rn,Wt)};l<a;){u=J(T),_=p.sub(u[0][0],s);var G=p.norm(_),K=p.dot(u[1][0],_),tt=p.norm(u[1][0])*G,et=p.dot(u[0][1],_),it=p.norm(u[0][1])*G,ht=K/tt,at=et/it,ct=G<d,nt=ht<m,pt=at<m;if(ct&&nt&&pt)return T;var X=H(T,u,_);X[0]<y?P?X=[A-(X[0]-y),X[1]]:X=[y+rt.EPSILON,X[1]]:X[0]>A&&(P?X=[y+(X[0]-A),X[1]]:X=[A-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 ft=p.norm(p.mul(X[0]-T[0],u[1][0])),Pt=p.norm(p.mul(X[1]-T[1],u[0][1]));if(ft+Pt<d)return T;T=X,l++}return T},bt.rationalCurveClosestPoint=function(r,s){return N.rationalCurvePoint(r,bt.rationalCurveClosestParam(r,s))},bt.rationalCurveClosestParam=function(r,s){for(var a=1/0,l=0,u=zt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,m=u.length-1;d<m;){var _=d++,y=u[_][0],A=u[_+1][0],I=u[_].slice(1),S=u[_+1].slice(1),P=Oe.segmentClosestPoint(s,I,S,y,A),k=p.norm(p.sub(s,P.pt));k<a&&(a=k,l=P.u)}for(var T=5,O=0,C,R=1e-4,z=5e-4,U,V=r.knots[0],q=$.last(r.knots),J=p.normSquared(p.sub(r.controlPoints[0],$.last(r.controlPoints)))<rt.EPSILON,H=l,G=function(X){return N.rationalCurveDerivatives(r,X,2)},K=function(X,ft,Pt){var Wt=p.dot(ft[1],Pt),Kt=p.dot(ft[2],Pt),Ut=p.dot(ft[1],ft[1]),$t=Kt+Ut;return X-Wt/$t};O<T;){C=G(H),U=p.sub(C[0],s);var tt=p.norm(U),et=p.dot(C[1],U),it=p.norm(C[1])*tt,ht=et/it,at=tt<R,ct=Math.abs(ht)<z;if(at&&ct)return H;var nt=K(H,C,U);nt<V?J?nt=q-(nt-V):nt=V:nt>q&&(J?nt=V+(nt-q):nt=q);var pt=p.norm(p.mul(nt-H,C[1]));if(pt<R)return H;H=nt,O++}return H},bt.rationalCurveParamAtArcLength=function(r,s,a,l,u){if(a==null&&(a=.001),s<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=_t.decomposeCurveIntoBeziers(r);var m=0;d[m];var _=-rt.EPSILON,y;for(u!=null?y=u:y=[];_<s&&m<d.length;){if(m<y.length?y[m]=y[m]:y[m]=bt.rationalBezierCurveArcLength(r),_+=y[m],s<_+rt.EPSILON)return bt.rationalBezierCurveParamAtArcLength(r,s,a,y[m]);m++}return-1},bt.rationalBezierCurveParamAtArcLength=function(r,s,a,l){if(s<0)return r.knots[0];var u;if(l!=null?u=l:u=bt.rationalBezierCurveArcLength(r),s>u)return $.last(r.knots);var d=r.knots[0],m=0,_=$.last(r.knots),y=u,A=0,I=0,S;for(a!=null?S=a:S=rt.TOLERANCE*2;y-m>S;)A=(d+_)/2,I=bt.rationalBezierCurveArcLength(r,A),I>s?(_=A,y=I):(d=A,m=I);return(d+_)/2},bt.rationalCurveArcLength=function(r,s,a){a==null&&(a=16),s==null?s=$.last(r.knots):s=s;for(var l=_t.decomposeCurveIntoBeziers(r),u=0,d=l[0],m=0;u<l.length&&d.knots[0]+rt.EPSILON<s;){var _=Math.min($.last(d.knots),s);m+=bt.rationalBezierCurveArcLength(d,_,a),d=l[++u]}return m},bt.rationalBezierCurveArcLength=function(r,s,a){a==null&&(a=16);var l;s==null?l=$.last(r.knots):l=s;for(var u=(l-r.knots[0])/2,d=0,m=r.degree+a,_,y,A=0;A<m;){var I=A++;_=u*bt.Tvalues[m][I]+u+r.knots[0],y=N.rationalCurveDerivatives(r,_,1),d+=bt.Cvalues[m][I]*p.norm(y[1])}return u*d};var Cn=f.eval.KnotMultiplicity=function(r,s){this.knot=r,this.mult=s};x["verb.eval.KnotMultiplicity"]=Cn,Cn.__name__=["verb","eval","KnotMultiplicity"],Cn.prototype={inc:function(){this.mult++},__class__:Cn};var qe=f.eval.Check=function(){};x["verb.eval.Check"]=qe,qe.__name__=["verb","eval","Check"],qe.isValidKnotVector=function(r,s){if(r.length==0||r.length<(s+1)*2)return!1;for(var a=$.first(r),l=0,u=s+1;l<u;){var d=l++;if(Math.abs(r[d]-a)>rt.EPSILON)return!1}a=$.last(r);for(var m=r.length-s-1,_=r.length;m<_;){var y=m++;if(Math.abs(r[y]-a)>rt.EPSILON)return!1}return qe.isNonDecreasing(r)},qe.isNonDecreasing=function(r){for(var s=$.first(r),a=0,l=r.length;a<l;){var u=a++;if(r[u]<s-rt.EPSILON)return!1;s=r[u]}return!0},qe.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(!qe.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},qe.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(!qe.isValidKnotVector(r.knotsU,r.degreeU)||!qe.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 he=f.eval.Divide=function(){};x["verb.eval.Divide"]=he,he.__name__=["verb","eval","Divide"],he.surfaceSplit=function(r,s,a){a==null&&(a=!1);var l,u,d;a?(d=r.controlPoints,l=r.knotsV,u=r.degreeV):(d=Ot.transpose(r.controlPoints),l=r.knotsU,u=r.degreeU);for(var m,_=[],y=0,A=u+1;y<A;)y++,_.push(s);m=_;for(var I=[],S=[],P=N.knotSpan(u,s,l),k=null,T=0;T<d.length;){var O=d[T];++T,k=_t.curveKnotRefine(new jt(u,l,O),m),I.push(k.controlPoints.slice(0,P+1)),S.push(k.controlPoints.slice(P+1))}var C=k.knots.slice(0,P+u+2),R=k.knots.slice(P+1);return a?[new ee(r.degreeU,u,r.knotsU.slice(),C,I),new ee(r.degreeU,u,r.knotsU.slice(),R,S)]:(I=Ot.transpose(I),S=Ot.transpose(S),[new ee(u,r.degreeV,C,r.knotsV.slice(),I),new ee(u,r.degreeV,R,r.knotsV.slice(),S)])},he.curveSplit=function(r,s){var a=r.degree;r.controlPoints;for(var l=r.knots,u,d=[],m=0,_=a+1;m<_;)m++,d.push(s);u=d;var y=_t.curveKnotRefine(r,u),A=N.knotSpan(a,s,l),I=y.knots.slice(0,A+a+2),S=y.knots.slice(A+1),P=y.controlPoints.slice(0,A+1),k=y.controlPoints.slice(A+1);return[new jt(a,I,P),new jt(a,S,k)]},he.rationalCurveByEqualArcLength=function(r,s){var a=bt.rationalCurveArcLength(r),l=a/s;return he.rationalCurveByArcLength(r,l)},he.rationalCurveByArcLength=function(r,s){var a=_t.decomposeCurveIntoBeziers(r),l=a.map(function(P){return bt.rationalBezierCurveArcLength(P)}),u=p.sum(l),d=[new Ln(r.knots[0],0)];if(s>u)return d;for(var m=s,_=0,y=m,A=0,I=0,S;_<a.length;){for(A+=l[_];y<A+rt.EPSILON;)S=bt.rationalBezierCurveParamAtArcLength(a[_],y-I,rt.TOLERANCE,l[_]),d.push(new Ln(S,y)),y+=m;I+=l[_],_++}return d};var Ln=f.eval.CurveLengthSample=function(r,s){this.u=r,this.len=s};x["verb.eval.CurveLengthSample"]=Ln,Ln.__name__=["verb","eval","CurveLengthSample"],Ln.prototype={__class__:Ln};var N=f.eval.Eval=function(){};x["verb.eval.Eval"]=N,N.__name__=["verb","eval","Eval"],N.rationalCurveTangent=function(r,s){var a=N.rationalCurveDerivatives(r,s,1);return a[1]},N.rationalSurfaceNormal=function(r,s,a){var l=N.rationalSurfaceDerivatives(r,s,a,1);return p.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,s,a,l){l==null&&(l=1);for(var u=N.surfaceDerivatives(r,s,a,l),d=N.rational2d(u),m=N.weight2d(u),_=[],y=d[0][0].length,A=0,I=l+1;A<I;){var S=A++;_.push([]);for(var P=0,k=l-S+1;P<k;){for(var T=P++,O=d[S][T],C=1,R=T+1;C<R;){var z=C++;p.subMulMutate(O,Ft.get(T,z)*m[0][z],_[S][T-z])}for(var U=1,V=S+1;U<V;){var q=U++;p.subMulMutate(O,Ft.get(S,q)*m[q][0],_[S-q][T]);for(var J=p.zeros1d(y),H=1,G=T+1;H<G;){var K=H++;p.addMulMutate(J,Ft.get(T,K)*m[q][K],_[S-q][T-K])}p.subMulMutate(O,Ft.get(S,q),J)}p.mulMutate(1/m[0][0],O),_[S].push(O)}}return _},N.rationalSurfacePoint=function(r,s,a){return N.dehomogenize(N.surfacePoint(r,s,a))},N.rationalCurveDerivatives=function(r,s,a){a==null&&(a=1);for(var l=N.curveDerivatives(r,s,a),u=N.rational1d(l),d=N.weight1d(l),m=[],_=0,y=a+1;_<y;){for(var A=_++,I=u[A],S=1,P=A+1;S<P;){var k=S++;p.subMulMutate(I,Ft.get(A,k)*d[k],m[A-k])}p.mulMutate(1/d[0],I),m.push(I)}return m},N.rationalCurvePoint=function(r,s){return N.dehomogenize(N.curvePoint(r,s))},N.surfaceDerivatives=function(r,s,a,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(u,d,r,s,a,l)},N.surfaceDerivativesGivenNM=function(r,s,a,l,u,d){var m=a.degreeU,_=a.degreeV,y=a.controlPoints,A=a.knotsU,I=a.knotsV;if(!N.areValidRelations(m,y.length,A.length)||!N.areValidRelations(_,y[0].length,I.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=y[0][0].length,P;d<m?P=d:P=m;var k;d<_?k=d:k=_;for(var T=p.zeros3d(d+1,d+1,S),O=N.knotSpanGivenN(r,m,l,A),C=N.knotSpanGivenN(s,_,u,I),R=N.derivativeBasisFunctionsGivenNI(O,l,m,r,A),z=N.derivativeBasisFunctionsGivenNI(C,u,_,s,I),U=p.zeros2d(_+1,S),V=0,q=0,J=P+1;q<J;){for(var H=q++,G=0,K=_+1;G<K;){var tt=G++;U[tt]=p.zeros1d(S);for(var et=0,it=m+1;et<it;){var ht=et++;p.addMulMutate(U[tt],R[H][ht],y[O-m+ht][C-_+tt])}}var at=d-H;at<k?V=at:V=k;for(var ct=0,nt=V+1;ct<nt;){var pt=ct++;T[H][pt]=p.zeros1d(S);for(var X=0,ft=_+1;X<ft;){var Pt=X++;p.addMulMutate(T[H][pt],z[pt][Pt],U[Pt])}}}return T},N.surfacePoint=function(r,s,a){var l=r.knotsU.length-r.degreeU-2,u=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,u,r,s,a)},N.surfacePointGivenNM=function(r,s,a,l,u){var d=a.degreeU,m=a.degreeV,_=a.controlPoints,y=a.knotsU,A=a.knotsV;if(!N.areValidRelations(d,_.length,y.length)||!N.areValidRelations(m,_[0].length,A.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,y),P=N.knotSpanGivenN(s,m,u,A),k=N.basisFunctionsGivenKnotSpanIndex(S,l,d,y),T=N.basisFunctionsGivenKnotSpanIndex(P,u,m,A),O=S-d,C=P,R=p.zeros1d(I),z=p.zeros1d(I),U=0,V=m+1;U<V;){var q=U++;z=p.zeros1d(I),C=P-m+q;for(var J=0,H=d+1;J<H;){var G=J++;p.addMulMutate(z,k[G],_[O+G][C])}p.addMulMutate(R,T[q],z)}return R},N.curveRegularSamplePoints=function(r,s){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/s,u=l*l,d=a[0],m=p.mul(l,a[1]),_=p.mul(u*.5,a[2]),y=p.mul(u*l*.5,a[3]),A=p.add(_,_),I=p.add(y,y),S=p.mul(.3333333333333333,y),P=[],k=0,T=s+1;k<T;)k++,P.push(N.dehomogenize(d)),p.addAllMutate([d,m,_,S]),p.addAllMutate([m,A,y]),p.addAllMutate([A,I]),p.addAllMutate([_,y]);return P},N.curveRegularSamplePoints2=function(r,s){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/s,u=l*l,d=a[0],m=p.mul(l,a[1]),_=p.mul(u*.5,a[2]),y=p.mul(u*l*.5,a[3]),A=p.add(_,_),I=p.add(y,y),S=p.mul(.3333333333333333,y),P=[],k=0,T=s+1;k<T;)k++,P.push(N.dehomogenize(d)),p.addAllMutate([d,m,_,S]),p.addAllMutate([m,A,y]),p.addAllMutate([A,I]),p.addAllMutate([_,y]);return P},N.rationalSurfaceRegularSampleDerivatives=function(r,s,a,l){for(var u=N.surfaceRegularSampleDerivatives(r,s,a,l),d=[],m=s+1,_=a+1,y=l+1,A=0;A<m;){var I=A++,S=[];d.push(S);for(var P=0;P<_;){for(var k=P++,T=u[I][k],O=N.rational2d(T),C=N.weight2d(T),R=[],z=O[0][0].length,U=0;U<y;){var V=U++;R.push([]);for(var q=0,J=y-V;q<J;){for(var H=q++,G=O[V][H],K=1,tt=H+1;K<tt;){var et=K++;p.subMulMutate(G,Ft.get(H,et)*C[0][et],R[V][H-et])}for(var it=1,ht=V+1;it<ht;){var at=it++;p.subMulMutate(G,Ft.get(V,at)*C[at][0],R[V-at][H]);for(var ct=p.zeros1d(z),nt=1,pt=H+1;nt<pt;){var X=nt++;p.addMulMutate(ct,Ft.get(H,X)*C[at][X],R[V-at][H-X])}p.subMulMutate(G,Ft.get(V,at),ct)}p.mulMutate(1/C[0][0],G),R[V].push(G)}}S.push(R)}}return d},N.surfaceRegularSampleDerivatives=function(r,s,a,l){var u=r.degreeU,d=r.degreeV,m=r.controlPoints,_=r.knotsU,y=r.knotsV,A=m[0][0].length;($.last(_)-_[0])/s,($.last(y)-y[0])/a;for(var I=N.regularlySpacedDerivativeBasisFunctions(u,_,s),S=I.item0,P=I.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,y,a),T=k.item0,O=k.item1,C=[],R=s+1,z=a+1,U=0;U<R;){var V=U++,q=[];C.push(q);for(var J=0;J<z;){var H=J++;q.push(N.surfaceDerivativesGivenBasesKnotSpans(u,d,m,S[V],T[H],P[V],O[H],A,l))}}return C},N.rationalSurfaceRegularSamplePoints=function(r,s,a){return N.dehomogenize2d(N.surfaceRegularSamplePoints(r,s,a))},N.surfaceRegularSamplePoints=function(r,s,a){var l=r.degreeU,u=r.degreeV,d=r.controlPoints,m=r.knotsU,_=r.knotsV,y=d[0][0].length;($.last(m)-m[0])/s,($.last(_)-_[0])/a;for(var A=N.regularlySpacedBasisFunctions(l,m,s),I=A.item0,S=A.item1,P=N.regularlySpacedBasisFunctions(u,_,a),k=P.item0,T=P.item1,O=[],C=s+1,R=a+1,z=0;z<C;){var U=z++,V=[];O.push(V);for(var q=0;q<R;){var J=q++;V.push(N.surfacePointGivenBasesKnotSpans(l,u,d,I[U],k[J],S[U],T[J],y))}}return O},N.regularlySpacedBasisFunctions=function(r,s,a){for(var l=s.length-r-2,u=($.last(s)-s[0])/a,d=[],m=[],_=s[0],y=N.knotSpanGivenN(l,r,_,s),A=a+1,I=0;I<A;){for(I++;_>=s[y+1];)y++;m.push(y),d.push(N.basisFunctionsGivenKnotSpanIndex(y,_,r,s)),_+=u}return new re(m,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,s,a){for(var l=s.length-r-2,u=($.last(s)-s[0])/a,d=[],m=[],_=s[0],y=N.knotSpanGivenN(l,r,_,s),A=a+1,I=0;I<A;){for(I++;_>=s[y+1];)y++;m.push(y),d.push(N.derivativeBasisFunctionsGivenNI(y,_,r,l,s)),_+=u}return new re(m,d)},N.surfacePointGivenBasesKnotSpans=function(r,s,a,l,u,d,m,_){for(var y=p.zeros1d(_),A,I=l-r,S=u-s,P=0,k=s+1;P<k;){var T=P++;A=p.zeros1d(_);for(var O=0,C=r+1;O<C;){var R=O++;p.addMulMutate(A,d[R],a[I+R][S])}S++,p.addMulMutate(y,m[T],A)}return y},N.surfaceDerivativesGivenBasesKnotSpans=function(r,s,a,l,u,d,m,_,y){var A=a[0][0].length,I;y<r?I=y:I=r;var S;y<s?S=y:S=s;for(var P=p.zeros3d(I+1,S+1,A),k=p.zeros2d(s+1,A),T=0,O=0,C=I+1;O<C;){for(var R=O++,z=0,U=s+1;z<U;){var V=z++;k[V]=p.zeros1d(A);for(var q=0,J=r+1;q<J;){var H=q++;p.addMulMutate(k[V],d[R][H],a[l-r+H][u-s+V])}}var G=y-R;G<S?T=G:T=S;for(var K=0,tt=T+1;K<tt;){var et=K++;P[R][et]=p.zeros1d(A);for(var it=0,ht=s+1;it<ht;){var at=it++;p.addMulMutate(P[R][et],m[et][at],k[at])}}}return P},N.curveDerivatives=function(r,s,a){var l=r.knots.length-r.degree-2;return N.curveDerivativesGivenN(l,r,s,a)},N.curveDerivativesGivenN=function(r,s,a,l){var u=s.degree,d=s.controlPoints,m=s.knots;if(!N.areValidRelations(u,d.length,m.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<u?y=l:y=u;for(var A=p.zeros2d(l+1,_),I=N.knotSpanGivenN(r,u,a,m),S=N.derivativeBasisFunctionsGivenNI(I,a,u,y,m),P=0,k=y+1;P<k;)for(var T=P++,O=0,C=u+1;O<C;){var R=O++;p.addMulMutate(A[T],S[T][R],d[I-u+R])}return A},N.curvePoint=function(r,s){var a=r.knots.length-r.degree-2;return N.curvePointGivenN(a,r,s)},N.areValidRelations=function(r,s,a){return s+r+1-a==0},N.curvePointGivenN=function(r,s,a){var l=s.degree,u=s.controlPoints,d=s.knots;if(!N.areValidRelations(l,u.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var m=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(m,a,l,d),y=p.zeros1d(u[0].length),A=0,I=l+1;A<I;){var S=A++;p.addMulMutate(y,_[S],u[m-l+S])}return y},N.volumePoint=function(r,s,a,l){var u=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,m=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,u,d,m,s,a,l)},N.volumePointGivenNML=function(r,s,a,l,u,d,m){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,y=r.degreeU,A=r.degreeV,I=r.degreeW,S=r.knotsU,P=r.knotsV,k=r.knotsW,T=_[0][0][0].length,O=N.knotSpanGivenN(s,y,u,S),C=N.knotSpanGivenN(a,A,d,P),R=N.knotSpanGivenN(l,I,m,k),z=N.basisFunctionsGivenKnotSpanIndex(O,u,y,S),U=N.basisFunctionsGivenKnotSpanIndex(C,d,A,P),V=N.basisFunctionsGivenKnotSpanIndex(R,m,I,k),q=O-y,J=p.zeros1d(T),H=p.zeros1d(T),G=p.zeros1d(T),K=0,tt=I+1;K<tt;){var et=K++;G=p.zeros1d(T);for(var it=R-I+et,ht=0,at=A+1;ht<at;){var ct=ht++;H=p.zeros1d(T);for(var nt=C-A+ct,pt=0,X=y+1;pt<X;){var ft=pt++;p.addMulMutate(H,z[ft],_[q+ft][nt][it])}p.addMulMutate(G,U[ct],H)}p.addMulMutate(J,V[et],G)}return J},N.derivativeBasisFunctions=function(r,s,a){var l=N.knotSpan(s,r,a),u=a.length-1,d=u-s-1;return N.derivativeBasisFunctionsGivenNI(l,r,s,d,a)},N.derivativeBasisFunctionsGivenNI=function(r,s,a,l,u){var d=p.zeros2d(a+1,a+1),m=p.zeros1d(a+1),_=p.zeros1d(a+1),y=0,A=0;d[0][0]=1;for(var I=1,S=a+1;I<S;){var P=I++;m[P]=s-u[r+1-P],_[P]=u[r+P]-s,y=0;for(var k=0;k<P;){var T=k++;d[P][T]=_[T+1]+m[P-T],A=d[T][P-1]/d[P][T],d[T][P]=y+_[T+1]*A,y=m[P-T]*A}d[P][P]=y}for(var O=p.zeros2d(l+1,a+1),C=p.zeros2d(2,a+1),R=0,z=1,U=0,V=0,q=0,J=0,H=0,G=0,K=a+1;G<K;){var tt=G++;O[0][tt]=d[tt][a]}for(var et=0,it=a+1;et<it;){var ht=et++;R=0,z=1,C[0][0]=1;for(var at=1,ct=l+1;at<ct;){var nt=at++;U=0,V=ht-nt,q=a-nt,ht>=nt&&(C[z][0]=C[R][0]/d[q+1][V],U=C[z][0]*d[V][q]),V>=-1?J=1:J=-V,ht-1<=q?H=nt-1:H=a-ht;for(var pt=J,X=H+1;pt<X;){var ft=pt++;C[z][ft]=(C[R][ft]-C[R][ft-1])/d[q+1][V+ft],U+=C[z][ft]*d[V+ft][q]}ht<=q&&(C[z][nt]=-C[R][nt-1]/d[q+1][ht],U+=C[z][nt]*d[ht][q]),O[nt][ht]=U;var Pt=R;R=z,z=Pt}}for(var Wt=a,Kt=1,Ut=l+1;Kt<Ut;){for(var $t=Kt++,Me=0,Xe=a+1;Me<Xe;){var be=Me++;O[$t][be]*=Wt}Wt*=a-$t}return O},N.basisFunctions=function(r,s,a){var l=N.knotSpan(s,r,a);return N.basisFunctionsGivenKnotSpanIndex(l,r,s,a)},N.basisFunctionsGivenKnotSpanIndex=function(r,s,a,l){var u=p.zeros1d(a+1),d=p.zeros1d(a+1),m=p.zeros1d(a+1),_=0,y=0;u[0]=1;for(var A=1,I=a+1;A<I;){var S=A++;d[S]=s-l[r+1-S],m[S]=l[r+S]-s,_=0;for(var P=0;P<S;){var k=P++;y=u[k]/(m[k+1]+d[S-k]),u[k]=_+m[k+1]*y,_=d[S-k]*y}u[S]=_}return u},N.knotSpan=function(r,s,a){return N.knotSpanGivenN(a.length-r-2,r,s,a)},N.knotSpanGivenN=function(r,s,a,l){if(a>l[r+1]-rt.EPSILON)return r;if(a<l[s]+rt.EPSILON)return s;for(var u=s,d=r+1,m=Math.floor((u+d)/2);a<l[m]||a>=l[m+1];)a<l[m]?d=m:u=m,m=Math.floor((u+d)/2);return m},N.dehomogenize=function(r){for(var s=r.length,a=[],l=r[s-1],u=r.length-1,d=0;d<u;){var m=d++;a.push(r[m]/l)}return a},N.rational1d=function(r){var s=r[0].length-1;return r.map(function(a){return a.slice(0,s)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var s=r[0].length-1;return r.map(function(a){return a[s]})},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,s){var a=r.length,l=r[0].length,u=[],d=0,m=[],_;s!=null?_=s:_=p.rep(r.length,1);for(var y=0;y<a;){var A=y++,I=[];m=r[A],d=_[A];for(var S=0;S<l;){var P=S++;I.push(m[P]*d)}I.push(d),u.push(I)}return u},N.homogenize2d=function(r,s){var a=r.length,l=[],u;if(s!=null)u=s;else{for(var d=[],m=0;m<a;)m++,d.push(p.rep(r[0].length,1));u=d}for(var _=0;_<a;){var y=_++;l.push(N.homogenize1d(r[y],u[y]))}return l};var lt=f.eval.Intersect=function(){};x["verb.eval.Intersect"]=lt,lt.__name__=["verb","eval","Intersect"],lt.surfaces=function(r,s,a){var l=zt.rationalSurfaceAdaptive(r),u=zt.rationalSurfaceAdaptive(s),d=lt.meshes(l,u),m=d.map(function(_){return _.map(function(y){return lt.surfacesAtPointWithEstimate(r,s,y.uv0,y.uv1,a)})});return m.map(function(_){return gt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},lt.surfacesAtPointWithEstimate=function(r,s,a,l,u){var d,m,_,y,A,I,S,P,k,T,O,C,R,z=5,U=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),m=d[0][0],y=d[1][0],A=d[0][1],_=p.normalized(p.cross(y,A)),I=p.dot(_,m),S=N.rationalSurfaceDerivatives(s,l[0],l[1],1),P=S[0][0],T=S[1][0],O=S[0][1],k=p.normalized(p.cross(T,O)),C=p.dot(k,P),R=p.distSquared(m,P),R<u*u)break;var V=p.normalized(p.cross(_,k)),q=p.dot(V,m),J=lt.threePlanes(_,I,k,C,V,q);if(J==null)throw new Q("panic!");var H=p.sub(J,m),G=p.sub(J,P),K=p.cross(y,_),tt=p.cross(A,_),et=p.cross(T,k),it=p.cross(O,k),ht=p.dot(tt,H)/p.dot(tt,y),at=p.dot(K,H)/p.dot(K,A),ct=p.dot(it,G)/p.dot(it,T),nt=p.dot(et,G)/p.dot(et,O);a=p.add([ht,at],a),l=p.add([ct,nt],l),U++}while(U<z);return new Jn(a,l,m,R)},lt.meshes=function(r,s,a,l){a==null&&(a=new lr(r)),l==null&&(l=new lr(s));var u=lt.boundingBoxTrees(a,l,0),d=$.unique(u.map(function(m){return lt.triangles(r,m.item0,s,m.item1)}).filter(function(m){return m!=null}).filter(function(m){return p.distSquared(m.min.point,m.max.point)>rt.EPSILON}),function(m,_){var y=p.sub(m.min.uv0,_.min.uv0),A=p.dot(y,y),I=p.sub(m.max.uv0,_.max.uv0),S=p.dot(I,I),P=p.sub(m.min.uv0,_.max.uv0),k=p.dot(P,P),T=p.sub(m.max.uv0,_.min.uv0),O=p.dot(T,T);return A<rt.EPSILON&&S<rt.EPSILON||k<rt.EPSILON&&O<rt.EPSILON});return lt.makeMeshIntersectionPolylines(d)},lt.meshSlices=function(r,s,a,l){for(var u=new Fr(r),d=u.boundingBox(),m=d.min[0],_=d.min[1],y=d.max[0],A=d.max[1],I=p.span(s,a,l),S=[],P=0;P<I.length;){var k=I[P];++P;var T=[[m,_,k],[y,_,k],[y,A,k],[m,A,k]],O=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],R=new Ke(C,T,null,O);S.push(lt.meshes(r,R,u))}return S},lt.makeMeshIntersectionPolylines=function(r){if(r.length==0)return[];for(var s=0;s<r.length;){var a=r[s];++s,a.max.opp=a.min,a.min.opp=a.max}for(var l=lt.kdTreeFromSegments(r),u=[],d=0;d<r.length;){var m=r[d];++d,u.push(m.min),u.push(m.max)}for(var _=0;_<u.length;){var y=u[_];if(++_,y.adj==null){var A=lt.lookupAdjacentSegment(y,l,r.length);A!=null&&A.adj==null&&(y.adj=A,A.adj=y)}}var I=u.filter(function(z){return z.adj==null});I.length==0&&(I=u);for(var S=[],P=0,k=!1;I.length!=0;){var T=I.pop();if(!T.visited){for(var O=[],C=T;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,O.push(C),P+=2,C=C.opp.adj,C==T)););O.length>0&&(O.push(O[O.length-1].opp),S.push(O))}if(I.length==0&&u.length>0&&(k||P<u.length)){k=!0;var R=u.pop();I.push(R)}}return S},lt.kdTreeFromSegments=function(r){for(var s=[],a=0;a<r.length;){var l=r[a];++a,s.push(new Mn(l.min.point,l.min)),s.push(new Mn(l.max.point,l.max))}return new es(s,p.distSquared)},lt.lookupAdjacentSegment=function(r,s,a){var l=s.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,s,a,l,u){a==null&&(a=.001),l!=null?l=l:l=new or(r),u!=null?u=u:u=new Rr(s);var d=lt.boundingBoxTrees(l,u,a);return $.unique(d.map(function(m){var _=m.item0,y=m.item1,A=$.first(_.knots),I=$.last(_.knots),S=(A+I)/2,P=$.first(y.knotsU),k=$.last(y.knotsU),T=$.first(y.knotsV),O=$.last(y.knotsV),C=[(P+k)/2,(T+O)/2];return lt.curveAndSurfaceWithEstimate(_,y,[S].concat(C),a)}).filter(function(m){return p.distSquared(m.curvePoint,m.surfacePoint)<a*a}),function(m,_){return Math.abs(m.u-_.u)<.5*a})},lt.curveAndSurfaceWithEstimate=function(r,s,a,l){l==null&&(l=.001);var u=function(y){var A=N.rationalCurvePoint(r,y[0]),I=N.rationalSurfacePoint(s,y[1],y[2]),S=p.sub(A,I);return p.dot(S,S)},d=function(y){var A=N.rationalCurveDerivatives(r,y[0],1),I=N.rationalSurfaceDerivatives(s,y[1],y[2],1),S=p.sub(I[0][0],A[0]),P=p.mul(-1,A[1]),k=I[1][0],T=I[0][1];return[2*p.dot(P,S),2*p.dot(k,S),2*p.dot(T,S)]},m=$e.uncmin(u,a,l*l,d),_=m.solution;return new Zn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(s,_[1],_[2]))},lt.polylineAndMesh=function(r,s,a){for(var l=lt.boundingBoxTrees(new hr(r),new lr(s),a),u=[],d=0;d<l.length;){var m=l[d];++d;var _=m.item0,y=m.item1,A=lt.segmentWithTriangle(r.points[_],r.points[_+1],s.points,s.faces[y]);if(A!=null){var I=A.point,S=p.lerp(A.p,[r.params[_]],[r.params[_+1]])[0],P=ne.triangleUVFromPoint(s,y,I);u.push(new Qn(I,S,P,_,y))}}return u},lt.boundingBoxTrees=function(r,s,a){a==null&&(a=1e-9);var l=[],u=[];l.push(r),u.push(s);for(var d=[];l.length>0;){var m=l.pop(),_=u.pop();if(!(m.empty()||_.empty())&&m.boundingBox().intersects(_.boundingBox(),a)){var y=m.indivisible(a),A=_.indivisible(a);if(y&&A){d.push(new re(m.yield(),_.yield()));continue}else if(y&&!A){var I=_.split();l.push(m),u.push(I.item1),l.push(m),u.push(I.item0);continue}else if(!y&&A){var S=m.split();l.push(S.item1),u.push(_),l.push(S.item0),u.push(_);continue}var P=m.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,s,a){var l=lt.boundingBoxTrees(new or(r),new or(s),0);return $.unique(l.map(function(u){return lt.curvesWithEstimate(r,s,$.first(u.item0.knots),$.first(u.item1.knots),a)}).filter(function(u){return p.distSquared(u.point0,u.point1)<a}),function(u,d){return Math.abs(u.u0-d.u0)<a*5})},lt.curvesWithEstimate=function(r,s,a,l,u){var d=function(P){var k=N.rationalCurvePoint(r,P[0]),T=N.rationalCurvePoint(s,P[1]),O=p.sub(k,T);return p.dot(O,O)},m=function(P){var k=N.rationalCurveDerivatives(r,P[0],1),T=N.rationalCurveDerivatives(s,P[1],1),O=p.sub(k[0],T[0]),C=k[1],R=p.mul(-1,T[1]);return[2*p.dot(C,O),2*p.dot(R,O)]},_=$e.uncmin(d,[a,l],u*u,m),y=_.solution[0],A=_.solution[1],I=N.rationalCurvePoint(r,y),S=N.rationalCurvePoint(s,A);return new tn(I,S,y,A)},lt.triangles=function(r,s,a,l){var u=r.faces[s],d=a.faces[l],m=ne.getTriangleNorm(r.points,u),_=ne.getTriangleNorm(a.points,d),y=r.points[u[0]],A=a.points[d[0]],I=lt.planes(y,m,A,_);if(I==null)return null;var S=lt.clipRayInCoplanarTriangle(I,r,s);if(S==null)return null;var P=lt.clipRayInCoplanarTriangle(I,a,l);if(P==null)return null;var k=lt.mergeTriangleClipIntervals(S,P,r,s,a,l);return k==null?null:new ke(new zr(k.min.uv0,k.min.uv1,k.min.point,s,l),new zr(k.max.uv0,k.max.uv1,k.max.point,s,l))},lt.clipRayInCoplanarTriangle=function(r,s,a){for(var l=s.faces[a],u=[s.points[l[0]],s.points[l[1]],s.points[l[2]]],d=[s.uvs[l[0]],s.uvs[l[1]],s.uvs[l[2]]],m=[p.sub(d[1],d[0]),p.sub(d[2],d[1]),p.sub(d[0],d[2])],_=[p.sub(u[1],u[0]),p.sub(u[2],u[1]),p.sub(u[0],u[2])],y=_.map(p.normalized),A=_.map(p.norm),I=null,S=null,P=0;P<3;){var k=P++,T=u[k],O=y[k],C=lt.rays(T,O,r.origin,r.dir);if(C!=null){var R=C.u0,z=C.u1;R<-rt.EPSILON||R>A[k]+rt.EPSILON||((I==null||z<I.u)&&(I=new kn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],m[k],R/A[k]))),(S==null||z>S.u)&&(S=new kn(z,p.onRay(r.origin,r.dir,z),p.onRay(d[k],m[k],R/A[k]))))}}return S==null||I==null?null:new ke(I,S)},lt.mergeTriangleClipIntervals=function(r,s,a,l,u,d){if(s.min.u>r.max.u+rt.EPSILON||r.min.u>s.max.u+rt.EPSILON)return null;var m;r.min.u>s.min.u?m=new re(r.min,0):m=new re(s.min,1);var _;r.max.u<s.max.u?_=new re(r.max,0):_=new re(s.max,1);var y=new ke(new zr(null,null,m.item0.point,l,d),new zr(null,null,_.item0.point,l,d));return m.item1==0?(y.min.uv0=m.item0.uv,y.min.uv1=ne.triangleUVFromPoint(u,d,m.item0.point)):(y.min.uv0=ne.triangleUVFromPoint(a,l,m.item0.point),y.min.uv1=m.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=ne.triangleUVFromPoint(u,d,_.item0.point)):(y.max.uv0=ne.triangleUVFromPoint(a,l,_.item0.point),y.max.uv1=_.item0.uv),y},lt.planes=function(r,s,a,l){var u=p.cross(s,l);if(p.dot(u,u)<rt.EPSILON)return null;var d=0,m=Math.abs(u[0]),_=Math.abs(u[1]),y=Math.abs(u[2]);_>m&&(d=1,m=_),y>m&&(d=2,m=y);var A,I,S,P;d==0?(A=s[1],I=s[2],S=l[1],P=l[2]):d==1?(A=s[0],I=s[2],S=l[0],P=l[2]):(A=s[0],I=s[1],S=l[0],P=l[1]);var k=-p.dot(r,s),T=-p.dot(a,l),O=A*P-I*S,C=(I*T-k*P)/O,R=(k*S-A*T)/O,z;return d==0?z=[0,C,R]:d==1?z=[C,0,R]:z=[C,R,0],new En(z,p.normalized(u))},lt.threePlanes=function(r,s,a,l,u,d){var m=p.cross(a,u),_=p.dot(r,m);if(Math.abs(_)<rt.EPSILON)return null;var y=p.sub(p.mul(d,a),p.mul(l,u)),A=p.add(p.mul(s,m),p.cross(r,y));return p.mul(1/_,A)},lt.polylines=function(r,s,a){for(var l=lt.boundingBoxTrees(new hr(r),new hr(s),a),u=[],d=0;d<l.length;){var m=l[d];++d;var _=m.item0,y=m.item1,A=lt.segments(r.points[_],r.points[_+1],s.points[y],s.points[y+1],a);A!=null&&(A.u0=p.lerp(A.u0,[r.params[_]],[r.params[_+1]])[0],A.u1=p.lerp(A.u1,[s.params[y]],[s.params[y+1]])[0],u.push(A))}return u},lt.segments=function(r,s,a,l,u){var d=p.sub(s,r),m=Math.sqrt(p.dot(d,d)),_=p.mul(1/m,d),y=p.sub(l,a),A=Math.sqrt(p.dot(y,y)),I=p.mul(1/A,y),S=lt.rays(r,_,a,I);if(S!=null){var P=Math.min(Math.max(0,S.u0/m),1),k=Math.min(Math.max(0,S.u1/A),1),T=p.onRay(r,d,P),O=p.onRay(a,y,k),C=p.distSquared(T,O);if(C<u*u)return new tn(T,O,P,k)}return null},lt.rays=function(r,s,a,l){var u=p.dot(s,l),d=p.dot(s,a),m=p.dot(s,r),_=p.dot(l,a),y=p.dot(l,r),A=p.dot(s,s),I=p.dot(l,l),S=A*I-u*u;if(Math.abs(S)<rt.EPSILON)return null;var P=u*(d-m)-A*(_-y),k=P/S,T=(d-m+k*u)/A,O=p.onRay(r,s,T),C=p.onRay(a,l,k);return new tn(O,C,T,k)},lt.segmentWithTriangle=function(r,s,a,l){var u=a[l[0]],d=a[l[1]],m=a[l[2]],_=p.sub(d,u),y=p.sub(m,u),A=p.cross(_,y),I=p.sub(s,r),S=p.sub(r,u),P=-p.dot(A,S),k=p.dot(A,I);if(Math.abs(k)<rt.EPSILON)return null;var T=P/k;if(T<0||T>1)return null;var O=p.add(r,p.mul(T,I)),C=p.dot(_,y),R=p.dot(_,_),z=p.dot(y,y),U=p.sub(O,u),V=p.dot(U,_),q=p.dot(U,y),J=C*C-R*z;if(Math.abs(J)<rt.EPSILON)return null;var H=(C*q-z*V)/J,G=(C*V-R*q)/J;return H>1+rt.EPSILON||G>1+rt.EPSILON||G<-rt.EPSILON||H<-rt.EPSILON||H+G>1+rt.EPSILON?null:new ts(O,H,G,T)},lt.segmentAndPlane=function(r,s,a,l){var u=p.dot(l,p.sub(s,r));if(Math.abs(u)<rt.EPSILON)return null;var d=p.dot(l,p.sub(a,r)),m=d/u;return m>1+rt.EPSILON||m<-rt.EPSILON?null:{p:m}};var gt=f.eval.Make=function(){};x["verb.eval.Make"]=gt,gt.__name__=["verb","eval","Make"],gt.rationalTranslationalSurface=function(r,s){for(var a=N.rationalCurvePoint(s,$.first(s.knots)),l=$.first(s.knots),u=$.last(s.knots),d=2*s.controlPoints.length,m=(u-l)/(d-1),_=[],y=0;y<d;){var A=y++,I=p.sub(N.rationalCurvePoint(s,l+A*m),a),S=_t.rationalCurveTransform(r,[[1,0,0,I[0]],[0,1,0,I[1]],[0,0,1,I[2]],[0,0,0,1]]);_.push(S)}return gt.loftedSurface(_)},gt.surfaceBoundaryCurves=function(r){var s=gt.surfaceIsocurve(r,$.first(r.knotsU),!1),a=gt.surfaceIsocurve(r,$.last(r.knotsU),!1),l=gt.surfaceIsocurve(r,$.first(r.knotsV),!0),u=gt.surfaceIsocurve(r,$.last(r.knotsV),!0);return[s,a,l,u]},gt.surfaceIsocurve=function(r,s,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=bt.knotMultiplicities(l),m=-1,_=0,y=d.length;_<y;){var A=_++;if(Math.abs(s-d[A].knot)<rt.EPSILON){m=A;break}}var I=u+1;m>=0&&(I=I-d[m].mult);var S;I>0?S=_t.surfaceKnotRefine(r,p.rep(I,s),a):S=r;var P=N.knotSpan(u,s,l);return Math.abs(s-$.first(l))<rt.EPSILON?P=0:Math.abs(s-$.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 T,O=[],C=0,R=S.controlPoints;C<R.length;){var z=R[C];++C,O.push(z[P])}return T=O,T}()):new jt(S.degreeV,S.knotsV,S.controlPoints[P])},gt.loftedSurface=function(r,s){r=_t.unifyCurveKnotVectors(r);var a=r[0].degree;s==null&&(s=3),s>r.length-1&&(s=r.length-1);for(var l=r[0].knots,u=[],d=[],m=0,_=r[0].controlPoints.length;m<_;){var y=[m++],A=r.map(function(S){return function(P){return P.controlPoints[S[0]]}}(y)),I=gt.rationalInterpCurve(A,s,!0);d.push(I.controlPoints),u=I.knots}return new ee(a,s,l,u,d)},gt.clonedCurve=function(r){return new jt(r.degree,r.knots.slice(),r.controlPoints.map(function(s){return s.slice()}))},gt.rationalBezierCurve=function(r,s){for(var a=r.length-1,l=[],u=0,d=a+1;u<d;)u++,l.push(0);for(var m=0,_=a+1;m<_;)m++,l.push(1);return s==null&&(s=p.rep(r.length,1)),new jt(a,l,N.homogenize1d(r,s))},gt.fourPointSurface=function(r,s,a,l,u){u==null&&(u=3);for(var d=u,m=[],_=0,y=u+1;_<y;){for(var A=_++,I=[],S=0,P=u+1;S<P;){var k=S++,T=1-A/d,O=p.lerp(T,r,s),C=p.lerp(T,l,a),R=p.lerp(1-k/d,O,C);R.push(1),I.push(R)}m.push(I)}var z=p.rep(u+1,0),U=p.rep(u+1,1);return new ee(u,u,z.concat(U),z.concat(U),m)},gt.ellipseArc=function(r,s,a,l,u){var d=p.norm(s),m=p.norm(a);s=p.normalized(s),a=p.normalized(a),u<l&&(u=2*Math.PI+l);var _=u-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var A=_/y,I=Math.cos(A/2),S=p.add(r,p.add(p.mul(d*Math.cos(l),s),p.mul(m*Math.sin(l),a))),P=p.sub(p.mul(Math.cos(l),a),p.mul(Math.sin(l),s)),k=[],T=p.zeros1d(2*y+3),O=0,C=l,R=p.zeros1d(y*2);k[0]=S,R[0]=1;for(var z=1,U=y+1;z<U;){var V=z++;C+=A;var q=p.add(r,p.add(p.mul(d*Math.cos(C),s),p.mul(m*Math.sin(C),a)));R[O+2]=1,k[O+2]=q;var J=p.sub(p.mul(Math.cos(C),a),p.mul(Math.sin(C),s)),H=lt.rays(S,p.mul(1/p.norm(P),P),q,p.mul(1/p.norm(J),J)),G=p.add(S,p.mul(H.u0,P));R[O+1]=I,k[O+1]=G,O+=2,V<y&&(S=q,P=J)}for(var K=2*y+1,tt=0;tt<3;){var et=tt++;T[et]=0,T[et+K]=1}switch(y){case 2:T[3]=T[4]=.5;break;case 3:T[3]=T[4]=.3333333333333333,T[5]=T[6]=.6666666666666666;break;case 4:T[3]=T[4]=.25,T[5]=T[6]=.5,T[7]=T[8]=.75;break}return new jt(2,T,N.homogenize1d(k,R))},gt.arc=function(r,s,a,l,u,d){return gt.ellipseArc(r,p.mul(l,p.normalized(s)),p.mul(l,p.normalized(a)),u,d)},gt.polyline=function(r){for(var s=[0,0],a=0,l=0,u=r.length-1;l<u;){var d=l++;a+=p.dist(r[d],r[d+1]),s.push(a)}s.push(a),s=p.mul(1/a,s);for(var m,_=[],y=0,A=r.length;y<A;)y++,_.push(1);return m=_,new jt(1,s,N.homogenize1d(r.slice(0),m))},gt.extrudedSurface=function(r,s,a){for(var l=[[],[],[]],u=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),m=N.weight1d(a.controlPoints),_=p.mul(s,r),y=p.mul(.5*s,r),A=0,I=d.length;A<I;){var S=A++;l[2][S]=d[S],l[1][S]=p.add(y,d[S]),l[0][S]=p.add(_,d[S]),u[0][S]=m[S],u[1][S]=m[S],u[2][S]=m[S]}return new ee(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,u))},gt.cylindricalSurface=function(r,s,a,l,u){var d=p.cross(r,s),m=gt.arc(a,s,d,u,0,2*Math.PI);return gt.extrudedSurface(r,l,m)},gt.revolvedSurface=function(r,s,a,l){var u=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),m,_;l<=Math.PI/2?(m=1,_=p.zeros1d(6+2*(m-1))):l<=Math.PI?(m=2,_=p.zeros1d(6+2*(m-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(m=3,_=p.zeros1d(6+2*(m-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(m=4,_=p.zeros1d(6+2*(m-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/m,A=3+2*(m-1),I=0;I<3;){var S=I++;_[S]=0,_[A+S]=1}for(var P=Math.cos(y/2),k=0,T=p.zeros1d(m+1),O=p.zeros1d(m+1),C=p.zeros3d(2*m+1,u.length,3),R=p.zeros2d(2*m+1,u.length),z=1,U=m+1;z<U;){var V=z++;k+=y,O[V]=Math.cos(k),T[V]=Math.sin(k)}for(var q=0,J=u.length;q<J;){var H=q++,G=Oe.rayClosestPoint(u[H],s,a),K=p.sub(u[H],G),tt=p.norm(K),et=p.cross(a,K);tt>rt.EPSILON&&(K=p.mul(1/tt,K),et=p.mul(1/tt,et)),C[0][H]=u[H];var it=u[H];R[0][H]=d[H];for(var ht=et,at=0,ct=1,nt=m+1;ct<nt;){var pt=ct++,X;tt==0?X=G:X=p.add(G,p.add(p.mul(tt*O[pt],K),p.mul(tt*T[pt],et))),C[at+2][H]=X,R[at+2][H]=d[H];var ft=p.sub(p.mul(O[pt],et),p.mul(T[pt],K));if(tt==0)C[at+1][H]=G;else{var Pt=lt.rays(it,p.mul(1/p.norm(ht),ht),X,p.mul(1/p.norm(ft),ft)),Wt=p.add(it,p.mul(Pt.u0,ht));C[at+1][H]=Wt}R[at+1][H]=P*d[H],at+=2,pt<m&&(it=X,ht=ft)}}return new ee(2,r.degree,_,r.knots,N.homogenize2d(C,R))},gt.sphericalSurface=function(r,s,a,l){var u=gt.arc(r,p.mul(-1,s),a,l,0,Math.PI);return gt.revolvedSurface(u,r,s,2*Math.PI)},gt.conicalSurface=function(r,s,a,l,u){var d=2*Math.PI,m=1,_=[p.add(a,p.mul(l,r)),p.add(a,p.mul(u,s))],y=[0,0,1,1],A=[1,1],I=new jt(m,y,N.homogenize1d(_,A));return gt.revolvedSurface(I,a,r,d)},gt.rationalInterpCurve=function(r,s,a,l,u){if(a==null&&(a=!1),s==null&&(s=3),r.length<s+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],m=1,_=r.length;m<_;){var y=m++,A=p.norm(p.sub(r[y],r[y-1])),I=d[d.length-1];d.push(I+A)}for(var S=d[d.length-1],P=0,k=d.length;P<k;){var T=P++;d[T]=d[T]/S}var O=p.rep(s+1,0),C=l!=null&&u!=null,R;C?R=0:R=1;var z;C?z=d.length-s+1:z=d.length-s;for(var U=R;U<z;){for(var V=U++,q=0,J=0;J<s;){var H=J++;q+=d[V+H]}O.push(1/s*q)}var G=O.concat(p.rep(s+1,1)),K=[],tt;C?tt=r.length+1:tt=r.length-1;var et;C?et=r.length-(s-1):et=r.length-(s+1);for(var it=0;it<d.length;){var ht=d[it];++it;var at=N.knotSpanGivenN(tt,s,ht,G),ct=N.basisFunctionsGivenKnotSpanIndex(at,ht,s,G),nt=at-s,pt=p.zeros1d(nt),X=p.zeros1d(et-nt);K.push(pt.concat(ct).concat(X))}if(C){var ft=K[0].length-2,Pt=[-1,1].concat(p.zeros1d(ft)),Wt=p.zeros1d(ft).concat([-1,1]);$.spliceAndInsert(K,1,0,Pt),$.spliceAndInsert(K,K.length-1,0,Wt)}for(var Kt=r[0].length,Ut=[],$t=(1-G[G.length-s-2])/s,Me=G[s+1]/s,Xe=0;Xe<Kt;){var be=[Xe++],_e;if(!C)_e=r.map(function(er){return function(fr){return fr[er[0]]}}(be));else{_e=[r[0][be[0]]],_e.push(Me*l[be[0]]);for(var Te=1,ze=r.length-1;Te<ze;){var Qe=Te++;_e.push(r[Qe][be[0]])}_e.push($t*u[be[0]]),_e.push($.last(r)[be[0]])}var ur=Ot.solve(K,_e);Ut.push(ur)}var Je=Ot.transpose(Ut);if(!a){var tr=p.rep(Je.length,1);Je=N.homogenize1d(Je,tr)}return new jt(s,G,Je)};var _t=f.eval.Modify=function(){};x["verb.eval.Modify"]=_t,_t.__name__=["verb","eval","Modify"],_t.curveReverse=function(r){return new jt(r.degree,_t.knotsReverse(r.knots),$.reversed(r.controlPoints))},_t.surfaceReverse=function(r,s){return s==null&&(s=!1),s?new ee(r.degreeU,r.degreeV,r.knotsU,_t.knotsReverse(r.knotsV),function(a){for(var l,u=[],d=0,m=r.controlPoints;d<m.length;){var _=m[d];++d,u.push($.reversed(_))}return l=u,l}()):new ee(r.degreeU,r.degreeV,_t.knotsReverse(r.knotsU),r.knotsV,$.reversed(r.controlPoints))},_t.knotsReverse=function(r){var s=$.first(r);$.last(r);for(var a=[s],l=r.length,u=1;u<l;){var d=u++;a.push(a[d-1]+(r[l-d]-r[l-d-1]))}return a},_t.unifyCurveKnotVectors=function(r){r=r.map(gt.clonedCurve);for(var s=B.fold(r,function(G,K){return _t.imax(G.degree,K)},0),a=0,l=r.length;a<l;){var u=a++;r[u].degree<s&&(r[u]=_t.curveElevateDegree(r[u],s))}for(var d,m=[],_=0;_<r.length;){var y=r[_];++_,m.push(new ke($.first(y.knots),$.last(y.knots)))}d=m;for(var A=0,I=r.length;A<I;){var S=A++,P=[d[S].min];r[S].knots=r[S].knots.map(function(G){return function(K){return K-G[0]}}(P))}for(var k=d.map(function(G){return G.max-G.min}),T=B.fold(k,function(G,K){return Math.max(G,K)},0),O=0,C=r.length;O<C;){var R=O++,z=[T/k[R]];r[R].knots=r[R].knots.map(function(G){return function(K){return K*G[0]}}(z))}for(var U=B.fold(r,function(G,K){return p.sortedSetUnion(G.knots,K)},[]),V=0,q=r.length;V<q;){var J=V++,H=p.sortedSetSub(U,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=_t.curveKnotRefine(r[J],H)}return r},_t.imin=function(r,s){return r<s?r:s},_t.imax=function(r,s){return r>s?r:s},_t.curveElevateDegree=function(r,s){if(s<=r.degree)return r;var a=r.knots.length-r.degree-2,l=r.degree,u=r.knots,d=r.controlPoints,m=s-r.degree,_=r.controlPoints[0].length,y=p.zeros2d(l+m+1,l+1),A=[],I=[],S=[],P=a+l+1,k=s,T=Math.floor(k/2),O=[],C=[];y[0][0]=1,y[k][l]=1;for(var R=1,z=T+1;R<z;)for(var U=R++,V=1/Ft.get(k,U),q=_t.imin(l,U),J=_t.imax(0,U-m),H=q+1;J<H;){var G=J++;y[U][G]=V*Ft.get(l,G)*Ft.get(m,U-G)}for(var K=T+1;K<k;)for(var tt=K++,et=_t.imin(l,tt),it=_t.imax(0,tt-m),ht=et+1;it<ht;){var at=it++;y[tt][at]=y[k-tt][l-at]}var ct=k+1,nt=-1,pt=l,X=l+1,ft=1,Pt=u[0];O[0]=d[0];for(var Wt=0,Kt=k+1;Wt<Kt;){var Ut=Wt++;C[Ut]=Pt}for(var $t=0,Me=l+1;$t<Me;){var Xe=$t++;A[Xe]=d[Xe]}for(;X<P;){for(var be=X;X<P&&u[X]==u[X+1];)X=X+1;var _e=X-be+1,Te=u[X],ze=nt;nt=l-_e;var Qe;ze>0?Qe=Math.floor((ze+2)/2):Qe=1;var ur;if(nt>0?ur=Math.floor(k-(nt+1)/2):ur=k,nt>0){for(var Je=Te-Pt,tr=[],er=l;er>_e;)tr[er-_e-1]=Je/(u[pt+er]-Pt),er--;for(var fr=1,zn=nt+1;fr<zn;){for(var rn=fr++,ac=nt-rn,Ji=_e+rn,nn=l;nn>=Ji;)A[nn]=p.add(p.mul(tr[nn-Ji],A[nn]),p.mul(1-tr[nn-Ji],A[nn-1])),nn--;S[ac]=A[l]}}for(var Vo=Qe,oc=k+1;Vo<oc;){var Rn=Vo++;I[Rn]=p.zeros1d(_);for(var lc=_t.imin(l,Rn),Go=_t.imax(0,Rn-m),hc=lc+1;Go<hc;){var jo=Go++;I[Rn]=p.add(I[Rn],p.mul(y[Rn][jo],A[jo]))}}if(ze>1)for(var ta=ct-2,ea=ct,Wo=Te-Pt,uc=(Te-C[ct-1])/Wo,Ho=1;Ho<ze;){for(var ra=Ho++,_r=ta,sn=ea,Wr=sn-ct+1;sn-_r>ra;){if(_r<ft){var cc=(Te-C[_r])/(Pt-C[_r]);O[_r]=p.lerp(cc,O[_r],O[_r-1])}if(sn>=Qe){if(sn-ra<=ct-k+ze){var dc=(Te-C[sn-ra])/Wo;I[Wr]=p.lerp(dc,I[Wr],I[Wr+1])}}else I[Wr]=p.lerp(uc,I[Wr],I[Wr+1]);_r=_r+1,sn=sn-1,Wr=Wr-1}ta=ta-1,ea=ea+1}if(pt!=l)for(var Yo=0,pc=k-ze;Yo<pc;)Yo++,C[ct]=Pt,ct=ct+1;for(var qo=Qe,mc=ur+1;qo<mc;){var gc=qo++;O[ft]=I[gc],ft=ft+1}if(X<P){for(var Xo=0;Xo<nt;){var Ko=Xo++;A[Ko]=S[Ko]}for(var $o=nt,fc=l+1;$o<fc;){var Zo=$o++;A[Zo]=d[X-l+Zo]}pt=X,X=X+1,Pt=Te}else for(var Qo=0,_c=k+1;Qo<_c;){var yc=Qo++;C[ct+yc]=Te}}return new jt(s,C,O)},_t.rationalSurfaceTransform=function(r,s){for(var a=N.dehomogenize2d(r.controlPoints),l=0,u=a.length;l<u;)for(var d=l++,m=0,_=a[d].length;m<_;){var y=m++,A=a[d][y];A.push(1),a[d][y]=Ot.dot(s,A).slice(0,A.length-1)}return new ee(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},_t.rationalCurveTransform=function(r,s){for(var a=N.dehomogenize1d(r.controlPoints),l=0,u=a.length;l<u;){var d=l++,m=a[d];m.push(1),a[d]=Ot.dot(s,m).slice(0,m.length-1)}return new jt(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},_t.surfaceKnotRefine=function(r,s,a){var l=[],u,d,m;a?(m=r.controlPoints,u=r.knotsV,d=r.degreeV):(m=Ot.transpose(r.controlPoints),u=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<m.length;){var A=m[y];++y,_=_t.curveKnotRefine(new jt(d,u,A),s),l.push(_.controlPoints)}var I=_.knots;return a?new ee(r.degreeU,r.degreeV,r.knotsU.slice(),I,l):(l=Ot.transpose(l),new ee(r.degreeU,r.degreeV,I,r.knotsV.slice(),l))},_t.decomposeCurveIntoBeziers=function(r){for(var s=r.degree,a=r.controlPoints,l=r.knots,u=bt.knotMultiplicities(l),d=s+1,m=0;m<u.length;){var _=u[m];if(++m,_.mult<d){var y=p.rep(d-_.mult,_.knot),A=_t.curveKnotRefine(new jt(s,l,a),y);l=A.knots,a=A.controlPoints}}l.length/d-1;for(var I=d*2,S=[],P=0;P<a.length;){var k=l.slice(P,P+I),T=a.slice(P,P+d);S.push(new jt(s,k,T)),P+=d}return S},_t.curveKnotRefine=function(r,s){if(s.length==0)return gt.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,u=r.knots,d=l.length-1,m=d+a+1,_=s.length-1,y=N.knotSpan(a,s[0],u),A=N.knotSpan(a,s[_],u),I=[],S=[],P=0,k=y-a+1;P<k;){var T=P++;I[T]=l[T]}for(var O=A-1,C=d+1;O<C;){var R=O++;I[R+_+1]=l[R]}for(var z=0,U=y+1;z<U;){var V=z++;S[V]=u[V]}for(var q=A+a,J=m+1;q<J;){var H=q++;S[H+_+1]=u[H]}for(var G=A+a-1,K=A+a+_,tt=_;tt>=0;){for(;s[tt]<=u[G]&&G>y;)I[K-a-1]=l[G-a-1],S[K]=u[G],K=K-1,G=G-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]-s[tt];Math.abs(ct)<rt.EPSILON?I[at-1]=I[at]:(ct=ct/(S[K+ht]-u[G-a+ht]),I[at-1]=p.add(p.mul(ct,I[at-1]),p.mul(1-ct,I[at])))}S[K]=s[tt],K=K-1,tt--}return new jt(a,S,I)},_t.curveKnotInsert=function(r,s,a){for(var l=r.degree,u=r.controlPoints,d=r.knots,m=0,_=u.length,y=N.knotSpan(l,s,d),A=[],I=[],S=[],P=1,k=y+1;P<k;){var T=P++;I[T]=d[T]}for(var O=1,C=a+1;O<C;){var R=O++;I[y+R]=s}for(var z=y+1,U=d.length;z<U;){var V=z++;I[V+a]=d[V]}for(var q=0,J=y-l+1;q<J;){var H=q++;S[H]=u[H]}for(var G=y-m;G<_;){var K=G++;S[K+a]=u[K]}for(var tt=0,et=l-m+1;tt<et;){var it=tt++;A[it]=u[y-l+it]}for(var ht=0,at=0,ct=1,nt=a+1;ct<nt;){var pt=ct++;ht=y-l+pt;for(var X=0,ft=l-pt-m+1;X<ft;){var Pt=X++;at=(s-d[ht+Pt])/(d[Pt+y+1]-d[ht+Pt]),A[Pt]=p.add(p.mul(at,A[Pt+1]),p.mul(1-at,A[Pt]))}S[ht]=A[0],S[y+a-pt-m]=A[l-pt-m]}for(var Wt=ht+1,Kt=y-m;Wt<Kt;){var Ut=Wt++;S[Ut]=A[Ut-ht]}return new jt(l,I,S)};var zt=f.eval.Tess=function(){};x["verb.eval.Tess"]=zt,zt.__name__=["verb","eval","Tess"],zt.rationalCurveRegularSample=function(r,s,a){return zt.rationalCurveRegularSampleRange(r,r.knots[0],$.last(r.knots),s,a)},zt.rationalCurveRegularSampleRange=function(r,s,a,l,u){l<1&&(l=2);for(var d=[],m=(a-s)/(l-1),_=0,y=0;y<l;){var A=y++;_=s+m*A,u?d.push([_].concat(N.rationalCurvePoint(r,_))):d.push(N.rationalCurvePoint(r,_))}return d},zt.rationalCurveAdaptiveSample=function(r,s,a){if(a==null&&(a=!1),s==null&&(s=1e-6),r.degree==1)if(a){for(var l=[],u=0,d=r.controlPoints.length;u<d;){var m=u++;l.push([r.knots[m+1]].concat(N.dehomogenize(r.controlPoints[m])))}return l}else return r.controlPoints.map(N.dehomogenize);return zt.rationalCurveAdaptiveSampleRange(r,r.knots[0],$.last(r.knots),s,a)},zt.rationalCurveAdaptiveSampleRange=function(r,s,a,l,u){var d=N.rationalCurvePoint(r,s),m=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),y=s+(a-s)*_,A=N.rationalCurvePoint(r,y),I=p.sub(d,m),S=p.sub(d,A);if(p.dot(I,I)<l&&p.dot(S,S)>l||!Oe.threePointsAreFlat(d,A,m,l)){var P=s+(a-s)*.5,k=zt.rationalCurveAdaptiveSampleRange(r,s,P,l,u),T=zt.rationalCurveAdaptiveSampleRange(r,P,a,l,u);return k.slice(0,-1).concat(T)}else return u?[[s].concat(d),[a].concat(m)]:[d,m]},zt.rationalSurfaceNaive=function(r,s,a){s<1&&(s=1),a<1&&(a=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,u=r.knotsV,d=$.last(l)-l[0],m=$.last(u)-u[0],_=d/s,y=m/a,A=[],I=[],S=[],P=0,k=s+1;P<k;)for(var T=P++,O=0,C=a+1;O<C;){var R=O++,z=T*_,U=R*y;I.push([z,U]);var V=N.rationalSurfaceDerivatives(r,z,U,1),q=V[0][0];A.push(q);var J=p.normalized(p.cross(V[1][0],V[0][1]));S.push(J)}for(var H=[],G=0;G<s;)for(var K=G++,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],pt=[it,at,ct];H.push(nt),H.push(pt)}return new Ke(H,A,S,I)},zt.divideRationalSurfaceAdaptive=function(r,s){s==null&&(s=new Dr),s.minDivsU!=null?s.minDivsU=s.minDivsU:s.minDivsU=1,s.minDivsV!=null?s.minDivsU=s.minDivsV:s.minDivsU=1,s.refine!=null?s.refine=s.refine:s.refine=!0;var a=(r.controlPoints.length-1)*2,l=(r.controlPoints[0].length-1)*2,u;s.minDivsU>a?u=s.minDivsU=s.minDivsU:u=s.minDivsU=a;var d;s.minDivsV>l?d=s.minDivsV=s.minDivsV:d=s.minDivsV=l;for(var m=$.last(r.knotsU),_=r.knotsU[0],y=$.last(r.knotsV),A=r.knotsV[0],I=(m-_)/u,S=(y-A)/d,P=[],k=[],T=0,O=d+1;T<O;){for(var C=T++,R=[],z=0,U=u+1;z<U;){var V=z++,q=_+I*V,J=A+S*C,H=N.rationalSurfaceDerivatives(r,q,J,1),G=p.normalized(p.cross(H[0][1],H[1][0]));R.push(new Ye(H[0][0],G,[q,J],-1,p.isZero(G)))}k.push(R)}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 gr(r,ht))}if(!s.refine)return P;for(var at=0;at<d;)for(var ct=at++,nt=0;nt<u;){var pt=nt++,X=ct*u+pt,ft=zt.north(X,ct,pt,u,d,P),Pt=zt.east(X,ct,pt,u,d,P),Wt=zt.south(X,ct,pt,u,d,P),Kt=zt.west(X,ct,pt,u,d,P);P[X].neighbors=[Wt,Pt,ft,Kt],P[X].divide(s)}return P},zt.north=function(r,s,a,l,u,d){return s==0?null:d[r-l]},zt.south=function(r,s,a,l,u,d){return s==u-1?null:d[r+l]},zt.east=function(r,s,a,l,u,d){return a==l-1?null:d[r+1]},zt.west=function(r,s,a,l,u,d){return a==0?null:d[r-1]},zt.triangulateAdaptiveRefinementNodeTree=function(r){for(var s=Ke.empty(),a=0;a<r.length;){var l=r[a];++a,l.triangulate(s)}return s},zt.rationalSurfaceAdaptive=function(r,s){s!=null?s=s:s=new Dr;var a=zt.divideRationalSurfaceAdaptive(r,s);return zt.triangulateAdaptiveRefinementNodeTree(a)};var Dr=f.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"]=Dr,Dr.__name__=["verb","eval","AdaptiveRefinementOptions"],Dr.prototype={__class__:Dr};var gr=f.core.AdaptiveRefinementNode=function(r,s,a){if(this.srf=r,a==null?this.neighbors=[null,null,null,null]:this.neighbors=a,this.corners=s,this.corners==null){var l=r.knotsU[0],u=$.last(r.knotsU),d=r.knotsV[0],m=$.last(r.knotsV);this.corners=[Ye.fromUv(l,d),Ye.fromUv(u,d),Ye.fromUv(u,m),Ye.fromUv(l,m)]}};x["verb.eval.AdaptiveRefinementNode"]=gr,gr.__name__=["verb","eval","AdaptiveRefinementNode"],gr.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 s=r++;if(this.corners[s].point==null){var a=this.corners[s];this.evalSrf(a.uv[0],a.uv[1],a)}}},evalSrf:function(r,s,a){var l=N.rationalSurfaceDerivatives(this.srf,r,s,1),u=l[0][0],d=p.cross(l[0][1],l[1][0]),m=p.isZero(d);return m||(d=p.normalized(d)),a!=null?(a.degen=m,a.point=u,a.normal=d,a):new Ye(u,d,[r,s],-1,m)},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 s=[this.corners[r]];if(this.neighbors[r]==null)return s;var a=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,u=rt.EPSILON,d=this,m=[function(y){return y.uv[0]>d.corners[0].uv[0]+u&&y.uv[0]<d.corners[2].uv[0]-u},function(y){return y.uv[1]>d.corners[0].uv[1]+u&&y.uv[1]<d.corners[2].uv[1]-u}],_=a.filter(m[l]);return _.reverse(),s.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,s=0;s<r;){var a=s++;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,s){if(s<r.minDepth)return!0;if(s>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=p.normSquared(p.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=p.normSquared(p.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return p.normSquared(p.sub(a.normal,this.corners[0].normal))>r.normTol||p.normSquared(p.sub(a.normal,this.corners[1].normal))>r.normTol||p.normSquared(p.sub(a.normal,this.corners[2].normal))>r.normTol||p.normSquared(p.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new Dr),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,s,a){if(this.evalCorners(),!!this.shouldDivide(r,s)){if(s++,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 gr(this.srf,l),new gr(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]],m=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new gr(this.srf,d),new gr(this.srf,m)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var A=y[_];++_,A._divide(r,s,!a)}}},triangulate:function(r){if(r==null&&(r=Ke.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var s=0,a=this.children;s<a.length;){var l=a[s];if(++s,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var s=r.points.length,a=[],l=[],u=0,d=0;d<4;){var m=d++,_=this.getAllCorners(m);_.length==2&&(u=m+1);for(var y=0,A=_.length;y<A;){var I=y++;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=s,l.push(s),s++}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 T=this.center();r.uvs.push(T.uv),r.points.push(T.point),r.normals.push(T.normal);for(var O=r.points.length-1,C=0,R=a.length-1;C<a.length;)r.faces.push([O,l[C],l[R]]),R=C++;return r},__class__:gr};var At=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=At,At.__name__=["verb","exe","Dispatcher"],At.init=function(){At._init||(At._workerPool=new Ur(At.THREADS),At._init=!0)},At.dispatchMethod=function(r,s,a){At.init();var l=new In,u=function(d){l.resolve(d)};return At._workerPool.addWork(ut.getClassName(r),s,a,u),new fe(l)};var Ur=f.exe.WorkerPool=function(r,s){s==null&&(s="verb.js"),r==null&&(r=1),this._callbacks=new wt,this._working=new wt,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(Ur.basePath+s)}catch(u){u instanceof Q&&(u=u.val),l=new Worker(Ur.basePath+s.substring(0,-3)+".min.js")}this._pool.push(l)}};x["verb.exe.WorkerPool"]=Ur,Ur.__name__=["verb","exe","WorkerPool"],Ur.prototype={addWork:function(r,s,a,l){var u=new en(r,s,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 s=this._queue.shift(),a=[s.id],l=[this._pool.shift()];this._working.h[a[0]]=l[0],l[0].onmessage=function(u,d){return function(m){r._working.remove(d[0]),r._pool.push(u[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](m.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,a),l[0].postMessage(s)}},__class__:Ur};var en=function(r,s,a){this.className=r,this.methodName=s,this.args=a,this.id=en.uuid++};x["verb.exe._WorkerPool.Work"]=en,en.__name__=["verb","exe","_WorkerPool","Work"],en.prototype={__class__:en};var On=function(){};x["verb.geom.ICurve"]=On,On.__name__=["verb","geom","ICurve"],On.__interfaces__=[Nn],On.prototype={__class__:On};var Lt=f.geom.NurbsCurve=function(r){this._data=qe.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Lt,Lt.__name__=["verb","geom","NurbsCurve"],Lt.__interfaces__=[On],Lt.byKnotsControlPointsWeights=function(r,s,a,l){return new Lt(new jt(r,s.slice(),N.homogenize1d(a,l)))},Lt.byPoints=function(r,s){return s==null&&(s=3),new Lt(gt.rationalInterpCurve(r,s))},Lt.__super__=Qt,Lt.prototype=M(Qt.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 Lt(this._data)},domain:function(){return new ke($.first(this._data.knots),$.last(this._data.knots))},transform:function(r){return new Lt(_t.rationalCurveTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(_t,"rationalCurveTransform",[this._data,r]).then(function(s){return new Lt(s)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return At.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return At.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,s){return s==null&&(s=1),N.rationalCurveDerivatives(this._data,r,s)},derivativesAsync:function(r,s){return s==null&&(s=1),At.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,s])},closestPoint:function(r){return bt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return bt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalCurveClosestParam",[this._data,r])},length:function(){return bt.rationalCurveArcLength(this._data)},lengthAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return bt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return At.dispatchMethod(bt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,s){return bt.rationalCurveParamAtArcLength(this._data,r,s)},paramAtLengthAsync:function(r,s){return At.dispatchMethod(bt,"rationalCurveParamAtArcLength",[this._data,r,s])},divideByEqualArcLength:function(r){return he.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return At.dispatchMethod(he,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return he.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return At.dispatchMethod(he,"rationalCurveByArcLength",[this._data,r])},split:function(r){return he.curveSplit(this._data,r).map(function(s){return new Lt(s)})},splitAsync:function(r){return At.dispatchMethod(he,"curveSplit",[this._data,r]).then(function(s){return s.map(function(a){return new Lt(a)})})},reverse:function(){return new Lt(_t.curveReverse(this._data))},reverseAsync:function(){return At.dispatchMethod(_t,"curveReverse",[this._data]).then(function(r){return new Lt(r)})},tessellate:function(r){return zt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Lt});var Vr=f.geom.Arc=function(r,s,a,l,u,d){Lt.call(this,gt.arc(r,s,a,l,u,d)),this._center=r,this._xaxis=s,this._yaxis=a,this._radius=l,this._minAngle=u,this._maxAngle=d};x["verb.geom.Arc"]=Vr,Vr.__name__=["verb","geom","Arc"],Vr.__super__=Lt,Vr.prototype=M(Lt.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__:Vr});var is=f.geom.BezierCurve=function(r,s){Lt.call(this,gt.rationalBezierCurve(r,s))};x["verb.geom.BezierCurve"]=is,is.__name__=["verb","geom","BezierCurve"],is.__super__=Lt,is.prototype=M(Lt.prototype,{__class__:is});var as=f.geom.Circle=function(r,s,a,l){Vr.call(this,r,s,a,l,0,Math.PI*2)};x["verb.geom.Circle"]=as,as.__name__=["verb","geom","Circle"],as.__super__=Vr,as.prototype=M(Vr.prototype,{__class__:as});var Bn=function(){};x["verb.geom.ISurface"]=Bn,Bn.__name__=["verb","geom","ISurface"],Bn.__interfaces__=[Nn],Bn.prototype={__class__:Bn};var Et=f.geom.NurbsSurface=function(r){this._data=qe.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=Et,Et.__name__=["verb","geom","NurbsSurface"],Et.__interfaces__=[Bn],Et.byKnotsControlPointsWeights=function(r,s,a,l,u,d){return new Et(new ee(r,s,a,l,N.homogenize2d(u,d)))},Et.byCorners=function(r,s,a,l){return new Et(gt.fourPointSurface(r,s,a,l))},Et.byLoftingCurves=function(r,s){return new Et(gt.loftedSurface(function(a){for(var l,u=[],d=0;d<r.length;){var m=r[d];++d,u.push(m.asNurbs())}return l=u,l}(),s))},Et.__super__=Qt,Et.prototype=M(Qt.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 ee(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new Et(this.asNurbs())},domainU:function(){return new ke($.first(this._data.knotsU),$.last(this._data.knotsU))},domainV:function(){return new ke($.first(this._data.knotsV),$.last(this._data.knotsV))},point:function(r,s){return N.rationalSurfacePoint(this._data,r,s)},pointAsync:function(r,s){return At.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,s])},normal:function(r,s){return N.rationalSurfaceNormal(this._data,r,s)},normalAsync:function(r,s){return At.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,s])},derivatives:function(r,s,a){return a==null&&(a=1),N.rationalSurfaceDerivatives(this._data,r,s,a)},derivativesAsync:function(r,s,a){return a==null&&(a=1),At.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,s,a])},closestParam:function(r){return bt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return bt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return At.dispatchMethod(bt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,s){return s==null&&(s=!1),he.surfaceSplit(this._data,r,s).map(function(a){return new Et(a)})},splitAsync:function(r,s){return s==null&&(s=!1),At.dispatchMethod(he,"surfaceSplit",[this._data,r,s]).then(function(a){return a.map(function(l){return new Et(l)})})},reverse:function(r){return r==null&&(r=!1),new Et(_t.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),At.dispatchMethod(_t,"surfaceReverse",[this._data,r]).then(function(s){return new Et(s)})},isocurve:function(r,s){return s==null&&(s=!1),new Lt(gt.surfaceIsocurve(this._data,r,s))},isocurveAsync:function(r,s){return s==null&&(s=!1),At.dispatchMethod(gt,"surfaceIsocurve",[this._data,r,s]).then(function(a){return new Lt(a)})},boundaries:function(r){return gt.surfaceBoundaryCurves(this._data).map(function(s){return new Lt(s)})},boundariesAsync:function(r){return At.dispatchMethod(gt,"surfaceBoundaryCurves",[this._data]).then(function(s){return s.map(function(a){return new Lt(a)})})},tessellate:function(r){return zt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return At.dispatchMethod(zt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new Et(_t.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return At.dispatchMethod(_t,"rationalSurfaceTransform",[this._data,r]).then(function(s){return new Et(s)})},__class__:Et});var os=f.geom.ConicalSurface=function(r,s,a,l,u){Et.call(this,gt.conicalSurface(r,s,a,l,u)),this._axis=r,this._xaxis=s,this._base=a,this._height=l,this._radius=u};x["verb.geom.ConicalSurface"]=os,os.__name__=["verb","geom","ConicalSurface"],os.__super__=Et,os.prototype=M(Et.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__:os});var ls=f.geom.CylindricalSurface=function(r,s,a,l,u){Et.call(this,gt.cylindricalSurface(r,s,a,l,u)),this._axis=r,this._xaxis=s,this._base=a,this._height=l,this._radius=u};x["verb.geom.CylindricalSurface"]=ls,ls.__name__=["verb","geom","CylindricalSurface"],ls.__super__=Et,ls.prototype=M(Et.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__:ls});var Gr=f.geom.EllipseArc=function(r,s,a,l,u){Lt.call(this,gt.ellipseArc(r,s,a,l,u)),this._center=r,this._xaxis=s,this._yaxis=a,this._minAngle=l,this._maxAngle=u};x["verb.geom.EllipseArc"]=Gr,Gr.__name__=["verb","geom","EllipseArc"],Gr.__super__=Lt,Gr.prototype=M(Lt.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__:Gr});var hs=f.geom.Ellipse=function(r,s,a){Gr.call(this,r,s,a,0,Math.PI*2)};x["verb.geom.Ellipse"]=hs,hs.__name__=["verb","geom","Ellipse"],hs.__super__=Gr,hs.prototype=M(Gr.prototype,{__class__:hs});var us=f.geom.ExtrudedSurface=function(r,s){Et.call(this,gt.extrudedSurface(p.normalized(s),p.norm(s),r.asNurbs())),this._profile=r,this._direction=s};x["verb.geom.ExtrudedSurface"]=us,us.__name__=["verb","geom","ExtrudedSurface"],us.__super__=Et,us.prototype=M(Et.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:us});var jr=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=jr,jr.__name__=["verb","geom","Intersect"],jr.curves=function(r,s,a){return a==null&&(a=.001),lt.curves(r.asNurbs(),s.asNurbs(),a)},jr.curvesAsync=function(r,s,a){return a==null&&(a=.001),At.dispatchMethod(lt,"curves",[r.asNurbs(),s.asNurbs(),a])},jr.curveAndSurface=function(r,s,a){return a==null&&(a=.001),lt.curveAndSurface(r.asNurbs(),s.asNurbs(),a)},jr.curveAndSurfaceAsync=function(r,s,a){return a==null&&(a=.001),At.dispatchMethod(lt,"curveAndSurface",[r.asNurbs(),s.asNurbs(),a])},jr.surfaces=function(r,s,a){return a==null&&(a=.001),lt.surfaces(r.asNurbs(),s.asNurbs(),a).map(function(l){return new Lt(l)})},jr.surfacesAsync=function(r,s,a){return a==null&&(a=.001),At.dispatchMethod(lt,"surfaces",[r.asNurbs(),s.asNurbs(),a]).then(function(l){return l.map(function(u){return new Lt(u)})})};var cs=f.geom.Line=function(r,s){Lt.call(this,gt.polyline([r,s])),this._start=r,this._end=s};x["verb.geom.Line"]=cs,cs.__name__=["verb","geom","Line"],cs.__super__=Lt,cs.prototype=M(Lt.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:cs});var ds=f.geom.RevolvedSurface=function(r,s,a,l){Et.call(this,gt.revolvedSurface(r.asNurbs(),s,a,l)),this._profile=r,this._center=s,this._axis=a,this._angle=l};x["verb.geom.RevolvedSurface"]=ds,ds.__name__=["verb","geom","RevolvedSurface"],ds.__super__=Et,ds.prototype=M(Et.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:ds});var ps=f.geom.SphericalSurface=function(r,s){Et.call(this,gt.sphericalSurface(r,[0,0,1],[1,0,0],s)),this._center=r,this._radius=s};x["verb.geom.SphericalSurface"]=ps,ps.__name__=["verb","geom","SphericalSurface"],ps.__super__=Et,ps.prototype=M(Et.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:ps});var ms=f.geom.SweptSurface=function(r,s){Et.call(this,gt.rationalTranslationalSurface(r.asNurbs(),s.asNurbs())),this._profile=r,this._rail=s};x["verb.geom.SweptSurface"]=ms,ms.__name__=["verb","geom","SweptSurface"],ms.__super__=Et,ms.prototype=M(Et.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:ms});function Ze(r){return r instanceof Array?function(){return L.iter(r)}:typeof r.iterator=="function"?Be(r,r.iterator):r.iterator}var $i,nc=0;function Be(r,s){if(s==null)return null;s.__id__==null&&(s.__id__=nc++);var a;return r.hx__closures__==null?r.hx__closures__={}:a=r.hx__closures__[s.__id__],a==null&&(a=function(){return a.method.apply(a.scope,arguments)},a.scope=r,a.method=s,r.hx__closures__[s.__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 sc=x.Int={__name__:["Int"]},ic=x.Dynamic={__name__:["Dynamic"]},Ro=x.Float=Number;Ro.__name__=["Float"];var Fo=x.Bool=Boolean;Fo.__ename__=["Bool"];var Do=x.Class={__name__:["Class"]},Uo={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var s=[],a=0,l=this.length;a<l;){var u=a++;s[u]=r(this[u])}return s}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var s=[],a=0,l=this.length;a<l;){var u=a++,d=this[u];r(d)&&s.push(d)}return s});var Zi={},Xs=w.ArrayBuffer||le;Xs.prototype.slice==null&&(Xs.prototype.slice=le.sliceImpl),w.DataView;var Qi=w.Uint8Array||ar._new;(function(r,s){if(r.setImmediate)return;var a=1,l={},u=!1,d=r.document,m;function _(z){return l[a]=y.apply(s,z),a++}function y(z){var U=[].slice.call(arguments,1);return function(){typeof z=="function"?z.apply(s,U):new Function(""+z)()}}function A(z){if(u)setTimeout(y(A,z),0);else{var U=l[z];if(U){u=!0;try{U()}finally{I(z),u=!1}}}}function I(z){delete l[z]}function S(){m=function(){var z=_(arguments);return process.nextTick(y(A,z)),z}}function P(){if(r.postMessage&&!r.importScripts){var z=!0,U=r.onmessage;return r.onmessage=function(){z=!1},r.postMessage("","*"),r.onmessage=U,z}}function k(){var z="setImmediate$"+Math.random()+"$",U=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(z)===0&&A(+V.data.slice(z.length))};r.addEventListener?r.addEventListener("message",U,!1):r.attachEvent("onmessage",U),m=function(){var V=_(arguments);return r.postMessage(z+V,"*"),V}}function T(){var z=new MessageChannel;z.port1.onmessage=function(U){var V=U.data;A(V)},m=function(){var U=_(arguments);return z.port2.postMessage(U),U}}function O(){var z=d.documentElement;m=function(){var U=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){A(U),V.onreadystatechange=null,z.removeChild(V),V=null},z.appendChild(V),U}}function C(){m=function(){var z=_(arguments);return setTimeout(y(A,z),0),z}}var R=Object.getPrototypeOf&&Object.getPrototypeOf(r);R=R&&R.setTimeout?R:r,{}.toString.call(r.process)==="[object process]"?S():P()?k():r.MessageChannel?T():d&&"onreadystatechange"in d.createElement("script")?O():C(),R.setImmediate=m,R.clearImmediate=I})(new Function("return this")()),Xt.USE_CACHE=!1,Xt.USE_ENUM_INDEX=!1,Xt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Ht.DEFAULT_RESOLVER=ut,Ht.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Bt.count=0,oe.i64tmp=function(r){var s,a=new Gt(0,0);return s=a,s}(),Ct.__toStr={}.toString,ar.BYTES_PER_ELEMENT=1,It.queue=new D,Ft.memo=new wt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",bt.Tvalues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],bt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],At.THREADS=1,At._init=!1,Ur.basePath="",en.uuid=0,Ys.main()}(typeof console<"u"?console:{log:function(){}},e,typeof c<"u"?c:typeof n<"u"?n:typeof self<"u"?self:this),e})})(uh);var Dc=uh.exports;const Dn=Fc(Dc);class la{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,n,o){this.c0=t,this.c1=n,this.c2=-3*t+3*e-2*n-o,this.c3=2*t-2*e+n+o}initCatmullRom(t,e,n,o,h){this.init(e,n,h*(n-t),h*(o-e))}initNonuniformCatmullRom(t,e,n,o,h,c,g){let b=(e-t)/h-(n-t)/(h+c)+(n-e)/c,f=(n-e)/c-(o-e)/(c+g)+(o-n)/g;b*=c,f*=c,this.init(e,n,b,f)}calc(t){const e=t*t,n=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*n}}let ch=class extends Hs{constructor(t=[],e=!1,n="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=t.map(h=>new Y(h)),this._closed=e,this._curveType=n,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 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 Y){const n=e,o=this._points,h=o.length;if(h===0)return n.set(0,0,0);if(h===1)return n.copy(o[0]);const c=(h-(this._closed?0:1))*t;let g=Math.floor(c),b=c-g;this._closed?g+=g>0?0:(Math.floor(Math.abs(g)/h)+1)*h:b===0&&g===h-1&&(g=h-2,b=1);let f,w;this._closed||g>0?f=o[(g-1)%h]:(this._tmp.subVectors(o[0],o[1]).add(o[0]),f=new Y(this._tmp.x,this._tmp.y,this._tmp.z));const x=o[g%h],E=o[(g+1)%h];if(this._closed||g+2<h?w=o[(g+2)%h]:(this._tmp.subVectors(o[h-1],o[h-2]).add(o[h-1]),w=new Y(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const M=this._curveType==="chordal"?.5:.25;let L=Math.pow(f.distanceToSquared(x),M),B=Math.pow(x.distanceToSquared(E),M),D=Math.pow(E.distanceToSquared(w),M);B<1e-4&&(B=1),L<1e-4&&(L=B),D<1e-4&&(D=B),this._px.initNonuniformCatmullRom(f.x,x.x,E.x,w.x,L,B,D),this._py.initNonuniformCatmullRom(f.y,x.y,E.y,w.y,L,B,D),this._pz.initNonuniformCatmullRom(f.z,x.z,E.z,w.z,L,B,D)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(f.x,x.x,E.x,w.x,this._tension),this._py.initCatmullRom(f.y,x.y,E.y,w.y,this._tension),this._pz.initCatmullRom(f.z,x.z,E.z,w.z,this._tension));return n.set(this._px.calc(b),this._py.calc(b),this._pz.calc(b)),n}getPoints(t){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}setPoints(t){this._points=t.map(e=>new Y(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 n=new Y;return n.copy(e),n.applyMatrix4(t),n}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Nt;const t=new Nt;return this._points.forEach(e=>{t.expandByPoint(e)}),t}};class bn{constructor(t,e,n,o){this._degree=t,this._knots=[...e],this._controlPoints=n.map(h=>({x:h.x,y:h.y,z:h.z})),this._weights=o?[...o]:new Array(n.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(n=>[n.x,n.y,n.z]);return Bs(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return rh(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,n,o){return new bn(t,e,n,o)}static byPoints(t,e,n="Uniform"){let o;switch(n){case"Chord":o=th(e,t);break;case"SqrtChord":o=eh(e,t);break;case"Uniform":default:o=Jl(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 bn(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:n,end:o}=this.getParameterRange();for(let h=0;h<=t;h++){const c=n+(o-n)*(h/t);e.push(this.point(c))}return e}isClosed(t=1e-6){const{start:e,end:n}=this.getParameterRange(),o=this.point(e),h=this.point(n),c=o[0]-h[0],g=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(c*c+g*g+b*b)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new ch(t,!0,"centripetal"),n=Math.max(50,t.length*2);return e.getPoints(n)}static createClosedCurve(t,e,n="Chord"){const o=this.createFitPointsForClosedCurve(t).map(h=>[h.x,h.y,h.z]);return bn.byPoints(o,e,n)}}class Zr extends Hs{constructor(t,e,n,o,h){super();const c=arguments.length;if(c<2||c>5)throw He.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let g,b=3,f=!1;if(c>=3&&(Array.isArray(n)?(g=n,c>=4&&(b=o||3),c>=5&&(f=h)):n!==void 0&&(b=n||3,c>=4&&(f=o))),n===void 0&&c>=4&&(b=o||3,c>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw He.ILLEGAL_PARAMETERS;const w=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Dn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,w,g)}else{if(this._fitPoints=t,this._knotParameterization=e,c>=3&&(this._degree=n||3),c>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw He.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Dn.geom.NurbsCurve.byPoints(g,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=bn.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Dn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Dn.geom.NurbsCurve.byPoints(t,this._degree)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else if(this._controlPoints)if(this._closed){const t=bn.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Dn.geom.NurbsCurve.byPoints(e,this._degree),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints())}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights(),n=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Dn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,t,n,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(),n=t[e],o=this._nurbsCurve.point(n);return new Y(o[0],o[1],o[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),n=t[t.length-e-1],o=this._nurbsCurve.point(n);return new Y(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,n=t<0||t>=e?e-1:t,o=this._fitPoints[n];return{x:o.x,y:o.y,z:o.z||0}}getControlPointAt(t){const e=this._controlPoints.length,n=t<0||t>=e?e-1:t;return this._controlPoints[n]}getPoints(t=100){const e=this._nurbsCurve,n=[],o=e.knots(),h=this._nurbsCurve.degree(),c=o[h],g=o[o.length-h-1],b=(g-c)/(t-1);for(let f=0;f<t;f++){const w=f===t-1?g:c+f*b,x=e.point(w);n.push(new Y(x[0],x[1],x[2]))}return n}getCurvePoints(t,e){const n=[],o=t.knots(),h=o[3],c=(o[o.length-4]-h)/(e-1);for(let g=0;g<e;g++){const b=h+g*c;n.push(t.point(b))}return n}calculateBoundingBox(){const t=this.getPoints(100);return new Nt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((n,o)=>{e[o]=[n.x,n.y,n.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((n,o)=>{e[o]=[n.x,n.y,n.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((n,o)=>{e[o]={x:n[0],y:n[1],z:n[2]}}),e}static createClosedSpline(t,e="Uniform",n=3){if(t.length<n+1)throw new Error(`At least ${n+1} points are required for a degree ${n} closed spline`);return new Zr(t,e,n,!0)}}var vn=256,dh=[],ll=256,Zs;for(;vn--;)dh[vn]=(vn+256).toString(16).substring(1);function Uc(i){var t=0,e=11;if(!Zs||vn+e>ll*2)for(Zs="",vn=0;t<ll;t++)Zs+=dh[Math.random()*256|0];return Zs.substring(vn,vn+++e)}class Jr{constructor(t,e){t=t||{},Hn(t,{objectId:Uc()}),this._attrs=new wl(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:ro().workingDatabase}set database(t){this._database=t}close(){}}const no=class no extends Jr{constructor(){super(...arguments),this._layer="0",this._color=new Qr,this._lineType=ei,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=new Ui}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 n=this.getLayerColor();n&&n.RGB!=null&&(t=n)}else this.color.isByBlock||this.color.RGB!=null&&(t=this.color);const e=t.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||ei}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.clone()}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,n,o){}transformBy(t){return this}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:t=>{this.layer=t}}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:t=>{this.color.copy(t)}}}]}}get lineStyle(){var o;const{type:t,name:e}=this.getLineType(),n=(o=this.database)==null?void 0:o.tables.linetypeTable.getAt(e);return n?{type:t,...n.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==ei){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Ml?{type:"ByBlock",name:li}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:li}}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}attachEntityInfo(t){t&&(t.objectId=this.objectId,this.attrs.has("ownerId")&&(t.ownerId=this.ownerId),t.layerName=this.layer,t.visible=this.visibility)}};no.typeName="Entity";let Pe=no;const so=class so extends Pe{};so.typeName="Curve";let Ee=so;var Vn=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(Vn||{});const io=class io extends Ee{constructor(t,e,n=0,o=!1,h=0,c=0,g=null){super(),this._polyType=t,this._elevation=n;const b=g&&(g==null?void 0:g.length)===e.length,f=e.map((w,x)=>({x:w.x,y:w.y,bulge:b?g[x]:void 0}));this._geo=new wn(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 Nt({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 Y().set(o.x,o.y,this.elevation))),t.lines(e)}};io.typeName="2dPolyline";let ci=io;var ph=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(ph||{});const ao=class ao extends Pe{constructor(){super(),this._position=new Y,this._bulge=0,this._startWidth=0,this._endWidth=0,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get bulge(){return this._bulge}set bulge(t){this._bulge=t}get startWidth(){return this._startWidth}set startWidth(t){this._startWidth=t}get endWidth(){return this._endWidth}set endWidth(t){this._endWidth=t}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};ao.typeName="2dVertex";let Aa=ao;var Rs=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(Rs||{});const oo=class oo extends Ee{constructor(t,e,n=!1){super(),this._polyType=t,this._geo=new wn(e,n)}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 Nt({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 Y().set(o.x,o.y,0))),t.lines(e)}};oo.typeName="3dPolyline";let di=oo;var mh=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(mh||{});const lo=class lo extends Pe{constructor(){super(),this._position=new Y,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new Nt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};lo.typeName="3dVertex";let Sa=lo;const ho=class ho extends Ee{constructor(t,e,n,o,h=Z.Z_AXIS){super(),this._geo=new Ga(t,e,n,o,h,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 normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}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)}};ho.typeName="Arc";let pi=ho;const uo=class uo extends Pe{constructor(t){super(),this._blockName=t,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(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 properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:t=>{this.scaleFactors.x=t}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:t=>{this.scaleFactors.y=t}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:t=>{this.scaleFactors.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}get geometricExtents(){const t=new Nt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const c of h)t.union(c.geometricExtents)}const n=new Kr().setFromEuler(new ah(this.rotation,0,0)),o=new $r;return o.compose(this.position,n,this.scaleFactors),t.applyMatrix4(o),t}draw(t){const e=[],n=this.blockTableRecord;if(n!=null){const o=this.computeTransformMatrix(),h=Xr.instance.draw(t,n,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 Kr;return t.setFromAxisAngle(Z.Z_AXIS,this.rotation),new $r().compose(this._position,t,this._scaleFactors)}};uo.typeName="BlockReference";let Us=uo;const co=class co extends Ee{constructor(t,e,n=Z.Z_AXIS){super(),this._geo=new Ga(t,e,0,se,n,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}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}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)}};co.typeName="Circle";let mi=co;const po=class po extends Ee{constructor(t,e,n,o,h,c,g){super(),this._geo=new Wi(t,e,n,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 startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}draw(t){return t.ellipticalArc(this._geo)}};po.typeName="Ellipse";let gi=po;const mo=class mo extends Pe{constructor(){super(),this._vertices=[new Y,new Y,new Y],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 Y),this._vertices[3].copy(e);this._vertices[t].copy(e)}setEdgeInvisibilities(t){this._edgeInvisibilities=t}isEdgeVisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<t)===0}makeEdgeInvisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<t}get geometricExtents(){return new Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._vertices.length;++e)t.push(this.getVertexAt(e));return t}draw(t){const e=this._vertices.length,n=new Float32Array(e*3),o=new Uint16Array(e*2);for(let h=0;h<e;h++)n[h*3]=this._vertices[h].x,n[h*3+1]=this._vertices[h].y,n[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(o[h*2]=h,o[h*2+1]=(h+1)%4);return t.lineSegments(n,3,o)}};mo.typeName="Face";let fi=mo;var gh=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(gh||{}),fh=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(fh||{});const go=class go extends Pe{constructor(){super(),this._elevation=0,this._geo=new Gi,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(t){this._isSolidFill=t}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){const e=t.subEntityTraits;return e.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,patternLines:this.definitionLines},t.area(this._geo)}};go.typeName="Hatch";let Vs=go;var _h=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(_h||{});const fo=class fo extends Ee{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 Y().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Nt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e)}else return t.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Zr(this._vertices,"Uniform"),this._updated=!1)}};fo.typeName="Leader";let _i=fo;var yn=(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))(yn||{});const _o=class _o extends Ee{constructor(t,e){super(),this._geo=new ui(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,n,o){const h=this.startPoint,c=this.endPoint;switch(t){case yn.EndPoint:o.push(h),o.push(c);break;case yn.MidPoint:o.push(this.midPoint);break;case yn.Nearest:{const g=this._geo.project(e);o.push(g)}break;case yn.Perpendicular:{const g=this._geo.perpPoint(e);o.push(g)}break;case yn.Tangent:o.push(h);break}}transformBy(t){return this._geo.transform(t),this}draw(t){const e=this.startPoint,n=this.endPoint,o=[new Y(e.x,e.y,0),new Y(n.x,n.y,0)];return t.lines(o)}};_o.typeName="Line";let yi=_o;var Wa=(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))(Wa||{}),Lr=(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))(Lr||{}),Ie=(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))(Ie||{}),Ha=(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))(Ha||{}),Ya=(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))(Ya||{}),qa=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(qa||{});let yh=class vh{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(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new ve;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new ve;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new vh;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 yo=class yo extends Pe{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=Ie.TopLeft,this._direction=new Z(1,0,0),this._drawingDirection=Lr.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Nt}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:Ie[1],value:1},{label:Ie[2],value:2},{label:Ie[3],value:3},{label:Ie[4],value:4},{label:Ie[5],value:5},{label:Ie[6],value:6},{label:Ie[7],value:7},{label:Ie[8],value:8},{label:Ie[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Lr[1],value:1},{label:Lr[2],value:2},{label:Lr[3],value:3},{label:Lr[4],value:4},{label:Lr[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t,e){const n={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()};return t.mtext(n,o,e)}};yo.typeName="MText";let vi=yo;const vo=class vo extends Ee{constructor(t,e,n,o,h){super();const c=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(c<2||c>5)throw He.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Zr(t,e,n,o):this._geo=new Zr(t,e,n,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)}};vo.typeName="Spline";let Gs=vo;const Vc=new Z,bo=class bo extends Us{constructor(t,e,n){super(t),this._attachmentPoint=Ie.TopLeft,this._numColumns=n,this._numRows=e,this._columnWidth=new Array(n),this._rowHeight=new Array(e),this._cells=new Array(e*n)}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,n){return this._cells[t*e].text}setTextString(t,e,n){this._cells[t*e].text=n}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Nt}draw(t){let e=0,n=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,n=0;for(let M=0;M<=this.numColumns;M++)n+=M>0?this.columnWidth(M-1):0,h[c++]=n,h[c++]=e,h[c++]=0}const g=[],b=new Array(this.numRows*this.numColumns).fill(!1);n=0,c=0;let f=0;for(let E=0;E<this.numColumns;E++){n+=E>0?this.columnWidth(E-1):0,e=0;for(let M=0;M<this.numRows;M++){e+=M>0?this.rowHeight(M-1):0;const L=this.cell(M*this.numColumns+E);if(f=M*this.numColumns+E,L&&!b[f]){const B=L.borderWidth??1,D=L.borderHeight??1;this.fillVisited(b,f,this.numColumns,B,D),o[c++]=E+M*(this.numColumns+1),o[c++]=E+M*(this.numColumns+1)+B;const F=h[o[c-1]*3]-n,dt=E+(M+D)*(this.numColumns+1)+B;E+B==this.numColumns&&(o[c++]=E+M*(this.numColumns+1)+B,o[c++]=dt);const vt=-h[dt*3+1]-e;if(M+D==this.numRows&&(o[c++]=E+(M+D)*(this.numColumns+1)+D,o[c++]=E+(M+D)*(this.numColumns+1)),o[c++]=E+(M+D)*(this.numColumns+1),o[c++]=E+M*(this.numColumns+1),L.text){const ot=L.attachmentPoint||this.attachmentPoint||Ie.MiddleCenter,W=this.getTableTextOffset(ot,F,vt),ut={text:L.text,height:L.textHeight,width:F,position:Vc.set(n,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ot},st=this.getTextStyle(L);g.push(t.mtext(ut,st))}}}}g.push(t.lineSegments(h,3,o));const w=t.group(g),x=new Kr;return x.setFromAxisAngle(Z.Z_AXIS,this.rotation),hl.compose(this.position,x,this.scaleFactors),w.applyMatrix(hl),this.attachEntityInfo(w),w}fillVisited(t,e,n,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*n]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let n;return t.textStyle&&(n=e.getAt(t.textStyle)),n||(n=e.getAt("STANDARD")||e.getAt("Standard")),n.textStyle}getTableTextOffset(t,e,n){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(-n/2);break;case 5:o.set(e/2,-n/2,0);break;case 6:o.set(e,-n/2,0);break;case 7:o.setY(-n);break;case 8:o.set(e/2,-n,0);break;case 9:o.set(e,-n,0);break}return o}};bo.typeName="Table";let bi=bo;const hl=new $r;var bh=(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))(bh||{}),xh=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(xh||{});const xo=class xo extends Pe{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(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new Nt}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable;let e=t.getAt(this.styleName);return e||(e=t.getAt("STANDARD")||t.getAt("Standard")),e.textStyle}draw(t,e){const n={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Lr.BOTTOM_TO_TOP,attachmentPoint:Ie.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return t.mtext(n,o,e)}};xo.typeName="Text";let xi=xo;const wo=class wo extends Ee{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(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new Nt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new wn(this._vertices,!0),n=new Gi;n.add(e);const o=t.subEntityTraits;return o.fillType={solidFill:!0,patternAngle:0,patternLines:[]},t.area(n)}};wo.typeName="Trace";let wi=wo;const Ao=class Ao extends Ee{constructor(){super(),this._elevation=0,this._geo=new wn}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,n=0,o=-1,h=-1){const c=o<0?void 0:o,g=h<0?void 0:h,b={x:e.x,y:e.y,bulge:n,startWidth:c,endWidth:g};this._geo.addVertexAt(t,b)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new Y(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Nt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,this.elevation))),t.lines(e)}};Ao.typeName="Polyline";let Ai=Ao;const So=class So extends Pe{constructor(){super(),this._geo=new Y}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new Nt().expandByPoint(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}draw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}};So.typeName="Point";let Si=So;var wh=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(wh||{}),Ah=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(Ah||{});const Io=class Io extends Pe{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new Y,this._scale=new Zt(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 Nt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,n=this._height,o=new ve;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*n),this._clipBoundary.forEach(c=>{const g=c.x*e+h.x,b=c.y*n+h.y;t.push(new Y(g,b,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){ul.copy(t[1]);for(let e=1;e<4;e++)Qs.copy(t[e]),Qs.rotateAround(ul,this._rotation),t[e].setX(Qs.x),t[e].setY(Qs.y)}t.push(t[0])}return t}};Io.typeName="RasterImage";let js=Io;const ul=new Tt,Qs=new Tt,Po=class Po extends Ee{constructor(){super(),this._basePoint=new Y,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 Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}draw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}};Po.typeName="Ray";let Ii=Po;const Eo=class Eo extends Pe{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(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new Nt}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport(),n=t.group(this.createViewportRect(e,t));return this.attachEntityInfo(n),n}}toGiViewport(){const t=new yh;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 n=[];return n.push(e.lines([new Y(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new Y(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),n.push(e.lines([new Y(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new Y(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new Y(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new Y(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new Y(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new Y(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),n}};Eo.typeName="Viewport";let Pi=Eo;const ko=class ko extends js{draw(t){const e=this.boundaryPath(),n=new Gi;return n.add(new wn(e)),t.area(n)}};ko.typeName="Wipeout";let Ei=ko;const Mo=class Mo extends Ee{constructor(){super(),this._basePoint=new Y,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 Nt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}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)}};Mo.typeName="Xline";let ki=Mo;var Sh=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(Sh||{});const To=class To extends Pe{constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new Y,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new Y,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 Wn),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 n=this.database.tables.blockTable.getAt(this.dimBlockId);if(n){const o=new $r().makeTranslation(this.dimBlockPosition),h=Xr.instance.draw(t,n,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 Xr.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Xr.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,n){const o=new Y().subVectors(e,t).normalize();return new Y(e).addScaledVector(o,n)}findPointOnLine2(t,e,n){const o=t.x+n*Math.cos(e),h=t.y+n*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():Wa.Closed}};To.typeName="Dimension";let Or=To;const No=class No extends Or{constructor(t,e,n,o,h=null,c=null){super(),this._centerPoint=new Y().copy(t),this._xLine1Point=new Y().copy(e),this._xLine2Point=new Y().copy(n),this._arcPoint=new Y().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 Nt}};No.typeName="3PointAngularDimension";let Mi=No;const Co=class Co extends Or{constructor(t,e,n,o=null,h=null){super(),this._dimLinePoint=new Y().copy(n),this._xLine1Point=new Y().copy(t),this._xLine2Point=new Y().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 Nt}get isAppendArrow(){return!1}};Co.typeName="AlignedDimension";let Ti=Co;const Lo=class Lo extends Or{constructor(t,e,n,o,h=null,c=null){super(),this._arcPoint=new Y().copy(o),this._xLine1Point=new Y().copy(e),this._xLine2Point=new Y().copy(n),this._centerPoint=new Y().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 Nt}};Lo.typeName="ArcDimension";let Ia=Lo;const Oo=class Oo extends Or{constructor(t,e,n=0,o=null,h=null){super(),this._chordPoint=new Y().copy(t),this._farChordPoint=new Y().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=n,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 Nt}drawLines(t,e){const n=[],o=e.length;return o==1?n.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(e),n.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),n.push(this.drawLine(t,e[1])),n.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{n.push(this.drawLine(t,h))}),n}drawLine(t,e,n){if(n){const o=[e.startPoint,e.endPoint];return t.lines(o)}else return e.draw(t)}sortLines(t){const e=(n,o)=>n.x!==o.x?n.x-o.x:n.y!==o.y?n.y-o.y:n.z-o.z;t.sort((n,o)=>{const h=e(n.startPoint,o.startPoint);return h!==0?h:e(n.endPoint,o.endPoint)})}};Oo.typeName="DiametricDimension";let Ni=Oo;const Bo=class Bo extends Or{constructor(t,e,n=null,o=null){super(),this._definingPoint=new Y().copy(t),this._leaderEndPoint=new Y().copy(e),this.dimensionText=n,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 Nt}get arrowLineCount(){return 0}};Bo.typeName="OrdinateDimension";let Ci=Bo;const zo=class zo extends Or{constructor(t,e,n,o=null,h=null){super(),this._center=new Y().copy(t),this._chordPoint=new Y().copy(e),this._leaderLength=n,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 Nt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};zo.typeName="RadialDimension";let Li=zo;class Hi extends Jr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new ve,this._extents=new Nt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class Xa extends Jr{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((n,o)=>{n===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 Yi(this._recordsByName)}}class Ih extends Xa{getBtrIdAt(t){for(const[e,n]of this._recordsByName)if(n.blockTableRecordId==t)return n}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Ph extends Jr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class Eh{constructor(t){this.db=t}createDefaultLayer(){const t=new Qr;return t.colorIndex=7,this.db.tables.layerTable.add(new Xi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new Ds({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Ds({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Ds({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new eo({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Wn({name:"Standard",dimtxsty:"Standard"}))}createDefaultLayout(){const t=new Hi;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this.db.tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.dictionaries.layouts.setAt(t.layoutName,t),this.db.tables.blockTable.modelSpace.layoutId=t.objectId}createArrowBlock(){if(!this.db.tables.blockTable.getAt("_CAXARROW")){const e=new Vs;e.patternName="SOLID";const n=new ja;n.add(new zs({x:0,y:0},{x:-1,y:.125})),n.add(new zs({x:-1,y:.125},{x:-1,y:-.125})),n.add(new zs({x:-1,y:-.125},{x:0,y:0})),e.add(n);const o=new pe;o.name="_CAXARROW",o.appendEntity(e),this.db.tables.blockTable.add(o)}}}var Ka=(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))(Ka||{});function Gc(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function jc(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}var kh=(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))(kh||{});class Yi{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 Mh="Load Database";class Ne extends Sl{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=ka.getInstance().getEntry(Mh),n=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()-n),o}}class $a{constructor(t={}){this.config=t}async read(t,e,n,o){const h={name:Mh,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(w=>{w!=="total"&&(f+=`- ${w}: ${this.data[w]} ms
5
+ `)}),f+=`- total: ${this.data.total} ms`,f}};ka.getInstance().collect(h),this.progress=o;const c={value:0},g=new Il;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new Ne({stage:"START",step:1,progress:c,task:async f=>f},o)),g.addTask(new Ne({stage:"PARSE",step:5,progress:c,task:async f=>await this.parse(f)},o)),g.addTask(new Ne({stage:"FONT",step:5,progress:c,task:async f=>{const w=this.getFonts(f.model);return{model:f.model,data:w}}},o)),g.addTask(new Ne({stage:"LTYPE",step:1,progress:c,task:async f=>(this.processLineTypes(f.model,e),f)},o)),g.addTask(new Ne({stage:"STYLE",step:1,progress:c,task:async f=>(this.processTextStyles(f.model,e),f)},o)),g.addTask(new Ne({stage:"DIMSTYLE",step:1,progress:c,task:async f=>(this.processDimStyles(f.model,e),f)},o)),g.addTask(new Ne({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 Ne({stage:"VPORT",step:1,progress:c,task:async f=>(this.processViewports(f.model,e),f)},o)),g.addTask(new Ne({stage:"HEADER",step:1,progress:c,task:async f=>(this.processHeader(f.model,e),f)},o)),g.addTask(new Ne({stage:"BLOCK_RECORD",step:5,progress:c,task:async f=>(this.processBlockTables(f.model,e),f)},o)),g.addTask(new Ne({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 Ne({stage:"BLOCK",step:5,progress:c,task:async f=>(await this.processBlocks(f.model,e),f)},o)),g.addTask(new Ne({stage:"ENTITY",step:100,progress:c,task:async f=>(await this.processEntities(f.model,e,n,c,o),f)},o)),g.addTask(new Ne({stage:"END",step:0,progress:c,task:async f=>f},o));const b=Date.now();await g.run(t),h.data.total=Date.now()-b}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"),Xr.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,n,o,h){throw new Error("Not impelemented yet!")}}var ue,gs,Jt,ie,fs,nr,xe,vr,sr,on,_s,ys,ln,hn,vs,bs,xs,Fe,br,qt,un,ws,yt,we,As,Ae,Ss,xr,wr,ir,Is,cn,De,Ar,dn,ha,ua,Sr,Ir,Ps,Es,Pr,ks,ca,da,ce,Er,de,Ue,pa,ma,ga,fa,kr,Ve,pn,Ms,mn,Ge,Mr,je,Tr;(ue={})[ue.None=0]="None",ue[ue.Anonymous=1]="Anonymous",ue[ue.NonConstant=2]="NonConstant",ue[ue.Xref=4]="Xref",ue[ue.XrefOverlay=8]="XrefOverlay",ue[ue.ExternallyDependent=16]="ExternallyDependent",ue[ue.ResolvedOrDependent=32]="ResolvedOrDependent",ue[ue.ReferencedXref=64]="ReferencedXref";(gs={})[gs.BYBLOCK=0]="BYBLOCK",gs[gs.BYLAYER=256]="BYLAYER";(Jt={})[Jt.Rotated=0]="Rotated",Jt[Jt.Aligned=1]="Aligned",Jt[Jt.Angular=2]="Angular",Jt[Jt.Diameter=3]="Diameter",Jt[Jt.Radius=4]="Radius",Jt[Jt.Angular3Point=5]="Angular3Point",Jt[Jt.Ordinate=6]="Ordinate",Jt[Jt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Jt[Jt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Jt[Jt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(ie={})[ie.TopLeft=1]="TopLeft",ie[ie.TopCenter=2]="TopCenter",ie[ie.TopRight=3]="TopRight",ie[ie.MiddleLeft=4]="MiddleLeft",ie[ie.MiddleCenter=5]="MiddleCenter",ie[ie.MiddleRight=6]="MiddleRight",ie[ie.BottomLeft=7]="BottomLeft",ie[ie.BottomCenter=8]="BottomCenter",ie[ie.BottomRight=9]="BottomRight";(fs={})[fs.AtLeast=1]="AtLeast",fs[fs.Exact=2]="Exact";var cl=((nr={})[nr.Center=0]="Center",nr[nr.Above=1]="Above",nr[nr.Outside=2]="Outside",nr[nr.JIS=3]="JIS",nr[nr.Below=4]="Below",nr),Un=((xe={})[xe.Feet=0]="Feet",xe[xe.None=1]="None",xe[xe.Inch=2]="Inch",xe[xe.FeetAndInch=3]="FeetAndInch",xe[xe.Leading=4]="Leading",xe[xe.Trailing=8]="Trailing",xe[xe.LeadingAndTrailing=12]="LeadingAndTrailing",xe),Wc=((vr={})[vr.None=0]="None",vr[vr.Leading=1]="Leading",vr[vr.Trailing=2]="Trailing",vr[vr.LeadingAndTrailing=3]="LeadingAndTrailing",vr),Hc=((sr={})[sr.Center=0]="Center",sr[sr.Left=1]="Left",sr[sr.Right=2]="Right",sr[sr.OverFirst=3]="OverFirst",sr[sr.OverSecond=4]="OverSecond",sr),Yc=((on={})[on.Bottom=0]="Bottom",on[on.Center=1]="Center",on[on.Top=2]="Top",on),qc=((_s={})[_s.PatternFill=0]="PatternFill",_s[_s.SolidFill=1]="SolidFill",_s);(ys={})[ys.NonAssociative=0]="NonAssociative",ys[ys.Associative=1]="Associative";(ln={})[ln.Normal=0]="Normal",ln[ln.Outer=1]="Outer",ln[ln.Ignore=2]="Ignore";(hn={})[hn.UserDefined=0]="UserDefined",hn[hn.Predefined=1]="Predefined",hn[hn.Custom=2]="Custom";(vs={})[vs.NotAnnotated=0]="NotAnnotated",vs[vs.Annotated=1]="Annotated";(bs={})[bs.Solid=0]="Solid",bs[bs.Gradient=1]="Gradient";(xs={})[xs.TwoColor=0]="TwoColor",xs[xs.OneColor=1]="OneColor";var Xc=((Fe={})[Fe.Default=0]="Default",Fe[Fe.External=1]="External",Fe[Fe.Polyline=2]="Polyline",Fe[Fe.Derived=4]="Derived",Fe[Fe.Textbox=8]="Textbox",Fe[Fe.Outermost=16]="Outermost",Fe),Js=((br={})[br.Line=1]="Line",br[br.Circular=2]="Circular",br[br.Elliptic=3]="Elliptic",br[br.Spline=4]="Spline",br),Kc=((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);Kc.Off;(un={})[un.Standard=-3]="Standard",un[un.ByLayer=-2]="ByLayer",un[un.ByBlock=-1]="ByBlock";(ws={})[ws.English=0]="English",ws[ws.Metric=1]="Metric";(yt={})[yt.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",yt[yt.FRONT_CLIPPING=2]="FRONT_CLIPPING",yt[yt.BACK_CLIPPING=4]="BACK_CLIPPING",yt[yt.UCS_FOLLOW=8]="UCS_FOLLOW",yt[yt.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",yt[yt.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",yt[yt.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",yt[yt.FAST_ZOOM=128]="FAST_ZOOM",yt[yt.SNAP_MODE=256]="SNAP_MODE",yt[yt.GRID_MODE=512]="GRID_MODE",yt[yt.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",yt[yt.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",yt[yt.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",yt[yt.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",yt[yt.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",yt[yt.UNUSED=32768]="UNUSED",yt[yt.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",yt[yt.VIEWPORT_OFF=131072]="VIEWPORT_OFF",yt[yt.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",yt[yt.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",yt[yt.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",yt[yt.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(we={})[we.OPTIMIZED_2D=0]="OPTIMIZED_2D",we[we.WIREFRAME=1]="WIREFRAME",we[we.HIDDEN_LINE=2]="HIDDEN_LINE",we[we.FLAT_SHADED=3]="FLAT_SHADED",we[we.GOURAUD_SHADED=4]="GOURAUD_SHADED",we[we.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",we[we.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(As={})[As.UCS_UNCHANGED=0]="UCS_UNCHANGED",As[As.HAS_OWN_UCS=1]="HAS_OWN_UCS";(Ae={})[Ae.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",Ae[Ae.TOP=1]="TOP",Ae[Ae.BOTTOM=2]="BOTTOM",Ae[Ae.FRONT=3]="FRONT",Ae[Ae.BACK=4]="BACK",Ae[Ae.LEFT=5]="LEFT",Ae[Ae.RIGHT=6]="RIGHT";(Ss={})[Ss.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Ss[Ss.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(xr={})[xr.ByLayer=0]="ByLayer",xr[xr.ByBlock=1]="ByBlock",xr[xr.ByDictionaryDefault=2]="ByDictionaryDefault",xr[xr.ByObject=3]="ByObject";function St(i,t,e){return i.code===t&&(e==null||i.value===e)}function Rt(i){let t={};i.rewind();let e=i.next(),n=e.code;if(t.x=e.value,(e=i.next()).code!==n+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=i.next()).code!==n+20?i.rewind():t.z=e.value,t}let Za=Symbol();function xt(i,t){return(e,n,o)=>{let h=function(b,f=!1){return b.reduce((w,x)=>{x.pushContext&&w.push({});let E=w[w.length-1];for(let M of typeof x.code=="number"?[x.code]:x.code){let L=E[M]??(E[M]=[]);x.isMultiple&&L.length&&f&&console.warn(`Snippet ${L[L.length-1].name} for code(${M}) is shadowed by ${x.name}`),L.push(x)}return w},[{}])}(i,n.debug),c=!1,g=h.length-1;for(;!St(e,0,"EOF");){let b=function(D,F,dt){return D.find((vt,ot)=>{var W;return ot>=dt&&((W=vt[F])==null?void 0:W.length)})}(h,e.code,g),f=b==null?void 0:b[e.code],w=f==null?void 0:f[f.length-1];if(!b||!w){n.rewind();break}w.isMultiple||b[e.code].pop();let{name:x,parser:E,isMultiple:M,isReducible:L}=w,B=E==null?void 0:E(e,n,o);if(B===Za){n.rewind();break}if(x){let[D,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=_a(ot[ut]),Gt=_a(ot[ut+1]);Object.prototype.hasOwnProperty.call(W,st)||(typeof Gt=="number"?W[st]=[]:W[st]={}),W=W[st]}return[W,_a(ot[ot.length-1])]}(o,x);M&&!L?(Object.prototype.hasOwnProperty.call(D,F)||(D[F]=[]),D[F].push(B)):D[F]=B}w.pushContext&&(g-=1),c=!0,e=n.next()}return t&&Object.setPrototypeOf(o,t),c}}function _a(i){let t=Number.parseInt(i);return Number.isNaN(t)?i:t}function v({value:i}){return i}function j(i,t){return Rt(t)}function Dt({value:i}){return!!i}let $c=[{code:1001,name:"xdata",parser:Th}];function Th(i,t){var o;if(!St(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let n=[e.value];for(;!St(i,0,"EOF")&&i.code>=1e3;){let h=n[n.length-1];switch(i.code){case 1002:i.value==="{"?n.push([]):(n.pop(),(o=n[n.length-1])==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Nr(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Nr(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Nr(i.code),value:i.value});break;case 1010:h.push({type:Nr(i.code),value:Rt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Nr(i.code),value:Rt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Nr(i.code),value:Rt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Nr(i.code),value:Rt(t)});break;case 1041:h.push({name:"distance",type:Nr(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Nr(i.code),value:i.value})}i=t.next()}return t.rewind(),e}function Nr(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 xn(i,t,e){for(;St(i,102);){var n;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(;!St(c,102)&&!St(c,0,"EOF");)c=g.next()}(i,t),i=t.next();continue}let h=o.slice(1).trim();e.extensions??(e.extensions={}),(n=e.extensions)[h]??(n[h]=[]),function(c,g,b){for(;!St(c,102,"}")&&!St(c,0,"EOF");)b.push(c),c=g.next()}(i,t,e.extensions[h]),i=t.next()}t.rewind()}let Zc=0;function Nh(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=Zc++)}var Qc=[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 Ch(i){return Qc[i]}(wr={})[wr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",wr[wr.CAST=1]="CAST",wr[wr.RECEIVE=2]="RECEIVE",wr[wr.IGNORE=3]="IGNORE";let Vt=[...$c,{code:284,name:"shadowMode",parser:v},{code:390,name:"plotStyleHardId",parser:v},{code:380,name:"plotStyleType",parser:v},{code:440,name:"transparency",parser:v},{code:430,name:"colorName",parser:v},{code:420,name:"color",parser:v},{code:310,name:"proxyEntity",isMultiple:!0,parser:v},{code:92,name:"proxyByte",parser:v},{code:60,name:"isVisible",parser:Dt},{code:48,name:"lineTypeScale",parser:v},{code:370,name:"lineweight",parser:v},{code:62,name:"colorIndex",parser(i,t,e){let n=i.value;return n>0&&n<256&&(e.color=Ch(Math.abs(n))),n}},{code:347,name:"materialObjectHardId",parser:v},{code:6,name:"lineType",parser:v},{code:8,name:"layer",parser:v},{code:410,name:"layoutTabName",parser:v},{code:67,name:"isInPaperSpace",parser:Dt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:v},{code:102,parser:xn},{code:102,parser:xn},{code:102,parser:xn},{code:5,name:"handle",parser:v}];function qi(i){return[{code:3,name:i,parser:(t,e,n)=>(n._code3text=(n._code3text??"")+t.value,n._code3text+(n._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(t,e,n)=>(n._code1text=t.value,(n._code3text??"")+n._code1text)}]}function Lh(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}},td=[{code:210,name:"extrusionDirection",parser:j},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:100,name:"subclassMarker",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j},{code:39,name:"thickness",parser:v},{code:100},...Vt];class Oh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Lh(this,"parser",xt(td,Jc))}}Lh(Oh,"ForEntityName","ARC");(ir={})[ir.NONE=0]="NONE",ir[ir.INVISIBLE=1]="INVISIBLE",ir[ir.CONSTANT=2]="CONSTANT",ir[ir.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",ir[ir.PRESET=8]="PRESET";(Is={})[Is.MULTILINE=2]="MULTILINE",Is[Is.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(cn={})[cn.NONE=0]="NONE",cn[cn.MIRRORED_X=2]="MIRRORED_X",cn[cn.MIRRORED_Y=4]="MIRRORED_Y";var ed=((De={})[De.LEFT=0]="LEFT",De[De.CENTER=1]="CENTER",De[De.RIGHT=2]="RIGHT",De[De.ALIGNED=3]="ALIGNED",De[De.MIDDLE=4]="MIDDLE",De[De.FIT=5]="FIT",De),rd=((Ar={})[Ar.BASELINE=0]="BASELINE",Ar[Ar.BOTTOM=1]="BOTTOM",Ar[Ar.MIDDLE=2]="MIDDLE",Ar[Ar.TOP=3]="TOP",Ar);function Bh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let zh={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:ed.LEFT,valign:rd.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Rh=[{code:73,name:"valign",parser:v},{code:100},{code:210,name:"extrusionDirection",parser:j},{code:11,name:"endPoint",parser:j},{code:72,name:"valign",parser:v},{code:72,name:"halign",parser:v},{code:71,name:"generationFlag",parser:v},{code:7,name:"styleName",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"xScale",parser:v},{code:50,name:"rotation",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:j},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Fh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Bh(this,"parser",xt(Rh,zh))}}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}Bh(Fh,"ForEntityName","TEXT");let nd={...zh},sd=[{code:2},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:j},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedRecord",parser:Dt},{code:100},{code:280,name:"isLocked",parser:Dt},{code:74,name:"valign",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:3,name:"prompt",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},...Rh.slice(2)];class Uh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Dh(this,"parser",xt(sd,nd))}}Dh(Uh,"ForEntityName","ATTDEF");(dn={})[dn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",dn[dn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",dn[dn.BY_STYLE=5]="BY_STYLE";function id(i,t){let e={};for(let n of i){let o=t(n);o!=null&&(e[o]??(e[o]=[]),e[o].push(n))}return e}function*Oi(i,t=1/0,e=1){for(let n=i;n!==t;n+=e)yield n}function Yr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function Qa(i,t,e){if(St(t,102))return xn(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=Ch(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=Th(t,e);break;default:return!1}return!0}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}let ad={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},ni=[{code:46,name:"annotationHeight",parser:v},{code:101,parser(i,t){(function(e){e.rewind();let n=e.next();if(n.code!==101)throw Error("Bad call for skipEmbeddedObject()");do n=e.next();while(n.code!==0);e.rewind()})(t)}},{code:50,name:"columnHeight",parser:v},{code:49,name:"columnGutter",parser:v},{code:48,name:"columnWidth",parser:v},{code:79,name:"columnAutoHeight",parser:v},{code:78,name:"columnFlowReversed",parser:v},{code:76,name:"columnCount",parser:v},{code:75,name:"columnType",parser:v},{code:441,name:"backgroundFillTransparency",parser:v},{code:63,name:"backgroundFillColor",parser:v},{code:45,name:"fillBoxScale",parser:v},{code:[...Oi(430,440)],name:"backgroundColor",parser:v},{code:[...Oi(420,430)],name:"backgroundColor",parser:v},{code:90,name:"backgroundFill",parser:v},{code:44,name:"lineSpacing",parser:v},{code:73,name:"lineSpacingStyle",parser:v},{code:50,name:"rotation",parser:v},{code:43},{code:42},{code:11,name:"direction",parser:j},{code:210,name:"extrusionDirection",parser:j},{code:7,name:"styleName",parser:v},...qi("text"),{code:72,name:"drawingDirection",parser:v},{code:71,name:"attachmentPoint",parser:v},{code:41,name:"width",parser:v},{code:40,name:"height",parser:v},{code:10,name:"insertionPoint",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Gh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Vh(this,"parser",xt(ni,ad))}}function jh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Vh(Gh,"ForEntityName","MTEXT");let od={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},ld=[...ni.slice(ni.findIndex(({name:i})=>i==="columnType"),ni.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!St(i,0,"MTEXT"))return Za}},{code:2,name:"definitionTag",parser:v},{code:40,name:"annotationScale",parser:v},{code:10,name:"alignmentPoint",parser:j},{code:340,name:"secondaryAttributesHardId",parser:v},{code:70,name:"numberOfSecondaryAttributes",parser:v},{code:70,name:"isReallyLocked",parser:Dt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedEntriesKeep",parser:Dt},{code:100},{code:280,name:"lockPositionFlag",parser:Dt},{code:210,name:"extrusionDirection",parser:j},{code:11,name:"alignmentPoint",parser:j},{code:74,name:"verticalJustification",parser:v},{code:72,name:"horizontalJustification",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:7,name:"textStyle",parser:v},{code:51,name:"obliqueAngle",parser:v},{code:41,name:"scale",parser:v},{code:50,name:"rotation",parser:v},{code:73},{code:70,name:"attributeFlag",parser:v},{code:2,name:"tag",parser:v},{code:280},{code:100,name:"subclassMarker",parser:v},{code:1,name:"text",parser:v},{code:40,name:"textHeight",parser:v},{code:10,name:"startPoint",parser:j},{code:39,name:"thickness",parser:v},{code:100},...Vt];class Wh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){jh(this,"parser",xt(ld,od))}}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}jh(Wh,"ForEntityName","ATTRIB");let hd=[...qi("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Yh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Hh(this,"parser",xt(hd))}}function qh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Hh(Yh,"ForEntityName","BODY");let ud={thickness:0,extrusionDirection:{x:0,y:0,z:1}},cd=[{code:210,name:"extrusionDirection",parser:j},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Xh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){qh(this,"parser",xt(cd,ud))}}qh(Xh,"ForEntityName","CIRCLE");class si{parseEntity(t,e){let n={};for(;!St(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:Qa(o,h,c)}})(n,e,t),e=t.next()}return n}}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}ua="DIMENSION",(ha="ForEntityName")in si?Object.defineProperty(si,ha,{value:ua,enumerable:!0,configurable:!0,writable:!0}):si[ha]=ua;let dd={extrusionDirection:{x:0,y:0,z:1}},pd=[{code:42,name:"endAngle",parser:v},{code:41,name:"startAngle",parser:v},{code:40,name:"axisRatio",parser:v},{code:210,name:"extrusionDirection",parser:j},{code:11,name:"majorAxisEndPoint",parser:j},{code:10,name:"center",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class $h{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Kh(this,"parser",xt(pd,dd))}}Kh($h,"ForEntityName","ELLIPSE");(Sr={})[Sr.First=1]="First",Sr[Sr.Second=2]="Second",Sr[Sr.Third=4]="Third",Sr[Sr.Fourth=8]="Fourth";function Zh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let md=[{code:13,name:"vertices.3",parser:j},{code:12,name:"vertices.2",parser:j},{code:11,name:"vertices.1",parser:j},{code:10,name:"vertices.0",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Qh{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Zh(this,"parser",xt(md))}}Zh(Qh,"ForEntityName","3DFACE");let Jh=[{code:330,name:"sourceBoundaryObjects",parser:v,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:v}],gd=[{code:11,name:"end",parser:j},{code:10,name:"start",parser:j}],fd=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j}],_d=[{code:73,name:"isCCW",parser:Dt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"lengthOfMinorAxis",parser:v},{code:11,name:"end",parser:j},{code:10,name:"center",parser:j}],yd=[{code:13,name:"endTangent",parser:j},{code:12,name:"startTangent",parser:j},{code:11,name:"fitDatum",isMultiple:!0,parser:j},{code:97,name:"numberOfFitData",parser:v},{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:v},{code:96,name:"numberOfControlPoints",parser:v},{code:95,name:"numberOfKnots",parser:v},{code:74,name:"isPeriodic",parser:Dt},{code:73,name:"splineFlag",parser:v},{code:94,name:"degree",parser:v}],vd={[Js.Line]:gd,[Js.Circular]:fd,[Js.Elliptic]:_d,[Js.Spline]:yd},bd=[...Jh,{code:72,name:"edges",parser(i,t){let e={type:i.value},n=xt(vd[e.type]);if(!n)throw Error(`Invalid edge type ${e.type}`);return n(i=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:v}],xd=[...Jh,{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:v},{code:73,name:"isClosed",parser:Dt},{code:72,name:"hasBulge",parser:Dt}],wd=[{code:49,name:"dashLengths",parser:v,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:v},{code:45,name:"offset",parser:dl},{code:43,name:"base",parser:dl},{code:53,name:"angle",parser:v}];function dl(i,t){let e=i.code+1,n={x:i.value,y:1};return(i=t.next()).code===e?n.y=i.value:t.rewind(),n}function tu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Ad={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Sd=[{code:470},{code:463},{code:462,name:"colorTint",parser:v},{code:461,name:"gradientDefinition",parser:v},{code:460,name:"gradientRotation",parser:v},{code:453,name:"numberOfColors",parser:v},{code:452,name:"gradientColorFlag",parser:v},{code:451},{code:450,name:"gradientFlag",parser:v},{code:10,name:"seedPoints",parser:j,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:j},{code:98,name:"numberOfSeedPoints",parser:v},{code:47,name:"pixelSize",parser:v},{code:53,name:"definitionLines",parser:function(i,t){let e={};return xt(wd)(i,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:v},{code:77,name:"isDouble",parser:Dt},{code:73,name:"isAnnotated",parser:Dt},{code:41,name:"patternScale",parser:v},{code:52,name:"patternAngle",parser:v},{code:76,name:"patternType",parser:v},{code:75,name:"hatchStyle",parser:v},{code:92,name:"boundaryPaths",parser:function(i,t){let e={boundaryPathTypeFlag:i.value},n=e.boundaryPathTypeFlag&Xc.Polyline;return i=t.next(),n?xt(xd)(i,t,e):xt(bd)(i,t,e),e},isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:v},{code:71,name:"associativity",parser:v},{code:63,name:"patternFillColor",parser:v},{code:70,name:"solidFill",parser:v},{code:2,name:"patternName",parser:v},{code:210,name:"extrusionDirection",parser:j},{code:10,name:"elevationPoint",parser:j},{code:100,name:"subclassMarker",parser:v,pushContext:!0},...Vt];class eu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){tu(this,"parser",xt(Sd,Ad))}}tu(eu,"ForEntityName","HATCH");(Ir={})[Ir.ShowImage=1]="ShowImage",Ir[Ir.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",Ir[Ir.UseClippingBoundary=4]="UseClippingBoundary",Ir[Ir.TransparencyIsOn=8]="TransparencyIsOn";(Ps={})[Ps.Rectangular=1]="Rectangular",Ps[Ps.Polygonal=2]="Polygonal";(Es={})[Es.Outside=0]="Outside",Es[Es.Inside=1]="Inside";function ru(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Id={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Pd=[{code:290,name:"clipMode",parser:v},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:j},{code:91,name:"countBoundaryPoints",parser:v},{code:71,name:"clippingBoundaryType",parser:v},{code:360,name:"imageDefReactorHandle",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipped",parser:Dt},{code:70,name:"flags",parser:v},{code:340,name:"imageDefHandle",parser:v},{code:13,name:"imageSize",parser:j},{code:12,name:"vPixel",parser:j},{code:11,name:"uPixel",parser:j},{code:10,name:"position",parser:j},{code:90,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class nu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){ru(this,"parser",xt(Pd,Id))}}function su(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ru(nu,"ForEntityName","IMAGE");let Ed={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},kd=[{code:210,name:"extrusionDirection",parser:j},{code:45,name:"rowSpacing",parser:v},{code:44,name:"columnSpacing",parser:v},{code:71,name:"rowCount",parser:v},{code:70,name:"columnCount",parser:v},{code:50,name:"rotation",parser:v},{code:43,name:"zScale",parser:v},{code:42,name:"yScale",parser:v},{code:41,name:"xScale",parser:v},{code:10,name:"insertionPoint",parser:j},{code:2,name:"name",parser:v},{code:66,name:"isVariableAttributes",parser:Dt},{code:100,name:"subclassMarker",parser:v},...Vt];class iu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){su(this,"parser",xt(kd,Ed))}}function au(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}su(iu,"ForEntityName","INSERT");let Md={isArrowheadEnabled:!0},Td=[{code:213,name:"offsetFromAnnotation",parser:j},{code:212,name:"offsetFromBlock",parser:j},{code:211,name:"horizontalDirection",parser:j},{code:210,name:"normal",parser:j},{code:340,name:"associatedAnnotation",parser:v},{code:77,name:"byBlockColor",parser:v},{code:10,name:"vertices",parser:j,isMultiple:!0},{code:76,name:"numberOfVertices",parser:v},{code:41,name:"textWidth",parser:v},{code:40,name:"textHeight",parser:v},{code:75,name:"isHooklineExists",parser:Dt},{code:74,name:"isHooklineSameDirection",parser:Dt},{code:73,name:"leaderCreationFlag",parser:v},{code:72,name:"isSpline",parser:Dt},{code:71,name:"isArrowheadEnabled",parser:Dt},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class ou{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){au(this,"parser",xt(Td,Md))}}au(ou,"ForEntityName","LEADER");(Pr={})[Pr.TextAnnotation=0]="TextAnnotation",Pr[Pr.ToleranceAnnotation=1]="ToleranceAnnotation",Pr[Pr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Pr[Pr.NoAnnotation=3]="NoAnnotation";function lu(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={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Cd=[{code:210,name:"extrusionDirection",parser:j},{code:11,name:"endPoint",parser:j},{code:10,name:"startPoint",parser:j},{code:39,name:"thickness",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class hu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){lu(this,"parser",xt(Cd,Nd))}}lu(hu,"ForEntityName","LINE");(ks={})[ks.IS_CLOSED=1]="IS_CLOSED",ks[ks.PLINE_GEN=128]="PLINE_GEN";let Ld={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Od={bulge:0},Bd=[{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:91,name:"id",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v}],zd=[{code:210,name:"extrusionDirection",parser:j},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return xt(Bd,Od)(i,t,e),e}},{code:39,name:"thickness",parser:v},{code:38,name:"elevation",parser:v},{code:43,name:"constantWidth",parser:v},{code:70,name:"flag",parser:v},{code:90,name:"numberOfVertices",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class ii{parseEntity(t,e){let n={};return xt(zd,Ld)(e,t,n),n}}function uu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}da="LWPOLYLINE",(ca="ForEntityName")in ii?Object.defineProperty(ii,ca,{value:da,enumerable:!0,configurable:!0,writable:!0}):ii[ca]=da;let Rd=[{code:90,name:"overridenSubEntityCount",parser:v},{code:140,name:"edgeCreaseWeights",parser:v,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:v},{code:94,parser(i,t,e){e.edgeCount=i.value,e.edgeIndices=[];for(let n=0;n<e.edgeCount;++n){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 n=[];for(let h=0;h<e.totalFaceIndices&&!St(i,0);++h)i=t.next(),n.push(i.value);let o=0;for(;o<n.length;){let h=n[o++],c=[];for(let g=0;g<h;++g)c.push(n[o++]);e.faceIndices.push(c)}}},{code:10,name:"vertices",parser:j,isMultiple:!0},{code:92,name:"verticesCount",parser:v},{code:91,name:"subdivisionLevel",parser:v},{code:40,name:"blendCrease",parser:v},{code:72,name:"isBlendCreased",parser:Dt},{code:71,name:"version",parser:v},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Vt];class cu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){uu(this,"parser",xt(Rd))}}function du(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}uu(cu,"ForEntityName","MESH");let Fd={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},Dd=[{code:50,name:"angle",parser:v},{code:210,name:"extrusionDirection",parser:j},{code:39,name:"thickness",parser:v},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class pu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){du(this,"parser",xt(Dd,Fd))}}du(pu,"ForEntityName","POINT");(ce={})[ce.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ce[ce.CURVE_FIT=2]="CURVE_FIT",ce[ce.SPLINE_FIT=4]="SPLINE_FIT",ce[ce.POLYLINE_3D=8]="POLYLINE_3D",ce[ce.POLYGON_3D=16]="POLYGON_3D",ce[ce.CLOSED_POLYGON=32]="CLOSED_POLYGON",ce[ce.POLYFACE=64]="POLYFACE",ce[ce.CONTINUOUS=128]="CONTINUOUS";var ti=((Er={})[Er.NONE=0]="NONE",Er[Er.QUADRATIC=5]="QUADRATIC",Er[Er.CUBIC=6]="CUBIC",Er[Er.BEZIER=8]="BEZIER",Er),Ud=((de={})[de.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",de[de.TANGENT_DEFINED=2]="TANGENT_DEFINED",de[de.NOT_USED=4]="NOT_USED",de[de.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",de[de.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",de[de.FOR_POLYLINE=32]="FOR_POLYLINE",de[de.FOR_POLYGON=64]="FOR_POLYGON",de[de.POLYFACE=128]="POLYFACE",de);function mu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Vd={startWidth:0,endWidth:0,bulge:0},Gd=[{code:91,name:"id",parser:v},{code:[...Oi(71,75)],name:"faces",isMultiple:!0,parser:v},{code:50,name:"tangentDirection",parser:v},{code:70,name:"flag",parser:v},{code:42,name:"bulge",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:30,name:"z",parser:v},{code:20,name:"y",parser:v},{code:10,name:"x",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...Vt];class Ja{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){mu(this,"parser",xt(Gd,Vd))}}function gu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}mu(Ja,"ForEntityName","VERTEX");let jd={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:[]},Wd=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>St(i,0,"VERTEX")?(i=t.next(),new Ja().parseEntity(t,i)):Za},{code:210,name:"extrusionDirection",parser:j},{code:75,name:"smoothType",parser:v},{code:74,name:"surfaceNDensity",parser:v},{code:73,name:"surfaceMDensity",parser:v},{code:72,name:"meshNVertexCount",parser:v},{code:71,name:"meshMVertexCount",parser:v},{code:41,name:"endWidth",parser:v},{code:40,name:"startWidth",parser:v},{code:70,name:"flag",parser:v},{code:39,name:"thickness",parser:v},{code:30,name:"elevation",parser:v},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:v},...Vt];class fu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){gu(this,"parser",xt(Wd,jd))}}function _u(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}gu(fu,"ForEntityName","POLYLINE");let Hd=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class yu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){_u(this,"parser",xt(Hd))}}function vu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}_u(yu,"ForEntityName","RAY");let Yd=[...qi("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class bu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){vu(this,"parser",xt(Yd))}}function xu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}vu(bu,"ForEntityName","REGION");let qd={vertices:[],backLineVertices:[]},Xd=[{code:360,name:"geometrySettingHardId",parser:v},{code:12,name:"backLineVertices",isMultiple:!0,parser:j},{code:93,name:"numberOfBackLineVertices",parser:v},{code:11,name:"vertices",isMultiple:!0,parser:j},{code:92,name:"verticesCount",parser:v},{code:[63,411],name:"indicatorColor",parser:v},{code:70,name:"indicatorTransparency",parser:v},{code:41,name:"bottomHeight",parser:v},{code:40,name:"topHeight",parser:v},{code:10,name:"verticalDirection",parser:j},{code:1,name:"name",parser:v},{code:91,name:"flag",parser:v},{code:90,name:"state",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class wu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){xu(this,"parser",xt(Xd,qd))}}function Au(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}xu(wu,"ForEntityName","SECTION");let Kd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},$d=[{code:210,name:"extrusionDirection",parser:j},{code:39,name:"thickness",parser:v},{code:[...Oi(10,14)],name:"points",isMultiple:!0,parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Su{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Au(this,"parser",xt($d,Kd))}}function Iu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Au(Su,"ForEntityName","SOLID");let Zd=[{code:350,name:"historyObjectSoftId",parser:v},{code:100,name:"subclassMarker",parser:v},...qi("data"),{code:70,name:"version",parser:v},{code:100},...Vt];class Pu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Iu(this,"parser",xt(Zd))}}Iu(Pu,"ForEntityName","3DSOLID");(Ue={})[Ue.NONE=0]="NONE",Ue[Ue.CLOSED=1]="CLOSED",Ue[Ue.PERIODIC=2]="PERIODIC",Ue[Ue.RATIONAL=4]="RATIONAL",Ue[Ue.PLANAR=8]="PLANAR",Ue[Ue.LINEAR=16]="LINEAR";function Eu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Qd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Jd=[{code:11,name:"fitPoints",isMultiple:!0,parser:j},{code:10,name:"controlPoints",isMultiple:!0,parser:j},{code:41,name:"weights",isMultiple:!0,parser:v},{code:40,name:"knots",isMultiple:!0,parser:v},{code:13,name:"endTangent",parser:j},{code:12,name:"startTangent",parser:j},{code:44,name:"fitTolerance",parser:v},{code:43,name:"controlTolerance",parser:v},{code:42,name:"knotTolerance",parser:v},{code:74,name:"numberOfFitPoints",parser:v},{code:73,name:"numberOfControlPoints",parser:v},{code:72,name:"numberOfKnots",parser:v},{code:71,name:"degree",parser:v},{code:70,name:"flag",parser:v},{code:210,name:"normal",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class ku{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Eu(this,"parser",xt(Jd,Qd))}}Eu(ku,"ForEntityName","SPLINE");class ai{parseEntity(t,e){let n={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:n.subclassMarker=e.value,e=t.next();break;case 2:n.name=e.value,e=t.next();break;case 5:n.handle=e.value,e=t.next();break;case 10:n.startPoint=Yr(Rt(t)),e=t.lastReadGroup;break;case 11:n.directionVector=Yr(Rt(t)),e=t.lastReadGroup;break;case 90:n.tableValue=e.value,e=t.next();break;case 91:n.rowCount=e.value,e=t.next();break;case 92:n.columnCount=e.value,e=t.next();break;case 93:n.overrideFlag=e.value,e=t.next();break;case 94:n.borderColorOverrideFlag=e.value,e=t.next();break;case 95:n.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:n.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:n.rowHeightArr??(n.rowHeightArr=[]),n.rowHeightArr.push(e.value),e=t.next();break;case 142:n.columnWidthArr??(n.columnWidthArr=[]),n.columnWidthArr.push(e.value),e=t.next();break;case 280:n.version=e.value,e=t.next();break;case 310:n.bmpPreview??(n.bmpPreview=""),n.bmpPreview+=e.value,e=t.next();break;case 330:n.ownerDictionaryId=e.value,e=t.next();break;case 342:n.tableStyleId=e.value,e=t.next();break;case 343:n.blockRecordHandle=e.value,e=t.next();break;case 170:n.attachmentPoint=e.value,e=t.next();break;case 171:n.cells??(n.cells=[]),n.cells.push(function(o,h){let c=!1,g=!1,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(c){g=!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(f,w,x){for(;x.code!==304;)switch(x.code){case 301:case 93:case 90:case 94:x=w.next();break;case 1:f.text=x.value,x=w.next();break;case 300:f.attrText=x.value,x=w.next();break;case 302:f.text=x.value?x.value:f.text,x=w.next();break;default:console.log(`Ignore code: ${x.code}, value: ${x.value}`),x=w.next()}})(b,o,h),h=o.next();break;default:return b}return c=!1,g=!1,b}(t,e)),e=t.lastReadGroup;break;default:Qa(n,e,t),e=t.next()}}return n}}function Mu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ma="ACAD_TABLE",(pa="ForEntityName")in ai?Object.defineProperty(ai,pa,{value:ma,enumerable:!0,configurable:!0,writable:!0}):ai[pa]=ma;let t0=[{code:11,name:"xAxisDirection",parser:j},{code:210,name:"extrusionDirection",parser:j},{code:1,name:"text",parser:v},{code:10,name:"position",parser:j},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Tu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Mu(this,"parser",xt(t0))}}Mu(Tu,"ForEntityName","TOLERANCE");class oi{parseEntity(t,e){let n={};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=Yr(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=Yr(Rt(h));break;case 17:o.targetPoint=Yr(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=Yr(Rt(h));break;case 111:o.ucsXAxis=Yr(Rt(h));break;case 112:o.ucsYAxis=Yr(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}(n,t,e)&&Qa(n,e,t),e=t.next()}return n}}fa="VIEWPORT",(ga="ForEntityName")in oi?Object.defineProperty(oi,ga,{value:fa,enumerable:!0,configurable:!0,writable:!0}):oi[ga]=fa;(kr={})[kr.ShowImage=1]="ShowImage",kr[kr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",kr[kr.UseClippingBoundary=4]="UseClippingBoundary",kr[kr.Transparency=8]="Transparency";function Nu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let e0={brightness:50,constrast:50,fade:0},r0=[{code:14,name:"boundary",isMultiple:!0,parser:j},{code:91,name:"numberOfVertices",parser:v},{code:71,name:"boundaryType",parser:v},{code:360,name:"imageDefReactorHardId",parser:v},{code:283,name:"fade",parser:v},{code:282,name:"contrast",parser:v},{code:281,name:"brightness",parser:v},{code:280,name:"isClipping",parser:Dt},{code:70,name:"displayFlag",parser:v},{code:340,name:"imageDefHardId",parser:v},{code:13,name:"imageSize",parser:j},{code:12,name:"vDirection",parser:j},{code:11,name:"uDirection",parser:j},{code:10,name:"position",parser:j},{code:90,name:"classVersion",parser:v},{code:100,name:"subclassMarker",parser:v},...Vt];class Cu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Nu(this,"parser",xt(r0,e0))}}function Lu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Nu(Cu,"ForEntityName","WIPEOUT");let n0=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Vt];class Ou{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Lu(this,"parser",xt(n0))}}function Bu(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Lu(Ou,"ForEntityName","XLINE");let s0={},i0=[{code:170,name:"multileaderType",parser:v},{code:291,name:"doglegEnabled",parser:Dt},{code:40,name:"doglegLength",parser:v},{code:172,name:"contentType",parser:v},{code:3,name:"textContent",parser:v},{code:12,name:"textAnchor",parser:j},{code:344,name:"blockHandle",parser:v},{code:15,name:"blockPosition",parser:j},{code:302,name:"leaderSections",parser:function(i,t,e){let n,o={leaderLines:[]};for(;t.hasNext()&&(n=t.next()).code!==303;)switch(n.code){case 10:o.landingPoint=(n.value,Rt(t));break;case 11:o.doglegVector=(n.value,Rt(t));break;case 40:o.doglegLength=n.value;break;case 304:o.leaderLines.push(function(h,c,g){let b,f={vertices:[]};for(;c.hasNext()&&(b=c.next()).code!==305;)b.code===10&&f.vertices.push((b.value,Rt(c)));return f}(0,t))}return o},isMultiple:!0},...Vt];class zu{parseEntity(t,e){let n={};return this.parser(e,t,n),n}constructor(){Bu(this,"parser",xt(i0,s0))}}Bu(zu,"ForEntityName","MULTILEADER");let a0=Object.fromEntries([Oh,Uh,Wh,Yh,Xh,si,$h,Qh,nu,iu,ou,hu,ii,cu,Gh,zu,pu,fu,yu,bu,wu,Su,Pu,ku,ai,Fh,Tu,eu,Ja,oi,Cu,Ou].map(i=>[i.ForEntityName,new i]));function Ru(i,t){let e=[];for(;!St(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let n=a0[i.value];if(n){let o=i.value;i=t.next();let h=n.parseEntity(t,i);h.type=o,Nh(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=t.next()}return e}function o0(i,t){let e={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");){if(St(i,0,"BLOCK")){let n=l0(i=t.next(),t);Nh(n),n.name&&(e[n.name]=n)}i=t.next()}return e}function l0(i,t){let e={};for(;!St(i,0,"EOF");){if(St(i,0,"ENDBLK")){for(i=t.next();!St(i,0,"EOF");){if(St(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=Ru(i,t)}i=t.next()}return e}function h0(i,t){let e=null,n={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");)i.code===9?e=i.value:i.code===10?n[e]=Rt(t):n[e]=i.value,i=t.next();return n}(Ve={})[Ve.NOT_APPLICABLE=0]="NOT_APPLICABLE",Ve[Ve.KEEP_EXISTING=1]="KEEP_EXISTING",Ve[Ve.USE_CLONE=2]="USE_CLONE",Ve[Ve.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Ve[Ve.VALUE_NAME=4]="VALUE_NAME",Ve[Ve.UNMANGLE_NAME=5]="UNMANGLE_NAME";let to=[{code:330,name:"ownerObjectId",parser:v},{code:102,parser:xn},{code:102,parser:xn},{code:102,parser:xn},{code:5,name:"handle",parser:v}],u0=[{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:v},{code:280,name:"isHardOwned",parser:Dt},{code:100,name:"subclassMarker",parser:v},...to],c0=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:v},{code:90,name:"version",parser:v},{code:1,name:"fileName",parser:v},{code:10,name:"size",parser:j},{code:11,name:"sizeOfOnePixel",parser:j},{code:280,name:"isLoaded",parser:v},{code:281,name:"resolutionUnits",parser:v},{code:100,name:"subclassMarker",parser:v}];(pn={})[pn.NOUNIT=0]="NOUNIT",pn[pn.CENTIMETERS=2]="CENTIMETERS",pn[pn.INCH=5]="INCH";(Ms={})[Ms.PSLTSCALE=1]="PSLTSCALE",Ms[Ms.LIMCHECK=2]="LIMCHECK";(mn={})[mn.INCHES=0]="INCHES",mn[mn.MILLIMETERS=1]="MILLIMETERS",mn[mn.PIXELS=2]="PIXELS";(Ge={})[Ge.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",Ge[Ge.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",Ge[Ge.DRAWING_LIMITS=2]="DRAWING_LIMITS",Ge[Ge.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",Ge[Ge.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",Ge[Ge.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Mr={})[Mr.AS_DISPLAYED=0]="AS_DISPLAYED",Mr[Mr.WIREFRAME=1]="WIREFRAME",Mr[Mr.HIDDEN=2]="HIDDEN",Mr[Mr.RENDERED=3]="RENDERED";(je={})[je.DRAFT=0]="DRAFT",je[je.PREVIEW=1]="PREVIEW",je[je.NORMAL=2]="NORMAL",je[je.PRESENTATION=3]="PRESENTATION",je[je.MAXIMUM=4]="MAXIMUM",je[je.CUSTOM=5]="CUSTOM";let Fu=[{code:333,name:"shadePlotId",parser:v},{code:149,name:"imageOriginY",parser:v},{code:148,name:"imageOriginX",parser:v},{code:147,name:"scaleFactor",parser:v},{code:78,name:"shadePlotCustomDPI",parser:v},{code:77,name:"shadePlotResolution",parser:v},{code:76,name:"shadePlotMode",parser:v},{code:75,name:"standardScaleType",parser:v},{code:7,name:"currentStyleSheet",parser:v},{code:74,name:"plotType",parser:v},{code:73,name:"plotRotation",parser:v},{code:72,name:"plotPaperUnit",parser:v},{code:70,name:"layoutFlag",parser:v},{code:143,name:"printScaleDenominator",parser:v},{code:142,name:"printScaleNumerator",parser:v},{code:141,name:"windowAreaYMax",parser:v},{code:140,name:"windowAreaXMax",parser:v},{code:49,name:"windowAreaYMin",parser:v},{code:48,name:"windowAreaXMin",parser:v},{code:47,name:"plotOriginY",parser:v},{code:46,name:"plotOriginX",parser:v},{code:45,name:"paperHeight",parser:v},{code:44,name:"paperWidth",parser:v},{code:43,name:"marginTop",parser:v},{code:42,name:"marginRight",parser:v},{code:41,name:"marginBottom",parser:v},{code:40,name:"marginLeft",parser:v},{code:6,name:"plotViewName",parser:v},{code:4,name:"paperSize",parser:v},{code:2,name:"configName",parser:v},{code:1,name:"pageSetupName",parser:v},{code:100,name:"subclassMarker",parser:v},...to],d0=[{code:346,name:"orthographicUcsId",parser:v},{code:345,name:"namedUcsId",parser:v},{code:331,name:"viewportId",parser:v},{code:330,name:"paperSpaceTableId",parser:v},{code:76,name:"orthographicType",parser:v},{code:17,name:"ucsYAxis",parser:j},{code:16,name:"ucsXAxis",parser:j},{code:13,name:"ucsOrigin",parser:j},{code:146,name:"elevation",parser:v},{code:15,name:"maxExtent",parser:j},{code:14,name:"minExtent",parser:j},{code:12,name:"insertionPoint",parser:j},{code:11,name:"maxLimit",parser:j},{code:10,name:"minLimit",parser:j},{code:71,name:"tabOrder",parser:v},{code:70,name:"controlFlag",parser:v},{code:1,name:"layoutName",parser:v},{code:100,name:"subclassMarker",parser:v},...Fu],p0=[{code:40,name:"wcsToOCSTransform",parser:pl},{code:40,name:"ocsToWCSTransform",parser:pl},{code:41,name:"backClippingDistance",parser:v},{code:73,name:"isBackClipping",parser:Dt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:v},{code:72,name:"isFrontClipping",parser:Dt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Dt},{code:11,name:"position",parser:j},{code:210,name:"normal",parser:j},{code:10,name:"boundaryVertices",parser:j,isMultiple:!0},{code:70,name:"boundaryCount",parser:v},{code:100,name:"subclassMarker",parser:v},{code:100},...to];function pl(i,t){let e=[];for(let n=0;n<3&&St(i,40);++n){let o=[];for(let h=0;h<4&&St(i,40);++h)o.push(i.value),i=t.next();e.push(o)}return t.rewind(),e}let m0={LAYOUT:d0,PLOTSETTINGS:Fu,DICTIONARY:u0,SPATIAL_FILTER:p0,IMAGEDEF:c0};function g0(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let n=i.value,o=m0[n];if(i.code===0&&(o!=null&&o.length)){let h=xt(o),c={name:n};h(i=t.next(),t,c)?(e.push(c),i=t.peek()):i=t.next()}else i=t.next()}return{byName:id(e,({name:n})=>n)}}let qn=[{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102,parser(i,t){for(;!St(i,0,"EOF")&&!St(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:v}],f0=xt([{code:310,name:"bmpPreview",parser:v},{code:281,name:"scalability",parser:v},{code:280,name:"explodability",parser:v},{code:70,name:"insertionUnits",parser:v},{code:340,name:"layoutObjects",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...qn]),_0=[{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:cl.Above,defaultValueImperial:cl.Center},{name:"DIMZIN",code:78,defaultValue:Un.Trailing,defaultValueImperial:Un.Feet},{name:"DIMAZIN",code:79,defaultValue:Wc.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:Yc.Center},{name:"DIMTZIN",code:284,defaultValue:Un.Trailing,defaultValueImperial:Un.Feet},{name:"DIMALTZ",code:285,defaultValue:Un.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Un.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}],y0=xt([..._0.map(i=>({...i,parser:v})),{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},{code:105,name:"handle",parser:v},...qn.filter(i=>i.code!==5)]),v0=xt([{code:347,name:"materialObjectId",parser:v},{code:390,name:"plotStyleNameObjectId",parser:v},{code:370,name:"lineweight",parser:v},{code:290,name:"isPlotting",parser:Dt},{code:6,name:"lineType",parser:v},{code:62,name:"colorIndex",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...qn]);(Tr={})[Tr.NONE=0]="NONE",Tr[Tr.AbsoluteRotation=1]="AbsoluteRotation",Tr[Tr.TextEmbedded=2]="TextEmbedded",Tr[Tr.ShapeEmbedded=4]="ShapeEmbedded";let b0=xt([{code:9,name:"text",parser:v},{code:45,name:"offsetY",parser:v},{code:44,name:"offsetX",parser:v},{code:50,name:"rotation",parser:v},{code:46,name:"scale",parser:v},{code:340,name:"styleObjectId",parser:v},{code:75,name:"shapeNumber",parser:v},{code:74,name:"elementTypeFlag",parser:v},{code:49,name:"elementLength",parser:v}],{elementTypeFlag:0,elementLength:0}),x0=xt([{code:49,name:"pattern",parser(i,t){let e={};return b0(i,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:v},{code:73,name:"numberOfLineTypes",parser:v},{code:72,parser:v},{code:3,name:"description",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...qn]),w0=xt([{code:1e3,name:"extendedFont",parser:v},{code:1001},{code:4,name:"bigFont",parser:v},{code:3,name:"font",parser:v},{code:42,name:"lastHeight",parser:v},{code:71,name:"textGenerationFlag",parser:v},{code:50,name:"obliqueAngle",parser:v},{code:41,name:"widthFactor",parser:v},{code:40,name:"fixedTextHeight",parser:v},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...qn]),A0=xt([{code:[63,421,431],name:"ambientColor",parser:v},{code:142,name:"contrast",parser:v},{code:141,name:"brightness",parser:v},{code:282,name:"defaultLightingType",parser:v},{code:292,name:"isDefaultLightingOn",parser:Dt},{code:348,name:"visualStyleObjectId",parser:v},{code:333,name:"shadePlotObjectId",parser:v},{code:332,name:"backgroundObjectId",parser:v},{code:61,name:"majorGridLines",parser:v},{code:170,name:"shadePlotSetting",parser:v},{code:146,name:"elevation",parser:v},{code:79,name:"orthographicType",parser:v},{code:112,name:"ucsYAxis",parser:j},{code:111,name:"ucsXAxis",parser:j},{code:110,name:"ucsOrigin",parser:j},{code:74,name:"ucsIconSetting",parser:v},{code:71,name:"viewMode",parser:v},{code:281,name:"renderMode",parser:v},{code:1,name:"styleSheet",parser:v},{code:[331,441],name:"frozenLayers",parser:v,isMultiple:!0},{code:72,name:"circleSides",parser:v},{code:51,name:"viewTwistAngle",parser:v},{code:50,name:"snapRotationAngle",parser:v},{code:45,name:"viewHeight",parser:v},{code:44,name:"backClippingPlane",parser:v},{code:43,name:"frontClippingPlane",parser:v},{code:42,name:"lensLength",parser:v},{code:17,name:"viewTarget",parser:j},{code:16,name:"viewDirectionFromTarget",parser:j},{code:15,name:"gridSpacing",parser:j},{code:14,name:"snapSpacing",parser:j},{code:13,name:"snapBasePoint",parser:j},{code:12,name:"center",parser:j},{code:11,name:"upperRightCorner",parser:j},{code:10,name:"lowerLeftCorner",parser:j},{code:70,name:"standardFlag",parser:v},{code:2,name:"name",parser:v},{code:100,name:"subclassMarker",parser:v},...qn]),S0={BLOCK_RECORD:f0,DIMSTYLE:y0,LAYER:v0,LTYPE:x0,STYLE:w0,VPORT:A0},I0=xt([{code:70,name:"maxNumberOfEntries",parser:v},{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102},{code:360,isMultiple:!0},{code:102},{code:5,name:"handle",parser:v},{code:2,name:"name",parser:v}]);function P0(i,t){var n;let e={};for(;!St(i,0,"EOF")&&!St(i,0,"ENDSEC");){if(St(i,0,"TABLE")){i=t.next();let o={entries:[]};I0(i,t,o),e[o.name]=o}if(St(i,0)&&!St(i,0,"ENDTAB")){let o=i.value;i=t.next();let h=S0[o];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${o}'`),i=t.next();continue}let c={};h(i,t,c),(n=e[o])==null||n.entries.push(c)}i=t.next()}return e}function Ts(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class ml{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=gl(t,this._data[this._pointer++],this.debug),n={code:t,value:e};return St(n,0,"EOF")&&(this._eof=!0),this.lastReadGroup=n,n}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=gl(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){Ts(this,"_data",void 0),Ts(this,"debug",void 0),Ts(this,"_pointer",void 0),Ts(this,"_eof",void 0),Ts(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function gl(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(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' 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 E0{constructor(){Pa(this,"encoding","utf-8"),Pa(this,"encodingFailureFatal",!1)}}class k0 extends EventTarget{parseSync(t,e=!1){let n=new ml(t.split(/\r\n|\r|\n/g),e);if(!n.hasNext())throw Error("Empty file");return this.parseAll(n)}parseStream(t){let e="",n=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 ml(c);if(!g.hasNext())throw Error("Empty file");o(n.parseAll(g))}catch(c){h(c)}}),t.on("error",c=>{h(c)})})}async parseFromUrl(t,e){let n=await fetch(t,e);if(!n.body)return null;let o=n.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}},n=t.next();for(;!St(n,0,"EOF");)St(n,0,"SECTION")&&(St(n=t.next(),2,"HEADER")?(n=t.next(),e.header=h0(n,t)):St(n,2,"BLOCKS")?(n=t.next(),e.blocks=o0(n,t)):St(n,2,"ENTITIES")?(n=t.next(),e.entities=Ru(n,t)):St(n,2,"TABLES")?(n=t.next(),e.tables=P0(n,t)):St(n,2,"OBJECTS")&&(n=t.next(),e.objects=g0(n,t))),n=t.next();return e}constructor(t=new E0){super(),Pa(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}const fl=[{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 Bi{constructor(t){if(typeof t=="string"){const e=fl.find(n=>n.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=fl.find(n=>n.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 M0{parse(t){const e=new k0,n=this.getDxfInfoFromBuffer(t);let o="";return n.version&&n.version.value<=23&&n.encoding?o=new TextDecoder(n.encoding).decode(t):o=new TextDecoder().decode(t),e.parseSync(o)}getDxfInfoFromBuffer(t){var f,w,x;const n=new TextDecoder("utf-8");let o=0,h="",c=null,g=null,b=!1;for(;o<t.byteLength;){const E=Math.min(o+65536,t.byteLength),M=t.slice(o,E);o=E;const B=(h+n.decode(M,{stream:!0})).split(/\r?\n/);h=B.pop()??"";for(let D=0;D<B.length;D++){const F=B[D].trim();if(F==="SECTION"&&((f=B[D+2])==null?void 0:f.trim())==="HEADER")b=!0;else if(F==="ENDSEC"&&b)return{version:c,encoding:g};if(b&&F==="$ACADVER"){const dt=(w=B[D+2])==null?void 0:w.trim();dt&&(c=new Bi(dt))}else if(b&&F==="$DWGCODEPAGE"){const dt=(x=B[D+2])==null?void 0:x.trim();if(dt){const vt=Na[dt];g=kl(vt)}}if(c&&g)return{version:c,encoding:g}}}return{version:c,encoding:g}}}class _l{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 fi;return t.vertices.forEach((n,o)=>e.setVertexAt(o,n)),e}convertArc(t){return new pi(t.center,t.radius,kt.degToRad(t.startAngle),kt.degToRad(t.endAngle),t.extrusionDirection??Z.Z_AXIS)}convertCirle(t){return new mi(t.center,t.radius,t.extrusionDirection??Z.Z_AXIS)}convertEllipse(t){const e=new Z(t.majorAxisEndPoint),n=e.length();return new gi(t.center,t.extrusionDirection??Z.Z_AXIS,e,n,n*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,n=t.endPoint;return new yi(new Y(e.x,e.y,e.z||0),new Y(n.x,n.y,n.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Gs(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 Gs(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 Si;return e.position=t.position,e}convertSolid(t){const e=new wi;return t.points.forEach((n,o)=>e.setPointAt(o,n)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),n=!!(t.flag&8),o=[],h=[];if(t.vertices.map(c=>{c.flag&Ud.SPLINE_CONTROL_POINT||(o.push({x:c.x,y:c.y,z:c.z}),h.push(c.bulge??0))}),n){let c=Rs.SimplePoly;return t.flag&4&&(t.smoothType==ti.CUBIC?c=Rs.CubicSplinePoly:t.smoothType==ti.QUADRATIC&&(c=Rs.QuadSplinePoly)),new di(c,o,e)}else{let c=Vn.SimplePoly;return t.flag&2?c=Vn.FitCurvePoly:t.flag&4&&(t.smoothType==ti.CUBIC?c=Vn.CubicSplinePoly:t.smoothType==ti.QUADRATIC&&(c=Vn.QuadSplinePoly)),new ci(c,o,0,e,t.startWidth,t.endWidth,h)}}convertLWPolyline(t){const e=new Ai;return e.closed=!!(t.flag&1),t.vertices.forEach((n,o)=>{e.addVertexAt(o,new Tt(n.x,n.y),n.bulge,n.startWidth,n.endWidth)}),e}convertHatch(t){var o;const e=new Vs;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.isSolidFill=t.solidFill==qc.SolidFill,e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new wn;b.closed=g.isClosed,g.vertices.forEach((f,w)=>{b.addVertexAt(w,{x:f.x,y:f.y,bulge:f.bulge})}),e.add(b)}else{const g=h,b=new ja;g.edges.forEach(f=>{if(f.type==1){const w=f;b.add(new zs(w.start,w.end))}else if(f.type==2){const w=f;b.add(new jn(w.center,w.radius,kt.degToRad(w.startAngle||0),kt.degToRad(w.endAngle||0),!w.isCCW))}else if(f.type==3){const w=f;new Zt().subVectors(w.end,w.center);const E=Math.sqrt(Math.pow(w.end.x,2)+Math.pow(w.end.y,2)),M=E*w.lengthOfMinorAxis;let L=kt.degToRad(w.startAngle||0),B=kt.degToRad(w.endAngle||0);const D=Math.atan2(w.end.y,w.end.x);w.isCCW||(L=Math.PI*2-L,B=Math.PI*2-B),b.add(new ji({...w.center,z:0},E,M,L,B,!w.isCCW,D))}else if(f.type==4){const w=f;if(w.numberOfControlPoints>0&&w.numberOfKnots>0){const x=w.controlPoints.map(L=>({x:L.x,y:L.y,z:0}));let E=!0;const M=w.controlPoints.map(L=>(L.weight==null&&(E=!1),L.weight||1));b.add(new Zr(x,w.knots,E?M:void 0))}else if(w.numberOfFitData>0){const x=w.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new Zr(x,"Uniform"))}}}),e.add(b)}}),e}convertTable(t){const e=new bi(t.name,t.rowCount,t.columnCount);return e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),t.columnWidthArr.forEach((n,o)=>e.setColumnWidth(o,n)),t.rowHeightArr.forEach((n,o)=>e.setRowHeight(o,n)),t.cells.forEach((n,o)=>{e.setCell(o,n)}),e}convertText(t){const e=new xi;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=kt.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 vi;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=kt.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 _i;return t.vertices.forEach(n=>{e.appendVertex(n)}),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,n=new Ti(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(n.dimBlockPosition={...e.insertionPoint,z:0}),n.rotation=kt.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,n=new Mi(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,n=new Ci(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,n=new Li(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,n),n}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,n=new Ni(e.definitionPoint,e.centerPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,n),n}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(n=>{e.clipBoundary.push(new Tt(n))}),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 js;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(n=>{e.clipBoundary.push(new Tt(n))}),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 Ei;return this.processWipeout(t,e),e}convertViewport(t){const e=new Pi;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 Ii;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new ki;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Us(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?kt.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&e.color.setRGBValue(t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=Ui.deserialize(t.transparency))}numberArrayToPointArray(t,e){const n=t.length;let o=0;if(n/2==e?o=2:n/3==e&&(o=3),o==0)return;const h=[];for(let c=0,g=n/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 An extends Jr{constructor(t,e){t=t||{},Hn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const qr=class qr extends An{static isModelSapceName(t){return t.toLowerCase()==qr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(qr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new Y,this._layoutId="",this._entities=new Map}get isModelSapce(){return qr.isModelSapceName(this.name)}get isPaperSapce(){return qr.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 n=t[e];n.database=this.database,n.ownerId=this.objectId,this._entities.set(n.objectId,n)}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 Yi(this._entities)}getIdAt(t){return this._entities.get(t)}};qr.MODEL_SPACE_NAME="*MODEL_SPACE",qr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let pe=qr;class T0{convertLayout(t,e){var o,h;const n=new Hi;if(n.layoutName=t.layoutName,n.tabOrder=t.tabOrder,t.layoutName==="Model"){const c=pe.MODEL_SPACE_NAME;(o=e.tables.BLOCK_RECORD)==null||o.entries.some(g=>g.name.toUpperCase()===c?(n.blockTableRecordId=g.handle,!0):!1)}else(h=e.tables.BLOCK_RECORD)==null||h.entries.some(c=>c.layoutObjects===t.handle?(n.blockTableRecordId=c.handle,!0):!1),n.blockTableRecordId||(n.blockTableRecordId=t.paperSpaceTableId);return n.limits.min.copy(t.minLimit),n.limits.max.copy(t.maxLimit),n.extents.min.copy(t.minExtent),n.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,n),n}convertImageDef(t){const e=new Ph;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Du{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 n=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,t,e||this.config.workerUrl)}catch(h){const c=Date.now()-n;return{success:!1,error:h instanceof Error?h.message:String(h),duration:c}}}async executeInWorker(t,e,n){const o=Date.now();return new Promise((h,c)=>{const g=this.getAvailableWorker(n),b=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:x=>{clearTimeout(b),this.releaseWorker(g),h(x)},reject:x=>{clearTimeout(b),this.releaseWorker(g),c(x)},timeout:b});const f=x=>{const{id:E,success:M,data:L,error:B}=x.data;if(E!==t)return;this.cleanupTask(t);const D=Date.now()-o;h(M?{success:!0,data:L,duration:D}:{success:!1,error:B,duration:D})},w=x=>{this.cleanupTask(t),c(new Error(`Worker error: ${x.message}`))};g.addEventListener("message",f),g.addEventListener("error",w),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[n,o]of this.workers)if(!o.isBusy)return o.isBusy=!0,o.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const n=new Worker(t,{type:"module"}),o=this.generateWorkerId(),h={worker:n,isBusy:!0,id:o,createdAt:new Date};return this.workers.set(o,h),n}const e=Array.from(this.workers.values()).sort((n,o)=>n.createdAt.getTime()-o.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,n]of this.workers)if(n.worker===t){n.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 Uu{constructor(t){this.framework=new Du(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Vu(i){return new Uu(i)}class N0{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:n}=t.data;try{const o=await this.executeTask(n);this.sendResponse(e,!0,o)}catch(o){this.sendResponse(e,!1,void 0,o instanceof Error?o.message:String(o))}}}sendResponse(t,e,n,o){const h={id:t,success:e,data:n,error:o};self.postMessage(h)}}class Gu extends $a{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=Vu({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),n=await e.execute(t);if(e.destroy(),n.success)return{model:n.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${n.error}'`)}else return{model:new M0().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,n=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 b=n(c.font);b&&g.push(b)}if(c.bigFont){const b=n(c.bigFont);b&&g.push(b)}if(c.extendedFont){const b=n(c.extendedFont);b&&g.push(b)}e.set(c.name,g)});const o=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,o),Array.from(o)}getFontsInBlock(t,e,n,o){const h=/\\f(.*?)\|/g;t.forEach(c=>{if(c.type=="MTEXT"){const g=c;[...g.text.matchAll(h)].forEach(w=>{o.add(w[1].toLowerCase())});const f=n.get(g.styleName);f==null||f.forEach(w=>o.add(w))}else if(c.type=="TEXT"){const g=c,b=n.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(c.type=="INSERT"){const b=e[c.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,n,o)}})}async processEntities(t,e,n,o,h){const c=new _l;let g=t.entities;const b=g.length,f=new Ma(b,100-o.value,n);this.config.convertByEntityType&&(g=this.groupAndFlattenByType(g));const w=e.tables.blockTable.modelSpace;await f.processChunk(async(x,E)=>{let M=[],L=x<E?g[x].type:"";for(let B=x;B<E;B++){const D=g[B],F=c.convert(D);F&&(this.config.convertByEntityType&&D.type!==L&&(w.appendEntity(M),M=[],L=D.type),M.push(F))}if(w.appendEntity(M),h){let B=o.value+E/b*(100-o.value);B>100&&(B=100),await h(B,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e){const n=new _l,o=t.length,h=[];for(let c=0;c<o;c++){const g=t[c],b=n.convert(g);b&&h.push(b)}e.appendEntity(h)}processBlocks(t,e){const n=t.blocks;for(const[o,h]of Object.entries(n)){let c=e.tables.blockTable.getAt(h.name);c||(c=new pe,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 n=t.header;n.$ACADVER&&(e.version=n.$ACADVER),e.cecolor.colorIndex=n.$CECOLOR||256,e.angBase=n.$ANGBASE||0,e.angDir=n.$ANGDIR||0,n.$AUNITS!=null&&(e.aunits=n.$AUNITS),n.$EXTMAX&&(e.extmax=n.$EXTMAX),n.$EXTMIN&&(e.extmin=n.$EXTMIN),n.$INSUNITS!=null&&(e.insunits=n.$INSUNITS),e.pdmode=n.$PDMODE||0,e.pdsize=n.$PDSIZE||0}processBlockTables(t,e){var o;const n=(o=t.tables.BLOCK_RECORD)==null?void 0:o.entries;n&&n.length>0&&(e.tables.blockTable.removeAll(),n.forEach(h=>{const c=new pe;c.objectId=h.handle,c.name=h.name,c.layoutId=h.layoutObjects,e.tables.blockTable.add(c)}))}processObjects(t,e){const n=t.objects.byName,o=new T0;if("LAYOUT"in n){const h=e.dictionaries.layouts;n.LAYOUT.forEach(c=>{const g=o.convertLayout(c,t);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in n){const h=e.dictionaries.imageDefs;n.IMAGEDEF.forEach(c=>{const g=o.convertImageDef(c);h.setAt(g.objectId,g)})}}processViewports(t,e){var o,h;const n=(h=(o=t.tables)==null?void 0:o.VPORT)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const g=new ec;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 n=(h=(o=t.tables)==null?void 0:o.LAYER)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const g=new Qr;g.colorIndex=c.colorIndex;const b=new Xi({name:c.name,standardFlags:c.standardFlag,linetype:c.lineType,lineWeight:c.lineweight,isOff:c.colorIndex<0,color:g,isPlottable:c.isPlotting});this.processCommonTableEntryAttrs(c,b),e.tables.layerTable.add(b)})}processLineTypes(t,e){var o,h;const n=(h=(o=t.tables)==null?void 0:o.LTYPE)==null?void 0:h.entries;n&&n.length>0&&n.forEach(c=>{const g=new Ds(c);this.processCommonTableEntryAttrs(c,g),g.name=c.name,e.tables.linetypeTable.add(g)})}processTextStyles(t,e){var o;const n=(o=t.tables.STYLE)==null?void 0:o.entries;n&&n.length>0&&n.forEach(h=>{const c=new eo(h);this.processCommonTableEntryAttrs(h,c),e.tables.textStyleTable.add(c)})}processDimStyles(t,e){var o;const n=(o=t.tables.DIMSTYLE)==null?void 0:o.entries;n&&n.length>0&&n.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 Wn(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={},n=[];for(const o of t)e[o.type]||(e[o.type]=[],n.push(o.type)),e[o.type].push(o);return n.flatMap(o=>e[o])}}class ju extends $a{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,n,o,h){let c=t.tables.blockTable.modelSpace.newIterator().toArray();const g=c.length,b=new Ma(g,100-o.value,n);this.config.convertByEntityType&&(c=this.groupAndFlattenByType(c));const f=e.tables.blockTable.modelSpace;await b.processChunk(async(w,x)=>{let E=[],M=w<x?c[w].type:"";for(let L=w;L<x;L++){const B=c[L];this.config.convertByEntityType&&B.type!==M&&(this.triggerEvents(f,E),E=[],M=B.type),E.push(B)}if(this.triggerEvents(f,E),h){let L=o.value+x/g*(100-o.value);L>100&&(L=100),await h(L,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const n=e.newIterator().toArray();this.triggerEvents(e,n)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.dictionaries.layouts.newIterator();for(const n of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.layoutName});const e=this._database.dictionaries.imageDefs.newIterator();for(const n of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.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={},n=[];for(const o of t)e[o.type]||(e[o.type]=[],n.push(o.type)),e[o.type].push(o);return n.flatMap(o=>e[o])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}var Fs=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Fs||{});class dr{constructor(){this.events={registered:new ae,unregistered:new ae},this._converters=new Map,this.register("dxf",new Gu)}static createInstance(){return dr._instance==null&&(dr._instance=new dr),this._instance}static get instance(){return dr._instance||(dr._instance=new dr),dr._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 Sn extends Jr{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),n=this._recordsByName.get(e);return n?(this._recordsById.delete(n.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 Yi(this._recordsByName)}normalizeName(t){return t}}class Wu extends Sn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(pe.MODEL_SPACE_NAME);return t||(t=new pe,t.name=pe.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(pe.isModelSapceName(t))e=pe.MODEL_SPACE_NAME;else if(pe.isPaperSapceName(t)){const n=pe.PAPER_SPACE_NAME_PREFIX,o=t.substring(n.length);e=n+o}return e}}class Hu extends Sn{constructor(t){super(t)}}class Xi extends An{constructor(t,e){t=t||{},Hn(t,{color:new Qr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new Ui,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(n=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:n.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class Yu extends Sn{constructor(t){super(t);const e=new Qr,n=new Xi({name:"0",standardFlags:0,linetype:li,lineWeight:1,isOff:!1,color:e,isPlottable:!0});this.add(n)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class qu extends Sn{constructor(t){super(t)}}class Xu extends Sn{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())}},n=this.newIterator();for(const o of n)e(o.fileName),e(o.bigFontFileName);return Array.from(t)}}class Ku extends Sn{constructor(t){super(t)}}class C0 extends Jr{constructor(){super(),this.events={dictObjetSet:new ae,dictObjectErased:new ae,entityAppended:new ae,entityModified:new ae,layerAppended:new ae,layerModified:new ae,layerErased:new ae,openProgress:new ae,headerSysVarChanged:new ae},this._version=new Bi("AC1014"),this._angBase=0,this._angDir=0,this._aunits=Ta.DecimalDegrees,this._celtscale=1,this._cecolor=new Qr,this._extents=new Nt,this._insunits=Ka.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Wu(this),dimStyleTable:new Hu(this),linetypeTable:new qu(this),textStyleTable:new Xu(this),layerTable:new Yu(this),viewportTable:new Ku(this)},this._dictionaries={layouts:new Ih(this),imageDefs:new Xa(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 Bi(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,n=Fs.DXF){const o=dr.instance.get(n);if(o==null)throw new Error(`Database converter for file type '${n}' 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,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:c,subStageStatus:g,data:b}),e&&e.fontLoader&&c=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var M;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const n=await fetch(t);if(!n.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 '${n.status}'!`);const o=n.headers.get("content-length"),h=o?parseInt(o,10):null;let c=0;const g=(M=n.body)==null?void 0:M.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:L,value:B}=await g.read();if(L)break;if(b.push(B),c+=B.length,h!==null){const D=Math.round(c/h*100);this.events.openProgress.dispatch({database:this,percentage:D,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(c);let w=0;for(const L of b)f.set(L,w),w+=L.length;this.getFileNameFromUri(t).toLowerCase().split(".").pop()==="dwg"?await this.read(f.buffer,e,Fs.DWG):await this.read(f.buffer,e,Fs.DXF),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}async regen(){await new ju(this).read(null,this,500,async(e,n,o,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:n,subStageStatus:o,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Eh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}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})}getFileNameFromUri(t){try{const n=new URL(t).pathname.split("/");return n[n.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}var $u=(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))($u||{}),Zu=(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))(Zu||{}),Qu=(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))(Qu||{}),Ju=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(Ju||{}),tc=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(tc||{});const Ri=class Ri extends An{constructor(t,e){t=t||{},Hn(t,Ri.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)}};Ri.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 Wn=Ri;class Ds extends An{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}}const Fi=class Fi{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new ae},this.registerVar({name:"PICKBOX",type:"number",defaultValue:0})}static instance(){return this._instance||(this._instance=new Fi),this._instance}registerVar(t){this.registry.set(t.name.toUpperCase(),t)}registerMany(t){t.forEach(e=>this.registerVar(e))}getVar(t){if(t=t.toUpperCase(),this.cache.has(t))return this.cache.get(t)}setVar(t,e){t=t.toUpperCase();const n=this.getDescriptor(t);if(n){const o=this.getVar(t);if(this.cache.set(t,e),n.type!=="string"&&(typeof e=="string"||e instanceof String))if(n.type==="number"){const h=Number(e);if(Number.isNaN(h))throw new Error("Invalid input!");e=h}else n.type==="boolean"&&(e=this.parseBoolean(e));this.events.sysVarChanged.dispatch({name:t,newVal:e,oldVal:o})}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(t.toUpperCase())}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),n=new Set(["true","t","1","yes","y"]),o=new Set(["false","f","0","no","n"]);return n.has(e)?!0:(o.has(e),!1)}};Fi._instance=null;let Ea=Fi;class eo extends An{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 n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t}}const L0={center:new Tt,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:Ha.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:Ya.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:qa.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class ec extends An{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=L0}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 rc{constructor(){this.events={layoutCreated:new ae,layoutRemoved:new ae,layoutRenamed:new ae,layoutSwitched:new ae}}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 n=this.getWorkingDatabase(e),o=n.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(o,n)}setCurrentLayoutBtrId(t,e){const n=this.getWorkingDatabase(e),o=n.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(o,n)}setCurrentLayout(t,e){const n=this.getWorkingDatabase(e),o=n.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(o,n)}renameLayout(t,e,n){const h=this.getWorkingDatabase(n).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 n=this.getWorkingDatabase(e).dictionaries.layouts,o=n.getAt(t);let h=!1;return o&&(h=n.remove(t),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(t,e){const n=this.getWorkingDatabase(e),o=new Hi;o.layoutName=t,o.tabOrder=n.dictionaries.layouts.maxTabOrder;const h=new pe;return h.name=`*Paper_Space${o.tabOrder}`,n.tables.blockTable.add(h),n.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||ro().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function ro(){return zi.instance}const Di=class Di{constructor(){this._workingDatabase=null,this._layoutManager=new rc}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}};Di.instance=new Di;let zi=Di;exports.AcCmColor=Qr;exports.AcCmColorMethod=mt;exports.AcCmColorUtil=gn;exports.AcCmEntityColor=bc;exports.AcCmErrors=He;exports.AcCmEventDispatcher=xc;exports.AcCmEventManager=ae;exports.AcCmLoader=Mc;exports.AcCmLoadingManager=Pl;exports.AcCmObject=wl;exports.AcCmPerformanceCollector=ka;exports.AcCmTask=Sl;exports.AcCmTaskScheduler=Il;exports.AcCmTransparency=Ui;exports.AcCmTransparencyMethod=Se;exports.AcDb2dPolyline=ci;exports.AcDb2dVertex=Aa;exports.AcDb2dVertexType=ph;exports.AcDb3PointAngularDimension=Mi;exports.AcDb3dPolyline=di;exports.AcDb3dVertex=Sa;exports.AcDb3dVertexType=mh;exports.AcDbAlignedDimension=Ti;exports.AcDbAngleUnits=Ta;exports.AcDbArc=pi;exports.AcDbArcDimension=Ia;exports.AcDbBaseWorker=N0;exports.AcDbBatchProcessing=Ma;exports.AcDbBlockReference=Us;exports.AcDbBlockTable=Wu;exports.AcDbBlockTableRecord=pe;exports.AcDbCircle=mi;exports.AcDbCodePage=Na;exports.AcDbCurve=Ee;exports.AcDbDataGenerator=Eh;exports.AcDbDatabase=C0;exports.AcDbDatabaseConverter=$a;exports.AcDbDatabaseConverterManager=dr;exports.AcDbDiametricDimension=Ni;exports.AcDbDictionary=Xa;exports.AcDbDimArrowType=kh;exports.AcDbDimStyleTable=Hu;exports.AcDbDimStyleTableRecord=Wn;exports.AcDbDimTextHorizontal=$u;exports.AcDbDimTextVertical=Zu;exports.AcDbDimVerticalJustification=tc;exports.AcDbDimZeroSuppression=Qu;exports.AcDbDimZeroSuppressionAngular=Ju;exports.AcDbDimension=Or;exports.AcDbDwgVersion=Bi;exports.AcDbDxfConverter=Gu;exports.AcDbEllipse=gi;exports.AcDbEntity=Pe;exports.AcDbFace=fi;exports.AcDbFileType=Fs;exports.AcDbHatch=Vs;exports.AcDbHatchPatternType=gh;exports.AcDbHatchStyle=fh;exports.AcDbHostApplicationServices=zi;exports.AcDbLayerTable=Yu;exports.AcDbLayerTableRecord=Xi;exports.AcDbLayout=Hi;exports.AcDbLayoutDictionary=Ih;exports.AcDbLayoutManager=rc;exports.AcDbLeader=_i;exports.AcDbLeaderAnnotationType=_h;exports.AcDbLine=yi;exports.AcDbLineSpacingStyle=Sh;exports.AcDbLinetypeTable=qu;exports.AcDbLinetypeTableRecord=Ds;exports.AcDbMText=vi;exports.AcDbObject=Jr;exports.AcDbObjectIterator=Yi;exports.AcDbOrdinateDimension=Ci;exports.AcDbOsnapMode=yn;exports.AcDbPoint=Si;exports.AcDbPoly2dType=Vn;exports.AcDbPoly3dType=Rs;exports.AcDbPolyline=Ai;exports.AcDbRadialDimension=Li;exports.AcDbRasterImage=js;exports.AcDbRasterImageClipBoundaryType=wh;exports.AcDbRasterImageDef=Ph;exports.AcDbRasterImageImageDisplayOpt=Ah;exports.AcDbRay=Ii;exports.AcDbRegenerator=ju;exports.AcDbRenderingCache=Xr;exports.AcDbSpline=Gs;exports.AcDbSymbolTable=Sn;exports.AcDbSymbolTableRecord=An;exports.AcDbSysVarManager=Ea;exports.AcDbTable=bi;exports.AcDbText=xi;exports.AcDbTextHorizontalMode=bh;exports.AcDbTextStyleTable=Xu;exports.AcDbTextStyleTableRecord=eo;exports.AcDbTextVerticalMode=xh;exports.AcDbTrace=wi;exports.AcDbUnitsValue=Ka;exports.AcDbViewport=Pi;exports.AcDbViewportTable=Ku;exports.AcDbViewportTableRecord=ec;exports.AcDbWipeout=Ei;exports.AcDbWorkerApi=Uu;exports.AcDbWorkerManager=Du;exports.AcDbXline=ki;exports.AcGeArea2d=Gi;exports.AcGeBox2d=ve;exports.AcGeBox3d=Nt;exports.AcGeCatmullRomCurve3d=ch;exports.AcGeCircArc2d=jn;exports.AcGeCircArc3d=Ga;exports.AcGeCurve2d=Yn;exports.AcGeEllipseArc2d=ji;exports.AcGeEllipseArc3d=Wi;exports.AcGeEuler=ah;exports.AcGeGeometryUtil=Ql;exports.AcGeLine2d=zs;exports.AcGeLine3d=ui;exports.AcGeLoop2d=ja;exports.AcGeMathUtil=kt;exports.AcGeMatrix2d=Vi;exports.AcGeMatrix3d=$r;exports.AcGeNurbsCurve=bn;exports.AcGePlane=Ws;exports.AcGePoint2d=Tt;exports.AcGePoint3d=Y;exports.AcGePolyline2d=wn;exports.AcGeQuaternion=Kr;exports.AcGeShape2d=Va;exports.AcGeSpline3d=Zr;exports.AcGeTol=Fa;exports.AcGeVector2d=Zt;exports.AcGeVector3d=Z;exports.AcGiArrowType=Wa;exports.AcGiDefaultLightingType=qa;exports.AcGiMTextAttachmentPoint=Ie;exports.AcGiMTextFlowDirection=Lr;exports.AcGiOrthographicType=Ya;exports.AcGiRenderMode=Ha;exports.AcGiViewport=yh;exports.AcTrStringUtil=kc;exports.ByBlock=Ml;exports.ByLayer=ei;exports.DEBUG_MODE=Pc;exports.DEFAULT_LINE_TYPE=li;exports.DEFAULT_TOL=Da;exports.DEG2RAD=Ca;exports.DefaultLoadingManager=El;exports.FLOAT_TOL=_n;exports.ORIGIN_POINT_2D=Nc;exports.ORIGIN_POINT_3D=Ra;exports.RAD2DEG=La;exports.TAU=se;exports.acdbHostApplicationServices=ro;exports.basisFunction=hi;exports.calculateCurveLength=rh;exports.ceilPowerOfTwo=Wl;exports.clamp=Cr;exports.clone=Ns;exports.createWorkerApi=Vu;exports.damp=Ll;exports.deepClone=ya;exports.defaults=Hn;exports.degToRad=Vl;exports.dwgCodePageToEncoding=kl;exports.euclideanModulo=Oa;exports.evaluateNurbsPoint=Bs;exports.floorPowerOfTwo=Hl;exports.generateChordKnots=th;exports.generateSqrtChordKnots=eh;exports.generateUUID=Tl;exports.generateUniformKnots=Jl;exports.has=yl;exports.intPartLength=za;exports.interpolateControlPoints=Cc;exports.inverseLerp=Cl;exports.isBetween=Yl;exports.isBetweenAngle=ql;exports.isEmpty=vl;exports.isEqual=Gn;exports.isImperialUnits=jc;exports.isMetricUnits=Gc;exports.isPointInPolygon=Ua;exports.isPolygonIntersect=Zl;exports.isPowerOfTwo=jl;exports.lerp=Ba;exports.log=Ls;exports.mapLinear=Nl;exports.normalizeAngle=Os;exports.pingpong=Ol;exports.radToDeg=Gl;exports.randFloat=Fl;exports.randFloatSpread=Dl;exports.randInt=Rl;exports.relativeEps=Xl;exports.seededRandom=Ul;exports.setLogLevel=Ec;exports.smootherstep=zl;exports.smoothstep=Bl;