@mlightcad/data-model 1.3.12 → 1.3.13

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
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function lu(i,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const o in s)if(o!=="default"&&!(o in i)){const h=Object.getOwnPropertyDescriptor(s,o);h&&Object.defineProperty(i,o,h.get?h:{enumerable:!0,get:()=>s[o]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}const Zs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ji=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];function ds(i,t,e){return Math.max(t,Math.min(e,i))}const hl=class cl{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(t){t==null?this._color=null:(this._color=Math.round(ds(t,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let t=this._color.toString(16).toUpperCase();for(;t.length<6;)t="0"+t;return`0x${t}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(t){t==null?this._colorIndex=null:(this._colorIndex=ds(t,0,256),this._colorIndex>0&&this._colorIndex<256?(this._color=Ji[t],this._colorName=this.getColorNameByValue(this._color)):(this._color=null,this._colorName=null))}get colorName(){return this._colorName}set colorName(t){if(t){const e=Zs[t.toLowerCase()];e!==void 0?(this._colorName=t,this._color=e,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+t)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(t){return this.setRGB(t,t,t),this}setRGB(t,e,s){const o=Math.round(ds(t,0,255)),h=Math.round(ds(e,0,255)),u=Math.round(ds(s,0,255));return this.color=(o<<16)+(h<<8)+u,this}setColorName(t){const e=Zs[t.toLowerCase()];return e!==void 0?this.color=e:console.warn("Unknown color "+t),this}clone(){const t=new cl;return t.colorIndex=this.colorIndex,t.color=this.color,t._colorName=this._colorName,this}copy(t){return this.colorIndex=t.colorIndex,this.color=t.color,this._colorName=t._colorName,this}equals(t){return t.color==this.color&&t.colorIndex==this.colorIndex&&t._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(t){for(const[e,s]of Object.entries(Zs))if(s===t)return e;return null}getColorIndexByValue(t){const e=Ji.length-1;for(let s=1;s<e;++s)if(Ji[s]===t)return s;return null}};hl.NAMES=Zs;let Yr=hl;const je={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};let hu=class{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const o=s.indexOf(e);o!==-1&&s.splice(o,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let o=0,h=s.length;o<h;o++)s[o].call(this,t)}}},ie=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};var cu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function uu(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ul={exports:{}};(function(i){(function(t,e){i.exports?i.exports=e():t.log=e()})(cu,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={},u=null;function g(z,D){var B=z[D];if(typeof B.bind=="function")return B.bind(z);try{return Function.prototype.bind.call(B,z)}catch{return function(){return Function.prototype.apply.apply(B,[z,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function f(z){return z==="debug"&&(z="log"),typeof console===e?!1:z==="trace"&&s?b:console[z]!==void 0?g(console,z):console.log!==void 0?g(console,"log"):t}function w(){for(var z=this.getLevel(),D=0;D<o.length;D++){var B=o[D];this[B]=D<z?t:this.methodFactory(B,z,this.name)}if(this.log=this.debug,typeof console===e&&z<this.levels.SILENT)return"No console available for logging"}function x(z){return function(){typeof console!==e&&(w.call(this),this[z].apply(this,arguments))}}function E(z,D,B){return f(z)||x.apply(this,arguments)}function T(z,D){var B=this,dt,yt,ot,W="loglevel";typeof z=="string"?W+=":"+z:typeof z=="symbol"&&(W=void 0);function ct(xt){var Ot=(o[xt]||"silent").toUpperCase();if(!(typeof window===e||!W)){try{window.localStorage[W]=Ot;return}catch{}try{window.document.cookie=encodeURIComponent(W)+"="+Ot+";"}catch{}}}function st(){var xt;if(!(typeof window===e||!W)){try{xt=window.localStorage[W]}catch{}if(typeof xt===e)try{var Ot=window.document.cookie,de=encodeURIComponent(W),me=Ot.indexOf(de+"=");me!==-1&&(xt=/^([^;]+)/.exec(Ot.slice(me+de.length+1))[1])}catch{}return B.levels[xt]===void 0&&(xt=void 0),xt}}function Vt(){if(!(typeof window===e||!W)){try{window.localStorage.removeItem(W)}catch{}try{window.document.cookie=encodeURIComponent(W)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function qt(xt){var Ot=xt;if(typeof Ot=="string"&&B.levels[Ot.toUpperCase()]!==void 0&&(Ot=B.levels[Ot.toUpperCase()]),typeof Ot=="number"&&Ot>=0&&Ot<=B.levels.SILENT)return Ot;throw new TypeError("log.setLevel() called with invalid level: "+xt)}B.name=z,B.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},B.methodFactory=D||E,B.getLevel=function(){return ot??yt??dt},B.setLevel=function(xt,Ot){return ot=qt(xt),Ot!==!1&&ct(ot),w.call(B)},B.setDefaultLevel=function(xt){yt=qt(xt),st()||B.setLevel(xt,!1)},B.resetLevel=function(){ot=null,Vt(),w.call(B)},B.enableAll=function(xt){B.setLevel(B.levels.TRACE,xt)},B.disableAll=function(xt){B.setLevel(B.levels.SILENT,xt)},B.rebuild=function(){if(u!==B&&(dt=qt(u.getLevel())),w.call(B),u===B)for(var xt in h)h[xt].rebuild()},dt=qt(u?u.getLevel():"WARN");var Wt=st();Wt!=null&&(ot=qt(Wt)),w.call(B)}u=new T,u.getLogger=function(z){if(typeof z!="symbol"&&typeof z!="string"||z==="")throw new TypeError("You must supply a name when creating a logger.");var D=h[z];return D||(D=h[z]=new T(z,u.methodFactory)),D};var L=typeof window!==e?window.log:void 0;return u.noConflict=function(){return typeof window!==e&&window.log===u&&(window.log=L),u},u.getLoggers=function(){return h},u.default=u,u})})(ul);var dl=ul.exports;const du=uu(dl),mu=lu({__proto__:null,default:du},[dl]),pu=!0,Ns=mu;Ns.setLevel("debug");const gu=i=>{try{Ns.setLevel(i)}catch(t){Ns.setLevel("error"),Ns.error(t)}};function Ts(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function Gn(i,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i[s]===void 0&&(i[s]=e[s]);return i}function ml(i,t){return i!=null&&Object.prototype.hasOwnProperty.call(i,t)}function pl(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function Dn(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(!Dn(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)||!Dn(i[o],t[o]))return!1;return!0}let gl=class fl{constructor(t,e){this.events={attrChanged:new ie,modelChanged:new ie},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&Gn(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,u=s.silent,g=[],b=this._changing;this._changing=!0,b||(this._previousAttributes=Ts(this.attributes),this.changed={});const f=this.attributes,w=this.changed,x=this._previousAttributes;for(const E in o)e=o[E],Dn(f[E],e)||g.push(E),Dn(x[E],e)?delete w[E]:w[E]=e,h?delete f[E]:f[E]=e;if(!u){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(!u)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!pl(this.changed):ml(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?Ts(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const o in t){const h=t[o];Dn(e[o],h)||(s[o]=h)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return Ts(this._previousAttributes)}clone(){const t=Ts(this.attributes);return new fl(t)}},wa=class Ms{constructor(){this.entries=new Map}static getInstance(){return Ms.instance||(Ms.instance=new Ms),Ms.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 fu{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"],u=Math.floor(Math.log(t)/Math.log(s)),g=t/Math.pow(s,u);return`${parseFloat(g.toFixed(o))} ${h[u]}`}}class _l{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class yl{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 u=await h.run(s);return this.onProgress((o+1)/e,h),u})}catch(u){if(this.onError({error:u,taskIndex:o,task:h}))break}}this.onComplete(s)}}let vl=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 bl=new vl;let _u=class{constructor(t){this.manager=t!==void 0?t:bl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,o)=>{this.load(t,s,e,o)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};class Aa{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const o=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(o):setTimeout(o,0)})}async processChunk(t){let e=0;const s=async()=>{const o=e,h=Math.min(e+this._chunkSize,this._count);await t(o,h),e=h,e<this._count&&await this.scheduleTask(s)};await s()}}var Sa=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(Sa||{});class Hr{static get instance(){return this._instance||(this._instance=new Hr),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,u){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 T=!0;for(const L of E)if(L.color.isByBlock&&s?(Ho.copy(L.color),L.color.color=s,this.addEntity(L,g,t),L.color.copy(Ho)):this.addEntity(L,g,t),T){const z=g[0];t.basePoint=z.basePoint,T=!1}w=t.group(g),w&&o&&this.set(f,w),t.basePoint=x}return w&&h&&(w.applyMatrix(h),u&&(u.x!=0||u.y!=0||u.z!=1)&&(h.setFromExtrusionDirection(u),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 Ho=new Yr;var Pa=(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))(Pa||{});const yu=["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"],xl=i=>yu[i],si="Continuous",Qs="ByLayer",wl="ByBlock";var pn=(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))(pn||{}),Ia=(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))(Ia||{});function vu(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function bu(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}var Al=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(Al||{});class zi{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}const Sl="Load Database";class ke extends _l{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=wa.getInstance().getEntry(Sl),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const o=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",o?o.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-s),o}}class Ea{constructor(t={}){this.config=t}async read(t,e,s,o){const h={name:Sl,data:{total:0},format(){let f="";return Object.keys(this.data).forEach(w=>{w!=="total"&&(f+=`- ${w}: ${this.data[w]} ms
2
- `)}),f+=`- total: ${this.data.total} ms`,f}};wa.getInstance().collect(h),this.progress=o;const u={value:0},g=new yl;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new ke({stage:"START",step:1,progress:u,task:async f=>f},o)),g.addTask(new ke({stage:"PARSE",step:5,progress:u,task:async f=>await this.parse(f)},o)),g.addTask(new ke({stage:"FONT",step:5,progress:u,task:async f=>{const w=this.getFonts(f.model);return{model:f.model,data:w}}},o)),g.addTask(new ke({stage:"LTYPE",step:1,progress:u,task:async f=>(this.processLineTypes(f.model,e),f)},o)),g.addTask(new ke({stage:"STYLE",step:1,progress:u,task:async f=>(this.processTextStyles(f.model,e),f)},o)),g.addTask(new ke({stage:"DIMSTYLE",step:1,progress:u,task:async f=>(this.processDimStyles(f.model,e),f)},o)),g.addTask(new ke({stage:"LAYER",step:1,progress:u,task:async f=>(this.processLayers(f.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),f)},o)),g.addTask(new ke({stage:"VPORT",step:1,progress:u,task:async f=>(this.processViewports(f.model,e),f)},o)),g.addTask(new ke({stage:"HEADER",step:1,progress:u,task:async f=>(this.processHeader(f.model,e),f)},o)),g.addTask(new ke({stage:"BLOCK_RECORD",step:5,progress:u,task:async f=>(this.processBlockTables(f.model,e),f)},o)),g.addTask(new ke({stage:"OBJECT",step:5,progress:u,task:async f=>(this.processObjects(f.model,e),e.dictionaries.layouts.numEntries===0&&e.createDefaultData({layout:!0}),f)},o)),g.addTask(new ke({stage:"BLOCK",step:5,progress:u,task:async f=>(await this.processBlocks(f.model,e),f)},o)),g.addTask(new ke({stage:"ENTITY",step:100,progress:u,task:async f=>(await this.processEntities(f.model,e,s,u,o),f)},o)),g.addTask(new ke({stage:"END",step:0,progress:u,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"),Hr.instance.clear())}async parse(t,e){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,o,h){throw new Error("Not impelemented yet!")}}var he,ms,Qt,se,ps,tr,ve,gr,er,nn,gs,fs,sn,an,_s,ys,vs,Oe,fr,Yt,on,bs,_t,be,xs,xe,ws,_r,yr,rr,As,ln,ze,vr,hn,ta,ea,br,xr,Ss,Ps,wr,Is,ra,na,ce,Ar,ue,Re,sa,ia,aa,oa,Sr,Fe,cn,Es,un,Be,Pr,De,Ir;(he={})[he.None=0]="None",he[he.Anonymous=1]="Anonymous",he[he.NonConstant=2]="NonConstant",he[he.Xref=4]="Xref",he[he.XrefOverlay=8]="XrefOverlay",he[he.ExternallyDependent=16]="ExternallyDependent",he[he.ResolvedOrDependent=32]="ResolvedOrDependent",he[he.ReferencedXref=64]="ReferencedXref";(ms={})[ms.BYBLOCK=0]="BYBLOCK",ms[ms.BYLAYER=256]="BYLAYER";(Qt={})[Qt.Rotated=0]="Rotated",Qt[Qt.Aligned=1]="Aligned",Qt[Qt.Angular=2]="Angular",Qt[Qt.Diameter=3]="Diameter",Qt[Qt.Radius=4]="Radius",Qt[Qt.Angular3Point=5]="Angular3Point",Qt[Qt.Ordinate=6]="Ordinate",Qt[Qt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Qt[Qt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Qt[Qt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(se={})[se.TopLeft=1]="TopLeft",se[se.TopCenter=2]="TopCenter",se[se.TopRight=3]="TopRight",se[se.MiddleLeft=4]="MiddleLeft",se[se.MiddleCenter=5]="MiddleCenter",se[se.MiddleRight=6]="MiddleRight",se[se.BottomLeft=7]="BottomLeft",se[se.BottomCenter=8]="BottomCenter",se[se.BottomRight=9]="BottomRight";(ps={})[ps.AtLeast=1]="AtLeast",ps[ps.Exact=2]="Exact";var Yo=((tr={})[tr.Center=0]="Center",tr[tr.Above=1]="Above",tr[tr.Outside=2]="Outside",tr[tr.JIS=3]="JIS",tr[tr.Below=4]="Below",tr),zn=((ve={})[ve.Feet=0]="Feet",ve[ve.None=1]="None",ve[ve.Inch=2]="Inch",ve[ve.FeetAndInch=3]="FeetAndInch",ve[ve.Leading=4]="Leading",ve[ve.Trailing=8]="Trailing",ve[ve.LeadingAndTrailing=12]="LeadingAndTrailing",ve),xu=((gr={})[gr.None=0]="None",gr[gr.Leading=1]="Leading",gr[gr.Trailing=2]="Trailing",gr[gr.LeadingAndTrailing=3]="LeadingAndTrailing",gr),wu=((er={})[er.Center=0]="Center",er[er.Left=1]="Left",er[er.Right=2]="Right",er[er.OverFirst=3]="OverFirst",er[er.OverSecond=4]="OverSecond",er),Au=((nn={})[nn.Bottom=0]="Bottom",nn[nn.Center=1]="Center",nn[nn.Top=2]="Top",nn);(gs={})[gs.PatternFill=0]="PatternFill",gs[gs.SolidFill=1]="SolidFill";(fs={})[fs.NonAssociative=0]="NonAssociative",fs[fs.Associative=1]="Associative";(sn={})[sn.Normal=0]="Normal",sn[sn.Outer=1]="Outer",sn[sn.Ignore=2]="Ignore";(an={})[an.UserDefined=0]="UserDefined",an[an.Predefined=1]="Predefined",an[an.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 Su=((Oe={})[Oe.Default=0]="Default",Oe[Oe.External=1]="External",Oe[Oe.Polyline=2]="Polyline",Oe[Oe.Derived=4]="Derived",Oe[Oe.Textbox=8]="Textbox",Oe[Oe.Outermost=16]="Outermost",Oe),Hs=((fr={})[fr.Line=1]="Line",fr[fr.Circular=2]="Circular",fr[fr.Elliptic=3]="Elliptic",fr[fr.Spline=4]="Spline",fr),Pu=((Yt={})[Yt.Off=0]="Off",Yt[Yt.Solid=1]="Solid",Yt[Yt.Dashed=2]="Dashed",Yt[Yt.Dotted=3]="Dotted",Yt[Yt.ShotDash=4]="ShotDash",Yt[Yt.MediumDash=5]="MediumDash",Yt[Yt.LongDash=6]="LongDash",Yt[Yt.DoubleShortDash=7]="DoubleShortDash",Yt[Yt.DoubleMediumDash=8]="DoubleMediumDash",Yt[Yt.DoubleLongDash=9]="DoubleLongDash",Yt[Yt.DoubleMediumLongDash=10]="DoubleMediumLongDash",Yt[Yt.SparseDot=11]="SparseDot",Yt);Pu.Off;(on={})[on.Standard=-3]="Standard",on[on.ByLayer=-2]="ByLayer",on[on.ByBlock=-1]="ByBlock";(bs={})[bs.English=0]="English",bs[bs.Metric=1]="Metric";(_t={})[_t.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",_t[_t.FRONT_CLIPPING=2]="FRONT_CLIPPING",_t[_t.BACK_CLIPPING=4]="BACK_CLIPPING",_t[_t.UCS_FOLLOW=8]="UCS_FOLLOW",_t[_t.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",_t[_t.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",_t[_t.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",_t[_t.FAST_ZOOM=128]="FAST_ZOOM",_t[_t.SNAP_MODE=256]="SNAP_MODE",_t[_t.GRID_MODE=512]="GRID_MODE",_t[_t.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",_t[_t.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",_t[_t.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",_t[_t.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",_t[_t.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",_t[_t.UNUSED=32768]="UNUSED",_t[_t.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",_t[_t.VIEWPORT_OFF=131072]="VIEWPORT_OFF",_t[_t.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",_t[_t.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",_t[_t.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",_t[_t.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(be={})[be.OPTIMIZED_2D=0]="OPTIMIZED_2D",be[be.WIREFRAME=1]="WIREFRAME",be[be.HIDDEN_LINE=2]="HIDDEN_LINE",be[be.FLAT_SHADED=3]="FLAT_SHADED",be[be.GOURAUD_SHADED=4]="GOURAUD_SHADED",be[be.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",be[be.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";(xe={})[xe.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",xe[xe.TOP=1]="TOP",xe[xe.BOTTOM=2]="BOTTOM",xe[xe.FRONT=3]="FRONT",xe[xe.BACK=4]="BACK",xe[xe.LEFT=5]="LEFT",xe[xe.RIGHT=6]="RIGHT";(ws={})[ws.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ws[ws.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(_r={})[_r.ByLayer=0]="ByLayer",_r[_r.ByBlock=1]="ByBlock",_r[_r.ByDictionaryDefault=2]="ByDictionaryDefault",_r[_r.ByObject=3]="ByObject";function At(i,t,e){return i.code===t&&(e==null||i.value===e)}function Rt(i){let t={};i.rewind();let e=i.next(),s=e.code;if(t.x=e.value,(e=i.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=i.next()).code!==s+20?i.rewind():t.z=e.value,t}let ka=Symbol();function bt(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 T of typeof x.code=="number"?[x.code]:x.code){let L=E[T]??(E[T]=[]);x.isMultiple&&L.length&&f&&console.warn(`Snippet ${L[L.length-1].name} for code(${T}) is shadowed by ${x.name}`),L.push(x)}return w},[{}])}(i,s.debug),u=!1,g=h.length-1;for(;!At(e,0,"EOF");){let b=function(D,B,dt){return D.find((yt,ot)=>{var W;return ot>=dt&&((W=yt[B])==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:T,isReducible:L}=w,z=E==null?void 0:E(e,s,o);if(z===ka){s.rewind();break}if(x){let[D,B]=function(dt,yt){let ot=yt.split(".");if(!ot.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let W=dt;for(let ct=0;ct<ot.length-1;++ct){let st=la(ot[ct]),Vt=la(ot[ct+1]);Object.prototype.hasOwnProperty.call(W,st)||(typeof Vt=="number"?W[st]=[]:W[st]={}),W=W[st]}return[W,la(ot[ot.length-1])]}(o,x);T&&!L?(Object.prototype.hasOwnProperty.call(D,B)||(D[B]=[]),D[B].push(z)):D[B]=z}w.pushContext&&(g-=1),u=!0,e=s.next()}return t&&Object.setPrototypeOf(o,t),u}}function la(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 Bt({value:i}){return!!i}let Iu=[{code:1001,name:"xdata",parser:Pl}];function Pl(i,t){var o;if(!At(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let s=[e.value];for(;!At(i,0,"EOF")&&i.code>=1e3;){let h=s[s.length-1];switch(i.code){case 1002:i.value==="{"?s.push([]):(s.pop(),(o=s[s.length-1])==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Er(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Er(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Er(i.code),value:i.value});break;case 1010:h.push({type:Er(i.code),value:Rt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Er(i.code),value:Rt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Er(i.code),value:Rt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Er(i.code),value:Rt(t)});break;case 1041:h.push({name:"distance",type:Er(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Er(i.code),value:i.value})}i=t.next()}return t.rewind(),e}function Er(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 fn(i,t,e){for(;At(i,102);){var s;let o=i.value;if(i=t.next(),!o.startsWith("{")){t.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${o}`),function(u,g){for(;!At(u,102)&&!At(u,0,"EOF");)u=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(u,g,b){for(;!At(u,102,"}")&&!At(u,0,"EOF");)b.push(u),u=g.next()}(i,t,e.extensions[h]),i=t.next()}t.rewind()}let Eu=0;function Il(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=Eu++)}var ku=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function El(i){return ku[i]}(yr={})[yr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",yr[yr.CAST=1]="CAST",yr[yr.RECEIVE=2]="RECEIVE",yr[yr.IGNORE=3]="IGNORE";let Ut=[...Iu,{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:Bt},{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=El(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:Bt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:v},{code:102,parser:fn},{code:102,parser:fn},{code:102,parser:fn},{code:5,name:"handle",parser:v}];function Ri(i){return[{code:3,name:i,parser:(t,e,s)=>(s._code3text=(s._code3text??"")+t.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(t,e,s)=>(s._code1text=t.value,(s._code3text??"")+s._code1text)}]}function kl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Tu={extrusionDirection:{x:0,y:0,z:1}},Mu=[{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},...Ut];class Tl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kl(this,"parser",bt(Mu,Tu))}}kl(Tl,"ForEntityName","ARC");(rr={})[rr.NONE=0]="NONE",rr[rr.INVISIBLE=1]="INVISIBLE",rr[rr.CONSTANT=2]="CONSTANT",rr[rr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",rr[rr.PRESET=8]="PRESET";(As={})[As.MULTILINE=2]="MULTILINE",As[As.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(ln={})[ln.NONE=0]="NONE",ln[ln.MIRRORED_X=2]="MIRRORED_X",ln[ln.MIRRORED_Y=4]="MIRRORED_Y";var Nu=((ze={})[ze.LEFT=0]="LEFT",ze[ze.CENTER=1]="CENTER",ze[ze.RIGHT=2]="RIGHT",ze[ze.ALIGNED=3]="ALIGNED",ze[ze.MIDDLE=4]="MIDDLE",ze[ze.FIT=5]="FIT",ze),Cu=((vr={})[vr.BASELINE=0]="BASELINE",vr[vr.BOTTOM=1]="BOTTOM",vr[vr.MIDDLE=2]="MIDDLE",vr[vr.TOP=3]="TOP",vr);function Ml(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Nl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Nu.LEFT,valign:Cu.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Cl=[{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},...Ut];class Ll{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ml(this,"parser",bt(Cl,Nl))}}function Ol(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ml(Ll,"ForEntityName","TEXT");let Lu={...Nl},Ou=[{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:Bt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedRecord",parser:Bt},{code:100},{code:280,name:"isLocked",parser:Bt},{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},...Cl.slice(2)];class zl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ol(this,"parser",bt(Ou,Lu))}}Ol(zl,"ForEntityName","ATTDEF");(hn={})[hn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",hn[hn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",hn[hn.BY_STYLE=5]="BY_STYLE";function zu(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*ii(i,t=1/0,e=1){for(let s=i;s!==t;s+=e)yield s}function jr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function Ta(i,t,e){if(At(t,102))return fn(t,e,i),!0;switch(t.code){case 0:i.type=t.value;break;case 5:i.handle=t.value;break;case 330:i.ownerBlockRecordSoftId=t.value;break;case 67:i.isInPaperSpace=!!t.value;break;case 8:i.layer=t.value;break;case 6:i.lineType=t.value;break;case 347:i.materialObjectHardId=t.value;break;case 62:i.colorIndex=t.value,i.color=El(Math.abs(t.value));break;case 370:i.lineweight=t.value;break;case 48:i.lineTypeScale=t.value;break;case 60:i.isVisible=!!t.value;break;case 92:i.proxyByte=t.value;break;case 310:i.proxyEntity=t.value;break;case 100:break;case 420:i.color=t.value;break;case 430:i.transparency=t.value;break;case 390:i.plotStyleHardId=t.value;break;case 284:i.shadowMode=t.value;break;case 1001:i.xdata=Pl(t,e);break;default:return!1}return!0}function Rl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Ru={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Js=[{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:[...ii(430,440)],name:"backgroundColor",parser:v},{code:[...ii(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},...Ri("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},...Ut];class Fl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Rl(this,"parser",bt(Js,Ru))}}function Bl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Rl(Fl,"ForEntityName","MTEXT");let Fu={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Bu=[...Js.slice(Js.findIndex(({name:i})=>i==="columnType"),Js.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!At(i,0,"MTEXT"))return ka}},{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:Bt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedEntriesKeep",parser:Bt},{code:100},{code:280,name:"lockPositionFlag",parser:Bt},{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},...Ut];class Dl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Bl(this,"parser",bt(Bu,Fu))}}function Ul(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Bl(Dl,"ForEntityName","ATTRIB");let Du=[...Ri("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Ut];class Vl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ul(this,"parser",bt(Du))}}function Gl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ul(Vl,"ForEntityName","BODY");let Uu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Vu=[{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},...Ut];class jl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gl(this,"parser",bt(Vu,Uu))}}Gl(jl,"ForEntityName","CIRCLE");class ti{parseEntity(t,e){let s={};for(;!At(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(o,h,u){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(u);break;case 11:o.textPoint=Rt(u);break;case 12:o.insertionPoint=Rt(u);break;case 13:o.subDefinitionPoint1=Rt(u);break;case 14:o.subDefinitionPoint2=Rt(u);break;case 15:o.centerPoint=Rt(u);break;case 16:o.arcPoint=Rt(u);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(u);break;case 3:o.styleName=h.value;break;default:Ta(o,h,u)}})(s,e,t),e=t.next()}return s}}function Wl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ea="DIMENSION",(ta="ForEntityName")in ti?Object.defineProperty(ti,ta,{value:ea,enumerable:!0,configurable:!0,writable:!0}):ti[ta]=ea;let Gu={extrusionDirection:{x:0,y:0,z:1}},ju=[{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},...Ut];class Hl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wl(this,"parser",bt(ju,Gu))}}Wl(Hl,"ForEntityName","ELLIPSE");(br={})[br.First=1]="First",br[br.Second=2]="Second",br[br.Third=4]="Third",br[br.Fourth=8]="Fourth";function Yl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Wu=[{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},...Ut];class ql{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Yl(this,"parser",bt(Wu))}}Yl(ql,"ForEntityName","3DFACE");let Xl=[{code:330,name:"sourceBoundaryObjects",parser:v,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:v}],Hu=[{code:11,name:"end",parser:j},{code:10,name:"start",parser:j}],Yu=[{code:73,name:"isCCW",parser:Bt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j}],qu=[{code:73,name:"isCCW",parser:Bt},{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}],Xu=[{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:Bt},{code:73,name:"splineFlag",parser:v},{code:94,name:"degree",parser:v}],Ku={[Hs.Line]:Hu,[Hs.Circular]:Yu,[Hs.Elliptic]:qu,[Hs.Spline]:Xu},$u=[...Xl,{code:72,name:"edges",parser(i,t){let e={type:i.value},s=bt(Ku[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}],Zu=[...Xl,{code:10,name:"vertices",parser(i,t){let e={...Rt(t),bulge:0};return(i=t.next()).code===42?e.bulge=i.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:v},{code:73,name:"isClosed",parser:Bt},{code:72,name:"hasBulge",parser:Bt}],Qu=[{code:49,name:"dashLengths",parser:v,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:v},{code:45,name:"offset",parser:qo},{code:43,name:"base",parser:qo},{code:53,name:"angle",parser:v}];function qo(i,t){let e=i.code+1,s={x:i.value,y:1};return(i=t.next()).code===e?s.y=i.value:t.rewind(),s}function Kl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Ju={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},td=[{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 bt(Qu)(i,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:v},{code:77,name:"isDouble",parser:Bt},{code:73,name:"isAnnotated",parser:Bt},{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&Su.Polyline;return i=t.next(),s?bt(Zu)(i,t,e):bt($u)(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},...Ut];class $l{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Kl(this,"parser",bt(td,Ju))}}Kl($l,"ForEntityName","HATCH");(xr={})[xr.ShowImage=1]="ShowImage",xr[xr.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",xr[xr.UseClippingBoundary=4]="UseClippingBoundary",xr[xr.TransparencyIsOn=8]="TransparencyIsOn";(Ss={})[Ss.Rectangular=1]="Rectangular",Ss[Ss.Polygonal=2]="Polygonal";(Ps={})[Ps.Outside=0]="Outside",Ps[Ps.Inside=1]="Inside";function Zl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let ed={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},rd=[{code:290,name:"clipMode",parser: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:Bt},{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},...Ut];class Ql{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zl(this,"parser",bt(rd,ed))}}function Jl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Zl(Ql,"ForEntityName","IMAGE");let nd={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},sd=[{code:210,name:"extrusionDirection",parser: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:Bt},{code:100,name:"subclassMarker",parser:v},...Ut];class th{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Jl(this,"parser",bt(sd,nd))}}function eh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Jl(th,"ForEntityName","INSERT");let id={isArrowheadEnabled:!0},ad=[{code:213,name:"offsetFromAnnotation",parser: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:Bt},{code:74,name:"isHooklineSameDirection",parser:Bt},{code:73,name:"leaderCreationFlag",parser:v},{code:72,name:"isSpline",parser:Bt},{code:71,name:"isArrowheadEnabled",parser:Bt},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...Ut],rh=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){eh(this,"parser",bt(ad,id))}};eh(rh,"ForEntityName","LEADER");(wr={})[wr.TextAnnotation=0]="TextAnnotation",wr[wr.ToleranceAnnotation=1]="ToleranceAnnotation",wr[wr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",wr[wr.NoAnnotation=3]="NoAnnotation";function nh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let od={thickness:0,extrusionDirection:{x:0,y:0,z:1}},ld=[{code:210,name:"extrusionDirection",parser: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},...Ut];class sh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nh(this,"parser",bt(ld,od))}}nh(sh,"ForEntityName","LINE");(Is={})[Is.IS_CLOSED=1]="IS_CLOSED",Is[Is.PLINE_GEN=128]="PLINE_GEN";let hd={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},cd={bulge:0},ud=[{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}],dd=[{code:210,name:"extrusionDirection",parser:j},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return bt(ud,cd)(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},...Ut];class ei{parseEntity(t,e){let s={};return bt(dd,hd)(e,t,s),s}}function ih(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}na="LWPOLYLINE",(ra="ForEntityName")in ei?Object.defineProperty(ei,ra,{value:na,enumerable:!0,configurable:!0,writable:!0}):ei[ra]=na;let md=[{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&&!At(i,0);++h)i=t.next(),s.push(i.value);let o=0;for(;o<s.length;){let h=s[o++],u=[];for(let g=0;g<h;++g)u.push(s[o++]);e.faceIndices.push(u)}}},{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:Bt},{code:71,name:"version",parser:v},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Ut];class ah{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ih(this,"parser",bt(md))}}function oh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ih(ah,"ForEntityName","MESH");let pd={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},gd=[{code:50,name:"angle",parser: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},...Ut];class lh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){oh(this,"parser",bt(gd,pd))}}oh(lh,"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 Ys=((Ar={})[Ar.NONE=0]="NONE",Ar[Ar.QUADRATIC=5]="QUADRATIC",Ar[Ar.CUBIC=6]="CUBIC",Ar[Ar.BEZIER=8]="BEZIER",Ar),fd=((ue={})[ue.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ue[ue.TANGENT_DEFINED=2]="TANGENT_DEFINED",ue[ue.NOT_USED=4]="NOT_USED",ue[ue.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ue[ue.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ue[ue.FOR_POLYLINE=32]="FOR_POLYLINE",ue[ue.FOR_POLYGON=64]="FOR_POLYGON",ue[ue.POLYFACE=128]="POLYFACE",ue);function hh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let _d={startWidth:0,endWidth:0,bulge:0},yd=[{code:91,name:"id",parser:v},{code:[...ii(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},...Ut];class Ma{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){hh(this,"parser",bt(yd,_d))}}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}hh(Ma,"ForEntityName","VERTEX");let vd={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:[]},bd=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>At(i,0,"VERTEX")?(i=t.next(),new Ma().parseEntity(t,i)):ka},{code:210,name:"extrusionDirection",parser: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},...Ut];class uh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ch(this,"parser",bt(bd,vd))}}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}ch(uh,"ForEntityName","POLYLINE");let xd=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Ut];class mh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dh(this,"parser",bt(xd))}}function ph(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}dh(mh,"ForEntityName","RAY");let wd=[...Ri("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Ut];class gh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ph(this,"parser",bt(wd))}}function fh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ph(gh,"ForEntityName","REGION");let Ad={vertices:[],backLineVertices:[]},Sd=[{code:360,name:"geometrySettingHardId",parser: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},...Ut];class _h{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){fh(this,"parser",bt(Sd,Ad))}}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}fh(_h,"ForEntityName","SECTION");let Pd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Id=[{code:210,name:"extrusionDirection",parser:j},{code:39,name:"thickness",parser:v},{code:[...ii(10,14)],name:"points",isMultiple:!0,parser:j},{code:100,name:"subclassMarker",parser:v},...Ut];class vh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){yh(this,"parser",bt(Id,Pd))}}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}yh(vh,"ForEntityName","SOLID");let Ed=[{code:350,name:"historyObjectSoftId",parser:v},{code:100,name:"subclassMarker",parser:v},...Ri("data"),{code:70,name:"version",parser:v},{code:100},...Ut];class xh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){bh(this,"parser",bt(Ed))}}bh(xh,"ForEntityName","3DSOLID");(Re={})[Re.NONE=0]="NONE",Re[Re.CLOSED=1]="CLOSED",Re[Re.PERIODIC=2]="PERIODIC",Re[Re.RATIONAL=4]="RATIONAL",Re[Re.PLANAR=8]="PLANAR",Re[Re.LINEAR=16]="LINEAR";function wh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let kd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Td=[{code:11,name:"fitPoints",isMultiple:!0,parser: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},...Ut];class Ah{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){wh(this,"parser",bt(Td,kd))}}wh(Ah,"ForEntityName","SPLINE");class ri{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=jr(Rt(t)),e=t.lastReadGroup;break;case 11:s.directionVector=jr(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 u=!1,g=!1,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(u){g=!0;continue}b.cellType=h.value,u=!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 u=!1,g=!1,b}(t,e)),e=t.lastReadGroup;break;default:Ta(s,e,t),e=t.next()}}return s}}function Sh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ia="ACAD_TABLE",(sa="ForEntityName")in ri?Object.defineProperty(ri,sa,{value:ia,enumerable:!0,configurable:!0,writable:!0}):ri[sa]=ia;let Md=[{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},...Ut];class Ph{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sh(this,"parser",bt(Md))}}Sh(Ph,"ForEntityName","TOLERANCE");let ni=class{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(o,h,u){if(u==="EOF")return!1;switch(u.code){case 0:return!1;case 8:o.layer=u.value;break;case 100:o.subclassMarker=u.value;break;case 10:o.viewportCenter=jr(Rt(h));break;case 40:o.width=u.value;break;case 41:o.height=u.value;break;case 68:o.status=u.value;break;case 69:o.viewportId=u.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=jr(Rt(h));break;case 17:o.targetPoint=jr(Rt(h));break;case 42:o.perspectiveLensLength=u.value;break;case 43:o.frontClipZ=u.value;break;case 44:o.backClipZ=u.value;break;case 45:o.viewHeight=u.value;break;case 50:o.snapAngle=u.value;break;case 51:o.viewTwistAngle=u.value;break;case 72:o.circleZoomPercent=u.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(u.value);break;case 90:o.statusBitFlags=u.value;break;case 340:o.clippingBoundaryId=u.value;break;case 1:o.sheetName=u.value;break;case 281:o.renderMode=u.value;break;case 71:o.ucsPerViewport=u.value;break;case 110:o.ucsOrigin=jr(Rt(h));break;case 111:o.ucsXAxis=jr(Rt(h));break;case 112:o.ucsYAxis=jr(Rt(h));break;case 345:o.ucsId=u.value;break;case 346:o.ucsBaseId=u.value;break;case 79:o.orthographicType=u.value;break;case 146:o.elevation=u.value;break;case 170:o.shadePlotMode=u.value;break;case 61:o.majorGridFrequency=u.value;break;case 332:o.backgroundId=u.value;break;case 333:o.shadePlotId=u.value;break;case 348:o.visualStyleId=u.value;break;case 292:o.isDefaultLighting=!!u.value;break;case 282:o.defaultLightingType=u.value;break;case 141:o.brightness=u.value;break;case 142:o.contrast=u.value;break;case 63:case 421:case 431:o.ambientLightColor=u.value;break;case 361:o.sunId=u.value;break;case 335:case 343:case 344:case 91:o.softPointer=u.value}return!0}(s,t,e)&&Ta(s,e,t),e=t.next()}return s}};oa="VIEWPORT",(aa="ForEntityName")in ni?Object.defineProperty(ni,aa,{value:oa,enumerable:!0,configurable:!0,writable:!0}):ni[aa]=oa;(Sr={})[Sr.ShowImage=1]="ShowImage",Sr[Sr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Sr[Sr.UseClippingBoundary=4]="UseClippingBoundary",Sr[Sr.Transparency=8]="Transparency";function Ih(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Nd={brightness:50,constrast:50,fade:0},Cd=[{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:Bt},{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},...Ut];class Eh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ih(this,"parser",bt(Cd,Nd))}}function kh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ih(Eh,"ForEntityName","WIPEOUT");let Ld=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Ut],Th=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kh(this,"parser",bt(Ld))}};function Mh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}kh(Th,"ForEntityName","XLINE");let Od={},zd=[{code:170,name:"multileaderType",parser:v},{code:291,name:"doglegEnabled",parser:Bt},{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,u,g){let b,f={vertices:[]};for(;u.hasNext()&&(b=u.next()).code!==305;)b.code===10&&f.vertices.push((b.value,Rt(u)));return f}(0,t))}return o},isMultiple:!0},...Ut];class Nh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Mh(this,"parser",bt(zd,Od))}}Mh(Nh,"ForEntityName","MULTILEADER");let Rd=Object.fromEntries([Tl,zl,Dl,Vl,jl,ti,Hl,ql,Ql,th,rh,sh,ei,ah,Fl,Nh,lh,uh,mh,gh,_h,vh,xh,Ah,ri,Ll,Ph,$l,Ma,ni,Eh,Th].map(i=>[i.ForEntityName,new i]));function Ch(i,t){let e=[];for(;!At(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let s=Rd[i.value];if(s){let o=i.value;i=t.next();let h=s.parseEntity(t,i);h.type=o,Il(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=t.next()}return e}function Fd(i,t){let e={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");){if(At(i,0,"BLOCK")){let s=Bd(i=t.next(),t);Il(s),s.name&&(e[s.name]=s)}i=t.next()}return e}function Bd(i,t){let e={};for(;!At(i,0,"EOF");){if(At(i,0,"ENDBLK")){for(i=t.next();!At(i,0,"EOF");){if(At(i,100,"AcDbBlockEnd"))return e;i=t.next()}break}switch(i.code){case 1:e.xrefPath=i.value;break;case 2:e.name=i.value;break;case 3:e.name2=i.value;break;case 5:e.handle=i.value;break;case 8:e.layer=i.value;break;case 10:e.position=Rt(t);break;case 67:e.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(e.type=i.value);break;case 100:break;case 330:e.ownerHandle=i.value;break;case 0:e.entities=Ch(i,t)}i=t.next()}return e}function Dd(i,t){let e=null,s={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");)i.code===9?e=i.value:i.code===10?s[e]=Rt(t):s[e]=i.value,i=t.next();return s}(Fe={})[Fe.NOT_APPLICABLE=0]="NOT_APPLICABLE",Fe[Fe.KEEP_EXISTING=1]="KEEP_EXISTING",Fe[Fe.USE_CLONE=2]="USE_CLONE",Fe[Fe.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Fe[Fe.VALUE_NAME=4]="VALUE_NAME",Fe[Fe.UNMANGLE_NAME=5]="UNMANGLE_NAME";let Na=[{code:330,name:"ownerObjectId",parser:v},{code:102,parser:fn},{code:102,parser:fn},{code:102,parser:fn},{code:5,name:"handle",parser:v}],Ud=[{code:3,name:"entries",parser:(i,t)=>{let e={name:i.value};return(i=t.next()).code===350?e.objectSoftId=i.value:i.code===360?e.objectHardId=i.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:v},{code:280,name:"isHardOwned",parser:Bt},{code:100,name:"subclassMarker",parser:v},...Na],Vd=[{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";(un={})[un.INCHES=0]="INCHES",un[un.MILLIMETERS=1]="MILLIMETERS",un[un.PIXELS=2]="PIXELS";(Be={})[Be.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",Be[Be.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",Be[Be.DRAWING_LIMITS=2]="DRAWING_LIMITS",Be[Be.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",Be[Be.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",Be[Be.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Pr={})[Pr.AS_DISPLAYED=0]="AS_DISPLAYED",Pr[Pr.WIREFRAME=1]="WIREFRAME",Pr[Pr.HIDDEN=2]="HIDDEN",Pr[Pr.RENDERED=3]="RENDERED";(De={})[De.DRAFT=0]="DRAFT",De[De.PREVIEW=1]="PREVIEW",De[De.NORMAL=2]="NORMAL",De[De.PRESENTATION=3]="PRESENTATION",De[De.MAXIMUM=4]="MAXIMUM",De[De.CUSTOM=5]="CUSTOM";let Lh=[{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},...Na],Gd=[{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},...Lh],jd=[{code:40,name:"wcsToOCSTransform",parser:Xo},{code:40,name:"ocsToWCSTransform",parser:Xo},{code:41,name:"backClippingDistance",parser:v},{code:73,name:"isBackClipping",parser:Bt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:v},{code:72,name:"isFrontClipping",parser:Bt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Bt},{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},...Na];function Xo(i,t){let e=[];for(let s=0;s<3&&At(i,40);++s){let o=[];for(let h=0;h<4&&At(i,40);++h)o.push(i.value),i=t.next();e.push(o)}return t.rewind(),e}let Wd={LAYOUT:Gd,PLOTSETTINGS:Lh,DICTIONARY:Ud,SPATIAL_FILTER:jd,IMAGEDEF:Vd};function Hd(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,o=Wd[s];if(i.code===0&&(o!=null&&o.length)){let h=bt(o),u={name:s};h(i=t.next(),t,u)?(e.push(u),i=t.peek()):i=t.next()}else i=t.next()}return{byName:zu(e,({name:s})=>s)}}let jn=[{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102,parser(i,t){for(;!At(i,0,"EOF")&&!At(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:v}],Yd=bt([{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},...jn]),qd=[{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:Yo.Above,defaultValueImperial:Yo.Center},{name:"DIMZIN",code:78,defaultValue:zn.Trailing,defaultValueImperial:zn.Feet},{name:"DIMAZIN",code:79,defaultValue:xu.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:wu.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Au.Center},{name:"DIMTZIN",code:284,defaultValue:zn.Trailing,defaultValueImperial:zn.Feet},{name:"DIMALTZ",code:285,defaultValue:zn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:zn.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}],Xd=bt([...qd.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},...jn.filter(i=>i.code!==5)]),Kd=bt([{code:347,name:"materialObjectId",parser:v},{code:390,name:"plotStyleNameObjectId",parser:v},{code:370,name:"lineweight",parser:v},{code:290,name:"isPlotting",parser:Bt},{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},...jn]);(Ir={})[Ir.NONE=0]="NONE",Ir[Ir.AbsoluteRotation=1]="AbsoluteRotation",Ir[Ir.TextEmbedded=2]="TextEmbedded",Ir[Ir.ShapeEmbedded=4]="ShapeEmbedded";let $d=bt([{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}),Zd=bt([{code:49,name:"pattern",parser(i,t){let e={};return $d(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},...jn]),Qd=bt([{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},...jn]),Jd=bt([{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:Bt},{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},...jn]),t0={BLOCK_RECORD:Yd,DIMSTYLE:Xd,LAYER:Kd,LTYPE:Zd,STYLE:Qd,VPORT:Jd},e0=bt([{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 r0(i,t){var s;let e={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");){if(At(i,0,"TABLE")){i=t.next();let o={entries:[]};e0(i,t,o),e[o.name]=o}if(At(i,0)&&!At(i,0,"ENDTAB")){let o=i.value;i=t.next();let h=t0[o];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${o}'`),i=t.next();continue}let u={};h(i,t,u),(s=e[o])==null||s.entries.push(u)}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 Ko{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=$o(t,this._data[this._pointer++],this.debug),s={code:t,value:e};return At(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=$o(t.code,this._data[this._pointer+1],this.debug),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t,e=!1){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 $o(i,t,e=!1){return i<=9?t:i>=10&&i<=59?parseFloat(t.trim()):i>=60&&i<=99?parseInt(t.trim()):i>=100&&i<=109?t:i>=110&&i<=149?parseFloat(t.trim()):i>=160&&i<=179?parseInt(t.trim()):i>=210&&i<=239?parseFloat(t.trim()):i>=270&&i<=289?parseInt(t.trim()):i>=290&&i<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(t.trim()):i>=300&&i<=369?t:i>=370&&i<=389?parseInt(t.trim()):i>=390&&i<=399?t:i>=400&&i<=409?parseInt(t.trim()):i>=410&&i<=419?t:i>=420&&i<=429?parseInt(t.trim()):i>=430&&i<=439?t:i>=440&&i<=459?parseInt(t.trim()):i>=460&&i<=469?parseFloat(t.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?t:i>=1010&&i<=1059?parseFloat(t.trim()):i>=1060&&i<=1071?parseInt(t.trim()):(e&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:t}),t)}function pa(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class n0{constructor(){pa(this,"encoding","utf-8"),pa(this,"encodingFailureFatal",!1)}}class s0 extends EventTarget{parseSync(t,e=!1){let s=new Ko(t.split(/\r\n|\r|\n/g),e);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(t){let e="",s=this;return new Promise((o,h)=>{t.on("data",u=>{e+=u}),t.on("end",()=>{try{let u=e.split(/\r\n|\r|\n/g),g=new Ko(u);if(!g.hasNext())throw Error("Empty file");o(s.parseAll(g))}catch(u){h(u)}}),t.on("error",u=>{h(u)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:u,value:g}=await o.read();if(u){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(g,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!At(s,0,"EOF");)At(s,0,"SECTION")&&(At(s=t.next(),2,"HEADER")?(s=t.next(),e.header=Dd(s,t)):At(s,2,"BLOCKS")?(s=t.next(),e.blocks=Fd(s,t)):At(s,2,"ENTITIES")?(s=t.next(),e.entities=Ch(s,t)):At(s,2,"TABLES")?(s=t.next(),e.tables=r0(s,t)):At(s,2,"OBJECTS")&&(s=t.next(),e.objects=Hd(s,t))),s=t.next();return e}constructor(t=new n0){super(),pa(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}const Zo=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class ai{constructor(t){if(typeof t=="string"){const e=Zo.find(s=>s.name===t);if(!e)throw new Error(`Unknown DWG version name: ${t}`);this.name=e.name,this.value=e.value;return}if(typeof t=="number"){const e=Zo.find(s=>s.value===t);if(!e)throw new Error(`Unknown DWG version value: ${t}`);this.name=e.name,this.value=e.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class i0{parse(t){const e=new s0,s=this.getDxfInfoFromBuffer(t);let o="";return s.version&&s.version.value<=23&&s.encoding?o=new TextDecoder(s.encoding).decode(t):o=new TextDecoder().decode(t),e.parseSync(o)}getDxfInfoFromBuffer(t){var f,w,x;const s=new TextDecoder("utf-8");let o=0,h="",u=null,g=null,b=!1;for(;o<t.byteLength;){const E=Math.min(o+65536,t.byteLength),T=t.slice(o,E);o=E;const z=(h+s.decode(T,{stream:!0})).split(/\r?\n/);h=z.pop()??"";for(let D=0;D<z.length;D++){const B=z[D].trim();if(B==="SECTION"&&((f=z[D+2])==null?void 0:f.trim())==="HEADER")b=!0;else if(B==="ENDSEC"&&b)return{version:u,encoding:g};if(b&&B==="$ACADVER"){const dt=(w=z[D+2])==null?void 0:w.trim();dt&&(u=new ai(dt))}else if(b&&B==="$DWGCODEPAGE"){const dt=(x=z[D+2])==null?void 0:x.trim();if(dt){const yt=Pa[dt];g=xl(yt)}}if(u&&g)return{version:u,encoding:g}}}return{version:u,encoding:g}}}const fe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Qo=1234567;const Ca=Math.PI/180,La=180/Math.PI;function Oh(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(fe[i&255]+fe[i>>8&255]+fe[i>>16&255]+fe[i>>24&255]+"-"+fe[t&255]+fe[t>>8&255]+"-"+fe[t>>16&15|64]+fe[t>>24&255]+"-"+fe[e&63|128]+fe[e>>8&255]+"-"+fe[e>>16&255]+fe[e>>24&255]+fe[s&255]+fe[s>>8&255]+fe[s>>16&255]+fe[s>>24&255]).toLowerCase()}function Tr(i,t,e){return Math.max(t,Math.min(e,i))}function Oa(i,t){return(i%t+t)%t}function zh(i,t,e,s,o){return s+(i-t)*(o-s)/(e-t)}function Rh(i,t,e){return i!==t?(e-i)/(t-i):0}function za(i,t,e){return(1-e)*i+e*t}function Fh(i,t,e,s){return za(i,t,1-Math.exp(-e*s))}function Bh(i,t=1){return t-Math.abs(Oa(i,t*2)-t)}function Dh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Uh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Vh(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Gh(i,t){return i+Math.random()*(t-i)}function jh(i){return i*(.5-Math.random())}function Wh(i){i!==void 0&&(Qo=i);let t=Qo+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Hh(i){return i*Ca}function Yh(i){return i*La}function qh(i){return(i&i-1)===0&&i!==0}function Xh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Kh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Cs(i){const t=Math.PI*2;return(i%t+t)%t}function $h(i,t,e){return i>t&&i<e||i>e&&i<t}function Zh(i,t,e,s=!1){return i=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 Ra(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Qh(i,t=1e-7){const e=Ra(i);return Math.max(Math.pow(10,e)*t,t)}const Et={DEG2RAD:Ca,RAD2DEG:La,generateUUID:Oh,clamp:Tr,euclideanModulo:Oa,mapLinear:zh,inverseLerp:Rh,lerp:za,damp:Fh,pingpong:Bh,smoothstep:Dh,smootherstep:Uh,randInt:Vh,randFloat:Gh,randFloatSpread:jh,seededRandom:Wh,degToRad:Hh,radToDeg:Yh,isPowerOfTwo:qh,ceilPowerOfTwo:Xh,floorPowerOfTwo:Kh,normalizeAngle:Cs,isBetween:$h,isBetweenAngle:Zh,intPartLength:Ra,relativeEps:Qh},ga=class Jh{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:o,y:h}=t;this.x=o,this.y=h;return}if(s===2){this.x=t,this.y=e;return}throw je.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new Jh(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,o=t.elements;return this.x=o[0]*e+o[3]*s+o[6],this.y=o[1]*e+o[4]*s+o[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),o=Math.sin(e),h=this.x-t.x,u=this.y-t.y;return this.x=h*s-u*o+t.x,this.y=h*o+u*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(Et.relativeEps(this.x,t),Et.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};ga.EMPTY=Object.freeze(new ga(0,0));let $t=ga;const fa=class tc{constructor(t,e,s,o,h,u,g,b,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&o!=null&&h!=null&&u!=null&&g!=null&&b!=null&&f!=null&&this.set(t,e,s,o,h,u,g,b,f)}set(t,e,s,o,h,u,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]=u,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,u=s[0],g=s[3],b=s[6],f=s[1],w=s[4],x=s[7],E=s[2],T=s[5],L=s[8],z=o[0],D=o[3],B=o[6],dt=o[1],yt=o[4],ot=o[7],W=o[2],ct=o[5],st=o[8];return h[0]=u*z+g*dt+b*W,h[3]=u*D+g*yt+b*ct,h[6]=u*B+g*ot+b*st,h[1]=f*z+w*dt+x*W,h[4]=f*D+w*yt+x*ct,h[7]=f*B+w*ot+x*st,h[2]=E*z+T*dt+L*W,h[5]=E*D+T*yt+L*ct,h[8]=E*B+T*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],u=t[4],g=t[5],b=t[6],f=t[7],w=t[8];return e*u*w-e*g*f-s*h*w+s*g*b+o*h*f-o*u*b}invert(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],u=t[4],g=t[5],b=t[6],f=t[7],w=t[8],x=w*u-g*f,E=g*b-w*h,T=f*h-u*b,L=e*x+s*E+o*T;if(L===0)return this.set(0,0,0,0,0,0,0,0,0);const z=1/L;return t[0]=x*z,t[1]=(o*f-w*s)*z,t[2]=(g*s-o*u)*z,t[3]=E*z,t[4]=(w*e-o*b)*z,t[5]=(o*h-g*e)*z,t[6]=T*z,t[7]=(s*b-f*e)*z,t[8]=(u*e-s*h)*z,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,o,h,u,g){const b=Math.cos(h),f=Math.sin(h);return this.set(s*b,s*f,-s*(b*u+f*g)+u+t,-o*f,o*b,-o*(-f*u+b*g)+g+e,0,0,1),this}scale(t,e){return this.premultiply(ha.makeScale(t,e)),this}rotate(t){return this.premultiply(ha.makeRotation(-t)),this}translate(t,e){return this.premultiply(ha.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof $t?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let o=0;o<9;o++)if(e[o]!==s[o])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new tc().fromArray(this.elements)}};fa.IDENTITY=Object.freeze(new fa);let Fi=fa;const ha=new Fi,mn=1e-6,ne=2*Math.PI,a0={x:0,y:0},Fa={x:0,y:0,z:0};class Ba{constructor(){this.equalPointTol=mn,this.equalVectorTol=mn}equalPoint2d(t,e){return new $t(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new $(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=mn){return t<e&&t>-e}static equal(t,e,s=mn){return Math.abs(t-e)<s}static great(t,e,s=mn){return t-e>s}static less(t,e,s=mn){return t-e<s}}const Da=new Ba;function Ua(i,t,e=!1){const s=i.x,o=i.y;let h=!1;const u=t.length;for(let g=0,b=u-1;g<u;b=g++){const f=t[g].x,w=t[g].y,x=t[b].x,E=t[b].y;let T=w>o!=E>o;e&&(T=w>=o!=E>=o),T&&s<(x-f)*(o-w)/(E-w)+f&&(h=!h)}return h}function ec(i,t){if(i.length===0||t.length===0)return!1;const e=new _e().setFromPoints(i),s=new _e().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let o=0;o<i.length;){if(Ua(i[o],t,!0))return!0;o<i.length-1&&Da.equalPoint2d(i[o+1],i[o])&&++o,++o}return!1}const rc={isPointInPolygon:Ua,isPolygonIntersect:ec};function nc(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 sc(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 u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=e-s;g++){const b=o[g]/h;u.push(b*(e-s+1))}for(let g=0;g<=s;g++)u.push(e-s+1);return u}function ic(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 u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=e-s;g++){const b=o[g]/h;u.push(b*(e-s+1))}for(let g=0;g<=s;g++)u.push(e-s+1);return u}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],u=o>1e-10?(e-s[i])/o:0,g=h>1e-10?(s[i+t+1]-e)/h:0;return u*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,u=t;if(i=Math.max(e[u],Math.min(e[h+1],i)),Math.abs(i-e[h+1])<1e-8)return[...s[h]];if(Math.abs(i-e[u])<1e-8)return[...s[0]];const g=[0,0,0];let b=0;for(let f=0;f<=h;f++){const w=oi(f,u,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-u-1];if(Math.abs(i-f)<1e-8)return[...s[h]];if(Math.abs(i-e[u])<1e-8)return[...s[0]]}return b>1e-10&&(g[0]/=b,g[1]/=b,g[2]/=b),g}function ac(i,t,e,s){const o=i,h=t[o],u=t[t.length-o-1];let g=0;const b=1e3,f=(u-h)/b;let w=Ls(h,i,t,e,s);for(let z=1;z<=b;z++){const D=h+z*f,B=Ls(D,i,t,e,s),dt=B[0]-w[0],yt=B[1]-w[1],ot=B[2]-w[2];g+=Math.sqrt(dt*dt+yt*yt+ot*ot),w=B}const x=Ls(u,i,t,e,s),E=x[0]-w[0],T=x[1]-w[1],L=x[2]-w[2];return g+=Math.sqrt(E*E+T*T+L*L),g}function o0(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,u,g){let b=s[o+0],f=s[o+1],w=s[o+2],x=s[o+3];const E=h[u+0],T=h[u+1],L=h[u+2],z=h[u+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]=T,t[e+2]=L,t[e+3]=z;return}if(x!==z||b!==E||f!==T||w!==L){let D=1-g;const B=b*E+f*T+w*L+x*z,dt=B>=0?1:-1,yt=1-B*B;if(yt>Number.EPSILON){const W=Math.sqrt(yt),ct=Math.atan2(W,B*dt);D=Math.sin(D*ct)/W,g=Math.sin(g*ct)/W}const ot=g*dt;if(b=b*D+E*ot,f=f*D+T*ot,w=w*D+L*ot,x=x*D+z*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,u){const g=s[o],b=s[o+1],f=s[o+2],w=s[o+3],x=h[u],E=h[u+1],T=h[u+2],L=h[u+3];return t[e]=g*L+w*x+b*T-f*E,t[e+1]=b*L+w*E+f*x-g*T,t[e+2]=f*L+w*T+g*E-b*x,t[e+3]=w*L-g*x-b*E-f*T,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,o){return this._x=t,this._y=e,this._z=s,this._w=o,this._onChangeCallback(),this}clone(){return new 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,u=t.order,g=Math.cos,b=Math.sin,f=g(s/2),w=g(o/2),x=g(h/2),E=b(s/2),T=b(o/2),L=b(h/2);switch(u){case"XYZ":this._x=E*w*x+f*T*L,this._y=f*T*x-E*w*L,this._z=f*w*L+E*T*x,this._w=f*w*x-E*T*L;break;case"YXZ":this._x=E*w*x+f*T*L,this._y=f*T*x-E*w*L,this._z=f*w*L-E*T*x,this._w=f*w*x+E*T*L;break;case"ZXY":this._x=E*w*x-f*T*L,this._y=f*T*x+E*w*L,this._z=f*w*L+E*T*x,this._w=f*w*x-E*T*L;break;case"ZYX":this._x=E*w*x-f*T*L,this._y=f*T*x+E*w*L,this._z=f*w*L-E*T*x,this._w=f*w*x+E*T*L;break;case"YZX":this._x=E*w*x+f*T*L,this._y=f*T*x+E*w*L,this._z=f*w*L-E*T*x,this._w=f*w*x-E*T*L;break;case"XZY":this._x=E*w*x-f*T*L,this._y=f*T*x-E*w*L,this._z=f*w*L+E*T*x,this._w=f*w*x+E*T*L;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,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],u=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 T=.5/Math.sqrt(E+1);this._w=.25/T,this._x=(w-b)*T,this._y=(h-f)*T,this._z=(u-o)*T}else if(s>g&&s>x){const T=2*Math.sqrt(1+s-g-x);this._w=(w-b)/T,this._x=.25*T,this._y=(o+u)/T,this._z=(h+f)/T}else if(g>x){const T=2*Math.sqrt(1+g-s-x);this._w=(h-f)/T,this._x=(o+u)/T,this._y=.25*T,this._z=(b+w)/T}else{const T=2*Math.sqrt(1+x-s-g);this._w=(u-o)/T,this._x=(h+f)/T,this._y=(b+w)/T,this._z=.25*T}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(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,u=t._w,g=e._x,b=e._y,f=e._z,w=e._w;return this._x=s*w+u*g+o*f-h*b,this._y=o*w+u*b+h*g-s*f,this._z=h*w+u*f+s*b-o*g,this._w=u*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,u=this._w;let g=u*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=u,this._x=s,this._y=o,this._z=h,this;const b=1-g*g;if(b<=Number.EPSILON){const T=1-e;return this._w=T*u+e*this._w,this._x=T*s+e*this._x,this._y=T*o+e*this._y,this._z=T*h+e*this._z,this.normalize(),this}const f=Math.sqrt(b),w=Math.atan2(f,g),x=Math.sin((1-e)*w)/f,E=Math.sin(e*w)/f;return this._w=u*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 Ve=class oc{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:u,z:g}=t;this.x=h,this.y=u,this.z=g||0;return}if(o===3){this.x=t,this.y=e,this.z=s;return}throw je.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new oc(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,u=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])*u,this.y=(h[1]*e+h[5]*s+h[9]*o+h[13])*u,this.z=(h[2]*e+h[6]*s+h[10]*o+h[14])*u,this}applyQuaternion(t){const e=this.x,s=this.y,o=this.z,h=t.x,u=t.y,g=t.z,b=t.w,f=2*(u*o-g*s),w=2*(g*e-h*o),x=2*(h*s-u*e);return this.x=e+b*f+u*x-g*w,this.y=s+b*w+g*f-h*x,this.z=o+b*x+h*w-u*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,u=e.x,g=e.y,b=e.z;return this.x=o*b-h*g,this.y=h*u-s*b,this.z=s*g-o*u,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return ca.copy(this).projectOnVector(t),this.sub(ca)}reflect(t){return this.sub(ca.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}};Ve.X_AXIS=Object.freeze(new Ve(1,0,0)),Ve.NEGATIVE_X_AXIS=Object.freeze(new Ve(-1,0,0)),Ve.Y_AXIS=Object.freeze(new Ve(0,1,0)),Ve.NEGATIVE_Y_AXIS=Object.freeze(new Ve(0,-1,0)),Ve.Z_AXIS=Object.freeze(new Ve(0,0,1)),Ve.NEGATIVE_Z_AXIS=Object.freeze(new Ve(0,0,-1));let $=Ve;const ca=new $,Jo=new qr,_a=class lc{constructor(t,e,s,o,h,u,g,b,f,w,x,E,T,L,z,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&&u!=null&&g!=null&&b!=null&&f!=null&&w!=null&&x!=null&&E!=null&&T!=null&&L!=null&&z!=null&&D!=null&&this.set(t,e,s,o,h,u,g,b,f,w,x,E,T,L,z,D)}set(t,e,s,o,h,u,g,b,f,w,x,E,T,L,z,D){const B=this.elements;return B[0]=t,B[4]=e,B[8]=s,B[12]=o,B[1]=h,B[5]=u,B[9]=g,B[13]=b,B[2]=f,B[6]=w,B[10]=x,B[14]=E,B[3]=T,B[7]=L,B[11]=z,B[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 lc().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(Da.equalPoint3d(t,$.Z_AXIS))this.identity();else{const e=new $(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors($.Y_AXIS,t).normalize():e.crossVectors($.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/Rn.setFromMatrixColumn(t,0).length(),h=1/Rn.setFromMatrixColumn(t,1).length(),u=1/Rn.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]*u,e[9]=s[9]*u,e[10]=s[10]*u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(l0,t,h0)}lookAt(t,e,s){const o=this.elements;return Ue.subVectors(t,e),Ue.lengthSq()===0&&(Ue.z=1),Ue.normalize(),Gr.crossVectors(s,Ue),Gr.lengthSq()===0&&(Math.abs(s.z)===1?Ue.x+=1e-4:Ue.z+=1e-4,Ue.normalize(),Gr.crossVectors(s,Ue)),Gr.normalize(),qs.crossVectors(Ue,Gr),o[0]=Gr.x,o[4]=qs.x,o[8]=Ue.x,o[1]=Gr.y,o[5]=qs.y,o[9]=Ue.y,o[2]=Gr.z,o[6]=qs.z,o[10]=Ue.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,u=s[0],g=s[4],b=s[8],f=s[12],w=s[1],x=s[5],E=s[9],T=s[13],L=s[2],z=s[6],D=s[10],B=s[14],dt=s[3],yt=s[7],ot=s[11],W=s[15],ct=o[0],st=o[4],Vt=o[8],qt=o[12],Wt=o[1],xt=o[5],Ot=o[9],de=o[13],me=o[2],Te=o[6],Jt=o[10],ae=o[14],Q=o[3],Nt=o[7],oe=o[11],cr=o[15];return h[0]=u*ct+g*Wt+b*me+f*Q,h[4]=u*st+g*xt+b*Te+f*Nt,h[8]=u*Vt+g*Ot+b*Jt+f*oe,h[12]=u*qt+g*de+b*ae+f*cr,h[1]=w*ct+x*Wt+E*me+T*Q,h[5]=w*st+x*xt+E*Te+T*Nt,h[9]=w*Vt+x*Ot+E*Jt+T*oe,h[13]=w*qt+x*de+E*ae+T*cr,h[2]=L*ct+z*Wt+D*me+B*Q,h[6]=L*st+z*xt+D*Te+B*Nt,h[10]=L*Vt+z*Ot+D*Jt+B*oe,h[14]=L*qt+z*de+D*ae+B*cr,h[3]=dt*ct+yt*Wt+ot*me+W*Q,h[7]=dt*st+yt*xt+ot*Te+W*Nt,h[11]=dt*Vt+yt*Ot+ot*Jt+W*oe,h[15]=dt*qt+yt*de+ot*ae+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],u=t[1],g=t[5],b=t[9],f=t[13],w=t[2],x=t[6],E=t[10],T=t[14],L=t[3],z=t[7],D=t[11],B=t[15];return L*(+h*b*x-o*f*x-h*g*E+s*f*E+o*g*T-s*b*T)+z*(+e*b*T-e*f*E+h*u*E-o*u*T+o*f*w-h*b*w)+D*(+e*f*x-e*g*T-h*u*x+s*u*T+h*g*w-s*f*w)+B*(-o*g*w-e*b*x+e*g*E+o*u*x-s*u*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 $?(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],u=t[4],g=t[5],b=t[6],f=t[7],w=t[8],x=t[9],E=t[10],T=t[11],L=t[12],z=t[13],D=t[14],B=t[15],dt=x*D*f-z*E*f+z*b*T-g*D*T-x*b*B+g*E*B,yt=L*E*f-w*D*f-L*b*T+u*D*T+w*b*B-u*E*B,ot=w*z*f-L*x*f+L*g*T-u*z*T-w*g*B+u*x*B,W=L*x*b-w*z*b-L*g*E+u*z*E+w*g*D-u*x*D,ct=e*dt+s*yt+o*ot+h*W;if(ct===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const st=1/ct;return t[0]=dt*st,t[1]=(z*E*h-x*D*h-z*o*T+s*D*T+x*o*B-s*E*B)*st,t[2]=(g*D*h-z*b*h+z*o*f-s*D*f-g*o*B+s*b*B)*st,t[3]=(x*b*h-g*E*h-x*o*f+s*E*f+g*o*T-s*b*T)*st,t[4]=yt*st,t[5]=(w*D*h-L*E*h+L*o*T-e*D*T-w*o*B+e*E*B)*st,t[6]=(L*b*h-u*D*h-L*o*f+e*D*f+u*o*B-e*b*B)*st,t[7]=(u*E*h-w*b*h+w*o*f-e*E*f-u*o*T+e*b*T)*st,t[8]=ot*st,t[9]=(L*x*h-w*z*h-L*s*T+e*z*T+w*s*B-e*x*B)*st,t[10]=(u*z*h-L*g*h+L*s*f-e*z*f-u*s*B+e*g*B)*st,t[11]=(w*g*h-u*x*h-w*s*f+e*x*f+u*s*T-e*g*T)*st,t[12]=W*st,t[13]=(w*z*o-L*x*o+L*s*E-e*z*E-w*s*D+e*x*D)*st,t[14]=(L*g*o-u*z*o-L*s*b+e*z*b+u*s*D-e*g*D)*st,t[15]=(u*x*o-w*g*o+w*s*b-e*x*b-u*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 $?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,u=t.x,g=t.y,b=t.z,f=h*u,w=h*g;return this.set(f*u+s,f*g-o*b,f*b+o*g,0,f*g+o*b,w*g+s,w*b-o*u,0,f*b-o*g,w*b+o*u,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,u){return this.set(1,s,h,0,t,1,u,0,e,o,1,0,0,0,0,1),this}compose(t,e,s){const o=this.elements,h=e.x,u=e.y,g=e.z,b=e.w,f=h+h,w=u+u,x=g+g,E=h*f,T=h*w,L=h*x,z=u*w,D=u*x,B=g*x,dt=b*f,yt=b*w,ot=b*x,W=s.x,ct=s.y,st=s.z;return o[0]=(1-(z+B))*W,o[1]=(T+ot)*W,o[2]=(L-yt)*W,o[3]=0,o[4]=(T-ot)*ct,o[5]=(1-(E+B))*ct,o[6]=(D+dt)*ct,o[7]=0,o[8]=(L+yt)*st,o[9]=(D-dt)*st,o[10]=(1-(E+z))*st,o[11]=0,o[12]=t.x,o[13]=t.y,o[14]=t.z,o[15]=1,this}decompose(t,e,s){const o=this.elements;let h=Rn.set(o[0],o[1],o[2]).length();const u=Rn.set(o[4],o[5],o[6]).length(),g=Rn.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],nr.copy(this);const b=1/h,f=1/u,w=1/g;return nr.elements[0]*=b,nr.elements[1]*=b,nr.elements[2]*=b,nr.elements[4]*=f,nr.elements[5]*=f,nr.elements[6]*=f,nr.elements[8]*=w,nr.elements[9]*=w,nr.elements[10]*=w,e.setFromRotationMatrix(nr),s.x=h,s.y=u,s.z=g,this}equals(t){const e=this.elements,s=t.elements;for(let o=0;o<16;o++)if(e[o]!==s[o])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};_a.IDENTITY=Object.freeze(new _a);let Xr=_a;const Rn=new $,nr=new Xr,l0=new $(0,0,0),h0=new $(1,1,1),Gr=new $,qs=new $,Ue=new $;class Mt{constructor(t=void 0,e=void 0){this.min=t==null?new $(1/0,1/0,1/0):new $(t.x,t.y,t.z),this.max=e==null?new $(-1/0,-1/0,-1/0):new $(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(ua.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=ua.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Mt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $(0,0,0):new $(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $(0,0,0):new $(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,ua).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:(kr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),kr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),kr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),kr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),kr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),kr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),kr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),kr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(kr),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 kr=[new $,new $,new $,new $,new $,new $,new $,new $],ua=new $,tl=new $t;class _e{constructor(t=void 0,e=void 0){this.min=t==null?new $t(1/0,1/0):new $t(t.x,t.y),this.max=e==null?new $t(-1/0,-1/0):new $t(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=tl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new _e().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $t(0,0):new $t(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $t(0,0):new $t(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,tl).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const el=new $,c0=new $,u0=new Fi;class Us{constructor(t=new $(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(c0.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||u0.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 Us().copy(this)}}class Tt extends $t{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,o)=>{s.toArray(e,o*2)}),e}}class Y extends ${static pointArrayToNumberArray(t,e=!0){const s=e?3:2,o=new Array(t.length*s);return t.forEach((h,u)=>{h.toArray(o,u*s)}),o}}const rl=new Xr,nl=new qr,hc=class ya{constructor(t=0,e=0,s=0,o=ya.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 ya(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],u=o[4],g=o[8],b=o[1],f=o[5],w=o[9],x=o[2],E=o[6],T=o[10];switch(e){case"XYZ":this._y=Math.asin(Tr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-w,T),this._z=Math.atan2(-u,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,T),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,T),this._z=Math.atan2(-u,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,T),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-u,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,T));break;case"XZY":this._z=Math.asin(-Tr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(E,f),this._y=Math.atan2(g,h)):(this._x=Math.atan2(-w,T),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return rl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(rl,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return nl.setFromEuler(this),this.setFromQuaternion(nl,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};hc.DEFAULT_ORDER="XYZ";let cc=hc;class uc{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Va extends uc{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 Bi extends Va{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new _e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const o=this.loops[s].getPoints(t);e.push(o)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),o=this.sortBoundaryBoxesByAreas(s),h=new Map,u=o.length;for(let b=0;b<u;b++)h.set(o[b],{index:o[b],children:[]});const g={index:-1,children:[]};for(let b=0;b<u;b++){const f=o[b],w=e[f],x=s[f];let E=b+1;for(;E<u;E++){const T=o[E],L=e[T];if(s[T].containsBox(x)&&rc.isPointInPolygon(w[Et.randInt(0,w.length-1)],L)){(t=h.get(T))==null||t.children.push(h.get(f));break}}E===u&&g.children.push(h.get(f))}return g}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new _e().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((o,h)=>{const u=o.size,g=u.width*u.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 Va{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,o=this.getPoint(0),h=0;e.push(0);for(let u=1;u<=t;u++)s=this.getPoint(u/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 u;e?u=e:u=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]-u,f<0)g=o+1;else if(f>0)b=o-1;else{b=o;break}if(o=b,s[o]===u)return o/(h-1);const w=s[o],x=s[o+1]-w,E=(u-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),u=new Tt;return u.copy(h).sub(o).normalize(),u}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class Un extends Wn{constructor(t,e,s,o,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(u==5){const g=t;this.center=new Tt(g.x,g.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(s)):Et.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(o)):Et.normalizeAngle(o)}else throw je.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const o=(st,Vt)=>({x:(st.x+Vt.x)/2,y:(st.y+Vt.y)/2}),h=(st,Vt)=>(Vt.y-st.y)/(Vt.x-st.x),u=st=>-1/st,g=o(t,e),b=o(e,s),f=h(t,e),w=h(e,s),x=u(f),E=u(w),T=(st,Vt,qt,Wt)=>{const xt=(Wt-Vt)/(st-qt),Ot=st*xt+Vt;return{x:xt,y:Ot}},L=g.y-x*g.x,z=b.y-E*b.x,D=T(x,L,E,z),B=Math.sqrt(Math.pow(t.x-D.x,2)+Math.pow(t.y-D.y,2)),dt=(st,Vt)=>Math.atan2(st.y-Vt.y,st.x-Vt.x),yt=dt(t,D),ot=dt(e,D),W=dt(s,D),ct=W>yt&&W<ot||yt>W&&yt<ot||ot>W&&ot<yt;this.center=D,this.radius=B,this._clockwise=!ct,this._startAngle=yt,this._endAngle=W}createByStartEndPointsAndBulge(t,e,s){let o,h,u;s<0?(o=Math.atan(-s)*4,h=new $t(t),u=new $t(e)):(o=Math.atan(s)*4,h=new $t(e),u=new $t(t));const g=new $t().subVectors(u,h),b=g.length(),f=new $t().addVectors(h,g.multiplyScalar(.5)),w=Math.abs(b/2/Math.tan(o/2)),x=g.normalize();let E;if(o<Math.PI){const T=new $t(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(T.multiplyScalar(-w))}else{const T=new $t(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(T.multiplyScalar(w))}s<0?(this._startAngle=Math.atan2(h.y-E.y,h.x-E.x),this._endAngle=Math.atan2(u.y-E.y,u.x-E.x)):(this._startAngle=Math.atan2(u.y-E.y,u.x-E.x),this._endAngle=Math.atan2(h.y-E.y,h.x-E.x)),this._clockwise=s<0,this.center=E,this.radius=u.sub(E).length()}get center(){return this._center}set center(t){this._center=new Tt(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(t)):Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const e=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(e):e,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return this.clockwise?Et.normalizeAngle(t-e):Et.normalizeAngle(e-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=Et.normalizeAngle((t+e)/2),o=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(o)}get closed(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return Math.abs(e-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of e){const u=this._getInternalAngle(h);Et.isBetweenAngle(u,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const s=t.map(h=>h.x),o=t.map(h=>h.y);return new _e(new Tt(Math.min(...s),Math.min(...o)),new Tt(Math.max(...s),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Un(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),s=this.center.x+this.radius*Math.cos(e),o=this.center.y+this.radius*Math.sin(e);return new Tt(s,o)}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(s=ne,o=0),this.clockwise)for(let h=0;h<=t;h++){const u=o-s*(h/t),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}else for(let h=0;h<=t;h++){const u=o+s*(h/t),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}return e}}class d0 extends uc{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 Vs extends d0{}class Kr extends Vs{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 $().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(dn).normalize();return new Y(this._start).addScaledVector(s,t)}else{const s=this.delta(dn).normalize();return new Y(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=dn.subVectors(this._start,this._end).normalize();this._start=new Y(this._start).addScaledVector(s,t)}else{const s=this.delta(dn).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=Et.clamp(o,0,1)),o}closestPointToPoint(t,e,s){const o=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(o).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=dn.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=dn.subVectors(t,s).dot(e),h=dn.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 Mt(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Kr(this._start.clone(),this._end.clone())}}const dn=new $,sl=new $,Xs=new $;class _n extends Vs{static computeCenterPoint(t,e,s){const o=new $().addVectors(t,e).multiplyScalar(.5),h=new $().addVectors(t,s).multiplyScalar(.5),u=new $().subVectors(e,t),g=new $().subVectors(s,t),b=new $().crossVectors(u,g).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new $().crossVectors(u,b).normalize(),w=new $().crossVectors(g,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=w.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),T=new Kr(o,o.clone().add(x)),L=new Kr(h,h.clone().add(E)),z=new $;return T.closestPointToPoint(L.startPoint,!0,z)?z:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const o=_n.computeCenterPoint(t,e,s);if(o){const h=o.distanceTo(t),u=new $().subVectors(t,o),g=new $().subVectors(e,o),b=Math.atan2(u.y,u.x),f=Math.atan2(g.y,g.x);return new _n(o,h,b,f,$.Z_AXIS)}}constructor(t,e,s,o,h,u=$.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=o,this.normal=h,this.refVec=u,(o-s)%ne==0?(this.startAngle=0,this.endAngle=ne):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Et.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new $(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new $(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)Et.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,u=-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>u&&(u=f.y),f.z>g&&(g=f.z)}return new Mt({x:e,y:s,z:o},{x:h,y:u,z:g})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=ne,o=0);for(let h=0;h<=t;h++){const u=o+s*(h/t),g=this.getPointAtAngle(u);e.push(g)}return e}transform(t){const e=da.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=da.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),s.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new _n(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(da.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,o={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},h=this.center,u=this.radius;return new Y(h.x+u*(s.x*Math.cos(t)+o.x*Math.sin(t)),h.y+u*(s.y*Math.cos(t)+o.y*Math.sin(t)),h.z+u*(s.z*Math.cos(t)+o.z*Math.sin(t)))}get plane(){const t=new $(this.center).distanceTo(Fa);return new Us(this.normal,t)}}const da=new $;class Di extends Wn{constructor(t,e,s,o=0,h=ne,u=!1,g=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(h-o)%ne==0?(this.startAngle=0,this.endAngle=ne):(this.startAngle=o,this.endAngle=h),this.clockwise=u,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 je.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Et.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,o=-1/0;for(let h=0;h<=100;h++){const u=this.getPoint(h/100);t=Math.min(t,u.x),e=Math.min(e,u.y),s=Math.max(s,u.x),o=Math.max(o,u.y)}return new _e({x:t,y:e},{x:s,y:o})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(o?s=0:s=e),this.clockwise===!0&&!o&&(s===e?s=-e:s=s-e);const h=this.startAngle+t*s;let u=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=u-this.center.x,x=g-this.center.y;u=w*b-x*f+this.center.x,g=w*f+x*b+this.center.y}return new Tt(u,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 Di(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Ui extends Vs{constructor(t,e,s,o,h,u=0,g=ne){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(g-u);Math.abs(b-ne)<1e-10||Math.abs(b-2*ne)<1e-10?(this.startAngle=0,this.endAngle=ne):(this.startAngle=u,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 je.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-ne)<1e-10?ne:Et.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new $(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new $(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new $().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 u=this.startAngle+h*e,g=this.getPointAtAngle(u),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($.X_AXIS)||this.majorAxis.equals($.Y_AXIS)||this.majorAxis.isParallelTo($.X_AXIS)||this.majorAxis.isParallelTo($.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Et.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,u=-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>u&&(u=f.y),f.z>g&&(g=f.z)}return new Mt({x:e,y:s,z:o},{x:h,y:u,z:g})}else{let t=1/0,e=1/0,s=1/0,o=-1/0,h=-1/0,u=-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),u=Math.max(u,f.z)}return new Mt({x:t,y:e,z:s},{x:o,y:h,z:u})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=ne,o=0);for(let h=0;h<=t;h++){const u=o+s*(h/t),g=this.getPointAtAngle(u);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 $(t).sub(this.center),s=e.dot(this.majorAxis),o=e.dot(this.minorAxis),h=s/this.majorAxisRadius,u=o/this.minorAxisRadius;return h*h+u*u<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Ui(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new $(this.center).distanceTo(Fa);return new Us(this.normal,t)}}class vn 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 u=new Un(o,h,o.bulge);t+=u.length}else t+=new Tt(o.x,o.y).distanceTo(h)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new Tt(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new _e().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(o=>s.push(new 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 u=null;if(o<s-1?u=this._vertices[o+1]:o==s-1&&this.closed&&(u=this._vertices[0]),u){const g=new Un(h,u,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}}class Vi 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 _e(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Vi(this._start.clone(),this._end.clone())}}class dc 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 _e;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(o=>{e.push(new Tt(o.x,o.y))})}),e}}function m0(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var mc={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 u=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 Nt.__string_rec(this,"")};function T(r,n){function a(){}a.prototype=r;var l=new a;for(var c in n)l[c]=n[c];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 c=r.split("-");return new Date(c[0],c[1]-1,c[2],0,0,0);case 19:var d=r.split(" "),p=d[0].split("-"),_=d[1].split(":");return new Date(p[0],p[1]-1,p[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},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 z=function(){};x.Lambda=z,z.__name__=["Lambda"],z.fold=function(r,n,a){for(var l=Ke(r)();l.hasNext();){var c=l.next();a=n(c,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 B=function(){};x.Reflect=B,B.__name__=["Reflect"],B.field=function(r,n){try{return r[n]}catch(a){return a instanceof Q&&(a=a.val),null}},B.callMethod=function(r,n,a){return n.apply(r,a)},B.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},B.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},B.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 Nt.__string_rec(r,"")},dt.parseFloat=function(r){return parseFloat(r)};var yt=function(){this.b=""};x.StringBuf=yt,yt.__name__=["StringBuf"],yt.prototype={add:function(r){this.b+=dt.string(r)},__class__:yt};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 ct=function(){};x.Type=ct,ct.__name__=["Type"],ct.getClassName=function(r){var n=r.__name__;return n==null?null:n.join(".")},ct.getEnumName=function(r){var n=r.__ename__;return n.join(".")},ct.resolveClass=function(r){var n=x[r];return n==null||!n.__name__?null:n},ct.resolveEnum=function(r){var n=x[r];return n==null||!n.__ename__?null:n},ct.createEmptyInstance=function(r){function n(){}return n.prototype=r.prototype,new n},ct.createEnum=function(r,n,a){var l=B.field(r,n);if(l==null)throw new Q("No such constructor "+n);if(B.isFunction(l)){if(a==null)throw new Q("Constructor "+n+" need parameters");return B.callMethod(r,l,a)}if(a!=null&&a.length!=0)throw new Q("Constructor "+n+" does not need parameters");return l},ct.getEnumConstructs=function(r){var n=r.__constructs__;return n.slice()},ct.typeof=function(r){var n=typeof r;switch(n){case"boolean":return W.TBool;case"string":return W.TClass(String);case"number":return Math.ceil(r)==r%2147483648?W.TInt:W.TFloat;case"object":if(r==null)return W.TNull;var a=r.__enum__;if(a!=null)return W.TEnum(a);var l=Nt.getClass(r);return l!=null?W.TClass(l):W.TObject;case"function":return r.__name__||r.__ename__?W.TObject:W.TFunction;case"undefined":return W.TNull;default:return W.TUnknown}};var st=function(){};x["haxe.IMap"]=st,st.__name__=["haxe","IMap"];var Vt=function(r,n){this.high=r,this.low=n};x["haxe._Int64.___Int64"]=Vt,Vt.__name__=["haxe","_Int64","___Int64"],Vt.prototype={__class__:Vt};var qt=function(){this.buf=new yt,this.cache=[],this.useCache=qt.USE_CACHE,this.useEnumIndex=qt.USE_ENUM_INDEX,this.shash=new me,this.scount=0};x["haxe.Serializer"]=qt,qt.__name__=["haxe","Serializer"],qt.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 c=a++,d=this.cache[c];if(typeof d==n&&d==r)return this.buf.b+="r",c==null?this.buf.b+="null":this.buf.b+=""+c,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var n=0,a=B.fields(r);n<a.length;){var l=a[n];++n,this.serializeString(l),this.serialize(B.field(r,l))}this.buf.b+="g"},serialize:function(r){{var n=ct.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 c=n[2];if(c==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(c){case Array:var d=0;this.buf.b+="a";for(var p=r.length,_=0;_<p;){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,P=A.h,S=null;P!=null;){var I;S=P[0],P=P[1],I=S,this.serialize(I)}this.buf.b+="h";break;case Date:var k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case me:this.buf.b+="b";for(var M=r,O=M.keys();O.hasNext();){var C=O.next();this.serializeString(C),this.serialize(qi[C]!=null?M.getReserved(C):M.h[C])}this.buf.b+="h";break;case xt:this.buf.b+="q";for(var F=r,R=F.keys();R.hasNext();){var U=R.next();this.buf.b+=":",U==null?this.buf.b+="null":this.buf.b+=""+U,this.serialize(F.h[U])}this.buf.b+="h";break;case Ot:this.buf.b+="M";for(var V=r,q=V.keys();q.hasNext();){var J=q.next(),H=B.field(J,"__id__");B.deleteField(J,"__id__"),this.serialize(J),J.__id__=H,this.serialize(V.h[J.__id__])}this.buf.b+="h";break;case Te:for(var G=r,K=0,tt=G.length-2,et=new yt,it=qt.BASE64;K<tt;){var ht=G.get(K++),at=G.get(K++),ut=G.get(K++);et.add(it.charAt(ht>>2)),et.add(it.charAt((ht<<4|at>>4)&63)),et.add(it.charAt((at<<2|ut>>6)&63)),et.add(it.charAt(ut&63))}if(K==tt){var nt=G.get(K++),mt=G.get(K++);et.add(it.charAt(nt>>2)),et.add(it.charAt((nt<<4|mt>>4)&63)),et.add(it.charAt(mt<<2&63))}else if(K==tt+1){var X=G.get(K++);et.add(it.charAt(X>>2)),et.add(it.charAt(X<<4&63))}var gt=et.b;this.buf.b+="s",gt.length==null?this.buf.b+="null":this.buf.b+=""+gt.length,this.buf.b+=":",gt==null?this.buf.b+="null":this.buf.b+=""+gt;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ct.getClassName(c)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ct.getClassName(c)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Nt.__instanceof(r,No)){var Pt=ct.getClassName(r);this.buf.b+="A",this.serializeString(Pt)}else if(Nt.__instanceof(r,Co))this.buf.b+="B",this.serializeString(ct.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var jt=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(ct.getEnumName(jt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=dt.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Xt=r.length;this.buf.b+=dt.string(Xt-2);for(var Dt=2;Dt<Xt;){var Kt=Dt++;this.serialize(r[Kt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+dt.string(r))}}},__class__:qt};var Wt=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=Wt.DEFAULT_RESOLVER;n==null&&(n=ct,Wt.DEFAULT_RESOLVER=n),this.setResolver(n)};x["haxe.Unserializer"]=Wt,Wt.__name__=["haxe","Unserializer"],Wt.initCodes=function(){for(var r=[],n=0,a=Wt.BASE64.length;n<a;){var l=n++;r[Wt.BASE64.charCodeAt(l)]=l}return r},Wt.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(n){return null},resolveEnum:function(n){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,n=!1,a=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=a)break;n=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return n&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var n=this.buf.charCodeAt(this.pos);if(n>=43&&n<58||n==101||n==69)this.pos++;else break}return dt.parseFloat(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 ct.createEnum(r,n);for(var l=[];a-- >0;)l.push(this.unserialize());return ct.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 c=this.buf.charCodeAt(this.pos);if(c==104){this.pos++;break}if(c==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var p={};return this.cache.push(p),this.unserializeObject(p),p;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var 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(),P=this.resolver.resolveClass(A);if(P==null)throw new Q("Class not found "+A);var S=ct.createEmptyInstance(P);return this.cache.push(S),this.unserializeObject(S),S;case 119:var I=this.unserialize(),k=this.resolver.resolveEnum(I);if(k==null)throw new Q("Enum not found "+I);var M=this.unserializeEnum(k,this.unserialize());return this.cache.push(M),M;case 106:var O=this.unserialize(),C=this.resolver.resolveEnum(O);if(C==null)throw new Q("Enum not found "+O);this.pos++;var F=this.readDigits(),R=ct.getEnumConstructs(C)[F];if(R==null)throw new Q("Unknown enum index "+O+"@"+F);var U=this.unserializeEnum(C,R);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 me;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 xt;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 Ot;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var it;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var ht=L.substr(this.buf,this.pos,19);it=L.strDate(ht),this.pos+=19}else{var at=this.readFloat(),ut=new Date;ut.setTime(at),it=ut}return this.cache.push(it),it;case 115:var nt=this.readDigits(),mt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var X=Wt.CODES;X==null&&(X=Wt.initCodes(),Wt.CODES=X);var gt=this.pos,Pt=nt&3,jt;jt=(nt>>2)*3+(Pt>=2?Pt-1:0);for(var Xt=gt+(nt-Pt),Dt=Te.alloc(jt),Kt=0;gt<Xt;){var Ie=X[ot.fastCodeAt(mt,gt++)],Ye=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Ie<<2|Ye>>4);var ye=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Ye<<4|ye>>2);var ge=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,ye<<6|ge)}if(Pt>=2){var Ee=X[ot.fastCodeAt(mt,gt++)],Le=X[ot.fastCodeAt(mt,gt++)];if(Dt.set(Kt++,Ee<<2|Le>>4),Pt==3){var $e=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Le<<4|$e>>2)}}return this.pos+=nt,this.cache.push(Dt),Dt;case 67:var lr=this.unserialize(),Ze=this.resolver.resolveClass(lr);if(Ze==null)throw new Q("Class not found "+lr);var Qe=ct.createEmptyInstance(Ze);if(this.cache.push(Qe),Qe.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Qe;case 65:var Je=this.unserialize(),mr=this.resolver.resolveClass(Je);if(mr==null)throw new Q("Class not found "+Je);return mr;case 66:var Ln=this.unserialize(),tn=this.resolver.resolveEnum(Ln);if(tn==null)throw new Q("Enum not found "+Ln);return tn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Wt};var xt=function(){this.h={}};x["haxe.ds.IntMap"]=xt,xt.__name__=["haxe","ds","IntMap"],xt.__interfaces__=[st],xt.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__:xt};var Ot=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Ot,Ot.__name__=["haxe","ds","ObjectMap"],Ot.__interfaces__=[st],Ot.prototype={set:function(r,n){var a=r.__id__||(r.__id__=++Ot.count);this.h[a]=n,this.h.__keys__[a]=r},keys:function(){var r=[];for(var n in this.h.__keys__)this.h.hasOwnProperty(n)&&r.push(this.h.__keys__[n]);return L.iter(r)},__class__:Ot};var de=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};de.Some=function(r){var n=["Some",0,r];return n.__enum__=de,n.toString=E,n},de.None=["None",1],de.None.toString=E,de.None.__enum__=de;var me=function(){this.h={}};x["haxe.ds.StringMap"]=me,me.__name__=["haxe","ds","StringMap"],me.__interfaces__=[st],me.prototype={set:function(r,n){qi[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return qi[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__:me};var Te=function(r){this.length=r.byteLength,this.b=new Xi(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Te,Te.__name__=["haxe","io","Bytes"],Te.alloc=function(r){return new Te(new Ws(r))},Te.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:Te};var Jt=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};Jt.Blocked=["Blocked",0],Jt.Blocked.toString=E,Jt.Blocked.__enum__=Jt,Jt.Overflow=["Overflow",1],Jt.Overflow.toString=E,Jt.Overflow.__enum__=Jt,Jt.OutsideBounds=["OutsideBounds",2],Jt.OutsideBounds.toString=E,Jt.OutsideBounds.__enum__=Jt,Jt.Custom=function(r){var n=["Custom",3,r];return n.__enum__=Jt,n.toString=E,n};var ae=function(){};x["haxe.io.FPHelper"]=ae,ae.__name__=["haxe","io","FPHelper"],ae.i32ToFloat=function(r){var n=1-(r>>>31<<1),a=r>>>23&255,l=r&8388607;return l==0&&a==0?0:n*(1+Math.pow(2,-23)*l)*Math.pow(2,a-127)},ae.floatToI32=function(r){if(r==0)return 0;var n;r<0?n=-r:n=r;var a=Math.floor(Math.log(n)/.6931471805599453);a<-127?a=-127:a>128&&(a=128);var l=Math.round((n/Math.pow(2,a)-1)*8388608)&8388607;return(r<0?-2147483648:0)|a+127<<23|l},ae.i64ToDouble=function(r,n){var a=1-(n>>>31<<1),l=(n>>20&2047)-1023,c=(n&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return c==0&&l==-1023?0:a*(1+Math.pow(2,-52)*c)*Math.pow(2,l)},ae.doubleToI64=function(r){var n=ae.i64tmp;if(r==0)n.low=0,n.high=0;else{var a;r<0?a=-r:a=r;var l=Math.floor(Math.log(a)/.6931471805599453),c,d=(a/Math.pow(2,l)-1)*4503599627370496;c=Math.round(d);var p=c|0,_=c/4294967296|0;n.low=p,n.high=(r<0?-2147483648:0)|l+1023<<20|_}return n};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};x["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=T(Error.prototype,{__class__:Q});var Nt=function(){};x["js.Boot"]=Nt,Nt.__name__=["js","Boot"],Nt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var a=Nt.__nativeClassName(r);return a!=null?Nt.__resolveNativeClass(a):null},Nt.__string_rec=function(r,n){if(r==null)return"null";if(n.length>=5)return"<...>";var a=typeof r;switch(a=="function"&&(r.__name__||r.__ename__)&&(a="object"),a){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";n+=" ";for(var c=2,d=r.length;c<d;){var p=c++;p!=2?l+=","+Nt.__string_rec(r[p],n):l+=Nt.__string_rec(r[p],n)}return l+")"}var _=r.length,y="[";n+=" ";for(var A=0;A<_;){var P=A++;y+=(P>0?",":"")+Nt.__string_rec(r[P],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 I=r.toString();if(I!="[object Object]")return I}var k=null,M=`{
2
+ `)}),f+=`- total: ${this.data.total} ms`,f}};wa.getInstance().collect(h),this.progress=o;const u={value:0},g=new yl;g.setCompleteCallback(()=>this.onFinished()),g.setErrorCallback(f=>this.onError(f)),g.addTask(new ke({stage:"START",step:1,progress:u,task:async f=>f},o)),g.addTask(new ke({stage:"PARSE",step:5,progress:u,task:async f=>await this.parse(f)},o)),g.addTask(new ke({stage:"FONT",step:5,progress:u,task:async f=>{const w=this.getFonts(f.model);return{model:f.model,data:w}}},o)),g.addTask(new ke({stage:"LTYPE",step:1,progress:u,task:async f=>(this.processLineTypes(f.model,e),f)},o)),g.addTask(new ke({stage:"STYLE",step:1,progress:u,task:async f=>(this.processTextStyles(f.model,e),f)},o)),g.addTask(new ke({stage:"DIMSTYLE",step:1,progress:u,task:async f=>(this.processDimStyles(f.model,e),f)},o)),g.addTask(new ke({stage:"LAYER",step:1,progress:u,task:async f=>(this.processLayers(f.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),f)},o)),g.addTask(new ke({stage:"VPORT",step:1,progress:u,task:async f=>(this.processViewports(f.model,e),f)},o)),g.addTask(new ke({stage:"HEADER",step:1,progress:u,task:async f=>(this.processHeader(f.model,e),f)},o)),g.addTask(new ke({stage:"BLOCK_RECORD",step:5,progress:u,task:async f=>(this.processBlockTables(f.model,e),f)},o)),g.addTask(new ke({stage:"OBJECT",step:5,progress:u,task:async f=>(this.processObjects(f.model,e),e.dictionaries.layouts.numEntries===0&&e.createDefaultData({layout:!0}),f)},o)),g.addTask(new ke({stage:"BLOCK",step:5,progress:u,task:async f=>(await this.processBlocks(f.model,e),f)},o)),g.addTask(new ke({stage:"ENTITY",step:100,progress:u,task:async f=>(await this.processEntities(f.model,e,s,u,o),f)},o)),g.addTask(new ke({stage:"END",step:0,progress:u,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"),Hr.instance.clear())}async parse(t,e){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,o,h){throw new Error("Not impelemented yet!")}}var he,ms,Qt,se,ps,tr,ve,gr,er,nn,gs,fs,sn,an,_s,ys,vs,ze,fr,Yt,on,bs,_t,be,xs,xe,ws,_r,yr,rr,As,ln,Re,vr,hn,ta,ea,br,xr,Ss,Ps,wr,Is,ra,na,ce,Ar,ue,Fe,sa,ia,aa,oa,Sr,Be,cn,Es,un,De,Pr,Ue,Ir;(he={})[he.None=0]="None",he[he.Anonymous=1]="Anonymous",he[he.NonConstant=2]="NonConstant",he[he.Xref=4]="Xref",he[he.XrefOverlay=8]="XrefOverlay",he[he.ExternallyDependent=16]="ExternallyDependent",he[he.ResolvedOrDependent=32]="ResolvedOrDependent",he[he.ReferencedXref=64]="ReferencedXref";(ms={})[ms.BYBLOCK=0]="BYBLOCK",ms[ms.BYLAYER=256]="BYLAYER";(Qt={})[Qt.Rotated=0]="Rotated",Qt[Qt.Aligned=1]="Aligned",Qt[Qt.Angular=2]="Angular",Qt[Qt.Diameter=3]="Diameter",Qt[Qt.Radius=4]="Radius",Qt[Qt.Angular3Point=5]="Angular3Point",Qt[Qt.Ordinate=6]="Ordinate",Qt[Qt.ReferenceIsExclusive=32]="ReferenceIsExclusive",Qt[Qt.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",Qt[Qt.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(se={})[se.TopLeft=1]="TopLeft",se[se.TopCenter=2]="TopCenter",se[se.TopRight=3]="TopRight",se[se.MiddleLeft=4]="MiddleLeft",se[se.MiddleCenter=5]="MiddleCenter",se[se.MiddleRight=6]="MiddleRight",se[se.BottomLeft=7]="BottomLeft",se[se.BottomCenter=8]="BottomCenter",se[se.BottomRight=9]="BottomRight";(ps={})[ps.AtLeast=1]="AtLeast",ps[ps.Exact=2]="Exact";var Yo=((tr={})[tr.Center=0]="Center",tr[tr.Above=1]="Above",tr[tr.Outside=2]="Outside",tr[tr.JIS=3]="JIS",tr[tr.Below=4]="Below",tr),zn=((ve={})[ve.Feet=0]="Feet",ve[ve.None=1]="None",ve[ve.Inch=2]="Inch",ve[ve.FeetAndInch=3]="FeetAndInch",ve[ve.Leading=4]="Leading",ve[ve.Trailing=8]="Trailing",ve[ve.LeadingAndTrailing=12]="LeadingAndTrailing",ve),xu=((gr={})[gr.None=0]="None",gr[gr.Leading=1]="Leading",gr[gr.Trailing=2]="Trailing",gr[gr.LeadingAndTrailing=3]="LeadingAndTrailing",gr),wu=((er={})[er.Center=0]="Center",er[er.Left=1]="Left",er[er.Right=2]="Right",er[er.OverFirst=3]="OverFirst",er[er.OverSecond=4]="OverSecond",er),Au=((nn={})[nn.Bottom=0]="Bottom",nn[nn.Center=1]="Center",nn[nn.Top=2]="Top",nn);(gs={})[gs.PatternFill=0]="PatternFill",gs[gs.SolidFill=1]="SolidFill";(fs={})[fs.NonAssociative=0]="NonAssociative",fs[fs.Associative=1]="Associative";(sn={})[sn.Normal=0]="Normal",sn[sn.Outer=1]="Outer",sn[sn.Ignore=2]="Ignore";(an={})[an.UserDefined=0]="UserDefined",an[an.Predefined=1]="Predefined",an[an.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 Su=((ze={})[ze.Default=0]="Default",ze[ze.External=1]="External",ze[ze.Polyline=2]="Polyline",ze[ze.Derived=4]="Derived",ze[ze.Textbox=8]="Textbox",ze[ze.Outermost=16]="Outermost",ze),Hs=((fr={})[fr.Line=1]="Line",fr[fr.Circular=2]="Circular",fr[fr.Elliptic=3]="Elliptic",fr[fr.Spline=4]="Spline",fr),Pu=((Yt={})[Yt.Off=0]="Off",Yt[Yt.Solid=1]="Solid",Yt[Yt.Dashed=2]="Dashed",Yt[Yt.Dotted=3]="Dotted",Yt[Yt.ShotDash=4]="ShotDash",Yt[Yt.MediumDash=5]="MediumDash",Yt[Yt.LongDash=6]="LongDash",Yt[Yt.DoubleShortDash=7]="DoubleShortDash",Yt[Yt.DoubleMediumDash=8]="DoubleMediumDash",Yt[Yt.DoubleLongDash=9]="DoubleLongDash",Yt[Yt.DoubleMediumLongDash=10]="DoubleMediumLongDash",Yt[Yt.SparseDot=11]="SparseDot",Yt);Pu.Off;(on={})[on.Standard=-3]="Standard",on[on.ByLayer=-2]="ByLayer",on[on.ByBlock=-1]="ByBlock";(bs={})[bs.English=0]="English",bs[bs.Metric=1]="Metric";(_t={})[_t.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",_t[_t.FRONT_CLIPPING=2]="FRONT_CLIPPING",_t[_t.BACK_CLIPPING=4]="BACK_CLIPPING",_t[_t.UCS_FOLLOW=8]="UCS_FOLLOW",_t[_t.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",_t[_t.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",_t[_t.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",_t[_t.FAST_ZOOM=128]="FAST_ZOOM",_t[_t.SNAP_MODE=256]="SNAP_MODE",_t[_t.GRID_MODE=512]="GRID_MODE",_t[_t.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",_t[_t.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",_t[_t.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",_t[_t.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",_t[_t.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",_t[_t.UNUSED=32768]="UNUSED",_t[_t.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",_t[_t.VIEWPORT_OFF=131072]="VIEWPORT_OFF",_t[_t.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",_t[_t.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",_t[_t.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",_t[_t.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(be={})[be.OPTIMIZED_2D=0]="OPTIMIZED_2D",be[be.WIREFRAME=1]="WIREFRAME",be[be.HIDDEN_LINE=2]="HIDDEN_LINE",be[be.FLAT_SHADED=3]="FLAT_SHADED",be[be.GOURAUD_SHADED=4]="GOURAUD_SHADED",be[be.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",be[be.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";(xe={})[xe.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",xe[xe.TOP=1]="TOP",xe[xe.BOTTOM=2]="BOTTOM",xe[xe.FRONT=3]="FRONT",xe[xe.BACK=4]="BACK",xe[xe.LEFT=5]="LEFT",xe[xe.RIGHT=6]="RIGHT";(ws={})[ws.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",ws[ws.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(_r={})[_r.ByLayer=0]="ByLayer",_r[_r.ByBlock=1]="ByBlock",_r[_r.ByDictionaryDefault=2]="ByDictionaryDefault",_r[_r.ByObject=3]="ByObject";function At(i,t,e){return i.code===t&&(e==null||i.value===e)}function Rt(i){let t={};i.rewind();let e=i.next(),s=e.code;if(t.x=e.value,(e=i.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=i.next()).code!==s+20?i.rewind():t.z=e.value,t}let ka=Symbol();function bt(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 T of typeof x.code=="number"?[x.code]:x.code){let L=E[T]??(E[T]=[]);x.isMultiple&&L.length&&f&&console.warn(`Snippet ${L[L.length-1].name} for code(${T}) is shadowed by ${x.name}`),L.push(x)}return w},[{}])}(i,s.debug),u=!1,g=h.length-1;for(;!At(e,0,"EOF");){let b=function(D,B,dt){return D.find((yt,ot)=>{var W;return ot>=dt&&((W=yt[B])==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:T,isReducible:L}=w,z=E==null?void 0:E(e,s,o);if(z===ka){s.rewind();break}if(x){let[D,B]=function(dt,yt){let ot=yt.split(".");if(!ot.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let W=dt;for(let ct=0;ct<ot.length-1;++ct){let st=la(ot[ct]),Vt=la(ot[ct+1]);Object.prototype.hasOwnProperty.call(W,st)||(typeof Vt=="number"?W[st]=[]:W[st]={}),W=W[st]}return[W,la(ot[ot.length-1])]}(o,x);T&&!L?(Object.prototype.hasOwnProperty.call(D,B)||(D[B]=[]),D[B].push(z)):D[B]=z}w.pushContext&&(g-=1),u=!0,e=s.next()}return t&&Object.setPrototypeOf(o,t),u}}function la(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 Bt({value:i}){return!!i}let Iu=[{code:1001,name:"xdata",parser:Pl}];function Pl(i,t){var o;if(!At(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let s=[e.value];for(;!At(i,0,"EOF")&&i.code>=1e3;){let h=s[s.length-1];switch(i.code){case 1002:i.value==="{"?s.push([]):(s.pop(),(o=s[s.length-1])==null||o.push(h));break;case 1e3:case 1004:case 1040:case 1070:case 1071:h.push({type:Er(i.code),value:i.value});break;case 1003:h.push({name:"layer",type:Er(i.code),value:i.value});break;case 1005:h.push({name:"handle",type:Er(i.code),value:i.value});break;case 1010:h.push({type:Er(i.code),value:Rt(t)});break;case 1011:h.push({name:"worldSpacePosition",type:Er(i.code),value:Rt(t)});break;case 1012:h.push({name:"worldSpaceDisplacement",type:Er(i.code),value:Rt(t)});break;case 1013:h.push({name:"worldSpaceDirection",type:Er(i.code),value:Rt(t)});break;case 1041:h.push({name:"distance",type:Er(i.code),value:i.value});break;case 1042:h.push({name:"scale",type:Er(i.code),value:i.value})}i=t.next()}return t.rewind(),e}function Er(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 fn(i,t,e){for(;At(i,102);){var s;let o=i.value;if(i=t.next(),!o.startsWith("{")){t.debug&&console.warn(`Invalid application group, expected to start with "{" but received: ${o}`),function(u,g){for(;!At(u,102)&&!At(u,0,"EOF");)u=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(u,g,b){for(;!At(u,102,"}")&&!At(u,0,"EOF");)b.push(u),u=g.next()}(i,t,e.extensions[h]),i=t.next()}t.rewind()}let Eu=0;function Il(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=Eu++)}var ku=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function El(i){return ku[i]}(yr={})[yr.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",yr[yr.CAST=1]="CAST",yr[yr.RECEIVE=2]="RECEIVE",yr[yr.IGNORE=3]="IGNORE";let Ut=[...Iu,{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:Bt},{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=El(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:Bt},{code:100},{code:160},{code:330,name:"ownerBlockRecordSoftId",parser:v},{code:102,parser:fn},{code:102,parser:fn},{code:102,parser:fn},{code:5,name:"handle",parser:v}];function Ri(i){return[{code:3,name:i,parser:(t,e,s)=>(s._code3text=(s._code3text??"")+t.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(t,e,s)=>(s._code1text=t.value,(s._code3text??"")+s._code1text)}]}function kl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Tu={extrusionDirection:{x:0,y:0,z:1}},Mu=[{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},...Ut];class Tl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kl(this,"parser",bt(Mu,Tu))}}kl(Tl,"ForEntityName","ARC");(rr={})[rr.NONE=0]="NONE",rr[rr.INVISIBLE=1]="INVISIBLE",rr[rr.CONSTANT=2]="CONSTANT",rr[rr.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",rr[rr.PRESET=8]="PRESET";(As={})[As.MULTILINE=2]="MULTILINE",As[As.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(ln={})[ln.NONE=0]="NONE",ln[ln.MIRRORED_X=2]="MIRRORED_X",ln[ln.MIRRORED_Y=4]="MIRRORED_Y";var Nu=((Re={})[Re.LEFT=0]="LEFT",Re[Re.CENTER=1]="CENTER",Re[Re.RIGHT=2]="RIGHT",Re[Re.ALIGNED=3]="ALIGNED",Re[Re.MIDDLE=4]="MIDDLE",Re[Re.FIT=5]="FIT",Re),Cu=((vr={})[vr.BASELINE=0]="BASELINE",vr[vr.BOTTOM=1]="BOTTOM",vr[vr.MIDDLE=2]="MIDDLE",vr[vr.TOP=3]="TOP",vr);function Ml(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Nl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Nu.LEFT,valign:Cu.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Cl=[{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},...Ut];class Ll{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ml(this,"parser",bt(Cl,Nl))}}function Ol(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ml(Ll,"ForEntityName","TEXT");let Lu={...Nl},Ou=[{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:Bt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedRecord",parser:Bt},{code:100},{code:280,name:"isLocked",parser:Bt},{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},...Cl.slice(2)];class zl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ol(this,"parser",bt(Ou,Lu))}}Ol(zl,"ForEntityName","ATTDEF");(hn={})[hn.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",hn[hn.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",hn[hn.BY_STYLE=5]="BY_STYLE";function zu(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*ii(i,t=1/0,e=1){for(let s=i;s!==t;s+=e)yield s}function jr(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}function Ta(i,t,e){if(At(t,102))return fn(t,e,i),!0;switch(t.code){case 0:i.type=t.value;break;case 5:i.handle=t.value;break;case 330:i.ownerBlockRecordSoftId=t.value;break;case 67:i.isInPaperSpace=!!t.value;break;case 8:i.layer=t.value;break;case 6:i.lineType=t.value;break;case 347:i.materialObjectHardId=t.value;break;case 62:i.colorIndex=t.value,i.color=El(Math.abs(t.value));break;case 370:i.lineweight=t.value;break;case 48:i.lineTypeScale=t.value;break;case 60:i.isVisible=!!t.value;break;case 92:i.proxyByte=t.value;break;case 310:i.proxyEntity=t.value;break;case 100:break;case 420:i.color=t.value;break;case 430:i.transparency=t.value;break;case 390:i.plotStyleHardId=t.value;break;case 284:i.shadowMode=t.value;break;case 1001:i.xdata=Pl(t,e);break;default:return!1}return!0}function Rl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Ru={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Js=[{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:[...ii(430,440)],name:"backgroundColor",parser:v},{code:[...ii(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},...Ri("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},...Ut];class Fl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Rl(this,"parser",bt(Js,Ru))}}function Bl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Rl(Fl,"ForEntityName","MTEXT");let Fu={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Bu=[...Js.slice(Js.findIndex(({name:i})=>i==="columnType"),Js.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!At(i,0,"MTEXT"))return ka}},{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:Bt},{code:70,name:"mtextFlag",parser:v},{code:280,name:"isDuplicatedEntriesKeep",parser:Bt},{code:100},{code:280,name:"lockPositionFlag",parser:Bt},{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},...Ut];class Dl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Bl(this,"parser",bt(Bu,Fu))}}function Ul(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Bl(Dl,"ForEntityName","ATTRIB");let Du=[...Ri("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Ut];class Vl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ul(this,"parser",bt(Du))}}function Gl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ul(Vl,"ForEntityName","BODY");let Uu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Vu=[{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},...Ut];class jl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gl(this,"parser",bt(Vu,Uu))}}Gl(jl,"ForEntityName","CIRCLE");class ti{parseEntity(t,e){let s={};for(;!At(e,0,"EOF");){if(e.code===0){t.rewind();break}(function(o,h,u){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(u);break;case 11:o.textPoint=Rt(u);break;case 12:o.insertionPoint=Rt(u);break;case 13:o.subDefinitionPoint1=Rt(u);break;case 14:o.subDefinitionPoint2=Rt(u);break;case 15:o.centerPoint=Rt(u);break;case 16:o.arcPoint=Rt(u);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(u);break;case 3:o.styleName=h.value;break;default:Ta(o,h,u)}})(s,e,t),e=t.next()}return s}}function Wl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ea="DIMENSION",(ta="ForEntityName")in ti?Object.defineProperty(ti,ta,{value:ea,enumerable:!0,configurable:!0,writable:!0}):ti[ta]=ea;let Gu={extrusionDirection:{x:0,y:0,z:1}},ju=[{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},...Ut];class Hl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wl(this,"parser",bt(ju,Gu))}}Wl(Hl,"ForEntityName","ELLIPSE");(br={})[br.First=1]="First",br[br.Second=2]="Second",br[br.Third=4]="Third",br[br.Fourth=8]="Fourth";function Yl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Wu=[{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},...Ut];class ql{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Yl(this,"parser",bt(Wu))}}Yl(ql,"ForEntityName","3DFACE");let Xl=[{code:330,name:"sourceBoundaryObjects",parser:v,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:v}],Hu=[{code:11,name:"end",parser:j},{code:10,name:"start",parser:j}],Yu=[{code:73,name:"isCCW",parser:Bt},{code:51,name:"endAngle",parser:v},{code:50,name:"startAngle",parser:v},{code:40,name:"radius",parser:v},{code:10,name:"center",parser:j}],qu=[{code:73,name:"isCCW",parser:Bt},{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}],Xu=[{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:Bt},{code:73,name:"splineFlag",parser:v},{code:94,name:"degree",parser:v}],Ku={[Hs.Line]:Hu,[Hs.Circular]:Yu,[Hs.Elliptic]:qu,[Hs.Spline]:Xu},$u=[...Xl,{code:72,name:"edges",parser(i,t){let e={type:i.value},s=bt(Ku[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}],Zu=[...Xl,{code:10,name:"vertices",parser(i,t){let e={...Rt(t),bulge:0};return(i=t.next()).code===42?e.bulge=i.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:v},{code:73,name:"isClosed",parser:Bt},{code:72,name:"hasBulge",parser:Bt}],Qu=[{code:49,name:"dashLengths",parser:v,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:v},{code:45,name:"offset",parser:qo},{code:43,name:"base",parser:qo},{code:53,name:"angle",parser:v}];function qo(i,t){let e=i.code+1,s={x:i.value,y:1};return(i=t.next()).code===e?s.y=i.value:t.rewind(),s}function Kl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Ju={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},td=[{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 bt(Qu)(i,t,e),e},isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:v},{code:77,name:"isDouble",parser:Bt},{code:73,name:"isAnnotated",parser:Bt},{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&Su.Polyline;return i=t.next(),s?bt(Zu)(i,t,e):bt($u)(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},...Ut];class $l{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Kl(this,"parser",bt(td,Ju))}}Kl($l,"ForEntityName","HATCH");(xr={})[xr.ShowImage=1]="ShowImage",xr[xr.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",xr[xr.UseClippingBoundary=4]="UseClippingBoundary",xr[xr.TransparencyIsOn=8]="TransparencyIsOn";(Ss={})[Ss.Rectangular=1]="Rectangular",Ss[Ss.Polygonal=2]="Polygonal";(Ps={})[Ps.Outside=0]="Outside",Ps[Ps.Inside=1]="Inside";function Zl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let ed={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},rd=[{code:290,name:"clipMode",parser: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:Bt},{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},...Ut];class Ql{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zl(this,"parser",bt(rd,ed))}}function Jl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Zl(Ql,"ForEntityName","IMAGE");let nd={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},sd=[{code:210,name:"extrusionDirection",parser: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:Bt},{code:100,name:"subclassMarker",parser:v},...Ut];class th{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Jl(this,"parser",bt(sd,nd))}}function eh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Jl(th,"ForEntityName","INSERT");let id={isArrowheadEnabled:!0},ad=[{code:213,name:"offsetFromAnnotation",parser: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:Bt},{code:74,name:"isHooklineSameDirection",parser:Bt},{code:73,name:"leaderCreationFlag",parser:v},{code:72,name:"isSpline",parser:Bt},{code:71,name:"isArrowheadEnabled",parser:Bt},{code:3,name:"styleName",parser:v},{code:100,name:"subclassMarker",parser:v},...Ut],rh=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){eh(this,"parser",bt(ad,id))}};eh(rh,"ForEntityName","LEADER");(wr={})[wr.TextAnnotation=0]="TextAnnotation",wr[wr.ToleranceAnnotation=1]="ToleranceAnnotation",wr[wr.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",wr[wr.NoAnnotation=3]="NoAnnotation";function nh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let od={thickness:0,extrusionDirection:{x:0,y:0,z:1}},ld=[{code:210,name:"extrusionDirection",parser: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},...Ut];class sh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){nh(this,"parser",bt(ld,od))}}nh(sh,"ForEntityName","LINE");(Is={})[Is.IS_CLOSED=1]="IS_CLOSED",Is[Is.PLINE_GEN=128]="PLINE_GEN";let hd={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},cd={bulge:0},ud=[{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}],dd=[{code:210,name:"extrusionDirection",parser:j},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return bt(ud,cd)(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},...Ut];class ei{parseEntity(t,e){let s={};return bt(dd,hd)(e,t,s),s}}function ih(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}na="LWPOLYLINE",(ra="ForEntityName")in ei?Object.defineProperty(ei,ra,{value:na,enumerable:!0,configurable:!0,writable:!0}):ei[ra]=na;let md=[{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&&!At(i,0);++h)i=t.next(),s.push(i.value);let o=0;for(;o<s.length;){let h=s[o++],u=[];for(let g=0;g<h;++g)u.push(s[o++]);e.faceIndices.push(u)}}},{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:Bt},{code:71,name:"version",parser:v},{code:100,name:"subclassMarker",parser:function({value:i}){return i.trim()},pushContext:!0},...Ut];class ah{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ih(this,"parser",bt(md))}}function oh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ih(ah,"ForEntityName","MESH");let pd={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},gd=[{code:50,name:"angle",parser: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},...Ut];class lh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){oh(this,"parser",bt(gd,pd))}}oh(lh,"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 Ys=((Ar={})[Ar.NONE=0]="NONE",Ar[Ar.QUADRATIC=5]="QUADRATIC",Ar[Ar.CUBIC=6]="CUBIC",Ar[Ar.BEZIER=8]="BEZIER",Ar),fd=((ue={})[ue.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",ue[ue.TANGENT_DEFINED=2]="TANGENT_DEFINED",ue[ue.NOT_USED=4]="NOT_USED",ue[ue.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",ue[ue.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",ue[ue.FOR_POLYLINE=32]="FOR_POLYLINE",ue[ue.FOR_POLYGON=64]="FOR_POLYGON",ue[ue.POLYFACE=128]="POLYFACE",ue);function hh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let _d={startWidth:0,endWidth:0,bulge:0},yd=[{code:91,name:"id",parser:v},{code:[...ii(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},...Ut];class Ma{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){hh(this,"parser",bt(yd,_d))}}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}hh(Ma,"ForEntityName","VERTEX");let vd={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:[]},bd=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>At(i,0,"VERTEX")?(i=t.next(),new Ma().parseEntity(t,i)):ka},{code:210,name:"extrusionDirection",parser: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},...Ut];class uh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ch(this,"parser",bt(bd,vd))}}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}ch(uh,"ForEntityName","POLYLINE");let xd=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Ut];class mh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dh(this,"parser",bt(xd))}}function ph(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}dh(mh,"ForEntityName","RAY");let wd=[...Ri("data"),{code:70,name:"version",parser:v},{code:100,name:"subclassMarker",parser:v},...Ut];class gh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ph(this,"parser",bt(wd))}}function fh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ph(gh,"ForEntityName","REGION");let Ad={vertices:[],backLineVertices:[]},Sd=[{code:360,name:"geometrySettingHardId",parser: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},...Ut];class _h{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){fh(this,"parser",bt(Sd,Ad))}}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}fh(_h,"ForEntityName","SECTION");let Pd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Id=[{code:210,name:"extrusionDirection",parser:j},{code:39,name:"thickness",parser:v},{code:[...ii(10,14)],name:"points",isMultiple:!0,parser:j},{code:100,name:"subclassMarker",parser:v},...Ut];class vh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){yh(this,"parser",bt(Id,Pd))}}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}yh(vh,"ForEntityName","SOLID");let Ed=[{code:350,name:"historyObjectSoftId",parser:v},{code:100,name:"subclassMarker",parser:v},...Ri("data"),{code:70,name:"version",parser:v},{code:100},...Ut];class xh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){bh(this,"parser",bt(Ed))}}bh(xh,"ForEntityName","3DSOLID");(Fe={})[Fe.NONE=0]="NONE",Fe[Fe.CLOSED=1]="CLOSED",Fe[Fe.PERIODIC=2]="PERIODIC",Fe[Fe.RATIONAL=4]="RATIONAL",Fe[Fe.PLANAR=8]="PLANAR",Fe[Fe.LINEAR=16]="LINEAR";function wh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let kd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Td=[{code:11,name:"fitPoints",isMultiple:!0,parser: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},...Ut];class Ah{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){wh(this,"parser",bt(Td,kd))}}wh(Ah,"ForEntityName","SPLINE");class ri{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=jr(Rt(t)),e=t.lastReadGroup;break;case 11:s.directionVector=jr(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 u=!1,g=!1,b={};for(;!o.isEOF()&&h.code!==0&&!g;)switch(h.code){case 171:if(u){g=!0;continue}b.cellType=h.value,u=!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 u=!1,g=!1,b}(t,e)),e=t.lastReadGroup;break;default:Ta(s,e,t),e=t.next()}}return s}}function Sh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}ia="ACAD_TABLE",(sa="ForEntityName")in ri?Object.defineProperty(ri,sa,{value:ia,enumerable:!0,configurable:!0,writable:!0}):ri[sa]=ia;let Md=[{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},...Ut];class Ph{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sh(this,"parser",bt(Md))}}Sh(Ph,"ForEntityName","TOLERANCE");let ni=class{parseEntity(t,e){let s={};for(;e!=="EOF";){if(e.code===0){t.rewind();break}!function(o,h,u){if(u==="EOF")return!1;switch(u.code){case 0:return!1;case 8:o.layer=u.value;break;case 100:o.subclassMarker=u.value;break;case 10:o.viewportCenter=jr(Rt(h));break;case 40:o.width=u.value;break;case 41:o.height=u.value;break;case 68:o.status=u.value;break;case 69:o.viewportId=u.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=jr(Rt(h));break;case 17:o.targetPoint=jr(Rt(h));break;case 42:o.perspectiveLensLength=u.value;break;case 43:o.frontClipZ=u.value;break;case 44:o.backClipZ=u.value;break;case 45:o.viewHeight=u.value;break;case 50:o.snapAngle=u.value;break;case 51:o.viewTwistAngle=u.value;break;case 72:o.circleZoomPercent=u.value;break;case 331:o.frozenLayerIds??(o.frozenLayerIds=[]),o.frozenLayerIds.push(u.value);break;case 90:o.statusBitFlags=u.value;break;case 340:o.clippingBoundaryId=u.value;break;case 1:o.sheetName=u.value;break;case 281:o.renderMode=u.value;break;case 71:o.ucsPerViewport=u.value;break;case 110:o.ucsOrigin=jr(Rt(h));break;case 111:o.ucsXAxis=jr(Rt(h));break;case 112:o.ucsYAxis=jr(Rt(h));break;case 345:o.ucsId=u.value;break;case 346:o.ucsBaseId=u.value;break;case 79:o.orthographicType=u.value;break;case 146:o.elevation=u.value;break;case 170:o.shadePlotMode=u.value;break;case 61:o.majorGridFrequency=u.value;break;case 332:o.backgroundId=u.value;break;case 333:o.shadePlotId=u.value;break;case 348:o.visualStyleId=u.value;break;case 292:o.isDefaultLighting=!!u.value;break;case 282:o.defaultLightingType=u.value;break;case 141:o.brightness=u.value;break;case 142:o.contrast=u.value;break;case 63:case 421:case 431:o.ambientLightColor=u.value;break;case 361:o.sunId=u.value;break;case 335:case 343:case 344:case 91:o.softPointer=u.value}return!0}(s,t,e)&&Ta(s,e,t),e=t.next()}return s}};oa="VIEWPORT",(aa="ForEntityName")in ni?Object.defineProperty(ni,aa,{value:oa,enumerable:!0,configurable:!0,writable:!0}):ni[aa]=oa;(Sr={})[Sr.ShowImage=1]="ShowImage",Sr[Sr.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Sr[Sr.UseClippingBoundary=4]="UseClippingBoundary",Sr[Sr.Transparency=8]="Transparency";function Ih(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Nd={brightness:50,constrast:50,fade:0},Cd=[{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:Bt},{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},...Ut];class Eh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ih(this,"parser",bt(Cd,Nd))}}function kh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ih(Eh,"ForEntityName","WIPEOUT");let Ld=[{code:11,name:"direction",parser:j},{code:10,name:"position",parser:j},{code:100,name:"subclassMarker",parser:v},...Ut],Th=class{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kh(this,"parser",bt(Ld))}};function Mh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}kh(Th,"ForEntityName","XLINE");let Od={},zd=[{code:170,name:"multileaderType",parser:v},{code:291,name:"doglegEnabled",parser:Bt},{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,u,g){let b,f={vertices:[]};for(;u.hasNext()&&(b=u.next()).code!==305;)b.code===10&&f.vertices.push((b.value,Rt(u)));return f}(0,t))}return o},isMultiple:!0},...Ut];class Nh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Mh(this,"parser",bt(zd,Od))}}Mh(Nh,"ForEntityName","MULTILEADER");let Rd=Object.fromEntries([Tl,zl,Dl,Vl,jl,ti,Hl,ql,Ql,th,rh,sh,ei,ah,Fl,Nh,lh,uh,mh,gh,_h,vh,xh,Ah,ri,Ll,Ph,$l,Ma,ni,Eh,Th].map(i=>[i.ForEntityName,new i]));function Ch(i,t){let e=[];for(;!At(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let s=Rd[i.value];if(s){let o=i.value;i=t.next();let h=s.parseEntity(t,i);h.type=o,Il(h),e.push(h)}else t.debug&&console.warn(`Unsupported ENTITY type: ${i.value}`)}i=t.next()}return e}function Fd(i,t){let e={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");){if(At(i,0,"BLOCK")){let s=Bd(i=t.next(),t);Il(s),s.name&&(e[s.name]=s)}i=t.next()}return e}function Bd(i,t){let e={};for(;!At(i,0,"EOF");){if(At(i,0,"ENDBLK")){for(i=t.next();!At(i,0,"EOF");){if(At(i,100,"AcDbBlockEnd"))return e;i=t.next()}break}switch(i.code){case 1:e.xrefPath=i.value;break;case 2:e.name=i.value;break;case 3:e.name2=i.value;break;case 5:e.handle=i.value;break;case 8:e.layer=i.value;break;case 10:e.position=Rt(t);break;case 67:e.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(e.type=i.value);break;case 100:break;case 330:e.ownerHandle=i.value;break;case 0:e.entities=Ch(i,t)}i=t.next()}return e}function Dd(i,t){let e=null,s={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");)i.code===9?e=i.value:i.code===10?s[e]=Rt(t):s[e]=i.value,i=t.next();return s}(Be={})[Be.NOT_APPLICABLE=0]="NOT_APPLICABLE",Be[Be.KEEP_EXISTING=1]="KEEP_EXISTING",Be[Be.USE_CLONE=2]="USE_CLONE",Be[Be.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Be[Be.VALUE_NAME=4]="VALUE_NAME",Be[Be.UNMANGLE_NAME=5]="UNMANGLE_NAME";let Na=[{code:330,name:"ownerObjectId",parser:v},{code:102,parser:fn},{code:102,parser:fn},{code:102,parser:fn},{code:5,name:"handle",parser:v}],Ud=[{code:3,name:"entries",parser:(i,t)=>{let e={name:i.value};return(i=t.next()).code===350?e.objectSoftId=i.value:i.code===360?e.objectHardId=i.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:v},{code:280,name:"isHardOwned",parser:Bt},{code:100,name:"subclassMarker",parser:v},...Na],Vd=[{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";(un={})[un.INCHES=0]="INCHES",un[un.MILLIMETERS=1]="MILLIMETERS",un[un.PIXELS=2]="PIXELS";(De={})[De.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",De[De.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",De[De.DRAWING_LIMITS=2]="DRAWING_LIMITS",De[De.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",De[De.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",De[De.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Pr={})[Pr.AS_DISPLAYED=0]="AS_DISPLAYED",Pr[Pr.WIREFRAME=1]="WIREFRAME",Pr[Pr.HIDDEN=2]="HIDDEN",Pr[Pr.RENDERED=3]="RENDERED";(Ue={})[Ue.DRAFT=0]="DRAFT",Ue[Ue.PREVIEW=1]="PREVIEW",Ue[Ue.NORMAL=2]="NORMAL",Ue[Ue.PRESENTATION=3]="PRESENTATION",Ue[Ue.MAXIMUM=4]="MAXIMUM",Ue[Ue.CUSTOM=5]="CUSTOM";let Lh=[{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},...Na],Gd=[{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},...Lh],jd=[{code:40,name:"wcsToOCSTransform",parser:Xo},{code:40,name:"ocsToWCSTransform",parser:Xo},{code:41,name:"backClippingDistance",parser:v},{code:73,name:"isBackClipping",parser:Bt,pushContext:!0},{code:40,name:"frontClippingDistance",parser:v},{code:72,name:"isFrontClipping",parser:Bt,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:Bt},{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},...Na];function Xo(i,t){let e=[];for(let s=0;s<3&&At(i,40);++s){let o=[];for(let h=0;h<4&&At(i,40);++h)o.push(i.value),i=t.next();e.push(o)}return t.rewind(),e}let Wd={LAYOUT:Gd,PLOTSETTINGS:Lh,DICTIONARY:Ud,SPATIAL_FILTER:jd,IMAGEDEF:Vd};function Hd(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,o=Wd[s];if(i.code===0&&(o!=null&&o.length)){let h=bt(o),u={name:s};h(i=t.next(),t,u)?(e.push(u),i=t.peek()):i=t.next()}else i=t.next()}return{byName:zu(e,({name:s})=>s)}}let jn=[{code:100,name:"subclassMarker",parser:v},{code:330,name:"ownerObjectId",parser:v},{code:102,parser(i,t){for(;!At(i,0,"EOF")&&!At(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:v}],Yd=bt([{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},...jn]),qd=[{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:Yo.Above,defaultValueImperial:Yo.Center},{name:"DIMZIN",code:78,defaultValue:zn.Trailing,defaultValueImperial:zn.Feet},{name:"DIMAZIN",code:79,defaultValue:xu.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:wu.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Au.Center},{name:"DIMTZIN",code:284,defaultValue:zn.Trailing,defaultValueImperial:zn.Feet},{name:"DIMALTZ",code:285,defaultValue:zn.Trailing},{name:"DIMALTTZ",code:286,defaultValue:zn.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMTXSTY",code:340},{name:"DIMLDRBLK",code:341},{name:"DIMBLK",code:342},{name:"DIMBLK1",code:343},{name:"DIMBLK2",code:344},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWD",code:372,defaultValue:-2}],Xd=bt([...qd.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},...jn.filter(i=>i.code!==5)]),Kd=bt([{code:347,name:"materialObjectId",parser:v},{code:390,name:"plotStyleNameObjectId",parser:v},{code:370,name:"lineweight",parser:v},{code:290,name:"isPlotting",parser:Bt},{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},...jn]);(Ir={})[Ir.NONE=0]="NONE",Ir[Ir.AbsoluteRotation=1]="AbsoluteRotation",Ir[Ir.TextEmbedded=2]="TextEmbedded",Ir[Ir.ShapeEmbedded=4]="ShapeEmbedded";let $d=bt([{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}),Zd=bt([{code:49,name:"pattern",parser(i,t){let e={};return $d(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},...jn]),Qd=bt([{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},...jn]),Jd=bt([{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:Bt},{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},...jn]),t0={BLOCK_RECORD:Yd,DIMSTYLE:Xd,LAYER:Kd,LTYPE:Zd,STYLE:Qd,VPORT:Jd},e0=bt([{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 r0(i,t){var s;let e={};for(;!At(i,0,"EOF")&&!At(i,0,"ENDSEC");){if(At(i,0,"TABLE")){i=t.next();let o={entries:[]};e0(i,t,o),e[o.name]=o}if(At(i,0)&&!At(i,0,"ENDTAB")){let o=i.value;i=t.next();let h=t0[o];if(!h){t.debug&&console.warn(`parseTable: Invalid table name '${o}'`),i=t.next();continue}let u={};h(i,t,u),(s=e[o])==null||s.entries.push(u)}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 Ko{next(){if(!this.hasNext())return this._eof?this.debug&&console.warn("Cannot call 'next' after EOF group has been read"):this.debug&&console.warn("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]),{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=$o(t,this._data[this._pointer++],this.debug),s={code:t,value:e};return At(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=$o(t.code,this._data[this._pointer+1],this.debug),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t,e=!1){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 $o(i,t,e=!1){return i<=9?t:i>=10&&i<=59?parseFloat(t.trim()):i>=60&&i<=99?parseInt(t.trim()):i>=100&&i<=109?t:i>=110&&i<=149?parseFloat(t.trim()):i>=160&&i<=179?parseInt(t.trim()):i>=210&&i<=239?parseFloat(t.trim()):i>=270&&i<=289?parseInt(t.trim()):i>=290&&i<=299?function(s){if(s==="0")return!1;if(s==="1")return!0;throw TypeError("String '"+s+"' cannot be cast to Boolean type")}(t.trim()):i>=300&&i<=369?t:i>=370&&i<=389?parseInt(t.trim()):i>=390&&i<=399?t:i>=400&&i<=409?parseInt(t.trim()):i>=410&&i<=419?t:i>=420&&i<=429?parseInt(t.trim()):i>=430&&i<=439?t:i>=440&&i<=459?parseInt(t.trim()):i>=460&&i<=469?parseFloat(t.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?t:i>=1010&&i<=1059?parseFloat(t.trim()):i>=1060&&i<=1071?parseInt(t.trim()):(e&&console.warn("WARNING: Group code does not have a defined type: %j",{code:i,value:t}),t)}function pa(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class n0{constructor(){pa(this,"encoding","utf-8"),pa(this,"encodingFailureFatal",!1)}}class s0 extends EventTarget{parseSync(t,e=!1){let s=new Ko(t.split(/\r\n|\r|\n/g),e);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(t){let e="",s=this;return new Promise((o,h)=>{t.on("data",u=>{e+=u}),t.on("end",()=>{try{let u=e.split(/\r\n|\r|\n/g),g=new Ko(u);if(!g.hasNext())throw Error("Empty file");o(s.parseAll(g))}catch(u){h(u)}}),t.on("error",u=>{h(u)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let o=s.body.getReader(),h="";for(;;){let{done:u,value:g}=await o.read();if(u){h+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}h+=this._decoder.decode(g,{stream:!0})}return this.parseSync(h)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!At(s,0,"EOF");)At(s,0,"SECTION")&&(At(s=t.next(),2,"HEADER")?(s=t.next(),e.header=Dd(s,t)):At(s,2,"BLOCKS")?(s=t.next(),e.blocks=Fd(s,t)):At(s,2,"ENTITIES")?(s=t.next(),e.entities=Ch(s,t)):At(s,2,"TABLES")?(s=t.next(),e.tables=r0(s,t)):At(s,2,"OBJECTS")&&(s=t.next(),e.objects=Hd(s,t))),s=t.next();return e}constructor(t=new n0){super(),pa(this,"_decoder",void 0),this._decoder=new TextDecoder(t.encoding,{fatal:t.encodingFailureFatal})}}const Zo=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class ai{constructor(t){if(typeof t=="string"){const e=Zo.find(s=>s.name===t);if(!e)throw new Error(`Unknown DWG version name: ${t}`);this.name=e.name,this.value=e.value;return}if(typeof t=="number"){const e=Zo.find(s=>s.value===t);if(!e)throw new Error(`Unknown DWG version value: ${t}`);this.name=e.name,this.value=e.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class i0{parse(t){const e=new s0,s=this.getDxfInfoFromBuffer(t);let o="";return s.version&&s.version.value<=23&&s.encoding?o=new TextDecoder(s.encoding).decode(t):o=new TextDecoder().decode(t),e.parseSync(o)}getDxfInfoFromBuffer(t){var f,w,x;const s=new TextDecoder("utf-8");let o=0,h="",u=null,g=null,b=!1;for(;o<t.byteLength;){const E=Math.min(o+65536,t.byteLength),T=t.slice(o,E);o=E;const z=(h+s.decode(T,{stream:!0})).split(/\r?\n/);h=z.pop()??"";for(let D=0;D<z.length;D++){const B=z[D].trim();if(B==="SECTION"&&((f=z[D+2])==null?void 0:f.trim())==="HEADER")b=!0;else if(B==="ENDSEC"&&b)return{version:u,encoding:g};if(b&&B==="$ACADVER"){const dt=(w=z[D+2])==null?void 0:w.trim();dt&&(u=new ai(dt))}else if(b&&B==="$DWGCODEPAGE"){const dt=(x=z[D+2])==null?void 0:x.trim();if(dt){const yt=Pa[dt];g=xl(yt)}}if(u&&g)return{version:u,encoding:g}}}return{version:u,encoding:g}}}const fe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Qo=1234567;const Ca=Math.PI/180,La=180/Math.PI;function Oh(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(fe[i&255]+fe[i>>8&255]+fe[i>>16&255]+fe[i>>24&255]+"-"+fe[t&255]+fe[t>>8&255]+"-"+fe[t>>16&15|64]+fe[t>>24&255]+"-"+fe[e&63|128]+fe[e>>8&255]+"-"+fe[e>>16&255]+fe[e>>24&255]+fe[s&255]+fe[s>>8&255]+fe[s>>16&255]+fe[s>>24&255]).toLowerCase()}function Tr(i,t,e){return Math.max(t,Math.min(e,i))}function Oa(i,t){return(i%t+t)%t}function zh(i,t,e,s,o){return s+(i-t)*(o-s)/(e-t)}function Rh(i,t,e){return i!==t?(e-i)/(t-i):0}function za(i,t,e){return(1-e)*i+e*t}function Fh(i,t,e,s){return za(i,t,1-Math.exp(-e*s))}function Bh(i,t=1){return t-Math.abs(Oa(i,t*2)-t)}function Dh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Uh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Vh(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Gh(i,t){return i+Math.random()*(t-i)}function jh(i){return i*(.5-Math.random())}function Wh(i){i!==void 0&&(Qo=i);let t=Qo+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Hh(i){return i*Ca}function Yh(i){return i*La}function qh(i){return(i&i-1)===0&&i!==0}function Xh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Kh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Cs(i){const t=Math.PI*2;return(i%t+t)%t}function $h(i,t,e){return i>t&&i<e||i>e&&i<t}function Zh(i,t,e,s=!1){return i=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 Ra(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Qh(i,t=1e-7){const e=Ra(i);return Math.max(Math.pow(10,e)*t,t)}const Et={DEG2RAD:Ca,RAD2DEG:La,generateUUID:Oh,clamp:Tr,euclideanModulo:Oa,mapLinear:zh,inverseLerp:Rh,lerp:za,damp:Fh,pingpong:Bh,smoothstep:Dh,smootherstep:Uh,randInt:Vh,randFloat:Gh,randFloatSpread:jh,seededRandom:Wh,degToRad:Hh,radToDeg:Yh,isPowerOfTwo:qh,ceilPowerOfTwo:Xh,floorPowerOfTwo:Kh,normalizeAngle:Cs,isBetween:$h,isBetweenAngle:Zh,intPartLength:Ra,relativeEps:Qh},ga=class Jh{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:o,y:h}=t;this.x=o,this.y=h;return}if(s===2){this.x=t,this.y=e;return}throw je.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new Jh(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,o=t.elements;return this.x=o[0]*e+o[3]*s+o[6],this.y=o[1]*e+o[4]*s+o[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),o=Math.sin(e),h=this.x-t.x,u=this.y-t.y;return this.x=h*s-u*o+t.x,this.y=h*o+u*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(Et.relativeEps(this.x,t),Et.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};ga.EMPTY=Object.freeze(new ga(0,0));let $t=ga;const fa=class tc{constructor(t,e,s,o,h,u,g,b,f){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&o!=null&&h!=null&&u!=null&&g!=null&&b!=null&&f!=null&&this.set(t,e,s,o,h,u,g,b,f)}set(t,e,s,o,h,u,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]=u,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,u=s[0],g=s[3],b=s[6],f=s[1],w=s[4],x=s[7],E=s[2],T=s[5],L=s[8],z=o[0],D=o[3],B=o[6],dt=o[1],yt=o[4],ot=o[7],W=o[2],ct=o[5],st=o[8];return h[0]=u*z+g*dt+b*W,h[3]=u*D+g*yt+b*ct,h[6]=u*B+g*ot+b*st,h[1]=f*z+w*dt+x*W,h[4]=f*D+w*yt+x*ct,h[7]=f*B+w*ot+x*st,h[2]=E*z+T*dt+L*W,h[5]=E*D+T*yt+L*ct,h[8]=E*B+T*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],u=t[4],g=t[5],b=t[6],f=t[7],w=t[8];return e*u*w-e*g*f-s*h*w+s*g*b+o*h*f-o*u*b}invert(){const t=this.elements,e=t[0],s=t[1],o=t[2],h=t[3],u=t[4],g=t[5],b=t[6],f=t[7],w=t[8],x=w*u-g*f,E=g*b-w*h,T=f*h-u*b,L=e*x+s*E+o*T;if(L===0)return this.set(0,0,0,0,0,0,0,0,0);const z=1/L;return t[0]=x*z,t[1]=(o*f-w*s)*z,t[2]=(g*s-o*u)*z,t[3]=E*z,t[4]=(w*e-o*b)*z,t[5]=(o*h-g*e)*z,t[6]=T*z,t[7]=(s*b-f*e)*z,t[8]=(u*e-s*h)*z,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,o,h,u,g){const b=Math.cos(h),f=Math.sin(h);return this.set(s*b,s*f,-s*(b*u+f*g)+u+t,-o*f,o*b,-o*(-f*u+b*g)+g+e,0,0,1),this}scale(t,e){return this.premultiply(ha.makeScale(t,e)),this}rotate(t){return this.premultiply(ha.makeRotation(-t)),this}translate(t,e){return this.premultiply(ha.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof $t?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let o=0;o<9;o++)if(e[o]!==s[o])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new tc().fromArray(this.elements)}};fa.IDENTITY=Object.freeze(new fa);let Fi=fa;const ha=new Fi,mn=1e-6,ne=2*Math.PI,a0={x:0,y:0},Fa={x:0,y:0,z:0};class Ba{constructor(){this.equalPointTol=mn,this.equalVectorTol=mn}equalPoint2d(t,e){return new $t(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new $(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=mn){return t<e&&t>-e}static equal(t,e,s=mn){return Math.abs(t-e)<s}static great(t,e,s=mn){return t-e>s}static less(t,e,s=mn){return t-e<s}}const Da=new Ba;function Ua(i,t,e=!1){const s=i.x,o=i.y;let h=!1;const u=t.length;for(let g=0,b=u-1;g<u;b=g++){const f=t[g].x,w=t[g].y,x=t[b].x,E=t[b].y;let T=w>o!=E>o;e&&(T=w>=o!=E>=o),T&&s<(x-f)*(o-w)/(E-w)+f&&(h=!h)}return h}function ec(i,t){if(i.length===0||t.length===0)return!1;const e=new _e().setFromPoints(i),s=new _e().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let o=0;o<i.length;){if(Ua(i[o],t,!0))return!0;o<i.length-1&&Da.equalPoint2d(i[o+1],i[o])&&++o,++o}return!1}const rc={isPointInPolygon:Ua,isPolygonIntersect:ec};function nc(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 sc(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 u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=e-s;g++){const b=o[g]/h;u.push(b*(e-s+1))}for(let g=0;g<=s;g++)u.push(e-s+1);return u}function ic(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 u=[];for(let g=0;g<=s;g++)u.push(0);for(let g=1;g<=e-s;g++){const b=o[g]/h;u.push(b*(e-s+1))}for(let g=0;g<=s;g++)u.push(e-s+1);return u}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],u=o>1e-10?(e-s[i])/o:0,g=h>1e-10?(s[i+t+1]-e)/h:0;return u*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,u=t;if(i=Math.max(e[u],Math.min(e[h+1],i)),Math.abs(i-e[h+1])<1e-8)return[...s[h]];if(Math.abs(i-e[u])<1e-8)return[...s[0]];const g=[0,0,0];let b=0;for(let f=0;f<=h;f++){const w=oi(f,u,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-u-1];if(Math.abs(i-f)<1e-8)return[...s[h]];if(Math.abs(i-e[u])<1e-8)return[...s[0]]}return b>1e-10&&(g[0]/=b,g[1]/=b,g[2]/=b),g}function ac(i,t,e,s){const o=i,h=t[o],u=t[t.length-o-1];let g=0;const b=1e3,f=(u-h)/b;let w=Ls(h,i,t,e,s);for(let z=1;z<=b;z++){const D=h+z*f,B=Ls(D,i,t,e,s),dt=B[0]-w[0],yt=B[1]-w[1],ot=B[2]-w[2];g+=Math.sqrt(dt*dt+yt*yt+ot*ot),w=B}const x=Ls(u,i,t,e,s),E=x[0]-w[0],T=x[1]-w[1],L=x[2]-w[2];return g+=Math.sqrt(E*E+T*T+L*L),g}function o0(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,u,g){let b=s[o+0],f=s[o+1],w=s[o+2],x=s[o+3];const E=h[u+0],T=h[u+1],L=h[u+2],z=h[u+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]=T,t[e+2]=L,t[e+3]=z;return}if(x!==z||b!==E||f!==T||w!==L){let D=1-g;const B=b*E+f*T+w*L+x*z,dt=B>=0?1:-1,yt=1-B*B;if(yt>Number.EPSILON){const W=Math.sqrt(yt),ct=Math.atan2(W,B*dt);D=Math.sin(D*ct)/W,g=Math.sin(g*ct)/W}const ot=g*dt;if(b=b*D+E*ot,f=f*D+T*ot,w=w*D+L*ot,x=x*D+z*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,u){const g=s[o],b=s[o+1],f=s[o+2],w=s[o+3],x=h[u],E=h[u+1],T=h[u+2],L=h[u+3];return t[e]=g*L+w*x+b*T-f*E,t[e+1]=b*L+w*E+f*x-g*T,t[e+2]=f*L+w*T+g*E-b*x,t[e+3]=w*L-g*x-b*E-f*T,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,o){return this._x=t,this._y=e,this._z=s,this._w=o,this._onChangeCallback(),this}clone(){return new 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,u=t.order,g=Math.cos,b=Math.sin,f=g(s/2),w=g(o/2),x=g(h/2),E=b(s/2),T=b(o/2),L=b(h/2);switch(u){case"XYZ":this._x=E*w*x+f*T*L,this._y=f*T*x-E*w*L,this._z=f*w*L+E*T*x,this._w=f*w*x-E*T*L;break;case"YXZ":this._x=E*w*x+f*T*L,this._y=f*T*x-E*w*L,this._z=f*w*L-E*T*x,this._w=f*w*x+E*T*L;break;case"ZXY":this._x=E*w*x-f*T*L,this._y=f*T*x+E*w*L,this._z=f*w*L+E*T*x,this._w=f*w*x-E*T*L;break;case"ZYX":this._x=E*w*x-f*T*L,this._y=f*T*x+E*w*L,this._z=f*w*L-E*T*x,this._w=f*w*x+E*T*L;break;case"YZX":this._x=E*w*x+f*T*L,this._y=f*T*x+E*w*L,this._z=f*w*L-E*T*x,this._w=f*w*x-E*T*L;break;case"XZY":this._x=E*w*x-f*T*L,this._y=f*T*x-E*w*L,this._z=f*w*L+E*T*x,this._w=f*w*x+E*T*L;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,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],u=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 T=.5/Math.sqrt(E+1);this._w=.25/T,this._x=(w-b)*T,this._y=(h-f)*T,this._z=(u-o)*T}else if(s>g&&s>x){const T=2*Math.sqrt(1+s-g-x);this._w=(w-b)/T,this._x=.25*T,this._y=(o+u)/T,this._z=(h+f)/T}else if(g>x){const T=2*Math.sqrt(1+g-s-x);this._w=(h-f)/T,this._x=(o+u)/T,this._y=.25*T,this._z=(b+w)/T}else{const T=2*Math.sqrt(1+x-s-g);this._w=(u-o)/T,this._x=(h+f)/T,this._y=(b+w)/T,this._z=.25*T}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(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,u=t._w,g=e._x,b=e._y,f=e._z,w=e._w;return this._x=s*w+u*g+o*f-h*b,this._y=o*w+u*b+h*g-s*f,this._z=h*w+u*f+s*b-o*g,this._w=u*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,u=this._w;let g=u*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=u,this._x=s,this._y=o,this._z=h,this;const b=1-g*g;if(b<=Number.EPSILON){const T=1-e;return this._w=T*u+e*this._w,this._x=T*s+e*this._x,this._y=T*o+e*this._y,this._z=T*h+e*this._z,this.normalize(),this}const f=Math.sqrt(b),w=Math.atan2(f,g),x=Math.sin((1-e)*w)/f,E=Math.sin(e*w)/f;return this._w=u*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 Ge=class oc{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:u,z:g}=t;this.x=h,this.y=u,this.z=g||0;return}if(o===3){this.x=t,this.y=e,this.z=s;return}throw je.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new oc(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,u=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])*u,this.y=(h[1]*e+h[5]*s+h[9]*o+h[13])*u,this.z=(h[2]*e+h[6]*s+h[10]*o+h[14])*u,this}applyQuaternion(t){const e=this.x,s=this.y,o=this.z,h=t.x,u=t.y,g=t.z,b=t.w,f=2*(u*o-g*s),w=2*(g*e-h*o),x=2*(h*s-u*e);return this.x=e+b*f+u*x-g*w,this.y=s+b*w+g*f-h*x,this.z=o+b*x+h*w-u*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,u=e.x,g=e.y,b=e.z;return this.x=o*b-h*g,this.y=h*u-s*b,this.z=s*g-o*u,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return ca.copy(this).projectOnVector(t),this.sub(ca)}reflect(t){return this.sub(ca.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}};Ge.X_AXIS=Object.freeze(new Ge(1,0,0)),Ge.NEGATIVE_X_AXIS=Object.freeze(new Ge(-1,0,0)),Ge.Y_AXIS=Object.freeze(new Ge(0,1,0)),Ge.NEGATIVE_Y_AXIS=Object.freeze(new Ge(0,-1,0)),Ge.Z_AXIS=Object.freeze(new Ge(0,0,1)),Ge.NEGATIVE_Z_AXIS=Object.freeze(new Ge(0,0,-1));let $=Ge;const ca=new $,Jo=new qr,_a=class lc{constructor(t,e,s,o,h,u,g,b,f,w,x,E,T,L,z,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&&u!=null&&g!=null&&b!=null&&f!=null&&w!=null&&x!=null&&E!=null&&T!=null&&L!=null&&z!=null&&D!=null&&this.set(t,e,s,o,h,u,g,b,f,w,x,E,T,L,z,D)}set(t,e,s,o,h,u,g,b,f,w,x,E,T,L,z,D){const B=this.elements;return B[0]=t,B[4]=e,B[8]=s,B[12]=o,B[1]=h,B[5]=u,B[9]=g,B[13]=b,B[2]=f,B[6]=w,B[10]=x,B[14]=E,B[3]=T,B[7]=L,B[11]=z,B[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 lc().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(Da.equalPoint3d(t,$.Z_AXIS))this.identity();else{const e=new $(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors($.Y_AXIS,t).normalize():e.crossVectors($.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/Rn.setFromMatrixColumn(t,0).length(),h=1/Rn.setFromMatrixColumn(t,1).length(),u=1/Rn.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]*u,e[9]=s[9]*u,e[10]=s[10]*u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(l0,t,h0)}lookAt(t,e,s){const o=this.elements;return Ve.subVectors(t,e),Ve.lengthSq()===0&&(Ve.z=1),Ve.normalize(),Gr.crossVectors(s,Ve),Gr.lengthSq()===0&&(Math.abs(s.z)===1?Ve.x+=1e-4:Ve.z+=1e-4,Ve.normalize(),Gr.crossVectors(s,Ve)),Gr.normalize(),qs.crossVectors(Ve,Gr),o[0]=Gr.x,o[4]=qs.x,o[8]=Ve.x,o[1]=Gr.y,o[5]=qs.y,o[9]=Ve.y,o[2]=Gr.z,o[6]=qs.z,o[10]=Ve.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,u=s[0],g=s[4],b=s[8],f=s[12],w=s[1],x=s[5],E=s[9],T=s[13],L=s[2],z=s[6],D=s[10],B=s[14],dt=s[3],yt=s[7],ot=s[11],W=s[15],ct=o[0],st=o[4],Vt=o[8],qt=o[12],Wt=o[1],xt=o[5],Ot=o[9],de=o[13],me=o[2],Me=o[6],Jt=o[10],ae=o[14],Q=o[3],Nt=o[7],oe=o[11],cr=o[15];return h[0]=u*ct+g*Wt+b*me+f*Q,h[4]=u*st+g*xt+b*Me+f*Nt,h[8]=u*Vt+g*Ot+b*Jt+f*oe,h[12]=u*qt+g*de+b*ae+f*cr,h[1]=w*ct+x*Wt+E*me+T*Q,h[5]=w*st+x*xt+E*Me+T*Nt,h[9]=w*Vt+x*Ot+E*Jt+T*oe,h[13]=w*qt+x*de+E*ae+T*cr,h[2]=L*ct+z*Wt+D*me+B*Q,h[6]=L*st+z*xt+D*Me+B*Nt,h[10]=L*Vt+z*Ot+D*Jt+B*oe,h[14]=L*qt+z*de+D*ae+B*cr,h[3]=dt*ct+yt*Wt+ot*me+W*Q,h[7]=dt*st+yt*xt+ot*Me+W*Nt,h[11]=dt*Vt+yt*Ot+ot*Jt+W*oe,h[15]=dt*qt+yt*de+ot*ae+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],u=t[1],g=t[5],b=t[9],f=t[13],w=t[2],x=t[6],E=t[10],T=t[14],L=t[3],z=t[7],D=t[11],B=t[15];return L*(+h*b*x-o*f*x-h*g*E+s*f*E+o*g*T-s*b*T)+z*(+e*b*T-e*f*E+h*u*E-o*u*T+o*f*w-h*b*w)+D*(+e*f*x-e*g*T-h*u*x+s*u*T+h*g*w-s*f*w)+B*(-o*g*w-e*b*x+e*g*E+o*u*x-s*u*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 $?(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],u=t[4],g=t[5],b=t[6],f=t[7],w=t[8],x=t[9],E=t[10],T=t[11],L=t[12],z=t[13],D=t[14],B=t[15],dt=x*D*f-z*E*f+z*b*T-g*D*T-x*b*B+g*E*B,yt=L*E*f-w*D*f-L*b*T+u*D*T+w*b*B-u*E*B,ot=w*z*f-L*x*f+L*g*T-u*z*T-w*g*B+u*x*B,W=L*x*b-w*z*b-L*g*E+u*z*E+w*g*D-u*x*D,ct=e*dt+s*yt+o*ot+h*W;if(ct===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const st=1/ct;return t[0]=dt*st,t[1]=(z*E*h-x*D*h-z*o*T+s*D*T+x*o*B-s*E*B)*st,t[2]=(g*D*h-z*b*h+z*o*f-s*D*f-g*o*B+s*b*B)*st,t[3]=(x*b*h-g*E*h-x*o*f+s*E*f+g*o*T-s*b*T)*st,t[4]=yt*st,t[5]=(w*D*h-L*E*h+L*o*T-e*D*T-w*o*B+e*E*B)*st,t[6]=(L*b*h-u*D*h-L*o*f+e*D*f+u*o*B-e*b*B)*st,t[7]=(u*E*h-w*b*h+w*o*f-e*E*f-u*o*T+e*b*T)*st,t[8]=ot*st,t[9]=(L*x*h-w*z*h-L*s*T+e*z*T+w*s*B-e*x*B)*st,t[10]=(u*z*h-L*g*h+L*s*f-e*z*f-u*s*B+e*g*B)*st,t[11]=(w*g*h-u*x*h-w*s*f+e*x*f+u*s*T-e*g*T)*st,t[12]=W*st,t[13]=(w*z*o-L*x*o+L*s*E-e*z*E-w*s*D+e*x*D)*st,t[14]=(L*g*o-u*z*o-L*s*b+e*z*b+u*s*D-e*g*D)*st,t[15]=(u*x*o-w*g*o+w*s*b-e*x*b-u*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 $?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,u=t.x,g=t.y,b=t.z,f=h*u,w=h*g;return this.set(f*u+s,f*g-o*b,f*b+o*g,0,f*g+o*b,w*g+s,w*b-o*u,0,f*b-o*g,w*b+o*u,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,u){return this.set(1,s,h,0,t,1,u,0,e,o,1,0,0,0,0,1),this}compose(t,e,s){const o=this.elements,h=e.x,u=e.y,g=e.z,b=e.w,f=h+h,w=u+u,x=g+g,E=h*f,T=h*w,L=h*x,z=u*w,D=u*x,B=g*x,dt=b*f,yt=b*w,ot=b*x,W=s.x,ct=s.y,st=s.z;return o[0]=(1-(z+B))*W,o[1]=(T+ot)*W,o[2]=(L-yt)*W,o[3]=0,o[4]=(T-ot)*ct,o[5]=(1-(E+B))*ct,o[6]=(D+dt)*ct,o[7]=0,o[8]=(L+yt)*st,o[9]=(D-dt)*st,o[10]=(1-(E+z))*st,o[11]=0,o[12]=t.x,o[13]=t.y,o[14]=t.z,o[15]=1,this}decompose(t,e,s){const o=this.elements;let h=Rn.set(o[0],o[1],o[2]).length();const u=Rn.set(o[4],o[5],o[6]).length(),g=Rn.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],nr.copy(this);const b=1/h,f=1/u,w=1/g;return nr.elements[0]*=b,nr.elements[1]*=b,nr.elements[2]*=b,nr.elements[4]*=f,nr.elements[5]*=f,nr.elements[6]*=f,nr.elements[8]*=w,nr.elements[9]*=w,nr.elements[10]*=w,e.setFromRotationMatrix(nr),s.x=h,s.y=u,s.z=g,this}equals(t){const e=this.elements,s=t.elements;for(let o=0;o<16;o++)if(e[o]!==s[o])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};_a.IDENTITY=Object.freeze(new _a);let Xr=_a;const Rn=new $,nr=new Xr,l0=new $(0,0,0),h0=new $(1,1,1),Gr=new $,qs=new $,Ve=new $;class Mt{constructor(t=void 0,e=void 0){this.min=t==null?new $(1/0,1/0,1/0):new $(t.x,t.y,t.z),this.max=e==null?new $(-1/0,-1/0,-1/0):new $(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(ua.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=ua.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Mt().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $(0,0,0):new $(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $(0,0,0):new $(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,ua).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:(kr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),kr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),kr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),kr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),kr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),kr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),kr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),kr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(kr),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 kr=[new $,new $,new $,new $,new $,new $,new $,new $],ua=new $,tl=new $t;class _e{constructor(t=void 0,e=void 0){this.min=t==null?new $t(1/0,1/0):new $t(t.x,t.y),this.max=e==null?new $t(-1/0,-1/0):new $t(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=tl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new _e().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $t(0,0):new $t(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $t(0,0):new $t(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,tl).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const el=new $,c0=new $,u0=new Fi;class Us{constructor(t=new $(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(c0.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||u0.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 Us().copy(this)}}class Tt extends $t{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,o)=>{s.toArray(e,o*2)}),e}}class Y extends ${static pointArrayToNumberArray(t,e=!0){const s=e?3:2,o=new Array(t.length*s);return t.forEach((h,u)=>{h.toArray(o,u*s)}),o}}const rl=new Xr,nl=new qr,hc=class ya{constructor(t=0,e=0,s=0,o=ya.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 ya(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],u=o[4],g=o[8],b=o[1],f=o[5],w=o[9],x=o[2],E=o[6],T=o[10];switch(e){case"XYZ":this._y=Math.asin(Tr(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(-w,T),this._z=Math.atan2(-u,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,T),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,T),this._z=Math.atan2(-u,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,T),this._z=Math.atan2(b,h)):(this._x=0,this._z=Math.atan2(-u,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,T));break;case"XZY":this._z=Math.asin(-Tr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(E,f),this._y=Math.atan2(g,h)):(this._x=Math.atan2(-w,T),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return rl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(rl,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return nl.setFromEuler(this),this.setFromQuaternion(nl,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};hc.DEFAULT_ORDER="XYZ";let cc=hc;class uc{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Va extends uc{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 Bi extends Va{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new _e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const o=this.loops[s].getPoints(t);e.push(o)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),o=this.sortBoundaryBoxesByAreas(s),h=new Map,u=o.length;for(let b=0;b<u;b++)h.set(o[b],{index:o[b],children:[]});const g={index:-1,children:[]};for(let b=0;b<u;b++){const f=o[b],w=e[f],x=s[f];let E=b+1;for(;E<u;E++){const T=o[E],L=e[T];if(s[T].containsBox(x)&&rc.isPointInPolygon(w[Et.randInt(0,w.length-1)],L)){(t=h.get(T))==null||t.children.push(h.get(f));break}}E===u&&g.children.push(h.get(f))}return g}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new _e().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((o,h)=>{const u=o.size,g=u.width*u.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 Va{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,o=this.getPoint(0),h=0;e.push(0);for(let u=1;u<=t;u++)s=this.getPoint(u/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 u;e?u=e:u=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]-u,f<0)g=o+1;else if(f>0)b=o-1;else{b=o;break}if(o=b,s[o]===u)return o/(h-1);const w=s[o],x=s[o+1]-w,E=(u-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),u=new Tt;return u.copy(h).sub(o).normalize(),u}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}class Un extends Wn{constructor(t,e,s,o,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(u==5){const g=t;this.center=new Tt(g.x,g.y),this.radius=e,this._clockwise=h,this._startAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(s)):Et.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(o)):Et.normalizeAngle(o)}else throw je.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const o=(st,Vt)=>({x:(st.x+Vt.x)/2,y:(st.y+Vt.y)/2}),h=(st,Vt)=>(Vt.y-st.y)/(Vt.x-st.x),u=st=>-1/st,g=o(t,e),b=o(e,s),f=h(t,e),w=h(e,s),x=u(f),E=u(w),T=(st,Vt,qt,Wt)=>{const xt=(Wt-Vt)/(st-qt),Ot=st*xt+Vt;return{x:xt,y:Ot}},L=g.y-x*g.x,z=b.y-E*b.x,D=T(x,L,E,z),B=Math.sqrt(Math.pow(t.x-D.x,2)+Math.pow(t.y-D.y,2)),dt=(st,Vt)=>Math.atan2(st.y-Vt.y,st.x-Vt.x),yt=dt(t,D),ot=dt(e,D),W=dt(s,D),ct=W>yt&&W<ot||yt>W&&yt<ot||ot>W&&ot<yt;this.center=D,this.radius=B,this._clockwise=!ct,this._startAngle=yt,this._endAngle=W}createByStartEndPointsAndBulge(t,e,s){let o,h,u;s<0?(o=Math.atan(-s)*4,h=new $t(t),u=new $t(e)):(o=Math.atan(s)*4,h=new $t(e),u=new $t(t));const g=new $t().subVectors(u,h),b=g.length(),f=new $t().addVectors(h,g.multiplyScalar(.5)),w=Math.abs(b/2/Math.tan(o/2)),x=g.normalize();let E;if(o<Math.PI){const T=new $t(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(T.multiplyScalar(-w))}else{const T=new $t(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(T.multiplyScalar(w))}s<0?(this._startAngle=Math.atan2(h.y-E.y,h.x-E.x),this._endAngle=Math.atan2(u.y-E.y,u.x-E.x)):(this._startAngle=Math.atan2(u.y-E.y,u.x-E.x),this._endAngle=Math.atan2(h.y-E.y,h.x-E.x)),this._clockwise=s<0,this.center=E,this.radius=u.sub(E).length()}get center(){return this._center}set center(t){this._center=new Tt(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(Et.normalizeAngle(t)):Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const e=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(e):e,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return this.clockwise?Et.normalizeAngle(t-e):Et.normalizeAngle(e-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=Et.normalizeAngle((t+e)/2),o=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(o)}get closed(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return Math.abs(e-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const h of e){const u=this._getInternalAngle(h);Et.isBetweenAngle(u,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(h))}const s=t.map(h=>h.x),o=t.map(h=>h.y);return new _e(new Tt(Math.min(...s),Math.min(...o)),new Tt(Math.max(...s),Math.max(...o)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new Un(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),s=this.center.x+this.radius*Math.cos(e),o=this.center.y+this.radius*Math.sin(e);return new Tt(s,o)}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this._getInternalAngle(this.startAngle);if(this.closed&&(s=ne,o=0),this.clockwise)for(let h=0;h<=t;h++){const u=o-s*(h/t),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}else for(let h=0;h<=t;h++){const u=o+s*(h/t),g=this._clockwise?this._mirrorAngle(u):u,b=this.getPointAtAngle(g);e.push(new Tt(b.x,b.y))}return e}}class d0 extends uc{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 Vs extends d0{}class Kr extends Vs{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 $().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(dn).normalize();return new Y(this._start).addScaledVector(s,t)}else{const s=this.delta(dn).normalize();return new Y(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=dn.subVectors(this._start,this._end).normalize();this._start=new Y(this._start).addScaledVector(s,t)}else{const s=this.delta(dn).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=Et.clamp(o,0,1)),o}closestPointToPoint(t,e,s){const o=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(o).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=dn.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=dn.subVectors(t,s).dot(e),h=dn.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 Mt(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Kr(this._start.clone(),this._end.clone())}}const dn=new $,sl=new $,Xs=new $;class _n extends Vs{static computeCenterPoint(t,e,s){const o=new $().addVectors(t,e).multiplyScalar(.5),h=new $().addVectors(t,s).multiplyScalar(.5),u=new $().subVectors(e,t),g=new $().subVectors(s,t),b=new $().crossVectors(u,g).normalize();if(b.lengthSq()===0)return console.error("Points are collinear and cannot form a valid arc."),null;const f=new $().crossVectors(u,b).normalize(),w=new $().crossVectors(g,b).normalize(),x=f.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),E=w.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),T=new Kr(o,o.clone().add(x)),L=new Kr(h,h.clone().add(E)),z=new $;return T.closestPointToPoint(L.startPoint,!0,z)?z:(console.error("Cannot find a valid center for the arc."),null)}static createByThreePoints(t,e,s){const o=_n.computeCenterPoint(t,e,s);if(o){const h=o.distanceTo(t),u=new $().subVectors(t,o),g=new $().subVectors(e,o),b=Math.atan2(u.y,u.x),f=Math.atan2(g.y,g.x);return new _n(o,h,b,f,$.Z_AXIS)}}constructor(t,e,s,o,h,u=$.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=o,this.normal=h,this.refVec=u,(o-s)%ne==0?(this.startAngle=0,this.endAngle=ne):(this.startAngle=s,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new Y(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Et.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new $(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new $(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)Et.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,u=-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>u&&(u=f.y),f.z>g&&(g=f.z)}return new Mt({x:e,y:s,z:o},{x:h,y:u,z:g})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=ne,o=0);for(let h=0;h<=t;h++){const u=o+s*(h/t),g=this.getPointAtAngle(u);e.push(g)}return e}transform(t){const e=da.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),s=da.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),s.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new _n(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(da.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,o={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},h=this.center,u=this.radius;return new Y(h.x+u*(s.x*Math.cos(t)+o.x*Math.sin(t)),h.y+u*(s.y*Math.cos(t)+o.y*Math.sin(t)),h.z+u*(s.z*Math.cos(t)+o.z*Math.sin(t)))}get plane(){const t=new $(this.center).distanceTo(Fa);return new Us(this.normal,t)}}const da=new $;class Di extends Wn{constructor(t,e,s,o=0,h=ne,u=!1,g=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(h-o)%ne==0?(this.startAngle=0,this.endAngle=ne):(this.startAngle=o,this.endAngle=h),this.clockwise=u,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 je.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return Et.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,o=-1/0;for(let h=0;h<=100;h++){const u=this.getPoint(h/100);t=Math.min(t,u.x),e=Math.min(e,u.y),s=Math.max(s,u.x),o=Math.max(o,u.y)}return new _e({x:t,y:e},{x:s,y:o})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(o?s=0:s=e),this.clockwise===!0&&!o&&(s===e?s=-e:s=s-e);const h=this.startAngle+t*s;let u=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=u-this.center.x,x=g-this.center.y;u=w*b-x*f+this.center.x,g=w*f+x*b+this.center.y}return new Tt(u,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 Di(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Ui extends Vs{constructor(t,e,s,o,h,u=0,g=ne){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=o,this.minorAxisRadius=h;const b=Math.abs(g-u);Math.abs(b-ne)<1e-10||Math.abs(b-2*ne)<1e-10?(this.startAngle=0,this.endAngle=ne):(this.startAngle=u,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 je.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw je.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==ne?t:Et.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-ne)<1e-10?ne:Et.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new $(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new $(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new $().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 u=this.startAngle+h*e,g=this.getPointAtAngle(u),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($.X_AXIS)||this.majorAxis.equals($.Y_AXIS)||this.majorAxis.isParallelTo($.X_AXIS)||this.majorAxis.isParallelTo($.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let b=0;b<2*Math.PI;b+=Math.PI/2)Et.isBetweenAngle(b,this.startAngle,this.endAngle)&&t.push(b);let e=1/0,s=1/0,o=1/0,h=-1/0,u=-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>u&&(u=f.y),f.z>g&&(g=f.z)}return new Mt({x:e,y:s,z:o},{x:h,y:u,z:g})}else{let t=1/0,e=1/0,s=1/0,o=-1/0,h=-1/0,u=-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),u=Math.max(u,f.z)}return new Mt({x:t,y:e,z:s},{x:o,y:h,z:u})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,o=this.startAngle;this.closed&&(s=ne,o=0);for(let h=0;h<=t;h++){const u=o+s*(h/t),g=this.getPointAtAngle(u);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 $(t).sub(this.center),s=e.dot(this.majorAxis),o=e.dot(this.minorAxis),h=s/this.majorAxisRadius,u=o/this.minorAxisRadius;return h*h+u*u<=1}transform(t){return this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Ui(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new $(this.center).distanceTo(Fa);return new Us(this.normal,t)}}class vn 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 u=new Un(o,h,o.bulge);t+=u.length}else t+=new Tt(o.x,o.y).distanceTo(h)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}getPointAt(t){const e=this._vertices[t];return new Tt(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new _e().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(o=>s.push(new 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 u=null;if(o<s-1?u=this._vertices[o+1]:o==s-1&&this.closed&&(u=this._vertices[0]),u){const g=new Un(h,u,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}}class Vi 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 _e(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Vi(this._start.clone(),this._end.clone())}}class dc 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 _e;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(o=>{e.push(new Tt(o.x,o.y))})}),e}}function m0(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var mc={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 u=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 Nt.__string_rec(this,"")};function T(r,n){function a(){}a.prototype=r;var l=new a;for(var c in n)l[c]=n[c];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 c=r.split("-");return new Date(c[0],c[1]-1,c[2],0,0,0);case 19:var d=r.split(" "),p=d[0].split("-"),_=d[1].split(":");return new Date(p[0],p[1]-1,p[2],_[0],_[1],_[2]);default:throw new Q("Invalid date format : "+r)}},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 z=function(){};x.Lambda=z,z.__name__=["Lambda"],z.fold=function(r,n,a){for(var l=Ke(r)();l.hasNext();){var c=l.next();a=n(c,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 B=function(){};x.Reflect=B,B.__name__=["Reflect"],B.field=function(r,n){try{return r[n]}catch(a){return a instanceof Q&&(a=a.val),null}},B.callMethod=function(r,n,a){return n.apply(r,a)},B.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},B.isFunction=function(r){return typeof r=="function"&&!(r.__name__||r.__ename__)},B.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 Nt.__string_rec(r,"")},dt.parseFloat=function(r){return parseFloat(r)};var yt=function(){this.b=""};x.StringBuf=yt,yt.__name__=["StringBuf"],yt.prototype={add:function(r){this.b+=dt.string(r)},__class__:yt};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 ct=function(){};x.Type=ct,ct.__name__=["Type"],ct.getClassName=function(r){var n=r.__name__;return n==null?null:n.join(".")},ct.getEnumName=function(r){var n=r.__ename__;return n.join(".")},ct.resolveClass=function(r){var n=x[r];return n==null||!n.__name__?null:n},ct.resolveEnum=function(r){var n=x[r];return n==null||!n.__ename__?null:n},ct.createEmptyInstance=function(r){function n(){}return n.prototype=r.prototype,new n},ct.createEnum=function(r,n,a){var l=B.field(r,n);if(l==null)throw new Q("No such constructor "+n);if(B.isFunction(l)){if(a==null)throw new Q("Constructor "+n+" need parameters");return B.callMethod(r,l,a)}if(a!=null&&a.length!=0)throw new Q("Constructor "+n+" does not need parameters");return l},ct.getEnumConstructs=function(r){var n=r.__constructs__;return n.slice()},ct.typeof=function(r){var n=typeof r;switch(n){case"boolean":return W.TBool;case"string":return W.TClass(String);case"number":return Math.ceil(r)==r%2147483648?W.TInt:W.TFloat;case"object":if(r==null)return W.TNull;var a=r.__enum__;if(a!=null)return W.TEnum(a);var l=Nt.getClass(r);return l!=null?W.TClass(l):W.TObject;case"function":return r.__name__||r.__ename__?W.TObject:W.TFunction;case"undefined":return W.TNull;default:return W.TUnknown}};var st=function(){};x["haxe.IMap"]=st,st.__name__=["haxe","IMap"];var Vt=function(r,n){this.high=r,this.low=n};x["haxe._Int64.___Int64"]=Vt,Vt.__name__=["haxe","_Int64","___Int64"],Vt.prototype={__class__:Vt};var qt=function(){this.buf=new yt,this.cache=[],this.useCache=qt.USE_CACHE,this.useEnumIndex=qt.USE_ENUM_INDEX,this.shash=new me,this.scount=0};x["haxe.Serializer"]=qt,qt.__name__=["haxe","Serializer"],qt.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 c=a++,d=this.cache[c];if(typeof d==n&&d==r)return this.buf.b+="r",c==null?this.buf.b+="null":this.buf.b+=""+c,!0}return this.cache.push(r),!1},serializeFields:function(r){for(var n=0,a=B.fields(r);n<a.length;){var l=a[n];++n,this.serializeString(l),this.serialize(B.field(r,l))}this.buf.b+="g"},serialize:function(r){{var n=ct.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 c=n[2];if(c==String){this.serializeString(r);return}if(this.useCache&&this.serializeRef(r))return;switch(c){case Array:var d=0;this.buf.b+="a";for(var p=r.length,_=0;_<p;){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,P=A.h,S=null;P!=null;){var I;S=P[0],P=P[1],I=S,this.serialize(I)}this.buf.b+="h";break;case Date:var k=r;this.buf.b+="v",this.buf.add(k.getTime());break;case me:this.buf.b+="b";for(var M=r,O=M.keys();O.hasNext();){var C=O.next();this.serializeString(C),this.serialize(qi[C]!=null?M.getReserved(C):M.h[C])}this.buf.b+="h";break;case xt:this.buf.b+="q";for(var F=r,R=F.keys();R.hasNext();){var U=R.next();this.buf.b+=":",U==null?this.buf.b+="null":this.buf.b+=""+U,this.serialize(F.h[U])}this.buf.b+="h";break;case Ot:this.buf.b+="M";for(var V=r,q=V.keys();q.hasNext();){var J=q.next(),H=B.field(J,"__id__");B.deleteField(J,"__id__"),this.serialize(J),J.__id__=H,this.serialize(V.h[J.__id__])}this.buf.b+="h";break;case Me:for(var G=r,K=0,tt=G.length-2,et=new yt,it=qt.BASE64;K<tt;){var ht=G.get(K++),at=G.get(K++),ut=G.get(K++);et.add(it.charAt(ht>>2)),et.add(it.charAt((ht<<4|at>>4)&63)),et.add(it.charAt((at<<2|ut>>6)&63)),et.add(it.charAt(ut&63))}if(K==tt){var nt=G.get(K++),mt=G.get(K++);et.add(it.charAt(nt>>2)),et.add(it.charAt((nt<<4|mt>>4)&63)),et.add(it.charAt(mt<<2&63))}else if(K==tt+1){var X=G.get(K++);et.add(it.charAt(X>>2)),et.add(it.charAt(X<<4&63))}var gt=et.b;this.buf.b+="s",gt.length==null?this.buf.b+="null":this.buf.b+=""+gt.length,this.buf.b+=":",gt==null?this.buf.b+="null":this.buf.b+=""+gt;break;default:this.useCache&&this.cache.pop(),r.hxSerialize!=null?(this.buf.b+="C",this.serializeString(ct.getClassName(c)),this.useCache&&this.cache.push(r),r.hxSerialize(this),this.buf.b+="g"):(this.buf.b+="c",this.serializeString(ct.getClassName(c)),this.useCache&&this.cache.push(r),this.serializeFields(r))}break;case 4:if(Nt.__instanceof(r,No)){var Pt=ct.getClassName(r);this.buf.b+="A",this.serializeString(Pt)}else if(Nt.__instanceof(r,Co))this.buf.b+="B",this.serializeString(ct.getEnumName(r));else{if(this.useCache&&this.serializeRef(r))return;this.buf.b+="o",this.serializeFields(r)}break;case 7:var jt=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(ct.getEnumName(jt)),this.useEnumIndex?(this.buf.b+=":",this.buf.b+=dt.string(r[1])):this.serializeString(r[0]),this.buf.b+=":";var Xt=r.length;this.buf.b+=dt.string(Xt-2);for(var Dt=2;Dt<Xt;){var Kt=Dt++;this.serialize(r[Kt])}this.useCache&&this.cache.push(r);break;case 5:throw new Q("Cannot serialize function");default:throw new Q("Cannot serialize "+dt.string(r))}}},__class__:qt};var Wt=function(r){this.buf=r,this.length=r.length,this.pos=0,this.scache=[],this.cache=[];var n=Wt.DEFAULT_RESOLVER;n==null&&(n=ct,Wt.DEFAULT_RESOLVER=n),this.setResolver(n)};x["haxe.Unserializer"]=Wt,Wt.__name__=["haxe","Unserializer"],Wt.initCodes=function(){for(var r=[],n=0,a=Wt.BASE64.length;n<a;){var l=n++;r[Wt.BASE64.charCodeAt(l)]=l}return r},Wt.prototype={setResolver:function(r){r==null?this.resolver={resolveClass:function(n){return null},resolveEnum:function(n){return null}}:this.resolver=r},get:function(r){return this.buf.charCodeAt(r)},readDigits:function(){for(var r=0,n=!1,a=this.pos;;){var l=this.buf.charCodeAt(this.pos);if(l!=l)break;if(l==45){if(this.pos!=a)break;n=!0,this.pos++;continue}if(l<48||l>57)break;r=r*10+(l-48),this.pos++}return n&&(r*=-1),r},readFloat:function(){for(var r=this.pos;;){var n=this.buf.charCodeAt(this.pos);if(n>=43&&n<58||n==101||n==69)this.pos++;else break}return dt.parseFloat(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 ct.createEnum(r,n);for(var l=[];a-- >0;)l.push(this.unserialize());return ct.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 c=this.buf.charCodeAt(this.pos);if(c==104){this.pos++;break}if(c==117){this.pos++;var d=this.readDigits();l[l.length+d-1]=null}else l.push(this.unserialize())}return l;case 111:var p={};return this.cache.push(p),this.unserializeObject(p),p;case 114:var _=this.readDigits();if(_<0||_>=this.cache.length)throw new Q("Invalid reference");return this.cache[_];case 82:var 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(),P=this.resolver.resolveClass(A);if(P==null)throw new Q("Class not found "+A);var S=ct.createEmptyInstance(P);return this.cache.push(S),this.unserializeObject(S),S;case 119:var I=this.unserialize(),k=this.resolver.resolveEnum(I);if(k==null)throw new Q("Enum not found "+I);var M=this.unserializeEnum(k,this.unserialize());return this.cache.push(M),M;case 106:var O=this.unserialize(),C=this.resolver.resolveEnum(O);if(C==null)throw new Q("Enum not found "+O);this.pos++;var F=this.readDigits(),R=ct.getEnumConstructs(C)[F];if(R==null)throw new Q("Unknown enum index "+O+"@"+F);var U=this.unserializeEnum(C,R);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 me;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 xt;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 Ot;for(this.cache.push(tt),this.buf;this.buf.charCodeAt(this.pos)!=104;){var et=this.unserialize();tt.set(et,this.unserialize())}return this.pos++,tt;case 118:var it;if(this.buf.charCodeAt(this.pos)>=48&&this.buf.charCodeAt(this.pos)<=57&&this.buf.charCodeAt(this.pos+1)>=48&&this.buf.charCodeAt(this.pos+1)<=57&&this.buf.charCodeAt(this.pos+2)>=48&&this.buf.charCodeAt(this.pos+2)<=57&&this.buf.charCodeAt(this.pos+3)>=48&&this.buf.charCodeAt(this.pos+3)<=57&&this.buf.charCodeAt(this.pos+4)==45){var ht=L.substr(this.buf,this.pos,19);it=L.strDate(ht),this.pos+=19}else{var at=this.readFloat(),ut=new Date;ut.setTime(at),it=ut}return this.cache.push(it),it;case 115:var nt=this.readDigits(),mt=this.buf;if(this.get(this.pos++)!=58||this.length-this.pos<nt)throw new Q("Invalid bytes length");var X=Wt.CODES;X==null&&(X=Wt.initCodes(),Wt.CODES=X);var gt=this.pos,Pt=nt&3,jt;jt=(nt>>2)*3+(Pt>=2?Pt-1:0);for(var Xt=gt+(nt-Pt),Dt=Me.alloc(jt),Kt=0;gt<Xt;){var Ie=X[ot.fastCodeAt(mt,gt++)],Ye=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Ie<<2|Ye>>4);var ye=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Ye<<4|ye>>2);var ge=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,ye<<6|ge)}if(Pt>=2){var Ee=X[ot.fastCodeAt(mt,gt++)],Oe=X[ot.fastCodeAt(mt,gt++)];if(Dt.set(Kt++,Ee<<2|Oe>>4),Pt==3){var $e=X[ot.fastCodeAt(mt,gt++)];Dt.set(Kt++,Oe<<4|$e>>2)}}return this.pos+=nt,this.cache.push(Dt),Dt;case 67:var lr=this.unserialize(),Ze=this.resolver.resolveClass(lr);if(Ze==null)throw new Q("Class not found "+lr);var Qe=ct.createEmptyInstance(Ze);if(this.cache.push(Qe),Qe.hxUnserialize(this),this.get(this.pos++)!=103)throw new Q("Invalid custom data");return Qe;case 65:var Je=this.unserialize(),mr=this.resolver.resolveClass(Je);if(mr==null)throw new Q("Class not found "+Je);return mr;case 66:var Ln=this.unserialize(),tn=this.resolver.resolveEnum(Ln);if(tn==null)throw new Q("Enum not found "+Ln);return tn}throw this.pos--,new Q("Invalid char "+this.buf.charAt(this.pos)+" at position "+this.pos)},__class__:Wt};var xt=function(){this.h={}};x["haxe.ds.IntMap"]=xt,xt.__name__=["haxe","ds","IntMap"],xt.__interfaces__=[st],xt.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__:xt};var Ot=function(){this.h={},this.h.__keys__={}};x["haxe.ds.ObjectMap"]=Ot,Ot.__name__=["haxe","ds","ObjectMap"],Ot.__interfaces__=[st],Ot.prototype={set:function(r,n){var a=r.__id__||(r.__id__=++Ot.count);this.h[a]=n,this.h.__keys__[a]=r},keys:function(){var r=[];for(var n in this.h.__keys__)this.h.hasOwnProperty(n)&&r.push(this.h.__keys__[n]);return L.iter(r)},__class__:Ot};var de=x["haxe.ds.Option"]={__ename__:["haxe","ds","Option"],__constructs__:["Some","None"]};de.Some=function(r){var n=["Some",0,r];return n.__enum__=de,n.toString=E,n},de.None=["None",1],de.None.toString=E,de.None.__enum__=de;var me=function(){this.h={}};x["haxe.ds.StringMap"]=me,me.__name__=["haxe","ds","StringMap"],me.__interfaces__=[st],me.prototype={set:function(r,n){qi[r]!=null?this.setReserved(r,n):this.h[r]=n},get:function(r){return qi[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__:me};var Me=function(r){this.length=r.byteLength,this.b=new Xi(r),this.b.bufferValue=r,r.hxBytes=this,r.bytes=this.b};x["haxe.io.Bytes"]=Me,Me.__name__=["haxe","io","Bytes"],Me.alloc=function(r){return new Me(new Ws(r))},Me.prototype={get:function(r){return this.b[r]},set:function(r,n){this.b[r]=n&255},__class__:Me};var Jt=x["haxe.io.Error"]={__ename__:["haxe","io","Error"],__constructs__:["Blocked","Overflow","OutsideBounds","Custom"]};Jt.Blocked=["Blocked",0],Jt.Blocked.toString=E,Jt.Blocked.__enum__=Jt,Jt.Overflow=["Overflow",1],Jt.Overflow.toString=E,Jt.Overflow.__enum__=Jt,Jt.OutsideBounds=["OutsideBounds",2],Jt.OutsideBounds.toString=E,Jt.OutsideBounds.__enum__=Jt,Jt.Custom=function(r){var n=["Custom",3,r];return n.__enum__=Jt,n.toString=E,n};var ae=function(){};x["haxe.io.FPHelper"]=ae,ae.__name__=["haxe","io","FPHelper"],ae.i32ToFloat=function(r){var n=1-(r>>>31<<1),a=r>>>23&255,l=r&8388607;return l==0&&a==0?0:n*(1+Math.pow(2,-23)*l)*Math.pow(2,a-127)},ae.floatToI32=function(r){if(r==0)return 0;var n;r<0?n=-r:n=r;var a=Math.floor(Math.log(n)/.6931471805599453);a<-127?a=-127:a>128&&(a=128);var l=Math.round((n/Math.pow(2,a)-1)*8388608)&8388607;return(r<0?-2147483648:0)|a+127<<23|l},ae.i64ToDouble=function(r,n){var a=1-(n>>>31<<1),l=(n>>20&2047)-1023,c=(n&1048575)*4294967296+(r>>>31)*2147483648+(r&2147483647);return c==0&&l==-1023?0:a*(1+Math.pow(2,-52)*c)*Math.pow(2,l)},ae.doubleToI64=function(r){var n=ae.i64tmp;if(r==0)n.low=0,n.high=0;else{var a;r<0?a=-r:a=r;var l=Math.floor(Math.log(a)/.6931471805599453),c,d=(a/Math.pow(2,l)-1)*4503599627370496;c=Math.round(d);var p=c|0,_=c/4294967296|0;n.low=p,n.high=(r<0?-2147483648:0)|l+1023<<20|_}return n};var Q=function(r){Error.call(this),this.val=r,this.message=String(r),Error.captureStackTrace&&Error.captureStackTrace(this,Q)};x["js._Boot.HaxeError"]=Q,Q.__name__=["js","_Boot","HaxeError"],Q.__super__=Error,Q.prototype=T(Error.prototype,{__class__:Q});var Nt=function(){};x["js.Boot"]=Nt,Nt.__name__=["js","Boot"],Nt.getClass=function(r){if(r instanceof Array&&r.__enum__==null)return Array;var n=r.__class__;if(n!=null)return n;var a=Nt.__nativeClassName(r);return a!=null?Nt.__resolveNativeClass(a):null},Nt.__string_rec=function(r,n){if(r==null)return"null";if(n.length>=5)return"<...>";var a=typeof r;switch(a=="function"&&(r.__name__||r.__ename__)&&(a="object"),a){case"object":if(r instanceof Array){if(r.__enum__){if(r.length==2)return r[0];var l=r[0]+"(";n+=" ";for(var c=2,d=r.length;c<d;){var p=c++;p!=2?l+=","+Nt.__string_rec(r[p],n):l+=Nt.__string_rec(r[p],n)}return l+")"}var _=r.length,y="[";n+=" ";for(var A=0;A<_;){var P=A++;y+=(P>0?",":"")+Nt.__string_rec(r[P],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 I=r.toString();if(I!="[object Object]")return I}var k=null,M=`{
3
3
  `;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__"||(M.length!=2&&(M+=`,
4
4
  `),M+=n+k+" : "+Nt.__string_rec(r[k],n));return n=n.substring(1),M+=`
5
- `+n+"}",M;case"function":return"<function>";case"string":return r;default:return String(r)}},Nt.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var a=r.__interfaces__;if(a!=null)for(var l=0,c=a.length;l<c;){var d=l++,p=a[d];if(p==n||Nt.__interfLoop(p,n))return!0}return Nt.__interfLoop(r.__super__,n)},Nt.__instanceof=function(r,n){if(n==null)return!1;switch(n){case qc:return(r|0)===r;case To:return typeof r=="number";case Mo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case Xc:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||Nt.__interfLoop(Nt.getClass(r),n))return!0}else if(typeof n=="object"&&Nt.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==No&&r.__name__!=null||n==Co&&r.__ename__!=null?!0:r.__enum__==n}},Nt.__nativeClassName=function(r){var n=Nt.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},Nt.__isNativeObj=function(r){return Nt.__nativeClassName(r)!=null},Nt.__resolveNativeClass=function(r){return w[r]};var oe=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var a=0;a<n;){var l=a++;this.a[l]=0}this.byteLength=n}};x["js.html.compat.ArrayBuffer"]=oe,oe.__name__=["js","html","compat","ArrayBuffer"],oe.sliceImpl=function(r,n){var a=new Xi(this,r,n==null?null:n-r),l=new Ws(a.byteLength),c=new Xi(l);return c.set(a),l},oe.prototype={slice:function(r,n){return new oe(this.a.slice(r,n))},__class__:oe};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(Jt.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++],c=this.buf.a[a++],d=this.buf.a[a++],p=this.buf.a[a++];return n?l|c<<8|d<<16|p<<24:p|d<<8|c<<16|l<<24},getUint32:function(r,n){var a=this.getInt32(r,n);return a<0?a+4294967296:a},getFloat32:function(r,n){return ae.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var a=this.getInt32(r,n),l=this.getInt32(r+4,n);return ae.i64ToDouble(n?a:l,n?l:a)},setInt8:function(r,n){n<0?this.buf.a[r+this.offset]=n+128&255:this.buf.a[r+this.offset]=n&255},setUint8:function(r,n){this.buf.a[r+this.offset]=n&255},setInt16:function(r,n,a){this.setUint16(r,n<0?n+65536:n,a)},setUint16:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l]=n&255,this.buf.a[l++]=n>>8&255):(this.buf.a[l++]=n>>8&255,this.buf.a[l]=n&255)},setInt32:function(r,n,a){this.setUint32(r,n,a)},setUint32:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l++]=n&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>>24):(this.buf.a[l++]=n>>>24,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n&255)},setFloat32:function(r,n,a){this.setUint32(r,ae.floatToI32(n),a)},setFloat64:function(r,n,a){var l=ae.doubleToI64(n);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:cr};var sr=function(){};x["js.html.compat.Uint8Array"]=sr,sr.__name__=["js","html","compat","Uint8Array"],sr._new=function(r,n,a){var l;if(typeof r=="number"){l=[];for(var c=0;c<r;){var d=c++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l)}else if(Nt.__instanceof(r,oe)){var p=r;n==null&&(n=0),a==null&&(a=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+a),l.byteLength=l.length,l.byteOffset=n,l.buffer=p}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l);else throw new Q("TODO "+dt.string(r));return l.subarray=sr._subarray,l.set=sr._set,l},sr._set=function(r,n){var a=this;if(Nt.__instanceof(r.buffer,oe)){var l=r;if(r.byteLength+n>a.byteLength)throw new Q("set() outside of range");for(var c=0,d=r.byteLength;c<d;){var p=c++;a[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>a.byteLength)throw new Q("set() outside of range");for(var y=0,A=_.length;y<A;){var P=y++;a[P+n]=_[P]}}else throw new Q("TODO")},sr._subarray=function(r,n){var a=this,l=sr._new(a.slice(r,n));return l.byteOffset=r,l};var kt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&kt.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=kt,kt.__name__=["promhx","base","AsyncBase"],kt.link=function(r,n,a){r._update.push({async:n,linkf:function(l){n.handleResolve(a(l))}}),kt.immediateLinkUpdate(r,n,a)},kt.immediateLinkUpdate=function(r,n,a){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(a(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},kt.linkAll=function(r,n){for(var a=function(d,p,_){if(d.length==0||kt.allFulfilled(d)){for(var y,A=[],P=Ke(r)();P.hasNext();){var S=P.next();A.push(S==p?_:S._val)}y=A,n.handleResolve(y)}},l=Ke(r)();l.hasNext();){var c=l.next();c._update.push({async:n,linkf:function(d,p,_){return function(y){d(p,_,y)}}(a,function(d){for(var p,_=[],y=Ke(r)();y.hasNext();){var A=y.next();A!=c&&_.push(A)}return p=_,p}(),c)})}kt.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],y=Ke(r)();y.hasNext();){var A=y.next();_.push(A._val)}return p=_,p}())},kt.pipeLink=function(r,n,a){var l=!1,c=function(d){if(!l){l=!0;var p=a(d);p._update.push({async:n,linkf:Ce(n,n.handleResolve)}),kt.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:c}),r._resolved&&!r._pending)try{c(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},kt.allResolved=function(r){for(var n=Ke(r)();n.hasNext();){var a=n.next();if(!a._resolved)return!1}return!0},kt.allFulfilled=function(r){for(var n=Ke(r)();n.hasNext();){var a=n.next();if(!a._fulfilled)return!1}return!0},kt.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,this},isResolved:function(){return this._resolved},isErrored:function(){return this._errored},isErrorHandled:function(){return this._error.length>0},isErrorPending:function(){return this._errorPending},isFulfilled:function(){return this._fulfilled},isPending:function(){return this._pending},handleResolve:function(r){this._resolve(r)},_resolve:function(r){var n=this;this._pending?St.enqueue(function(a,l){return function(){a(l)}}(Ce(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,St.queue.add(function(){n._val=r;for(var a=0,l=n._update;a<l.length;){var c=l[a];++a;try{c.linkf(r)}catch(d){d instanceof Q&&(d=d.val),c.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),St.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,a=function(l){if(n._error.length>0)for(var c=0,d=n._error;c<d.length;){var p=d[c];++c,p(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,St.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),a(l)}else a(r)}),St.continueOnNextLoop())},then:function(r){var n=new kt(null);return kt.link(this,n,r),n},unlink:function(r){var n=this;St.queue.add(function(){n._update=n._update.filter(function(a){return a.async!=r})}),St.continueOnNextLoop()},isLinked:function(r){for(var n=!1,a=0,l=this._update;a<l.length;){var c=l[a];if(++a,c.async==r)return!0}return n},__class__:kt};var wn=f.promhx.Deferred=function(){kt.call(this)};x["promhx.Deferred"]=wn,wn.__name__=["promhx","Deferred"],wn.__super__=kt,wn.prototype=T(kt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pe(this)},stream:function(){return new Ht(this)},publicStream:function(){return new Cr(this)},__class__:wn});var pe=f.promhx.Promise=function(r){kt.call(this,r),this._rejected=!1};x["promhx.Promise"]=pe,pe.__name__=["promhx","Promise"],pe.whenAll=function(r){var n=new pe(null);return kt.linkAll(r,n),n},pe.promise=function(r){var n=new pe;return n.handleResolve(r),n},pe.__super__=kt,pe.prototype=T(kt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var n="Promise has already been resolved";throw new Q(An.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pe(null);return kt.link(this,n,r),n},unlink:function(r){var n=this;St.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var a="Downstream Promise is not fullfilled";n.handleError(An.DownstreamNotFullfilled(a))}}),St.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pe(null);return kt.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pe;return this.catchError(function(a){var l=r(a);l.then(Ce(n,n._resolve))}),this.then(Ce(n,n._resolve)),n},__class__:pe});var Ht=f.promhx.Stream=function(r){kt.call(this,r),this._end_promise=new pe};x["promhx.Stream"]=Ht,Ht.__name__=["promhx","Stream"],Ht.foreach=function(r){for(var n=new Ht(null),a=Ke(r)();a.hasNext();){var l=a.next();n.handleResolve(l)}return n.end(),n},Ht.wheneverAll=function(r){var n=new Ht(null);return kt.linkAll(r,n),n},Ht.concatAll=function(r){for(var n=new Ht(null),a=Ke(r)();a.hasNext();){var l=a.next();n.concat(l)}return n},Ht.mergeAll=function(r){for(var n=new Ht(null),a=Ke(r)();a.hasNext();){var l=a.next();n.merge(l)}return n},Ht.stream=function(r){var n=new Ht(null);return n.handleResolve(r),n},Ht.__super__=kt,Ht.prototype=T(kt.prototype,{then:function(r){var n=new Ht(null);return kt.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(a){n.end()}}),n},detachStream:function(r){for(var n=[],a=!1,l=0,c=this._update;l<c.length;){var d=c[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),a=!0):n.push(d)}return this._update=n,a},first:function(){var r=new pe(null);return this.then(function(n){r._resolved||r.handleResolve(n)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var n=new Ht(null);return kt.pipeLink(this,n,r),this._end_promise.then(function(a){n.end()}),n},errorPipe:function(r){var n=new Ht(null);return this.catchError(function(a){var l=r(a);l.then(Ce(n,n._resolve)),l._end_promise.then((Yi=n._end_promise,Ce(Yi,Yi._resolve)))}),this.then(Ce(n,n._resolve)),this._end_promise.then(function(a){n.end()}),n},handleEnd:function(){if(this._pending)St.queue.add(Ce(this,this.handleEnd)),St.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=de.Some(this._val):r=de.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return St.queue.add(Ce(this,this.handleEnd)),St.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:function(a){r(a)&&n.handleResolve(a)}}),kt.immediateLinkUpdate(this,n,function(a){return a}),n},concat:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:Ce(n,n.handleResolve)}),kt.immediateLinkUpdate(this,n,function(a){return a}),this._end_promise.then(function(a){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:Ce(n,n.handleResolve)}),r._update.push({async:n,linkf:Ce(n,n.handleResolve)}),kt.immediateLinkUpdate(this,n,function(a){return a}),kt.immediateLinkUpdate(r,n,function(a){return a}),n},__class__:Ht});var Cr=f.promhx.PublicStream=function(r){Ht.call(this,r)};x["promhx.PublicStream"]=Cr,Cr.__name__=["promhx","PublicStream"],Cr.publicstream=function(r){var n=new Cr(null);return n.handleResolve(r),n},Cr.__super__=Ht,Cr.prototype=T(Ht.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Cr});var St=function(){};x["promhx.base.EventLoop"]=St,St.__name__=["promhx","base","EventLoop"],St.enqueue=function(r){St.queue.add(r),St.continueOnNextLoop()},St.set_nextLoop=function(r){if(St.nextLoop!=null)throw new Q("nextLoop has already been set");return St.nextLoop=r,St.nextLoop},St.queueEmpty=function(){return St.queue.isEmpty()},St.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=St.queue.pop())!=null;)n();return St.queue.isEmpty()},St.clear=function(){St.queue=new D},St.f=function(){var r=St.queue.pop();r!=null&&r(),St.queue.isEmpty()||St.continueOnNextLoop()},St.continueOnNextLoop=function(){St.nextLoop!=null?St.nextLoop(St.f):setImmediate(St.f)};var An=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};An.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=An,n.toString=E,n},An.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=An,n.toString=E,n};var Gs=function(){};x["verb.Verb"]=Gs,Gs.__name__=["verb","Verb"],Gs.main=function(){b.log("verb 2.1.0")};var Z=function(){};x["verb.core.ArrayExtensions"]=Z,Z.__name__=["verb","core","ArrayExtensions"],Z.alloc=function(r,n){if(!(n<0))for(;r.length<n;)r.push(null)},Z.reversed=function(r){var n=r.slice();return n.reverse(),n},Z.last=function(r){return r[r.length-1]},Z.first=function(r){return r[0]},Z.spliceAndInsert=function(r,n,a,l){r.splice(n,a),r.splice(n,0,l)},Z.left=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(0,n)},Z.right=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n)},Z.rightWithPivot=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n-1)},Z.unique=function(r,n){if(r.length==0)return[];for(var a=[r.pop()];r.length>0;){for(var l=r.pop(),c=!0,d=0;d<a.length;){var p=a[d];if(++d,n(l,p)){c=!1;break}}c&&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,c=1,d=n+1;c<d;){var p=c++;if(Ft.memo_exists(l,p)){r--,a=Ft.get_memo(l,p);continue}a*=r--,a/=p,Ft.memoize(l,p,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,c=n+1;l<c;){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 xt),Ft.memo.h[r].h[n]=a};var Me=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"]=Me,Me.__name__=["verb","core","BoundingBox"],Me.intervalsOverlap=function(r,n,a,l,c){c==null&&(c=-1);var d;c<-.5?d=rt.TOLERANCE:d=c;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,y=Math.min(a,l)-d,A=Math.max(a,l)+d;return p>=y&&p<=A||_>=y&&_<=A||y>=p&&y<=_||A>=p&&A<=_},Me.prototype={fromPoint:function(r){return new Me([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 Me([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,c=r.min,d=r.max,p=0,_=this.dim;p<_;){var y=p++;if(!Me.intervalsOverlap(a[y],l[y],c[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 c=a++,d=this.getAxisLength(c);d>r&&(r=d,n=c)}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,c=r.min,d=r.max;if(!this.intersects(r,n))return null;for(var p=[],_=[],y=0,A=this.dim;y<A;){var P=y++;p.push(Math.min(l[P],d[P])),_.push(Math.max(a[P],c[P]))}return new Me([_,p])},__class__:Me};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var Zt=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Zt,Zt.__name__=["verb","core","SerializableBase"],Zt.prototype={serialize:function(){var r=new qt;return r.serialize(this),r.toString()},__class__:Zt};var Hn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=Hn,Hn.__name__=["verb","core","Plane"],Hn.__super__=Zt,Hn.prototype=T(Zt.prototype,{__class__:Hn});var Sn=f.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=Sn,Sn.__name__=["verb","core","Ray"],Sn.__super__=Zt,Sn.prototype=T(Zt.prototype,{__class__:Sn});var Gt=f.core.NurbsCurveData=function(r,n,a){this.degree=r,this.controlPoints=a,this.knots=n};x["verb.core.NurbsCurveData"]=Gt,Gt.__name__=["verb","core","NurbsCurveData"],Gt.__super__=Zt,Gt.prototype=T(Zt.prototype,{__class__:Gt});var te=f.core.NurbsSurfaceData=function(r,n,a,l,c){this.degreeU=r,this.degreeV=n,this.knotsU=a,this.knotsV=l,this.controlPoints=c};x["verb.core.NurbsSurfaceData"]=te,te.__name__=["verb","core","NurbsSurfaceData"],te.__super__=Zt,te.prototype=T(Zt.prototype,{__class__:te});var qe=f.core.MeshData=function(r,n,a,l){this.faces=r,this.points=n,this.normals=a,this.uvs=l};x["verb.core.MeshData"]=qe,qe.__name__=["verb","core","MeshData"],qe.empty=function(){return new qe([],[],[],[])},qe.__super__=Zt,qe.prototype=T(Zt.prototype,{__class__:qe});var Yn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=Yn,Yn.__name__=["verb","core","PolylineData"],Yn.__super__=Zt,Yn.prototype=T(Zt.prototype,{__class__:Yn});var qn=f.core.VolumeData=function(r,n,a,l,c,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=a,this.knotsU=l,this.knotsV=c,this.knotsW=d,this.controlPoints=p};x["verb.core.VolumeData"]=qn,qn.__name__=["verb","core","VolumeData"],qn.__super__=Zt,qn.prototype=T(Zt.prototype,{__class__:qn});var ee=f.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=ee,ee.__name__=["verb","core","Pair"],ee.prototype={__class__:ee};var Pe=f.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=Pe,Pe.__name__=["verb","core","Interval"],Pe.prototype={__class__:Pe};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 Xn=f.core.CurveSurfaceIntersection=function(r,n,a,l){this.u=r,this.uv=n,this.curvePoint=a,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=Xn,Xn.__name__=["verb","core","CurveSurfaceIntersection"],Xn.prototype={__class__:Xn};var Lr=f.core.MeshIntersectionPoint=function(r,n,a,l,c){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"]=Lr,Lr.__name__=["verb","core","MeshIntersectionPoint"],Lr.prototype={__class__:Lr};var Kn=f.core.PolylineMeshIntersection=function(r,n,a,l,c){this.point=r,this.u=n,this.uv=a,this.polylineIndex=l,this.faceIndex=c};x["verb.core.PolylineMeshIntersection"]=Kn,Kn.__name__=["verb","core","PolylineMeshIntersection"],Kn.prototype={__class__:Kn};var $n=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,a,l){this.uv0=r,this.uv1=n,this.point=a,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=$n,$n.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],$n.prototype={__class__:$n};var Zn=f.core.TriSegmentIntersection=function(r,n,a,l){this.point=r,this.s=n,this.t=a,this.p=l};x["verb.core.TriSegmentIntersection"]=Zn,Zn.__name__=["verb","core","TriSegmentIntersection"],Zn.prototype={__class__:Zn};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 We=function(r,n,a,l,c){c==null&&(c=!1),l==null&&(l=-1),this.uv=a,this.point=r,this.normal=n,this.id=l,this.degen=c};x["verb.core.SurfacePoint"]=We,We.__name__=["verb","core","SurfacePoint"],We.fromUv=function(r,n){return new We(null,null,[r,n])},We.prototype={__class__:We};var js=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=js,js.__name__=["verb","core","CurvePoint"],js.prototype={__class__:js};var Qn=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"]=Qn,Qn.__name__=["verb","core","KdTree"],Qn.prototype={buildTree:function(r,n,a){var l=n%this.dim,c,d;return r.length==0?null:r.length==1?new En(r[0],l,a):(r.sort(function(p,_){var y=p.point[l]-_.point[l];return y==0?0:y>0?1:-1}),c=Math.floor(r.length/2),d=new En(r[c],l,a),d.left=this.buildTree(r.slice(0,c),n+1,d),d.right=this.buildTree(r.slice(c+1),n+1,d),d)},nearest:function(r,n,a){var l=this,c=new Jn(function(S){return-S.item1}),d,p=null;p=function(S){for(var I,k=S.dimension,M=l.distanceFunction(r,S.kdPoint.point),O,C=[],F=0,R=l.dim;F<R;)F++,C.push(0);O=C;for(var U,V,q=function(K,tt){c.push(new ee(K,tt)),c.size()>n&&c.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){(c.size()<n||M<c.peek().item1)&&q(S,M);return}S.right==null?I=S.left:S.left==null?I=S.right:r[k]<S.kdPoint.point[k]?I=S.left:I=S.right,p(I),(c.size()<n||M<c.peek().item1)&&q(S,M),(c.size()<n||Math.abs(U)<c.peek().item1)&&(I==S.left?V=S.right:V=S.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,c.push(new ee(null,a));d(this.root);for(var y=[],A=0;A<n;){var P=A++;c.content[P].item0!=null&&y.push(new ee(c.content[P].item0.kdPoint,c.content[P].item1))}return y},__class__:Qn};var Jn=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=Jn,Jn.__name__=["verb","core","BinaryHeap"],Jn.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 c=this.content.pop();l!=n-1&&(this.content[l]=c,this.scoreFunction(c)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var 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 c=(r+1)*2,d=c-1,p=-1,_=0;if(d<n){var y=this.content[d];_=this.scoreFunction(y),_<l&&(p=d)}if(c<n){var A=this.content[c],P=this.scoreFunction(A);P<(p==-1?l:_)&&(p=c)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=a,r=p;else break}},__class__:Jn};var In=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=In,In.__name__=["verb","core","KdPoint"],In.prototype={__class__:In};var En=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"]=En,En.__name__=["verb","core","KdNode"],En.prototype={__class__:En};var ur=function(){};x["verb.eval.IBoundingBoxTree"]=ur,ur.__name__=["verb","eval","IBoundingBoxTree"],ur.prototype={__class__:ur};var ir=function(r,n){this._boundingBox=null,this._curve=r,n==null&&(n=m.domain(this._curve.knots)/64),this._knotTol=n};x["verb.core.LazyCurveBoundingBoxTree"]=ir,ir.__name__=["verb","core","LazyCurveBoundingBoxTree"],ir.__interfaces__=[ur],ir.prototype={split:function(){var r=Z.first(this._curve.knots),n=Z.last(this._curve.knots),a=n-r,l=le.curveSplit(this._curve,(n+r)/2+a*.1*Math.random());return new ee(new ir(l[0],this._knotTol),new ir(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Me(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:ir};var ar=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}this._faceIndices=n};x["verb.core.LazyMeshBoundingBoxTree"]=ar,ar.__name__=["verb","core","LazyMeshBoundingBoxTree"],ar.__interfaces__=[ur],ar.prototype={split:function(){var r=re.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=Z.left(r),a=Z.right(r);return new ee(new ar(this._mesh,n),new ar(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=re.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:ar};var or=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new Pe(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=or,or.__name__=["verb","core","LazyPolylineBoundingBoxTree"],or.__interfaces__=[ur],or.prototype={split:function(){var r=this._interval.min,n=this._interval.max,a=r+Math.ceil((n-r)/2),l=new Pe(r,a),c=new Pe(a,n);return new ee(new or(this._polyline,l),new or(this._polyline,c))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Me(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__:or};var Or=function(r,n,a,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,a==null&&(a=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Or,Or.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Or.__interfaces__=[ur],Or.prototype={split:function(){var r,n;this._splitV?(r=Z.first(this._surface.knotsV),n=Z.last(this._surface.knotsV)):(r=Z.first(this._surface.knotsU),n=Z.last(this._surface.knotsU));var a=(r+n)/2,l=le.surfaceSplit(this._surface,a,this._splitV);return new ee(new Or(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Or(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Me;for(var r=0,n=this._surface.controlPoints;r<n.length;){var a=n[r];++r,this._boundingBox.addRange(N.dehomogenize1d(a))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Or};var Lt=f.core.Mat=function(){};x["verb.core.Mat"]=Lt,Lt.__name__=["verb","core","Mat"],Lt.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(m.mul(r,n[d]))}return a},Lt.mult=function(r,n){var a,l,c,d,p,_,y,A;a=r.length,l=n.length,c=n[0].length,d=[];for(var P=a-1,S=0,I=0;P>=0;){for(p=[],_=r[P],I=c-1;I>=0;){for(y=_[l-1]*n[l-1][I],S=l-2;S>=1;)A=S-1,y+=_[S]*n[S][I]+_[A]*n[A][I],S-=2;S==0&&(y+=_[0]*n[0][I]),p[I]=y,I--}d[P]=p,P--}return d},Lt.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.add(r[d],n[d]))}return a},Lt.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.div(r[d],n))}return a},Lt.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.sub(r[d],n[d]))}return a},Lt.dot=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.dot(r[d],n))}return a},Lt.identity=function(r){for(var n=m.zeros2d(r,r),a=0;a<r;){var l=a++;n[l][l]=1}return n},Lt.transpose=function(r){if(r.length==0)return[];for(var n=[],a=0,l=r[0].length;a<l;){var c=a++;n.push(function(d){for(var p,_=[],y=0,A=r.length;y<A;){var P=y++;_.push(r[P][c])}return p=_,p}())}return n},Lt.solve=function(r,n){return Lt.LUsolve(Lt.LU(r),n)},Lt.LUsolve=function(r,n){var a,l,c=r.LU,d=c.length,p=n.slice(),_=r.P,y,A,P;for(a=d-1;a!=-1;)p[a]=n[a],--a;for(a=0;a<d;){for(y=_[a],_[a]!=a&&(P=p[a],p[a]=p[y],p[y]=P),A=c[a],l=0;l<a;)p[a]-=p[l]*A[l],++l;++a}for(a=d-1;a>=0;){for(A=c[a],l=a+1;l<d;)p[a]-=p[l]*A[l],++l;p[a]/=A[a],--a}return p},Lt.LU=function(r){for(var n,a,l,c,d,p,_,y,A,P=[],S=0,I=r.length;S<I;){var k=S++;P.push(r[k].slice())}r=P;var M=r.length,O=M-1,C=[];for(l=0;l<M;){for(_=l,p=r[l],A=Math.abs(p[l]),a=l+1;a<M;)c=Math.abs(r[a][l]),A<c&&(A=c,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=p,p=r[l]),d=p[l],n=l+1;n<M;)r[n][l]/=d,++n;for(n=l+1;n<M;){for(y=r[n],a=l+1;a<O;)y[a]-=y[l]*p[a],++a,y[a]-=y[l]*p[a],++a;a==O&&(y[a]-=y[l]*p[a]),++n}++l}return new ts(r,C)};var ts=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=ts,ts.__name__=["verb","core","_Mat","LUDecomp"],ts.prototype={__class__:ts};var re=f.core.Mesh=function(){};x["verb.core.Mesh"]=re,re.__name__=["verb","core","Mesh"],re.getTriangleNorm=function(r,n){var a=r[n[0]],l=r[n[1]],c=r[n[2]],d=m.sub(l,a),p=m.sub(c,a),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},re.makeMeshAabb=function(r,n){for(var a=new Me,l=0;l<n.length;){var c=n[l];++l,a.add(r.points[r.faces[c][0]]),a.add(r.points[r.faces[c][1]]),a.add(r.points[r.faces[c][2]])}return a},re.sortTrianglesOnLongestAxis=function(r,n,a){for(var l=r.getLongestAxis(),c=[],d=0;d<a.length;){var p=a[d];++d;var _=re.getMinCoordOnAxis(n.points,n.faces[p],l);c.push(new ee(_,p))}c.sort(function(I,k){var M=I.item0,O=k.item0;return M==O?0:M>O?1:-1});for(var y=[],A=0,P=c.length;A<P;){var S=A++;y.push(c[S].item1)}return y},re.getMinCoordOnAxis=function(r,n,a){for(var l=1/0,c=0;c<3;){var d=c++,p=r[n[d]][a];p<l&&(l=p)}return l},re.getTriangleCentroid=function(r,n){for(var a=[0,0,0],l=0;l<3;)for(var c=l++,d=0;d<3;){var p=d++;a[p]+=r[n[c]][p]}for(var _=0;_<3;){var y=_++;a[y]/=3}return a},re.triangleUVFromPoint=function(r,n,a){var l=r.faces[n],c=r.points[l[0]],d=r.points[l[1]],p=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],A=r.uvs[l[2]],P=m.sub(c,a),S=m.sub(d,a),I=m.sub(p,a),k=m.norm(m.cross(m.sub(c,d),m.sub(c,p))),M=m.norm(m.cross(S,I))/k,O=m.norm(m.cross(I,P))/k,C=m.norm(m.cross(P,S))/k;return m.add(m.mul(M,_),m.add(m.mul(O,y),m.mul(C,A)))};var zr=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}if(this._boundingBox=re.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=re.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=Z.left(p),y=Z.right(p);this._children=new ee(new zr(r,_),new zr(r,y))};x["verb.core.MeshBoundingBoxTree"]=zr,zr.__name__=["verb","core","MeshBoundingBoxTree"],zr.__interfaces__=[ur],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 Xe=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=Xe,Xe.__name__=["verb","core","Minimizer"],Xe.uncmin=function(r,n,a,l,c){a==null&&(a=1e-8),l==null&&(l=function(J){return Xe.numericalGradient(r,J)}),c==null&&(c=1e3),n=n.slice(0);var d=n.length,p=r(n),_=p,y;if(isNaN(p))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,rt.EPSILON);var A,P,S,I=Lt.identity(d),k=0,M=[],O,C,F,R,U,V,q="";for(P=l(n);k<c;){if(!m.all(m.finite(P))){q="Gradient has Infinity or NaN";break}if(A=m.neg(Lt.dot(I,P)),!m.all(m.finite(A))){q="Search direction has Infinity or NaN";break}if(V=m.norm(A),V<a){q="Newton step smaller than tol";break}for(U=1,y=m.dot(P,A),O=n;k<c&&!(U*V<a);){if(M=m.mul(U,A),O=m.add(n,M),_=r(O),_-p>=.1*U*y||isNaN(_)){U*=.5,++k;continue}break}if(U*V<a){q="Line search step size smaller than tol";break}if(k==c){q="maxit reached during line search";break}S=l(O),C=m.sub(S,P),R=m.dot(C,M),F=Lt.dot(I,C),I=Lt.sub(Lt.add(I,Lt.mul((R+m.dot(C,F))/(R*R),Xe.tensor(M,M))),Lt.div(Lt.add(Xe.tensor(F,M),Xe.tensor(M,F)),R)),n=O,p=_,P=S,++k}return new es(n,p,P,I,k,q)},Xe.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 c=n.slice(0),d,p,_=[],y,A=.001,P,S,I,k=0,M,O,C,F=0;F<a;)for(var R=F++,U=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(c[R]=n[R]+U,d=r(c),c[R]=n[R]-U,p=r(c),c[R]=n[R],isNaN(d)||isNaN(p)){U/=16;continue}if(_[R]=(d-p)/(2*U),P=n[R]-U,S=n[R],I=n[R]+U,M=(d-l)/U,O=(l-p)/U,C=m.max([Math.abs(_[R]),Math.abs(l),Math.abs(d),Math.abs(p),Math.abs(P),Math.abs(S),Math.abs(I),1e-8]),y=Math.min(m.max([Math.abs(M-_[R]),Math.abs(O-_[R]),Math.abs(M-O)])/C,U/C),y>A)U/=16;else break}return _},Xe.tensor=function(r,n){for(var a=r.length,l=n.length,c=[],d,p,_=a-1;_>=0;){d=[],p=r[_];for(var y=l-1;y>=3;)d[y]=p*n[y],--y,d[y]=p*n[y],--y,d[y]=p*n[y],--y,d[y]=p*n[y],--y;for(;y>=0;)d[y]=p*n[y],--y;c[_]=d,_--}return c};var es=function(r,n,a,l,c,d){this.solution=r,this.value=n,this.gradient=a,this.invHessian=l,this.iterations=c,this.message=d};x["verb.core.MinimizationResult"]=es,es.__name__=["verb","core","MinimizationResult"],es.prototype={__class__:es};var kn=function(){};x["verb.core.ISerializable"]=kn,kn.__name__=["verb","core","ISerializable"],kn.prototype={__class__:kn};var Hi=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Hi,Hi.__name__=["verb","core","Deserializer"],Hi.deserialize=function(r){var n=new Wt(r),a=n.unserialize();return a};var Ne=f.core.Trig=function(){};x["verb.core.Trig"]=Ne,Ne.__name__=["verb","core","Trig"],Ne.isPointInPlane=function(r,n,a){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<a},Ne.distToSegment=function(r,n,a){var l=Ne.segmentClosestPoint(n,r,a,0,1);return m.dist(n,l.pt)},Ne.rayClosestPoint=function(r,n,a){var l=m.sub(r,n),c=m.dot(l,a),d=m.add(n,m.mul(c,a));return d},Ne.distToRay=function(r,n,a){var l=Ne.rayClosestPoint(r,n,a),c=m.sub(l,r);return m.norm(c)},Ne.threePointsAreFlat=function(r,n,a,l){var c=m.sub(n,r),d=m.sub(a,r),p=m.cross(c,d),_=m.dot(p,p);return _<l},Ne.segmentClosestPoint=function(r,n,a,l,c){var d=m.sub(a,n),p=m.norm(d);if(p<rt.EPSILON)return{u:l,pt:n};var _=n,y=m.mul(1/p,d),A=m.sub(r,_),P=m.dot(A,y);return P<0?{u:l,pt:n}:P>p?{u:c,pt:a}:{u:l+(c-l)*P/p,pt:m.add(_,m.mul(P,y))}};var m=f.core.Vec=function(){};x["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,n){return Math.acos(m.dot(r,n)/(m.norm(r)*m.norm(n)))},m.positiveAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),y=m.norm(l)/p,A=_/p,P=Math.atan2(y,A),S=m.dot(a,l);return Math.abs(S)<rt.EPSILON||S>0?P:-P},m.signedAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),y=m.norm(l)/p,A=_/p,P=Math.atan2(y,A),S=m.dot(a,l);return S>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,n){var a=r[0]*n[1]-r[1]*n[0];return Math.atan2(a,m.dot(r,n))},m.domain=function(r){return Z.last(r)-Z.first(r)},m.range=function(r){for(var n=[],a=0,l=0;l<r;)l++,n.push(a),a+=1;return n},m.span=function(r,n,a){if(a==null)return[];if(a<rt.EPSILON)return[];if(r>n&&a>0)return[];if(n>r&&a<0)return[];for(var l=[],c=r;c<=n;)l.push(c),c+=a;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return z.fold(r,function(n,a){return Math.min(n,a)},1/0)},m.max=function(r){return z.fold(r,function(n,a){return Math.max(n,a)},-1/0)},m.all=function(r){return z.fold(r,function(n,a){return a&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,a){return m.add(r,m.mul(a,n))},m.lerp=function(r,n,a){return m.add(m.mul(r,n),m.mul(1-r,a))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,n){return[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]},m.dist=function(r,n){return m.norm(m.sub(r,n))},m.distSquared=function(r,n){return m.normSquared(m.sub(r,n))},m.sum=function(r){return z.fold(r,function(n,a){return a+n},0)},m.addAll=function(r){var n=Ke(r)();if(!n.hasNext())return null;var a=n.next().length;return z.fold(r,function(l,c){return m.add(c,l)},m.rep(a,0))},m.addAllMutate=function(r){for(var n=r[0],a=1,l=r.length;a<l;){var c=a++;m.addMutate(n,r[c])}},m.addMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]+n*a[d]}},m.subMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]-n*a[d]}},m.addMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]+n[c]}},m.subMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]-n[c]}},m.mulMutate=function(r,n){for(var a=0,l=n.length;a<l;){var c=a++;n[c]=n[c]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return z.fold(r,function(n,a){return a+n*n},0)},m.rep=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(n);return a},m.zeros1d=function(r){for(var n=[],a=0;a<r;)a++,n.push(0);return n},m.zeros2d=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(m.zeros1d(n));return a},m.zeros3d=function(r,n,a){for(var l=[],c=0;c<r;)c++,l.push(m.zeros2d(n,a));return l},m.dot=function(r,n){for(var a=0,l=0,c=r.length;l<c;){var d=l++;a+=r[d]*n[d]}return a},m.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]+n[d])}return a},m.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(r*n[d])}return a},m.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]/n)}return a},m.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]-n[d])}return a},m.isZero=function(r){for(var n=0,a=r.length;n<a;){var l=n++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var a=[],l=0,c=0;l<r.length||c<n.length;){if(l>=r.length){a.push(n[c]),c++;continue}else if(c>=n.length){a.push(r[l]),l++;continue}var d=r[l]-n[c];if(Math.abs(d)<rt.EPSILON){a.push(r[l]),l++,c++;continue}if(d>0){a.push(n[c]),c++;continue}a.push(r[l]),l++}return a},m.sortedSetSub=function(r,n){for(var a=[],l=0,c=0;l<r.length;){if(c>=n.length){a.push(r[l]),l++;continue}if(Math.abs(r[l]-n[c])<rt.EPSILON){l++,c++;continue}a.push(r[l]),l++}return a};var vt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=vt,vt.__name__=["verb","eval","Analyze"],vt.knotMultiplicities=function(r){for(var n=[new Tn(r[0],0)],a=n[0],l=0;l<r.length;){var c=r[l];++l,Math.abs(c-a.knot)>rt.EPSILON&&(a=new Tn(c,0),n.push(a)),a.inc()}return n},vt.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var a;n?a=r.controlPoints:a=Lt.transpose(r.controlPoints);for(var l=0,c=a[0].length;l<c;){var d=l++,p=m.dist(Z.first(a)[d],Z.last(a)[d])<rt.EPSILON;if(!p)return!1}return!0},vt.rationalSurfaceClosestPoint=function(r,n){var a=vt.rationalSurfaceClosestParam(r,n);return N.rationalSurfacePoint(r,a[0],a[1])},vt.rationalSurfaceClosestParam=function(r,n){for(var a=5,l=0,c,d=1e-4,p=5e-4,_,y=r.knotsU[0],A=Z.last(r.knotsU),P=r.knotsV[0],S=Z.last(r.knotsV),I=vt.isRationalSurfaceClosed(r),k=vt.isRationalSurfaceClosed(r,!1),M,O=zt.rationalSurfaceAdaptive(r,new Rr),C=1/0,F=0,R=O.points.length;F<R;){var U=F++,V=O.points[U],q=m.normSquared(m.sub(n,V));q<C&&(C=q,M=O.uvs[U])}for(var J=function(jt){return N.rationalSurfaceDerivatives(r,jt[0],jt[1],2)},H=function(jt,Xt,Dt){var Kt=Xt[1][0],Ie=Xt[0][1],Ye=Xt[2][0],ye=Xt[0][2],ge=Xt[1][1],Ee=Xt[1][1],Le=m.dot(Kt,Dt),$e=m.dot(Ie,Dt),lr=[-Le,-$e],Ze=m.dot(Kt,Kt)+m.dot(Ye,Dt),Qe=m.dot(Kt,Ie)+m.dot(ge,Dt),Je=m.dot(Kt,Ie)+m.dot(Ee,Dt),mr=m.dot(Ie,Ie)+m.dot(ye,Dt),Ln=[[Ze,Qe],[Je,mr]],tn=Lt.solve(Ln,lr);return m.add(tn,jt)};l<a;){c=J(M),_=m.sub(c[0][0],n);var G=m.norm(_),K=m.dot(c[1][0],_),tt=m.norm(c[1][0])*G,et=m.dot(c[0][1],_),it=m.norm(c[0][1])*G,ht=K/tt,at=et/it,ut=G<d,nt=ht<p,mt=at<p;if(ut&&nt&&mt)return M;var X=H(M,c,_);X[0]<y?I?X=[A-(X[0]-y),X[1]]:X=[y+rt.EPSILON,X[1]]:X[0]>A&&(I?X=[y+(X[0]-A),X[1]]:X=[A-rt.EPSILON,X[1]]),X[1]<P?k?X=[X[0],S-(X[1]-P)]:X=[X[0],P+rt.EPSILON]:X[1]>S&&(k?X=[X[0],P+(X[0]-S)]:X=[X[0],S-rt.EPSILON]);var gt=m.norm(m.mul(X[0]-M[0],c[1][0])),Pt=m.norm(m.mul(X[1]-M[1],c[0][1]));if(gt+Pt<d)return M;M=X,l++}return M},vt.rationalCurveClosestPoint=function(r,n){return N.rationalCurvePoint(r,vt.rationalCurveClosestParam(r,n))},vt.rationalCurveClosestParam=function(r,n){for(var a=1/0,l=0,c=zt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=c.length-1;d<p;){var _=d++,y=c[_][0],A=c[_+1][0],P=c[_].slice(1),S=c[_+1].slice(1),I=Ne.segmentClosestPoint(n,P,S,y,A),k=m.norm(m.sub(n,I.pt));k<a&&(a=k,l=I.u)}for(var M=5,O=0,C,F=1e-4,R=5e-4,U,V=r.knots[0],q=Z.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],Z.last(r.controlPoints)))<rt.EPSILON,H=l,G=function(X){return N.rationalCurveDerivatives(r,X,2)},K=function(X,gt,Pt){var jt=m.dot(gt[1],Pt),Xt=m.dot(gt[2],Pt),Dt=m.dot(gt[1],gt[1]),Kt=Xt+Dt;return X-jt/Kt};O<M;){C=G(H),U=m.sub(C[0],n);var tt=m.norm(U),et=m.dot(C[1],U),it=m.norm(C[1])*tt,ht=et/it,at=tt<F,ut=Math.abs(ht)<R;if(at&&ut)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 mt=m.norm(m.mul(nt-H,C[1]));if(mt<F)return H;H=nt,O++}return H},vt.rationalCurveParamAtArcLength=function(r,n,a,l,c){if(a==null&&(a=.001),n<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=ft.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-rt.EPSILON,y;for(c!=null?y=c:y=[];_<n&&p<d.length;){if(p<y.length?y[p]=y[p]:y[p]=vt.rationalBezierCurveArcLength(r),_+=y[p],n<_+rt.EPSILON)return vt.rationalBezierCurveParamAtArcLength(r,n,a,y[p]);p++}return-1},vt.rationalBezierCurveParamAtArcLength=function(r,n,a,l){if(n<0)return r.knots[0];var c;if(l!=null?c=l:c=vt.rationalBezierCurveArcLength(r),n>c)return Z.last(r.knots);var d=r.knots[0],p=0,_=Z.last(r.knots),y=c,A=0,P=0,S;for(a!=null?S=a:S=rt.TOLERANCE*2;y-p>S;)A=(d+_)/2,P=vt.rationalBezierCurveArcLength(r,A),P>n?(_=A,y=P):(d=A,p=P);return(d+_)/2},vt.rationalCurveArcLength=function(r,n,a){a==null&&(a=16),n==null?n=Z.last(r.knots):n=n;for(var l=ft.decomposeCurveIntoBeziers(r),c=0,d=l[0],p=0;c<l.length&&d.knots[0]+rt.EPSILON<n;){var _=Math.min(Z.last(d.knots),n);p+=vt.rationalBezierCurveArcLength(d,_,a),d=l[++c]}return p},vt.rationalBezierCurveArcLength=function(r,n,a){a==null&&(a=16);var l;n==null?l=Z.last(r.knots):l=n;for(var c=(l-r.knots[0])/2,d=0,p=r.degree+a,_,y,A=0;A<p;){var P=A++;_=c*vt.Tvalues[p][P]+c+r.knots[0],y=N.rationalCurveDerivatives(r,_,1),d+=vt.Cvalues[p][P]*m.norm(y[1])}return c*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 He=f.eval.Check=function(){};x["verb.eval.Check"]=He,He.__name__=["verb","eval","Check"],He.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var a=Z.first(r),l=0,c=n+1;l<c;){var d=l++;if(Math.abs(r[d]-a)>rt.EPSILON)return!1}a=Z.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var y=p++;if(Math.abs(r[y]-a)>rt.EPSILON)return!1}return He.isNonDecreasing(r)},He.isNonDecreasing=function(r){for(var n=Z.first(r),a=0,l=r.length;a<l;){var c=a++;if(r[c]<n-rt.EPSILON)return!1;n=r[c]}return!0},He.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(!He.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},He.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(!He.isValidKnotVector(r.knotsU,r.degreeU)||!He.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var le=f.eval.Divide=function(){};x["verb.eval.Divide"]=le,le.__name__=["verb","eval","Divide"],le.surfaceSplit=function(r,n,a){a==null&&(a=!1);var l,c,d;a?(d=r.controlPoints,l=r.knotsV,c=r.degreeV):(d=Lt.transpose(r.controlPoints),l=r.knotsU,c=r.degreeU);for(var p,_=[],y=0,A=c+1;y<A;)y++,_.push(n);p=_;for(var P=[],S=[],I=N.knotSpan(c,n,l),k=null,M=0;M<d.length;){var O=d[M];++M,k=ft.curveKnotRefine(new Gt(c,l,O),p),P.push(k.controlPoints.slice(0,I+1)),S.push(k.controlPoints.slice(I+1))}var C=k.knots.slice(0,I+c+2),F=k.knots.slice(I+1);return a?[new te(r.degreeU,c,r.knotsU.slice(),C,P),new te(r.degreeU,c,r.knotsU.slice(),F,S)]:(P=Lt.transpose(P),S=Lt.transpose(S),[new te(c,r.degreeV,C,r.knotsV.slice(),P),new te(c,r.degreeV,F,r.knotsV.slice(),S)])},le.curveSplit=function(r,n){var a=r.degree;r.controlPoints;for(var l=r.knots,c,d=[],p=0,_=a+1;p<_;)p++,d.push(n);c=d;var y=ft.curveKnotRefine(r,c),A=N.knotSpan(a,n,l),P=y.knots.slice(0,A+a+2),S=y.knots.slice(A+1),I=y.controlPoints.slice(0,A+1),k=y.controlPoints.slice(A+1);return[new Gt(a,P,I),new Gt(a,S,k)]},le.rationalCurveByEqualArcLength=function(r,n){var a=vt.rationalCurveArcLength(r),l=a/n;return le.rationalCurveByArcLength(r,l)},le.rationalCurveByArcLength=function(r,n){var a=ft.decomposeCurveIntoBeziers(r),l=a.map(function(I){return vt.rationalBezierCurveArcLength(I)}),c=m.sum(l),d=[new Mn(r.knots[0],0)];if(n>c)return d;for(var p=n,_=0,y=p,A=0,P=0,S;_<a.length;){for(A+=l[_];y<A+rt.EPSILON;)S=vt.rationalBezierCurveParamAtArcLength(a[_],y-P,rt.TOLERANCE,l[_]),d.push(new Mn(S,y)),y+=p;P+=l[_],_++}return d};var Mn=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=Mn,Mn.__name__=["verb","eval","CurveLengthSample"],Mn.prototype={__class__:Mn};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 m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,n,a,l){l==null&&(l=1);for(var c=N.surfaceDerivatives(r,n,a,l),d=N.rational2d(c),p=N.weight2d(c),_=[],y=d[0][0].length,A=0,P=l+1;A<P;){var S=A++;_.push([]);for(var I=0,k=l-S+1;I<k;){for(var M=I++,O=d[S][M],C=1,F=M+1;C<F;){var R=C++;m.subMulMutate(O,Ft.get(M,R)*p[0][R],_[S][M-R])}for(var U=1,V=S+1;U<V;){var q=U++;m.subMulMutate(O,Ft.get(S,q)*p[q][0],_[S-q][M]);for(var J=m.zeros1d(y),H=1,G=M+1;H<G;){var K=H++;m.addMulMutate(J,Ft.get(M,K)*p[q][K],_[S-q][M-K])}m.subMulMutate(O,Ft.get(S,q),J)}m.mulMutate(1/p[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),c=N.rational1d(l),d=N.weight1d(l),p=[],_=0,y=a+1;_<y;){for(var A=_++,P=c[A],S=1,I=A+1;S<I;){var k=S++;m.subMulMutate(P,Ft.get(A,k)*d[k],p[A-k])}m.mulMutate(1/d[0],P),p.push(P)}return p},N.rationalCurvePoint=function(r,n){return N.dehomogenize(N.curvePoint(r,n))},N.surfaceDerivatives=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(c,d,r,n,a,l)},N.surfaceDerivativesGivenNM=function(r,n,a,l,c,d){var p=a.degreeU,_=a.degreeV,y=a.controlPoints,A=a.knotsU,P=a.knotsV;if(!N.areValidRelations(p,y.length,A.length)||!N.areValidRelations(_,y[0].length,P.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=y[0][0].length,I;d<p?I=d:I=p;var k;d<_?k=d:k=_;for(var M=m.zeros3d(d+1,d+1,S),O=N.knotSpanGivenN(r,p,l,A),C=N.knotSpanGivenN(n,_,c,P),F=N.derivativeBasisFunctionsGivenNI(O,l,p,r,A),R=N.derivativeBasisFunctionsGivenNI(C,c,_,n,P),U=m.zeros2d(_+1,S),V=0,q=0,J=I+1;q<J;){for(var H=q++,G=0,K=_+1;G<K;){var tt=G++;U[tt]=m.zeros1d(S);for(var et=0,it=p+1;et<it;){var ht=et++;m.addMulMutate(U[tt],F[H][ht],y[O-p+ht][C-_+tt])}}var at=d-H;at<k?V=at:V=k;for(var ut=0,nt=V+1;ut<nt;){var mt=ut++;M[H][mt]=m.zeros1d(S);for(var X=0,gt=_+1;X<gt;){var Pt=X++;m.addMulMutate(M[H][mt],R[mt][Pt],U[Pt])}}}return M},N.surfacePoint=function(r,n,a){var l=r.knotsU.length-r.degreeU-2,c=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,c,r,n,a)},N.surfacePointGivenNM=function(r,n,a,l,c){var d=a.degreeU,p=a.degreeV,_=a.controlPoints,y=a.knotsU,A=a.knotsV;if(!N.areValidRelations(d,_.length,y.length)||!N.areValidRelations(p,_[0].length,A.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var P=_[0][0].length,S=N.knotSpanGivenN(r,d,l,y),I=N.knotSpanGivenN(n,p,c,A),k=N.basisFunctionsGivenKnotSpanIndex(S,l,d,y),M=N.basisFunctionsGivenKnotSpanIndex(I,c,p,A),O=S-d,C=I,F=m.zeros1d(P),R=m.zeros1d(P),U=0,V=p+1;U<V;){var q=U++;R=m.zeros1d(P),C=I-p+q;for(var J=0,H=d+1;J<H;){var G=J++;m.addMulMutate(R,k[G],_[O+G][C])}m.addMulMutate(F,M[q],R)}return F},N.curveRegularSamplePoints=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),y=m.mul(c*l*.5,a[3]),A=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),I=[],k=0,M=n+1;k<M;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,A,y]),m.addAllMutate([A,P]),m.addAllMutate([_,y]);return I},N.curveRegularSamplePoints2=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),y=m.mul(c*l*.5,a[3]),A=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),I=[],k=0,M=n+1;k<M;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,A,y]),m.addAllMutate([A,P]),m.addAllMutate([_,y]);return I},N.rationalSurfaceRegularSampleDerivatives=function(r,n,a,l){for(var c=N.surfaceRegularSampleDerivatives(r,n,a,l),d=[],p=n+1,_=a+1,y=l+1,A=0;A<p;){var P=A++,S=[];d.push(S);for(var I=0;I<_;){for(var k=I++,M=c[P][k],O=N.rational2d(M),C=N.weight2d(M),F=[],R=O[0][0].length,U=0;U<y;){var V=U++;F.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++;m.subMulMutate(G,Ft.get(H,et)*C[0][et],F[V][H-et])}for(var it=1,ht=V+1;it<ht;){var at=it++;m.subMulMutate(G,Ft.get(V,at)*C[at][0],F[V-at][H]);for(var ut=m.zeros1d(R),nt=1,mt=H+1;nt<mt;){var X=nt++;m.addMulMutate(ut,Ft.get(H,X)*C[at][X],F[V-at][H-X])}m.subMulMutate(G,Ft.get(V,at),ut)}m.mulMutate(1/C[0][0],G),F[V].push(G)}}S.push(F)}}return d},N.surfaceRegularSampleDerivatives=function(r,n,a,l){var c=r.degreeU,d=r.degreeV,p=r.controlPoints,_=r.knotsU,y=r.knotsV,A=p[0][0].length;(Z.last(_)-_[0])/n,(Z.last(y)-y[0])/a;for(var P=N.regularlySpacedDerivativeBasisFunctions(c,_,n),S=P.item0,I=P.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,y,a),M=k.item0,O=k.item1,C=[],F=n+1,R=a+1,U=0;U<F;){var V=U++,q=[];C.push(q);for(var J=0;J<R;){var H=J++;q.push(N.surfaceDerivativesGivenBasesKnotSpans(c,d,p,S[V],M[H],I[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,c=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,y=d[0][0].length;(Z.last(p)-p[0])/n,(Z.last(_)-_[0])/a;for(var A=N.regularlySpacedBasisFunctions(l,p,n),P=A.item0,S=A.item1,I=N.regularlySpacedBasisFunctions(c,_,a),k=I.item0,M=I.item1,O=[],C=n+1,F=a+1,R=0;R<C;){var U=R++,V=[];O.push(V);for(var q=0;q<F;){var J=q++;V.push(N.surfacePointGivenBasesKnotSpans(l,c,d,P[U],k[J],S[U],M[J],y))}}return O},N.regularlySpacedBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=(Z.last(n)-n[0])/a,d=[],p=[],_=n[0],y=N.knotSpanGivenN(l,r,_,n),A=a+1,P=0;P<A;){for(P++;_>=n[y+1];)y++;p.push(y),d.push(N.basisFunctionsGivenKnotSpanIndex(y,_,r,n)),_+=c}return new ee(p,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=(Z.last(n)-n[0])/a,d=[],p=[],_=n[0],y=N.knotSpanGivenN(l,r,_,n),A=a+1,P=0;P<A;){for(P++;_>=n[y+1];)y++;p.push(y),d.push(N.derivativeBasisFunctionsGivenNI(y,_,r,l,n)),_+=c}return new ee(p,d)},N.surfacePointGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_){for(var y=m.zeros1d(_),A,P=l-r,S=c-n,I=0,k=n+1;I<k;){var M=I++;A=m.zeros1d(_);for(var O=0,C=r+1;O<C;){var F=O++;m.addMulMutate(A,d[F],a[P+F][S])}S++,m.addMulMutate(y,p[M],A)}return y},N.surfaceDerivativesGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_,y){var A=a[0][0].length,P;y<r?P=y:P=r;var S;y<n?S=y:S=n;for(var I=m.zeros3d(P+1,S+1,A),k=m.zeros2d(n+1,A),M=0,O=0,C=P+1;O<C;){for(var F=O++,R=0,U=n+1;R<U;){var V=R++;k[V]=m.zeros1d(A);for(var q=0,J=r+1;q<J;){var H=q++;m.addMulMutate(k[V],d[F][H],a[l-r+H][c-n+V])}}var G=y-F;G<S?M=G:M=S;for(var K=0,tt=M+1;K<tt;){var et=K++;I[F][et]=m.zeros1d(A);for(var it=0,ht=n+1;it<ht;){var at=it++;m.addMulMutate(I[F][et],p[et][at],k[at])}}}return I},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 c=n.degree,d=n.controlPoints,p=n.knots;if(!N.areValidRelations(c,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<c?y=l:y=c;for(var A=m.zeros2d(l+1,_),P=N.knotSpanGivenN(r,c,a,p),S=N.derivativeBasisFunctionsGivenNI(P,a,c,y,p),I=0,k=y+1;I<k;)for(var M=I++,O=0,C=c+1;O<C;){var F=O++;m.addMulMutate(A[M],S[M][F],d[P-c+F])}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,c=n.controlPoints,d=n.knots;if(!N.areValidRelations(l,c.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(p,a,l,d),y=m.zeros1d(c[0].length),A=0,P=l+1;A<P;){var S=A++;m.addMulMutate(y,_[S],c[p-l+S])}return y},N.volumePoint=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,c,d,p,n,a,l)},N.volumePointGivenNML=function(r,n,a,l,c,d,p){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,y=r.degreeU,A=r.degreeV,P=r.degreeW,S=r.knotsU,I=r.knotsV,k=r.knotsW,M=_[0][0][0].length,O=N.knotSpanGivenN(n,y,c,S),C=N.knotSpanGivenN(a,A,d,I),F=N.knotSpanGivenN(l,P,p,k),R=N.basisFunctionsGivenKnotSpanIndex(O,c,y,S),U=N.basisFunctionsGivenKnotSpanIndex(C,d,A,I),V=N.basisFunctionsGivenKnotSpanIndex(F,p,P,k),q=O-y,J=m.zeros1d(M),H=m.zeros1d(M),G=m.zeros1d(M),K=0,tt=P+1;K<tt;){var et=K++;G=m.zeros1d(M);for(var it=F-P+et,ht=0,at=A+1;ht<at;){var ut=ht++;H=m.zeros1d(M);for(var nt=C-A+ut,mt=0,X=y+1;mt<X;){var gt=mt++;m.addMulMutate(H,R[gt],_[q+gt][nt][it])}m.addMulMutate(G,U[ut],H)}m.addMulMutate(J,V[et],G)}return J},N.derivativeBasisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a),c=a.length-1,d=c-n-1;return N.derivativeBasisFunctionsGivenNI(l,r,n,d,a)},N.derivativeBasisFunctionsGivenNI=function(r,n,a,l,c){var d=m.zeros2d(a+1,a+1),p=m.zeros1d(a+1),_=m.zeros1d(a+1),y=0,A=0;d[0][0]=1;for(var P=1,S=a+1;P<S;){var I=P++;p[I]=n-c[r+1-I],_[I]=c[r+I]-n,y=0;for(var k=0;k<I;){var M=k++;d[I][M]=_[M+1]+p[I-M],A=d[M][I-1]/d[I][M],d[M][I]=y+_[M+1]*A,y=p[I-M]*A}d[I][I]=y}for(var O=m.zeros2d(l+1,a+1),C=m.zeros2d(2,a+1),F=0,R=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++;F=0,R=1,C[0][0]=1;for(var at=1,ut=l+1;at<ut;){var nt=at++;U=0,V=ht-nt,q=a-nt,ht>=nt&&(C[R][0]=C[F][0]/d[q+1][V],U=C[R][0]*d[V][q]),V>=-1?J=1:J=-V,ht-1<=q?H=nt-1:H=a-ht;for(var mt=J,X=H+1;mt<X;){var gt=mt++;C[R][gt]=(C[F][gt]-C[F][gt-1])/d[q+1][V+gt],U+=C[R][gt]*d[V+gt][q]}ht<=q&&(C[R][nt]=-C[F][nt-1]/d[q+1][ht],U+=C[R][nt]*d[ht][q]),O[nt][ht]=U;var Pt=F;F=R,R=Pt}}for(var jt=a,Xt=1,Dt=l+1;Xt<Dt;){for(var Kt=Xt++,Ie=0,Ye=a+1;Ie<Ye;){var ye=Ie++;O[Kt][ye]*=jt}jt*=a-Kt}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 c=m.zeros1d(a+1),d=m.zeros1d(a+1),p=m.zeros1d(a+1),_=0,y=0;c[0]=1;for(var A=1,P=a+1;A<P;){var S=A++;d[S]=n-l[r+1-S],p[S]=l[r+S]-n,_=0;for(var I=0;I<S;){var k=I++;y=c[k]/(p[k+1]+d[S-k]),c[k]=_+p[k+1]*y,_=d[S-k]*y}c[S]=_}return c},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 c=n,d=r+1,p=Math.floor((c+d)/2);a<l[p]||a>=l[p+1];)a<l[p]?d=p:c=p,p=Math.floor((c+d)/2);return p},N.dehomogenize=function(r){for(var n=r.length,a=[],l=r[n-1],c=r.length-1,d=0;d<c;){var p=d++;a.push(r[p]/l)}return a},N.rational1d=function(r){var n=r[0].length-1;return r.map(function(a){return a.slice(0,n)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var n=r[0].length-1;return r.map(function(a){return a[n]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,n){var a=r.length,l=r[0].length,c=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var y=0;y<a;){var A=y++,P=[];p=r[A],d=_[A];for(var S=0;S<l;){var I=S++;P.push(p[I]*d)}P.push(d),c.push(P)}return c},N.homogenize2d=function(r,n){var a=r.length,l=[],c;if(n!=null)c=n;else{for(var d=[],p=0;p<a;)p++,d.push(m.rep(r[0].length,1));c=d}for(var _=0;_<a;){var y=_++;l.push(N.homogenize1d(r[y],c[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),c=zt.rationalSurfaceAdaptive(n),d=lt.meshes(l,c),p=d.map(function(_){return _.map(function(y){return lt.surfacesAtPointWithEstimate(r,n,y.uv0,y.uv1,a)})});return p.map(function(_){return pt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},lt.surfacesAtPointWithEstimate=function(r,n,a,l,c){var d,p,_,y,A,P,S,I,k,M,O,C,F,R=5,U=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),p=d[0][0],y=d[1][0],A=d[0][1],_=m.normalized(m.cross(y,A)),P=m.dot(_,p),S=N.rationalSurfaceDerivatives(n,l[0],l[1],1),I=S[0][0],M=S[1][0],O=S[0][1],k=m.normalized(m.cross(M,O)),C=m.dot(k,I),F=m.distSquared(p,I),F<c*c)break;var V=m.normalized(m.cross(_,k)),q=m.dot(V,p),J=lt.threePlanes(_,P,k,C,V,q);if(J==null)throw new Q("panic!");var H=m.sub(J,p),G=m.sub(J,I),K=m.cross(y,_),tt=m.cross(A,_),et=m.cross(M,k),it=m.cross(O,k),ht=m.dot(tt,H)/m.dot(tt,y),at=m.dot(K,H)/m.dot(K,A),ut=m.dot(it,G)/m.dot(it,M),nt=m.dot(et,G)/m.dot(et,O);a=m.add([ht,at],a),l=m.add([ut,nt],l),U++}while(U<R);return new $n(a,l,p,F)},lt.meshes=function(r,n,a,l){a==null&&(a=new ar(r)),l==null&&(l=new ar(n));var c=lt.boundingBoxTrees(a,l,0),d=Z.unique(c.map(function(p){return lt.triangles(r,p.item0,n,p.item1)}).filter(function(p){return p!=null}).filter(function(p){return m.distSquared(p.min.point,p.max.point)>rt.EPSILON}),function(p,_){var y=m.sub(p.min.uv0,_.min.uv0),A=m.dot(y,y),P=m.sub(p.max.uv0,_.max.uv0),S=m.dot(P,P),I=m.sub(p.min.uv0,_.max.uv0),k=m.dot(I,I),M=m.sub(p.max.uv0,_.min.uv0),O=m.dot(M,M);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 c=new zr(r),d=c.boundingBox(),p=d.min[0],_=d.min[1],y=d.max[0],A=d.max[1],P=m.span(n,a,l),S=[],I=0;I<P.length;){var k=P[I];++I;var M=[[p,_,k],[y,_,k],[y,A,k],[p,A,k]],O=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],F=new qe(C,M,null,O);S.push(lt.meshes(r,F,c))}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),c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.min),c.push(p.max)}for(var _=0;_<c.length;){var y=c[_];if(++_,y.adj==null){var A=lt.lookupAdjacentSegment(y,l,r.length);A!=null&&A.adj==null&&(y.adj=A,A.adj=y)}}var P=c.filter(function(R){return R.adj==null});P.length==0&&(P=c);for(var S=[],I=0,k=!1;P.length!=0;){var M=P.pop();if(!M.visited){for(var O=[],C=M;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,O.push(C),I+=2,C=C.opp.adj,C==M)););O.length>0&&(O.push(O[O.length-1].opp),S.push(O))}if(P.length==0&&c.length>0&&(k||I<c.length)){k=!0;var F=c.pop();P.push(F)}}return S},lt.kdTreeFromSegments=function(r){for(var n=[],a=0;a<r.length;){var l=r[a];++a,n.push(new In(l.min.point,l.min)),n.push(new In(l.max.point,l.max))}return new Qn(n,m.distSquared)},lt.lookupAdjacentSegment=function(r,n,a){var l=n.nearest(r.point,a,rt.EPSILON).filter(function(c){return r!=c.item0.obj}).map(function(c){return c.item0.obj});return l.length==1?l[0]:null},lt.curveAndSurface=function(r,n,a,l,c){a==null&&(a=.001),l!=null?l=l:l=new ir(r),c!=null?c=c:c=new Or(n);var d=lt.boundingBoxTrees(l,c,a);return Z.unique(d.map(function(p){var _=p.item0,y=p.item1,A=Z.first(_.knots),P=Z.last(_.knots),S=(A+P)/2,I=Z.first(y.knotsU),k=Z.last(y.knotsU),M=Z.first(y.knotsV),O=Z.last(y.knotsV),C=[(I+k)/2,(M+O)/2];return lt.curveAndSurfaceWithEstimate(_,y,[S].concat(C),a)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<a*a}),function(p,_){return Math.abs(p.u-_.u)<.5*a})},lt.curveAndSurfaceWithEstimate=function(r,n,a,l){l==null&&(l=.001);var c=function(y){var A=N.rationalCurvePoint(r,y[0]),P=N.rationalSurfacePoint(n,y[1],y[2]),S=m.sub(A,P);return m.dot(S,S)},d=function(y){var A=N.rationalCurveDerivatives(r,y[0],1),P=N.rationalSurfaceDerivatives(n,y[1],y[2],1),S=m.sub(P[0][0],A[0]),I=m.mul(-1,A[1]),k=P[1][0],M=P[0][1];return[2*m.dot(I,S),2*m.dot(k,S),2*m.dot(M,S)]},p=Xe.uncmin(c,a,l*l,d),_=p.solution;return new Xn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(n,_[1],_[2]))},lt.polylineAndMesh=function(r,n,a){for(var l=lt.boundingBoxTrees(new or(r),new ar(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,y=p.item1,A=lt.segmentWithTriangle(r.points[_],r.points[_+1],n.points,n.faces[y]);if(A!=null){var P=A.point,S=m.lerp(A.p,[r.params[_]],[r.params[_+1]])[0],I=re.triangleUVFromPoint(n,y,P);c.push(new Kn(P,S,I,_,y))}}return c},lt.boundingBoxTrees=function(r,n,a){a==null&&(a=1e-9);var l=[],c=[];l.push(r),c.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=c.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),a)){var y=p.indivisible(a),A=_.indivisible(a);if(y&&A){d.push(new ee(p.yield(),_.yield()));continue}else if(y&&!A){var P=_.split();l.push(p),c.push(P.item1),l.push(p),c.push(P.item0);continue}else if(!y&&A){var S=p.split();l.push(S.item1),c.push(_),l.push(S.item0),c.push(_);continue}var I=p.split(),k=_.split();l.push(I.item1),c.push(k.item1),l.push(I.item1),c.push(k.item0),l.push(I.item0),c.push(k.item1),l.push(I.item0),c.push(k.item0)}}return d},lt.curves=function(r,n,a){var l=lt.boundingBoxTrees(new ir(r),new ir(n),0);return Z.unique(l.map(function(c){return lt.curvesWithEstimate(r,n,Z.first(c.item0.knots),Z.first(c.item1.knots),a)}).filter(function(c){return m.distSquared(c.point0,c.point1)<a}),function(c,d){return Math.abs(c.u0-d.u0)<a*5})},lt.curvesWithEstimate=function(r,n,a,l,c){var d=function(I){var k=N.rationalCurvePoint(r,I[0]),M=N.rationalCurvePoint(n,I[1]),O=m.sub(k,M);return m.dot(O,O)},p=function(I){var k=N.rationalCurveDerivatives(r,I[0],1),M=N.rationalCurveDerivatives(n,I[1],1),O=m.sub(k[0],M[0]),C=k[1],F=m.mul(-1,M[1]);return[2*m.dot(C,O),2*m.dot(F,O)]},_=Xe.uncmin(d,[a,l],c*c,p),y=_.solution[0],A=_.solution[1],P=N.rationalCurvePoint(r,y),S=N.rationalCurvePoint(n,A);return new Qr(P,S,y,A)},lt.triangles=function(r,n,a,l){var c=r.faces[n],d=a.faces[l],p=re.getTriangleNorm(r.points,c),_=re.getTriangleNorm(a.points,d),y=r.points[c[0]],A=a.points[d[0]],P=lt.planes(y,p,A,_);if(P==null)return null;var S=lt.clipRayInCoplanarTriangle(P,r,n);if(S==null)return null;var I=lt.clipRayInCoplanarTriangle(P,a,l);if(I==null)return null;var k=lt.mergeTriangleClipIntervals(S,I,r,n,a,l);return k==null?null:new Pe(new Lr(k.min.uv0,k.min.uv1,k.min.point,n,l),new Lr(k.max.uv0,k.max.uv1,k.max.point,n,l))},lt.clipRayInCoplanarTriangle=function(r,n,a){for(var l=n.faces[a],c=[n.points[l[0]],n.points[l[1]],n.points[l[2]]],d=[n.uvs[l[0]],n.uvs[l[1]],n.uvs[l[2]]],p=[m.sub(d[1],d[0]),m.sub(d[2],d[1]),m.sub(d[0],d[2])],_=[m.sub(c[1],c[0]),m.sub(c[2],c[1]),m.sub(c[0],c[2])],y=_.map(m.normalized),A=_.map(m.norm),P=null,S=null,I=0;I<3;){var k=I++,M=c[k],O=y[k],C=lt.rays(M,O,r.origin,r.dir);if(C!=null){var F=C.u0,R=C.u1;F<-rt.EPSILON||F>A[k]+rt.EPSILON||((P==null||R<P.u)&&(P=new Pn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],F/A[k]))),(S==null||R>S.u)&&(S=new Pn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],F/A[k]))))}}return S==null||P==null?null:new Pe(P,S)},lt.mergeTriangleClipIntervals=function(r,n,a,l,c,d){if(n.min.u>r.max.u+rt.EPSILON||r.min.u>n.max.u+rt.EPSILON)return null;var p;r.min.u>n.min.u?p=new ee(r.min,0):p=new ee(n.min,1);var _;r.max.u<n.max.u?_=new ee(r.max,0):_=new ee(n.max,1);var y=new Pe(new Lr(null,null,p.item0.point,l,d),new Lr(null,null,_.item0.point,l,d));return p.item1==0?(y.min.uv0=p.item0.uv,y.min.uv1=re.triangleUVFromPoint(c,d,p.item0.point)):(y.min.uv0=re.triangleUVFromPoint(a,l,p.item0.point),y.min.uv1=p.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=re.triangleUVFromPoint(c,d,_.item0.point)):(y.max.uv0=re.triangleUVFromPoint(a,l,_.item0.point),y.max.uv1=_.item0.uv),y},lt.planes=function(r,n,a,l){var c=m.cross(n,l);if(m.dot(c,c)<rt.EPSILON)return null;var d=0,p=Math.abs(c[0]),_=Math.abs(c[1]),y=Math.abs(c[2]);_>p&&(d=1,p=_),y>p&&(d=2,p=y);var A,P,S,I;d==0?(A=n[1],P=n[2],S=l[1],I=l[2]):d==1?(A=n[0],P=n[2],S=l[0],I=l[2]):(A=n[0],P=n[1],S=l[0],I=l[1]);var k=-m.dot(r,n),M=-m.dot(a,l),O=A*I-P*S,C=(P*M-k*I)/O,F=(k*S-A*M)/O,R;return d==0?R=[0,C,F]:d==1?R=[C,0,F]:R=[C,F,0],new Sn(R,m.normalized(c))},lt.threePlanes=function(r,n,a,l,c,d){var p=m.cross(a,c),_=m.dot(r,p);if(Math.abs(_)<rt.EPSILON)return null;var y=m.sub(m.mul(d,a),m.mul(l,c)),A=m.add(m.mul(n,p),m.cross(r,y));return m.mul(1/_,A)},lt.polylines=function(r,n,a){for(var l=lt.boundingBoxTrees(new or(r),new or(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,y=p.item1,A=lt.segments(r.points[_],r.points[_+1],n.points[y],n.points[y+1],a);A!=null&&(A.u0=m.lerp(A.u0,[r.params[_]],[r.params[_+1]])[0],A.u1=m.lerp(A.u1,[n.params[y]],[n.params[y+1]])[0],c.push(A))}return c},lt.segments=function(r,n,a,l,c){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),y=m.sub(l,a),A=Math.sqrt(m.dot(y,y)),P=m.mul(1/A,y),S=lt.rays(r,_,a,P);if(S!=null){var I=Math.min(Math.max(0,S.u0/p),1),k=Math.min(Math.max(0,S.u1/A),1),M=m.onRay(r,d,I),O=m.onRay(a,y,k),C=m.distSquared(M,O);if(C<c*c)return new Qr(M,O,I,k)}return null},lt.rays=function(r,n,a,l){var c=m.dot(n,l),d=m.dot(n,a),p=m.dot(n,r),_=m.dot(l,a),y=m.dot(l,r),A=m.dot(n,n),P=m.dot(l,l),S=A*P-c*c;if(Math.abs(S)<rt.EPSILON)return null;var I=c*(d-p)-A*(_-y),k=I/S,M=(d-p+k*c)/A,O=m.onRay(r,n,M),C=m.onRay(a,l,k);return new Qr(O,C,M,k)},lt.segmentWithTriangle=function(r,n,a,l){var c=a[l[0]],d=a[l[1]],p=a[l[2]],_=m.sub(d,c),y=m.sub(p,c),A=m.cross(_,y),P=m.sub(n,r),S=m.sub(r,c),I=-m.dot(A,S),k=m.dot(A,P);if(Math.abs(k)<rt.EPSILON)return null;var M=I/k;if(M<0||M>1)return null;var O=m.add(r,m.mul(M,P)),C=m.dot(_,y),F=m.dot(_,_),R=m.dot(y,y),U=m.sub(O,c),V=m.dot(U,_),q=m.dot(U,y),J=C*C-F*R;if(Math.abs(J)<rt.EPSILON)return null;var H=(C*q-R*V)/J,G=(C*V-F*q)/J;return H>1+rt.EPSILON||G>1+rt.EPSILON||G<-rt.EPSILON||H<-rt.EPSILON||H+G>1+rt.EPSILON?null:new Zn(O,H,G,M)},lt.segmentAndPlane=function(r,n,a,l){var c=m.dot(l,m.sub(n,r));if(Math.abs(c)<rt.EPSILON)return null;var d=m.dot(l,m.sub(a,r)),p=d/c;return p>1+rt.EPSILON||p<-rt.EPSILON?null:{p}};var pt=f.eval.Make=function(){};x["verb.eval.Make"]=pt,pt.__name__=["verb","eval","Make"],pt.rationalTranslationalSurface=function(r,n){for(var a=N.rationalCurvePoint(n,Z.first(n.knots)),l=Z.first(n.knots),c=Z.last(n.knots),d=2*n.controlPoints.length,p=(c-l)/(d-1),_=[],y=0;y<d;){var A=y++,P=m.sub(N.rationalCurvePoint(n,l+A*p),a),S=ft.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(S)}return pt.loftedSurface(_)},pt.surfaceBoundaryCurves=function(r){var n=pt.surfaceIsocurve(r,Z.first(r.knotsU),!1),a=pt.surfaceIsocurve(r,Z.last(r.knotsU),!1),l=pt.surfaceIsocurve(r,Z.first(r.knotsV),!0),c=pt.surfaceIsocurve(r,Z.last(r.knotsV),!0);return[n,a,l,c]},pt.surfaceIsocurve=function(r,n,a){a==null&&(a=!1);var l;a?l=r.knotsV:l=r.knotsU;var c;a?c=r.degreeV:c=r.degreeU;for(var d=vt.knotMultiplicities(l),p=-1,_=0,y=d.length;_<y;){var A=_++;if(Math.abs(n-d[A].knot)<rt.EPSILON){p=A;break}}var P=c+1;p>=0&&(P=P-d[p].mult);var S;P>0?S=ft.surfaceKnotRefine(r,m.rep(P,n),a):S=r;var I=N.knotSpan(c,n,l);return Math.abs(n-Z.first(l))<rt.EPSILON?I=0:Math.abs(n-Z.last(l))<rt.EPSILON&&(I=(a?S.controlPoints[0].length:S.controlPoints.length)-1),a?new Gt(S.degreeU,S.knotsU,function(k){for(var M,O=[],C=0,F=S.controlPoints;C<F.length;){var R=F[C];++C,O.push(R[I])}return M=O,M}()):new Gt(S.degreeV,S.knotsV,S.controlPoints[I])},pt.loftedSurface=function(r,n){r=ft.unifyCurveKnotVectors(r);var a=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,c=[],d=[],p=0,_=r[0].controlPoints.length;p<_;){var y=[p++],A=r.map(function(S){return function(I){return I.controlPoints[S[0]]}}(y)),P=pt.rationalInterpCurve(A,n,!0);d.push(P.controlPoints),c=P.knots}return new te(a,n,l,c,d)},pt.clonedCurve=function(r){return new Gt(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},pt.rationalBezierCurve=function(r,n){for(var a=r.length-1,l=[],c=0,d=a+1;c<d;)c++,l.push(0);for(var p=0,_=a+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new Gt(a,l,N.homogenize1d(r,n))},pt.fourPointSurface=function(r,n,a,l,c){c==null&&(c=3);for(var d=c,p=[],_=0,y=c+1;_<y;){for(var A=_++,P=[],S=0,I=c+1;S<I;){var k=S++,M=1-A/d,O=m.lerp(M,r,n),C=m.lerp(M,l,a),F=m.lerp(1-k/d,O,C);F.push(1),P.push(F)}p.push(P)}var R=m.rep(c+1,0),U=m.rep(c+1,1);return new te(c,c,R.concat(U),R.concat(U),p)},pt.ellipseArc=function(r,n,a,l,c){var d=m.norm(n),p=m.norm(a);n=m.normalized(n),a=m.normalized(a),c<l&&(c=2*Math.PI+l);var _=c-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var A=_/y,P=Math.cos(A/2),S=m.add(r,m.add(m.mul(d*Math.cos(l),n),m.mul(p*Math.sin(l),a))),I=m.sub(m.mul(Math.cos(l),a),m.mul(Math.sin(l),n)),k=[],M=m.zeros1d(2*y+3),O=0,C=l,F=m.zeros1d(y*2);k[0]=S,F[0]=1;for(var R=1,U=y+1;R<U;){var V=R++;C+=A;var q=m.add(r,m.add(m.mul(d*Math.cos(C),n),m.mul(p*Math.sin(C),a)));F[O+2]=1,k[O+2]=q;var J=m.sub(m.mul(Math.cos(C),a),m.mul(Math.sin(C),n)),H=lt.rays(S,m.mul(1/m.norm(I),I),q,m.mul(1/m.norm(J),J)),G=m.add(S,m.mul(H.u0,I));F[O+1]=P,k[O+1]=G,O+=2,V<y&&(S=q,I=J)}for(var K=2*y+1,tt=0;tt<3;){var et=tt++;M[et]=0,M[et+K]=1}switch(y){case 2:M[3]=M[4]=.5;break;case 3:M[3]=M[4]=.3333333333333333,M[5]=M[6]=.6666666666666666;break;case 4:M[3]=M[4]=.25,M[5]=M[6]=.5,M[7]=M[8]=.75;break}return new Gt(2,M,N.homogenize1d(k,F))},pt.arc=function(r,n,a,l,c,d){return pt.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(a)),c,d)},pt.polyline=function(r){for(var n=[0,0],a=0,l=0,c=r.length-1;l<c;){var d=l++;a+=m.dist(r[d],r[d+1]),n.push(a)}n.push(a),n=m.mul(1/a,n);for(var p,_=[],y=0,A=r.length;y<A;)y++,_.push(1);return p=_,new Gt(1,n,N.homogenize1d(r.slice(0),p))},pt.extrudedSurface=function(r,n,a){for(var l=[[],[],[]],c=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),p=N.weight1d(a.controlPoints),_=m.mul(n,r),y=m.mul(.5*n,r),A=0,P=d.length;A<P;){var S=A++;l[2][S]=d[S],l[1][S]=m.add(y,d[S]),l[0][S]=m.add(_,d[S]),c[0][S]=p[S],c[1][S]=p[S],c[2][S]=p[S]}return new te(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,c))},pt.cylindricalSurface=function(r,n,a,l,c){var d=m.cross(r,n),p=pt.arc(a,n,d,c,0,2*Math.PI);return pt.extrudedSurface(r,l,p)},pt.revolvedSurface=function(r,n,a,l){var c=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),p,_;l<=Math.PI/2?(p=1,_=m.zeros1d(6+2*(p-1))):l<=Math.PI?(p=2,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(p=3,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(p=4,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/p,A=3+2*(p-1),P=0;P<3;){var S=P++;_[S]=0,_[A+S]=1}for(var I=Math.cos(y/2),k=0,M=m.zeros1d(p+1),O=m.zeros1d(p+1),C=m.zeros3d(2*p+1,c.length,3),F=m.zeros2d(2*p+1,c.length),R=1,U=p+1;R<U;){var V=R++;k+=y,O[V]=Math.cos(k),M[V]=Math.sin(k)}for(var q=0,J=c.length;q<J;){var H=q++,G=Ne.rayClosestPoint(c[H],n,a),K=m.sub(c[H],G),tt=m.norm(K),et=m.cross(a,K);tt>rt.EPSILON&&(K=m.mul(1/tt,K),et=m.mul(1/tt,et)),C[0][H]=c[H];var it=c[H];F[0][H]=d[H];for(var ht=et,at=0,ut=1,nt=p+1;ut<nt;){var mt=ut++,X;tt==0?X=G:X=m.add(G,m.add(m.mul(tt*O[mt],K),m.mul(tt*M[mt],et))),C[at+2][H]=X,F[at+2][H]=d[H];var gt=m.sub(m.mul(O[mt],et),m.mul(M[mt],K));if(tt==0)C[at+1][H]=G;else{var Pt=lt.rays(it,m.mul(1/m.norm(ht),ht),X,m.mul(1/m.norm(gt),gt)),jt=m.add(it,m.mul(Pt.u0,ht));C[at+1][H]=jt}F[at+1][H]=I*d[H],at+=2,mt<p&&(it=X,ht=gt)}}return new te(2,r.degree,_,r.knots,N.homogenize2d(C,F))},pt.sphericalSurface=function(r,n,a,l){var c=pt.arc(r,m.mul(-1,n),a,l,0,Math.PI);return pt.revolvedSurface(c,r,n,2*Math.PI)},pt.conicalSurface=function(r,n,a,l,c){var d=2*Math.PI,p=1,_=[m.add(a,m.mul(l,r)),m.add(a,m.mul(c,n))],y=[0,0,1,1],A=[1,1],P=new Gt(p,y,N.homogenize1d(_,A));return pt.revolvedSurface(P,a,r,d)},pt.rationalInterpCurve=function(r,n,a,l,c){if(a==null&&(a=!1),n==null&&(n=3),r.length<n+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],p=1,_=r.length;p<_;){var y=p++,A=m.norm(m.sub(r[y],r[y-1])),P=d[d.length-1];d.push(P+A)}for(var S=d[d.length-1],I=0,k=d.length;I<k;){var M=I++;d[M]=d[M]/S}var O=m.rep(n+1,0),C=l!=null&&c!=null,F;C?F=0:F=1;var R;C?R=d.length-n+1:R=d.length-n;for(var U=F;U<R;){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(m.rep(n+1,1)),K=[],tt;C?tt=r.length+1:tt=r.length-1;var et;C?et=r.length-(n-1):et=r.length-(n+1);for(var it=0;it<d.length;){var ht=d[it];++it;var at=N.knotSpanGivenN(tt,n,ht,G),ut=N.basisFunctionsGivenKnotSpanIndex(at,ht,n,G),nt=at-n,mt=m.zeros1d(nt),X=m.zeros1d(et-nt);K.push(mt.concat(ut).concat(X))}if(C){var gt=K[0].length-2,Pt=[-1,1].concat(m.zeros1d(gt)),jt=m.zeros1d(gt).concat([-1,1]);Z.spliceAndInsert(K,1,0,Pt),Z.spliceAndInsert(K,K.length-1,0,jt)}for(var Xt=r[0].length,Dt=[],Kt=(1-G[G.length-n-2])/n,Ie=G[n+1]/n,Ye=0;Ye<Xt;){var ye=[Ye++],ge;if(!C)ge=r.map(function(Je){return function(mr){return mr[Je[0]]}}(ye));else{ge=[r[0][ye[0]]],ge.push(Ie*l[ye[0]]);for(var Ee=1,Le=r.length-1;Ee<Le;){var $e=Ee++;ge.push(r[$e][ye[0]])}ge.push(Kt*c[ye[0]]),ge.push(Z.last(r)[ye[0]])}var lr=Lt.solve(K,ge);Dt.push(lr)}var Ze=Lt.transpose(Dt);if(!a){var Qe=m.rep(Ze.length,1);Ze=N.homogenize1d(Ze,Qe)}return new Gt(n,G,Ze)};var ft=f.eval.Modify=function(){};x["verb.eval.Modify"]=ft,ft.__name__=["verb","eval","Modify"],ft.curveReverse=function(r){return new Gt(r.degree,ft.knotsReverse(r.knots),Z.reversed(r.controlPoints))},ft.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new te(r.degreeU,r.degreeV,r.knotsU,ft.knotsReverse(r.knotsV),function(a){for(var l,c=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,c.push(Z.reversed(_))}return l=c,l}()):new te(r.degreeU,r.degreeV,ft.knotsReverse(r.knotsU),r.knotsV,Z.reversed(r.controlPoints))},ft.knotsReverse=function(r){var n=Z.first(r);Z.last(r);for(var a=[n],l=r.length,c=1;c<l;){var d=c++;a.push(a[d-1]+(r[l-d]-r[l-d-1]))}return a},ft.unifyCurveKnotVectors=function(r){r=r.map(pt.clonedCurve);for(var n=z.fold(r,function(G,K){return ft.imax(G.degree,K)},0),a=0,l=r.length;a<l;){var c=a++;r[c].degree<n&&(r[c]=ft.curveElevateDegree(r[c],n))}for(var d,p=[],_=0;_<r.length;){var y=r[_];++_,p.push(new Pe(Z.first(y.knots),Z.last(y.knots)))}d=p;for(var A=0,P=r.length;A<P;){var S=A++,I=[d[S].min];r[S].knots=r[S].knots.map(function(G){return function(K){return K-G[0]}}(I))}for(var k=d.map(function(G){return G.max-G.min}),M=z.fold(k,function(G,K){return Math.max(G,K)},0),O=0,C=r.length;O<C;){var F=O++,R=[M/k[F]];r[F].knots=r[F].knots.map(function(G){return function(K){return K*G[0]}}(R))}for(var U=z.fold(r,function(G,K){return m.sortedSetUnion(G.knots,K)},[]),V=0,q=r.length;V<q;){var J=V++,H=m.sortedSetSub(U,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=ft.curveKnotRefine(r[J],H)}return r},ft.imin=function(r,n){return r<n?r:n},ft.imax=function(r,n){return r>n?r:n},ft.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var a=r.knots.length-r.degree-2,l=r.degree,c=r.knots,d=r.controlPoints,p=n-r.degree,_=r.controlPoints[0].length,y=m.zeros2d(l+p+1,l+1),A=[],P=[],S=[],I=a+l+1,k=n,M=Math.floor(k/2),O=[],C=[];y[0][0]=1,y[k][l]=1;for(var F=1,R=M+1;F<R;)for(var U=F++,V=1/Ft.get(k,U),q=ft.imin(l,U),J=ft.imax(0,U-p),H=q+1;J<H;){var G=J++;y[U][G]=V*Ft.get(l,G)*Ft.get(p,U-G)}for(var K=M+1;K<k;)for(var tt=K++,et=ft.imin(l,tt),it=ft.imax(0,tt-p),ht=et+1;it<ht;){var at=it++;y[tt][at]=y[k-tt][l-at]}var ut=k+1,nt=-1,mt=l,X=l+1,gt=1,Pt=c[0];O[0]=d[0];for(var jt=0,Xt=k+1;jt<Xt;){var Dt=jt++;C[Dt]=Pt}for(var Kt=0,Ie=l+1;Kt<Ie;){var Ye=Kt++;A[Ye]=d[Ye]}for(;X<I;){for(var ye=X;X<I&&c[X]==c[X+1];)X=X+1;var ge=X-ye+1,Ee=c[X],Le=nt;nt=l-ge;var $e;Le>0?$e=Math.floor((Le+2)/2):$e=1;var lr;if(nt>0?lr=Math.floor(k-(nt+1)/2):lr=k,nt>0){for(var Ze=Ee-Pt,Qe=[],Je=l;Je>ge;)Qe[Je-ge-1]=Ze/(c[mt+Je]-Pt),Je--;for(var mr=1,Ln=nt+1;mr<Ln;){for(var tn=mr++,Kc=nt-tn,Ki=ge+tn,en=l;en>=Ki;)A[en]=m.add(m.mul(Qe[en-Ki],A[en]),m.mul(1-Qe[en-Ki],A[en-1])),en--;S[Kc]=A[l]}}for(var Lo=$e,$c=k+1;Lo<$c;){var On=Lo++;P[On]=m.zeros1d(_);for(var Zc=ft.imin(l,On),Oo=ft.imax(0,On-p),Qc=Zc+1;Oo<Qc;){var zo=Oo++;P[On]=m.add(P[On],m.mul(y[On][zo],A[zo]))}}if(Le>1)for(var $i=ut-2,Zi=ut,Ro=Ee-Pt,Jc=(Ee-C[ut-1])/Ro,Fo=1;Fo<Le;){for(var Qi=Fo++,pr=$i,rn=Zi,Vr=rn-ut+1;rn-pr>Qi;){if(pr<gt){var tu=(Ee-C[pr])/(Pt-C[pr]);O[pr]=m.lerp(tu,O[pr],O[pr-1])}if(rn>=$e){if(rn-Qi<=ut-k+Le){var eu=(Ee-C[rn-Qi])/Ro;P[Vr]=m.lerp(eu,P[Vr],P[Vr+1])}}else P[Vr]=m.lerp(Jc,P[Vr],P[Vr+1]);pr=pr+1,rn=rn-1,Vr=Vr-1}$i=$i-1,Zi=Zi+1}if(mt!=l)for(var Bo=0,ru=k-Le;Bo<ru;)Bo++,C[ut]=Pt,ut=ut+1;for(var Do=$e,nu=lr+1;Do<nu;){var su=Do++;O[gt]=P[su],gt=gt+1}if(X<I){for(var Uo=0;Uo<nt;){var Vo=Uo++;A[Vo]=S[Vo]}for(var Go=nt,iu=l+1;Go<iu;){var jo=Go++;A[jo]=d[X-l+jo]}mt=X,X=X+1,Pt=Ee}else for(var Wo=0,au=k+1;Wo<au;){var ou=Wo++;C[ut+ou]=Ee}}return new Gt(n,C,O)},ft.rationalSurfaceTransform=function(r,n){for(var a=N.dehomogenize2d(r.controlPoints),l=0,c=a.length;l<c;)for(var d=l++,p=0,_=a[d].length;p<_;){var y=p++,A=a[d][y];A.push(1),a[d][y]=Lt.dot(n,A).slice(0,A.length-1)}return new te(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},ft.rationalCurveTransform=function(r,n){for(var a=N.dehomogenize1d(r.controlPoints),l=0,c=a.length;l<c;){var d=l++,p=a[d];p.push(1),a[d]=Lt.dot(n,p).slice(0,p.length-1)}return new Gt(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},ft.surfaceKnotRefine=function(r,n,a){var l=[],c,d,p;a?(p=r.controlPoints,c=r.knotsV,d=r.degreeV):(p=Lt.transpose(r.controlPoints),c=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<p.length;){var A=p[y];++y,_=ft.curveKnotRefine(new Gt(d,c,A),n),l.push(_.controlPoints)}var P=_.knots;return a?new te(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Lt.transpose(l),new te(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},ft.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,a=r.controlPoints,l=r.knots,c=vt.knotMultiplicities(l),d=n+1,p=0;p<c.length;){var _=c[p];if(++p,_.mult<d){var y=m.rep(d-_.mult,_.knot),A=ft.curveKnotRefine(new Gt(n,l,a),y);l=A.knots,a=A.controlPoints}}l.length/d-1;for(var P=d*2,S=[],I=0;I<a.length;){var k=l.slice(I,I+P),M=a.slice(I,I+d);S.push(new Gt(n,k,M)),I+=d}return S},ft.curveKnotRefine=function(r,n){if(n.length==0)return pt.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,c=r.knots,d=l.length-1,p=d+a+1,_=n.length-1,y=N.knotSpan(a,n[0],c),A=N.knotSpan(a,n[_],c),P=[],S=[],I=0,k=y-a+1;I<k;){var M=I++;P[M]=l[M]}for(var O=A-1,C=d+1;O<C;){var F=O++;P[F+_+1]=l[F]}for(var R=0,U=y+1;R<U;){var V=R++;S[V]=c[V]}for(var q=A+a,J=p+1;q<J;){var H=q++;S[H+_+1]=c[H]}for(var G=A+a-1,K=A+a+_,tt=_;tt>=0;){for(;n[tt]<=c[G]&&G>y;)P[K-a-1]=l[G-a-1],S[K]=c[G],K=K-1,G=G-1;P[K-a-1]=P[K-a];for(var et=1,it=a+1;et<it;){var ht=et++,at=K-a+ht,ut=S[K+ht]-n[tt];Math.abs(ut)<rt.EPSILON?P[at-1]=P[at]:(ut=ut/(S[K+ht]-c[G-a+ht]),P[at-1]=m.add(m.mul(ut,P[at-1]),m.mul(1-ut,P[at])))}S[K]=n[tt],K=K-1,tt--}return new Gt(a,S,P)},ft.curveKnotInsert=function(r,n,a){for(var l=r.degree,c=r.controlPoints,d=r.knots,p=0,_=c.length,y=N.knotSpan(l,n,d),A=[],P=[],S=[],I=1,k=y+1;I<k;){var M=I++;P[M]=d[M]}for(var O=1,C=a+1;O<C;){var F=O++;P[y+F]=n}for(var R=y+1,U=d.length;R<U;){var V=R++;P[V+a]=d[V]}for(var q=0,J=y-l+1;q<J;){var H=q++;S[H]=c[H]}for(var G=y-p;G<_;){var K=G++;S[K+a]=c[K]}for(var tt=0,et=l-p+1;tt<et;){var it=tt++;A[it]=c[y-l+it]}for(var ht=0,at=0,ut=1,nt=a+1;ut<nt;){var mt=ut++;ht=y-l+mt;for(var X=0,gt=l-mt-p+1;X<gt;){var Pt=X++;at=(n-d[ht+Pt])/(d[Pt+y+1]-d[ht+Pt]),A[Pt]=m.add(m.mul(at,A[Pt+1]),m.mul(1-at,A[Pt]))}S[ht]=A[0],S[y+a-mt-p]=A[l-mt-p]}for(var jt=ht+1,Xt=y-p;jt<Xt;){var Dt=jt++;S[Dt]=A[Dt-ht]}return new Gt(l,P,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],Z.last(r.knots),n,a)},zt.rationalCurveRegularSampleRange=function(r,n,a,l,c){l<1&&(l=2);for(var d=[],p=(a-n)/(l-1),_=0,y=0;y<l;){var A=y++;_=n+p*A,c?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=[],c=0,d=r.controlPoints.length;c<d;){var p=c++;l.push([r.knots[p+1]].concat(N.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(N.dehomogenize);return zt.rationalCurveAdaptiveSampleRange(r,r.knots[0],Z.last(r.knots),n,a)},zt.rationalCurveAdaptiveSampleRange=function(r,n,a,l,c){var d=N.rationalCurvePoint(r,n),p=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),y=n+(a-n)*_,A=N.rationalCurvePoint(r,y),P=m.sub(d,p),S=m.sub(d,A);if(m.dot(P,P)<l&&m.dot(S,S)>l||!Ne.threePointsAreFlat(d,A,p,l)){var I=n+(a-n)*.5,k=zt.rationalCurveAdaptiveSampleRange(r,n,I,l,c),M=zt.rationalCurveAdaptiveSampleRange(r,I,a,l,c);return k.slice(0,-1).concat(M)}else return c?[[n].concat(d),[a].concat(p)]:[d,p]},zt.rationalSurfaceNaive=function(r,n,a){n<1&&(n=1),a<1&&(a=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,c=r.knotsV,d=Z.last(l)-l[0],p=Z.last(c)-c[0],_=d/n,y=p/a,A=[],P=[],S=[],I=0,k=n+1;I<k;)for(var M=I++,O=0,C=a+1;O<C;){var F=O++,R=M*_,U=F*y;P.push([R,U]);var V=N.rationalSurfaceDerivatives(r,R,U,1),q=V[0][0];A.push(q);var J=m.normalized(m.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,ut=it+1,nt=[it,ht,at],mt=[it,at,ut];H.push(nt),H.push(mt)}return new qe(H,A,S,P)},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,c;n.minDivsU>a?c=n.minDivsU=n.minDivsU:c=n.minDivsU=a;var d;n.minDivsV>l?d=n.minDivsV=n.minDivsV:d=n.minDivsV=l;for(var p=Z.last(r.knotsU),_=r.knotsU[0],y=Z.last(r.knotsV),A=r.knotsV[0],P=(p-_)/c,S=(y-A)/d,I=[],k=[],M=0,O=d+1;M<O;){for(var C=M++,F=[],R=0,U=c+1;R<U;){var V=R++,q=_+P*V,J=A+S*C,H=N.rationalSurfaceDerivatives(r,q,J,1),G=m.normalized(m.cross(H[0][1],H[1][0]));F.push(new We(H[0][0],G,[q,J],-1,m.isZero(G)))}k.push(F)}for(var K=0;K<d;)for(var tt=K++,et=0;et<c;){var it=et++,ht=[k[d-tt-1][it],k[d-tt-1][it+1],k[d-tt][it+1],k[d-tt][it]];I.push(new dr(r,ht))}if(!n.refine)return I;for(var at=0;at<d;)for(var ut=at++,nt=0;nt<c;){var mt=nt++,X=ut*c+mt,gt=zt.north(X,ut,mt,c,d,I),Pt=zt.east(X,ut,mt,c,d,I),jt=zt.south(X,ut,mt,c,d,I),Xt=zt.west(X,ut,mt,c,d,I);I[X].neighbors=[jt,Pt,gt,Xt],I[X].divide(n)}return I},zt.north=function(r,n,a,l,c,d){return n==0?null:d[r-l]},zt.south=function(r,n,a,l,c,d){return n==c-1?null:d[r+l]},zt.east=function(r,n,a,l,c,d){return a==l-1?null:d[r+1]},zt.west=function(r,n,a,l,c,d){return a==0?null:d[r-1]},zt.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=qe.empty(),a=0;a<r.length;){var l=r[a];++a,l.triangulate(n)}return n},zt.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new 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 dr=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],c=Z.last(r.knotsU),d=r.knotsV[0],p=Z.last(r.knotsV);this.corners=[We.fromUv(l,d),We.fromUv(c,d),We.fromUv(c,p),We.fromUv(l,p)]}};x["verb.eval.AdaptiveRefinementNode"]=dr,dr.__name__=["verb","eval","AdaptiveRefinementNode"],dr.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),c=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),a!=null?(a.degen=p,a.point=c,a.normal=d,a):new We(c,d,[r,n],-1,p)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){case 0:return this.children[0].getEdgeCorners(0);case 1:return this.children[0].getEdgeCorners(1).concat(this.children[1].getEdgeCorners(1));case 2:return this.children[1].getEdgeCorners(2);case 3:return this.children[1].getEdgeCorners(3).concat(this.children[0].getEdgeCorners(3))}switch(r){case 0:return this.children[0].getEdgeCorners(0).concat(this.children[1].getEdgeCorners(0));case 1:return this.children[1].getEdgeCorners(1);case 2:return this.children[1].getEdgeCorners(2).concat(this.children[0].getEdgeCorners(2));case 3:return this.children[0].getEdgeCorners(3)}return null},getAllCorners:function(r){var n=[this.corners[r]];if(this.neighbors[r]==null)return n;var a=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,c=rt.EPSILON,d=this,p=[function(y){return y.uv[0]>d.corners[0].uv[0]+c&&y.uv[0]<d.corners[2].uv[0]-c},function(y){return y.uv[1]>d.corners[0].uv[1]+c&&y.uv[1]<d.corners[2].uv[1]-c}],_=a.filter(p[l]);return _.reverse(),n.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){case 0:this.midPoints[0]=this.evalSrf(this.u05,this.corners[0].uv[1]);break;case 1:this.midPoints[1]=this.evalSrf(this.corners[1].uv[0],this.v05);break;case 2:this.midPoints[2]=this.evalSrf(this.u05,this.corners[2].uv[1]);break;case 3:this.midPoints[3]=this.evalSrf(this.corners[0].uv[0],this.v05);break}return this.midPoints[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,n=0;n<r;){var a=n++;if(this.corners[a],this.corners[a].degen){var l=this.corners[(a+1)%r],c=this.corners[(a+3)%r];l.degen?this.corners[a].normal=c.normal:this.corners[a].normal=l.normal}}},shouldDivide:function(r,n){if(n<r.minDepth)return!0;if(n>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=m.normSquared(m.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return m.normSquared(m.sub(a.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new 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)],c=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new dr(this.srf,l),new dr(this.srf,c)],this.children[0].neighbors=[this.neighbors[0],this.neighbors[1],this.children[1],this.neighbors[3]],this.children[1].neighbors=[this.children[0],this.neighbors[1],this.neighbors[2],this.neighbors[3]]}else{var d=[this.corners[0],this.midpoint(0),this.midpoint(2),this.corners[3]],p=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new dr(this.srf,d),new dr(this.srf,p)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var A=y[_];++_,A._divide(r,n,!a)}}},triangulate:function(r){if(r==null&&(r=qe.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,a=this.children;n<a.length;){var l=a[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,a=[],l=[],c=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(c=p+1);for(var y=0,A=_.length;y<A;){var P=y++;a.push(_[P])}}for(var S=0;S<a.length;){var I=a[S];if(++S,I.id!=-1){l.push(I.id);continue}r.uvs.push(I.uv),r.points.push(I.point),r.normals.push(I.normal),I.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[c],l[(c+2)%k],l[(c+1)%k]]),r.faces.push([l[(c+4)%k],l[(c+3)%k],l[c]]),r.faces.push([l[c],l[(c+3)%k],l[(c+2)%k]]),r}var M=this.center();r.uvs.push(M.uv),r.points.push(M.point),r.normals.push(M.normal);for(var O=r.points.length-1,C=0,F=a.length-1;C<a.length;)r.faces.push([O,l[C],l[F]]),F=C++;return r},__class__:dr};var wt=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=wt,wt.__name__=["verb","exe","Dispatcher"],wt.init=function(){wt._init||(wt._workerPool=new Fr(wt.THREADS),wt._init=!0)},wt.dispatchMethod=function(r,n,a){wt.init();var l=new wn,c=function(d){l.resolve(d)};return wt._workerPool.addWork(ct.getClassName(r),n,a,c),new pe(l)};var Fr=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new xt,this._working=new xt,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(Fr.basePath+n)}catch(c){c instanceof Q&&(c=c.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 c=new Jr(r,n,a);this._callbacks.set(c.id,l),this._queue.push(c),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),a=[n.id],l=[this._pool.shift()];this._working.h[a[0]]=l[0],l[0].onmessage=function(c,d){return function(p){r._working.remove(d[0]),r._pool.push(c[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](p.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,a),l[0].postMessage(n)}},__class__: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 Nn=function(){};x["verb.geom.ICurve"]=Nn,Nn.__name__=["verb","geom","ICurve"],Nn.__interfaces__=[kn],Nn.prototype={__class__:Nn};var Ct=f.geom.NurbsCurve=function(r){this._data=He.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Ct,Ct.__name__=["verb","geom","NurbsCurve"],Ct.__interfaces__=[Nn],Ct.byKnotsControlPointsWeights=function(r,n,a,l){return new Ct(new Gt(r,n.slice(),N.homogenize1d(a,l)))},Ct.byPoints=function(r,n){return n==null&&(n=3),new Ct(pt.rationalInterpCurve(r,n))},Ct.__super__=Zt,Ct.prototype=T(Zt.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new Gt(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ct(this._data)},domain:function(){return new Pe(Z.first(this._data.knots),Z.last(this._data.knots))},transform:function(r){return new Ct(ft.rationalCurveTransform(this._data,r))},transformAsync:function(r){return wt.dispatchMethod(ft,"rationalCurveTransform",[this._data,r]).then(function(n){return new Ct(n)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return wt.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return wt.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),N.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),wt.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return vt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return wt.dispatchMethod(vt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return vt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return wt.dispatchMethod(vt,"rationalCurveClosestParam",[this._data,r])},length:function(){return vt.rationalCurveArcLength(this._data)},lengthAsync:function(){return wt.dispatchMethod(vt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return vt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return wt.dispatchMethod(vt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return vt.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return wt.dispatchMethod(vt,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return le.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return wt.dispatchMethod(le,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return le.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return wt.dispatchMethod(le,"rationalCurveByArcLength",[this._data,r])},split:function(r){return le.curveSplit(this._data,r).map(function(n){return new Ct(n)})},splitAsync:function(r){return wt.dispatchMethod(le,"curveSplit",[this._data,r]).then(function(n){return n.map(function(a){return new Ct(a)})})},reverse:function(){return new Ct(ft.curveReverse(this._data))},reverseAsync:function(){return wt.dispatchMethod(ft,"curveReverse",[this._data]).then(function(r){return new Ct(r)})},tessellate:function(r){return zt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return wt.dispatchMethod(zt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ct});var Br=f.geom.Arc=function(r,n,a,l,c,d){Ct.call(this,pt.arc(r,n,a,l,c,d)),this._center=r,this._xaxis=n,this._yaxis=a,this._radius=l,this._minAngle=c,this._maxAngle=d};x["verb.geom.Arc"]=Br,Br.__name__=["verb","geom","Arc"],Br.__super__=Ct,Br.prototype=T(Ct.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},radius:function(){return this._radius},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Br});var rs=f.geom.BezierCurve=function(r,n){Ct.call(this,pt.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=rs,rs.__name__=["verb","geom","BezierCurve"],rs.__super__=Ct,rs.prototype=T(Ct.prototype,{__class__:rs});var ns=f.geom.Circle=function(r,n,a,l){Br.call(this,r,n,a,l,0,Math.PI*2)};x["verb.geom.Circle"]=ns,ns.__name__=["verb","geom","Circle"],ns.__super__=Br,ns.prototype=T(Br.prototype,{__class__:ns});var Cn=function(){};x["verb.geom.ISurface"]=Cn,Cn.__name__=["verb","geom","ISurface"],Cn.__interfaces__=[kn],Cn.prototype={__class__:Cn};var It=f.geom.NurbsSurface=function(r){this._data=He.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=It,It.__name__=["verb","geom","NurbsSurface"],It.__interfaces__=[Cn],It.byKnotsControlPointsWeights=function(r,n,a,l,c,d){return new It(new te(r,n,a,l,N.homogenize2d(c,d)))},It.byCorners=function(r,n,a,l){return new It(pt.fourPointSurface(r,n,a,l))},It.byLoftingCurves=function(r,n){return new It(pt.loftedSurface(function(a){for(var l,c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.asNurbs())}return l=c,l}(),n))},It.__super__=Zt,It.prototype=T(Zt.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new te(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new It(this.asNurbs())},domainU:function(){return new Pe(Z.first(this._data.knotsU),Z.last(this._data.knotsU))},domainV:function(){return new Pe(Z.first(this._data.knotsV),Z.last(this._data.knotsV))},point:function(r,n){return N.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return wt.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return N.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return wt.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,a){return a==null&&(a=1),N.rationalSurfaceDerivatives(this._data,r,n,a)},derivativesAsync:function(r,n,a){return a==null&&(a=1),wt.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,n,a])},closestParam:function(r){return vt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return wt.dispatchMethod(vt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return vt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return wt.dispatchMethod(vt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),le.surfaceSplit(this._data,r,n).map(function(a){return new It(a)})},splitAsync:function(r,n){return n==null&&(n=!1),wt.dispatchMethod(le,"surfaceSplit",[this._data,r,n]).then(function(a){return a.map(function(l){return new It(l)})})},reverse:function(r){return r==null&&(r=!1),new It(ft.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),wt.dispatchMethod(ft,"surfaceReverse",[this._data,r]).then(function(n){return new It(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Ct(pt.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),wt.dispatchMethod(pt,"surfaceIsocurve",[this._data,r,n]).then(function(a){return new Ct(a)})},boundaries:function(r){return pt.surfaceBoundaryCurves(this._data).map(function(n){return new Ct(n)})},boundariesAsync:function(r){return wt.dispatchMethod(pt,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(a){return new Ct(a)})})},tessellate:function(r){return zt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return wt.dispatchMethod(zt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new It(ft.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return wt.dispatchMethod(ft,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new It(n)})},__class__:It});var ss=f.geom.ConicalSurface=function(r,n,a,l,c){It.call(this,pt.conicalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.ConicalSurface"]=ss,ss.__name__=["verb","geom","ConicalSurface"],ss.__super__=It,ss.prototype=T(It.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:ss});var is=f.geom.CylindricalSurface=function(r,n,a,l,c){It.call(this,pt.cylindricalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.CylindricalSurface"]=is,is.__name__=["verb","geom","CylindricalSurface"],is.__super__=It,is.prototype=T(It.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 Dr=f.geom.EllipseArc=function(r,n,a,l,c){Ct.call(this,pt.ellipseArc(r,n,a,l,c)),this._center=r,this._xaxis=n,this._yaxis=a,this._minAngle=l,this._maxAngle=c};x["verb.geom.EllipseArc"]=Dr,Dr.__name__=["verb","geom","EllipseArc"],Dr.__super__=Ct,Dr.prototype=T(Ct.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Dr});var as=f.geom.Ellipse=function(r,n,a){Dr.call(this,r,n,a,0,Math.PI*2)};x["verb.geom.Ellipse"]=as,as.__name__=["verb","geom","Ellipse"],as.__super__=Dr,as.prototype=T(Dr.prototype,{__class__:as});var os=f.geom.ExtrudedSurface=function(r,n){It.call(this,pt.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=os,os.__name__=["verb","geom","ExtrudedSurface"],os.__super__=It,os.prototype=T(It.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:os});var Ur=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Ur,Ur.__name__=["verb","geom","Intersect"],Ur.curves=function(r,n,a){return a==null&&(a=.001),lt.curves(r.asNurbs(),n.asNurbs(),a)},Ur.curvesAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"curves",[r.asNurbs(),n.asNurbs(),a])},Ur.curveAndSurface=function(r,n,a){return a==null&&(a=.001),lt.curveAndSurface(r.asNurbs(),n.asNurbs(),a)},Ur.curveAndSurfaceAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"curveAndSurface",[r.asNurbs(),n.asNurbs(),a])},Ur.surfaces=function(r,n,a){return a==null&&(a=.001),lt.surfaces(r.asNurbs(),n.asNurbs(),a).map(function(l){return new Ct(l)})},Ur.surfacesAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"surfaces",[r.asNurbs(),n.asNurbs(),a]).then(function(l){return l.map(function(c){return new Ct(c)})})};var ls=f.geom.Line=function(r,n){Ct.call(this,pt.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=ls,ls.__name__=["verb","geom","Line"],ls.__super__=Ct,ls.prototype=T(Ct.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:ls});var hs=f.geom.RevolvedSurface=function(r,n,a,l){It.call(this,pt.revolvedSurface(r.asNurbs(),n,a,l)),this._profile=r,this._center=n,this._axis=a,this._angle=l};x["verb.geom.RevolvedSurface"]=hs,hs.__name__=["verb","geom","RevolvedSurface"],hs.__super__=It,hs.prototype=T(It.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:hs});var cs=f.geom.SphericalSurface=function(r,n){It.call(this,pt.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__=It,cs.prototype=T(It.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:cs});var us=f.geom.SweptSurface=function(r,n){It.call(this,pt.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=us,us.__name__=["verb","geom","SweptSurface"],us.__super__=It,us.prototype=T(It.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:us});function Ke(r){return r instanceof Array?function(){return L.iter(r)}:typeof r.iterator=="function"?Ce(r,r.iterator):r.iterator}var Yi,Yc=0;function Ce(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=Yc++);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 qc=x.Int={__name__:["Int"]},Xc=x.Dynamic={__name__:["Dynamic"]},To=x.Float=Number;To.__name__=["Float"];var Mo=x.Bool=Boolean;Mo.__ename__=["Bool"];var No=x.Class={__name__:["Class"]},Co={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++;n[c]=r(this[c])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++,d=this[c];r(d)&&n.push(d)}return n});var qi={},Ws=w.ArrayBuffer||oe;Ws.prototype.slice==null&&(Ws.prototype.slice=oe.sliceImpl),w.DataView;var Xi=w.Uint8Array||sr._new;(function(r,n){if(r.setImmediate)return;var a=1,l={},c=!1,d=r.document,p;function _(R){return l[a]=y.apply(n,R),a++}function y(R){var U=[].slice.call(arguments,1);return function(){typeof R=="function"?R.apply(n,U):new Function(""+R)()}}function A(R){if(c)setTimeout(y(A,R),0);else{var U=l[R];if(U){c=!0;try{U()}finally{P(R),c=!1}}}}function P(R){delete l[R]}function S(){p=function(){var R=_(arguments);return process.nextTick(y(A,R)),R}}function I(){if(r.postMessage&&!r.importScripts){var R=!0,U=r.onmessage;return r.onmessage=function(){R=!1},r.postMessage("","*"),r.onmessage=U,R}}function k(){var R="setImmediate$"+Math.random()+"$",U=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(R)===0&&A(+V.data.slice(R.length))};r.addEventListener?r.addEventListener("message",U,!1):r.attachEvent("onmessage",U),p=function(){var V=_(arguments);return r.postMessage(R+V,"*"),V}}function M(){var R=new MessageChannel;R.port1.onmessage=function(U){var V=U.data;A(V)},p=function(){var U=_(arguments);return R.port2.postMessage(U),U}}function O(){var R=d.documentElement;p=function(){var U=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){A(U),V.onreadystatechange=null,R.removeChild(V),V=null},R.appendChild(V),U}}function C(){p=function(){var R=_(arguments);return setTimeout(y(A,R),0),R}}var F=Object.getPrototypeOf&&Object.getPrototypeOf(r);F=F&&F.setTimeout?F:r,{}.toString.call(r.process)==="[object process]"?S():I()?k():r.MessageChannel?M():d&&"onreadystatechange"in d.createElement("script")?O():C(),F.setImmediate=p,F.clearImmediate=P})(new Function("return this")()),qt.USE_CACHE=!1,qt.USE_ENUM_INDEX=!1,qt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Wt.DEFAULT_RESOLVER=ct,Wt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Ot.count=0,ae.i64tmp=function(r){var n,a=new Vt(0,0);return n=a,n}(),Nt.__toStr={}.toString,sr.BYTES_PER_ELEMENT=1,St.queue=new D,Ft.memo=new xt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",vt.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]],vt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],wt.THREADS=1,wt._init=!1,Fr.basePath="",Jr.uuid=0,Gs.main()}(typeof console<"u"?console:{log:function(){}},e,typeof u<"u"?u:typeof s<"u"?s:typeof self<"u"?self:this),e})})(mc);var p0=mc.exports;const Fn=m0(p0);class ma{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,o){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-o,this.c3=2*t-2*e+s+o}initCatmullRom(t,e,s,o,h){this.init(e,s,h*(s-t),h*(o-e))}initNonuniformCatmullRom(t,e,s,o,h,u,g){let b=(e-t)/h-(s-t)/(h+u)+(s-e)/u,f=(s-e)/u-(o-e)/(u+g)+(o-s)/g;b*=u,f*=u,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}}class pc extends Vs{constructor(t=[],e=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new $,this._px=new ma,this._py=new ma,this._pz=new ma,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 u=(h-(this._closed?0:1))*t;let g=Math.floor(u),b=u-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 T=this._curveType==="chordal"?.5:.25;let L=Math.pow(f.distanceToSquared(x),T),z=Math.pow(x.distanceToSquared(E),T),D=Math.pow(E.distanceToSquared(w),T);z<1e-4&&(z=1),L<1e-4&&(L=z),D<1e-4&&(D=z),this._px.initNonuniformCatmullRom(f.x,x.x,E.x,w.x,L,z,D),this._py.initNonuniformCatmullRom(f.y,x.y,E.y,w.y,L,z,D),this._pz.initNonuniformCatmullRom(f.z,x.z,E.z,w.z,L,z,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 Mt;const t=new Mt;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 ac(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=sc(e,t);break;case"SqrtChord":o=ic(e,t);break;case"Uniform":default:o=nc(e,t.length);break}const h=t.map(g=>({x:g[0],y:g[1],z:g[2]})),u=new Array(h.length).fill(1);return new yn(e,o,h,u)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:o}=this.getParameterRange();for(let h=0;h<=t;h++){const u=s+(o-s)*(h/t);e.push(this.point(u))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),o=this.point(e),h=this.point(s),u=o[0]-h[0],g=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(u*u+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 pc(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 $r extends Vs{constructor(t,e,s,o,h){super();const u=arguments.length;if(u<2||u>5)throw je.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let g,b=3,f=!1;if(u>=3&&(Array.isArray(s)?(g=s,u>=4&&(b=o||3),u>=5&&(f=h)):s!==void 0&&(b=s||3,u>=4&&(f=o))),s===void 0&&u>=4&&(b=o||3,u>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw je.ILLEGAL_PARAMETERS;const w=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Fn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,w,g)}else{if(this._fitPoints=t,this._knotParameterization=e,u>=3&&(this._degree=s||3),u>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw je.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Fn.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=Fn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Fn.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=Fn.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=Fn.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(),u=o[h],g=o[o.length-h-1],b=(g-u)/(t-1);for(let f=0;f<t;f++){const w=f===t-1?g:u+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],u=(o[o.length-4]-h)/(e-1);for(let g=0;g<e;g++){const b=h+g*u;s.push(t.point(b))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Mt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]={x:s[0],y:s[1],z:s[2]}}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new $r(t,e,s,!0)}}var gn=256,gc=[],il=256,Ks;for(;gn--;)gc[gn]=(gn+256).toString(16).substring(1);function g0(i){var t=0,e=11;if(!Ks||gn+e>il*2)for(Ks="",gn=0;t<il;t++)Ks+=gc[Math.random()*256|0];return Ks.substring(gn,gn+++e)}class Zr{constructor(t,e){t=t||{},Gn(t,{objectId:g0()}),this._attrs=new gl(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:Xa().workingDatabase}set database(t){this._database=t}close(){}}const Ka=class Ka extends Zr{constructor(){super(...arguments),this._layer="0",this._color=new Yr,this._lineType=Qs,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.typeName}get layer(){return this._layer}set layer(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Qs}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,h){}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}}}]}}get lineStyle(){var s;const t=this.getLineType(),e=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Qs){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==wl?si:this.lineType;return si}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}attachEntityInfo(t){t&&(t.objectId=this.objectId,t.ownerId=this.ownerId,t.layerName=this.layer,t.visible=this.visibility)}};Ka.typeName="Entity";let Ae=Ka;const $a=class $a extends Ae{};$a.typeName="Curve";let Se=$a;var Bn=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(Bn||{});const Za=class Za extends Se{constructor(t,e,s=0,o=!1,h=0,u=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 vn(f,o)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){return new Array}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};Za.typeName="2dPolyline";let li=Za;var fc=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(fc||{});const Qa=class Qa extends Ae{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 Mt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};Qa.typeName="2dVertex";let va=Qa;var Os=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(Os||{});const Ja=class Ja extends Se{constructor(t,e,s=!1){super(),this._polyType=t,this._geo=new vn(e,s)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){return new Array}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,0))),t.lines(e,this.lineStyle)}};Ja.typeName="3dPolyline";let hi=Ja;var _c=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(_c||{});const to=class to extends Ae{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 Mt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};to.typeName="3dVertex";let ba=to;const eo=class eo extends Se{constructor(t,e,s,o,h=$.Z_AXIS){super(),this._geo=new _n(t,e,s,o,h,$.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,this.lineStyle)}};eo.typeName="Arc";let ci=eo;const ro=class ro extends Ae{constructor(t){super(),this._blockName=t,this._position=new Y,this._rotation=0,this._normal=new $(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 Mt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const u of h)t.union(u.geometricExtents)}const s=new qr().setFromEuler(new cc(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=Hr.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_AXIS,this.rotation),new Xr().compose(this._position,t,this._scaleFactors)}};ro.typeName="BlockReference";let Fs=ro;const no=class no extends Se{constructor(t,e,s=$.Z_AXIS){super(),this._geo=new _n(t,e,0,ne,s,$.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,this.lineStyle)}};no.typeName="Circle";let ui=no;const so=class so extends Se{constructor(t,e,s,o,h,u,g){super(),this._geo=new Ui(t,e,s,o,h,u,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,this.lineStyle)}};so.typeName="Ellipse";let di=so;const io=class io extends Ae{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 Mt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._vertices.length;++e)t.push(this.getVertexAt(e));return t}draw(t){const e=this._vertices.length,s=new Float32Array(e*3),o=new Uint16Array(e*2);for(let h=0;h<e;h++)s[h*3]=this._vertices[h].x,s[h*3+1]=this._vertices[h].y,s[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(o[h*2]=h,o[h*2+1]=(h+1)%4);return t.lineSegments(s,3,o,this.lineStyle)}};io.typeName="Face";let mi=io;var yc=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(yc||{}),vc=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(vc||{});const ao=class ao extends Ae{constructor(){super(),this._elevation=0,this._geo=new Bi,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}};ao.typeName="Hatch";let pi=ao;var bc=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(bc||{});const oo=class oo extends Se{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 Mt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new $r(this._vertices,"Uniform"),this._updated=!1)}};oo.typeName="Leader";let gi=oo;const lo=class lo extends Se{constructor(t,e){super(),this._geo=new Kr(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,h){const u=this.startPoint,g=this.endPoint;switch(t){case pn.EndPoint:h.push(u),h.push(g);break;case pn.MidPoint:h.push(this.midPoint);break;case pn.Nearest:{const b=this._geo.project(s);h.push(b)}break;case pn.Perpendicular:{const b=this._geo.perpPoint(s);h.push(b)}break;case pn.Tangent:h.push(u);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,this.lineStyle)}};lo.typeName="Line";let fi=lo;var Ga=(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))(Ga||{}),Mr=(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))(Mr||{}),we=(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))(we||{}),ja=(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))(ja||{}),Wa=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(Wa||{}),Ha=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Ha||{});class Gi{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 _e;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new _e;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Gi;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}const ho=class ho extends Ae{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=we.TopLeft,this._direction=new $(1,0,0),this._drawingDirection=Mr.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Mt}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:we[1],value:1},{label:we[2],value:2},{label:we[3],value:3},{label:we[4],value:4},{label:we[5],value:5},{label:we[6],value:6},{label:we[7],value:7},{label:we[8],value:8},{label:we[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Mr[1],value:1},{label:Mr[2],value:2},{label:Mr[3],value:3},{label:Mr[4],value:4},{label:Mr[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(),color:this.rgbColor};return t.mtext(s,o,e)}};ho.typeName="MText";let _i=ho;const co=class co extends Se{constructor(t,e,s,o,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u<2||u>5)throw je.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new $r(t,e,s,o):this._geo=new $r(t,e,s,o,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}};co.typeName="Spline";let Bs=co;const f0=new $,uo=class uo extends Fs{constructor(t,e,s){super(t),this._attachmentPoint=we.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Mt}draw(t){let e=0,s=0;const o=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let u=0;for(let E=0;E<=this.numRows;E++){e-=E>0?this.rowHeight(E-1):0,s=0;for(let T=0;T<=this.numColumns;T++)s+=T>0?this.columnWidth(T-1):0,h[u++]=s,h[u++]=e,h[u++]=0}const g=[],b=new Array(this.numRows*this.numColumns).fill(!1);s=0,u=0;let f=0;for(let E=0;E<this.numColumns;E++){s+=E>0?this.columnWidth(E-1):0,e=0;for(let T=0;T<this.numRows;T++){e+=T>0?this.rowHeight(T-1):0;const L=this.cell(T*this.numColumns+E);if(f=T*this.numColumns+E,L&&!b[f]){const z=L.borderWidth??1,D=L.borderHeight??1;this.fillVisited(b,f,this.numColumns,z,D),o[u++]=E+T*(this.numColumns+1),o[u++]=E+T*(this.numColumns+1)+z;const B=h[o[u-1]*3]-s,dt=E+(T+D)*(this.numColumns+1)+z;E+z==this.numColumns&&(o[u++]=E+T*(this.numColumns+1)+z,o[u++]=dt);const yt=-h[dt*3+1]-e;if(T+D==this.numRows&&(o[u++]=E+(T+D)*(this.numColumns+1)+D,o[u++]=E+(T+D)*(this.numColumns+1)),o[u++]=E+(T+D)*(this.numColumns+1),o[u++]=E+T*(this.numColumns+1),L.text){const ot=L.attachmentPoint||this.attachmentPoint||we.MiddleCenter,W=this.getTableTextOffset(ot,B,yt),ct={text:L.text,height:L.textHeight,width:B,position:f0.set(s,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ot},st={...this.getTextStyle(L),color:this.color.color};g.push(t.mtext(ct,st))}}}}g.push(t.lineSegments(h,3,o,this.lineStyle));const w=t.group(g),x=new qr;return x.setFromAxisAngle($.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 u=0;u<o;++u)for(let g=0;g<h;++g)t[e+u+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 $;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}};uo.typeName="Table";let yi=uo;const al=new Xr;var xc=(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))(xc||{}),wc=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(wc||{});const mo=class mo extends Ae{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 Mt}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:Mr.BOTTOM_TO_TOP,attachmentPoint:we.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return t.mtext(s,o,e)}};mo.typeName="Text";let vi=mo;const po=class po extends Se{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 Mt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new vn(this._vertices,!0),s=new Bi;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};po.typeName="Trace";let bi=po;const go=class go extends Se{constructor(){super(),this._elevation=0,this._geo=new vn}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 u=o<0?void 0:o,g=h<0?void 0:h,b={x:e.x,y:e.y,bulge:s,startWidth:u,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 Mt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};go.typeName="Polyline";let xi=go;const fo=class fo extends Ae{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 Mt().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,color:this.rgbColor})}};fo.typeName="Point";let wi=fo;var Ac=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(Ac||{}),Sc=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(Sc||{});const _o=class _o extends Ae{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new Y,this._scale=new $t(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Mt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,o=new _e;o.setFromPoints(this._clipBoundary);const h=new Tt;h.setX(this._position.x-o.min.x*e),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(u=>{const g=u.x*e+h.x,b=u.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}};_o.typeName="RasterImage";let Ds=_o;const ol=new Tt,$s=new Tt,yo=class yo extends Se{constructor(){super(),this._basePoint=new Y,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Mt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}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,this.lineStyle)}};yo.typeName="Ray";let Ai=yo;const vo=class vo extends Ae{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 Mt}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport(),s=t.group(this.createViewportRect(e,t));return this.attachEntityInfo(s),s}}toGiViewport(){const t=new Gi;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)],this.lineStyle)),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)],this.lineStyle)),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)],this.lineStyle)),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)],this.lineStyle)),s}};vo.typeName="Viewport";let Si=vo;const bo=class bo extends Ds{draw(t){const e=this.boundaryPath(),s=new Bi;return s.add(new vn(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};bo.typeName="Wipeout";let Pi=bo;const xo=class xo extends Se{constructor(){super(),this._basePoint=new Y,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Mt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}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,this.lineStyle)}};xo.typeName="Xline";let Ii=xo;var Pc=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(Pc||{});const wo=class wo extends Ae{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 $(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 Vn),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=Hr.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 Hr.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Hr.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():Ga.Closed}};wo.typeName="Dimension";let Nr=wo;const Ao=class Ao extends Nr{constructor(t,e,s,o,h=null,u=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=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Mt}};Ao.typeName="3PointAngularDimension";let Ei=Ao;const So=class So extends Nr{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 Mt}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),u=new Kr(o,h);return t.push(u),e.endPoint=o,this.adjustExtensionLine(e),t.push(e),s.endPoint=h,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Kr(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,o=t.endPoint,h=new $().subVectors(o,s).normalize(),g=new $().subVectors(e,s).dot(h),b=new $().copy(h).multiplyScalar(g);return new $().addVectors(s,b)}};So.typeName="AlignedDimension";let ki=So;const Po=class Po extends Nr{constructor(t,e,s,o,h=null,u=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=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Mt}};Po.typeName="ArcDimension";let xa=Po;const Io=class Io extends Nr{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 Mt}drawLines(t,e){const s=[],o=e.length;return o==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{s.push(this.drawLine(t,h))}),s}drawLine(t,e,s){if(s){const o=[e.startPoint,e.endPoint];return t.lines(o,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;t.sort((s,o)=>{const h=e(s.startPoint,o.startPoint);return h!==0?h:e(s.endPoint,o.endPoint)})}};Io.typeName="DiametricDimension";let Ti=Io;const Eo=class Eo extends Nr{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 Mt}get arrowLineCount(){return 0}};Eo.typeName="OrdinateDimension";let Mi=Eo;const ko=class ko extends Nr{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 Mt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};ko.typeName="RadialDimension";let Ni=ko;class ll{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertFace(t){const e=new mi;return t.vertices.forEach((s,o)=>e.setVertexAt(o,s)),e}convertArc(t){return new ci(t.center,t.radius,Et.degToRad(t.startAngle),Et.degToRad(t.endAngle),t.extrusionDirection??$.Z_AXIS)}convertCirle(t){return new ui(t.center,t.radius,t.extrusionDirection??$.Z_AXIS)}convertEllipse(t){const e=new $(t.majorAxisEndPoint),s=e.length();return new di(t.center,t.extrusionDirection??$.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 Bs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new Bs(e,"Uniform",t.degree,!!(t.flag&1))}}catch(e){console.log(`Failed to convert spline with error: ${e}`)}return null}convertPoint(t){const e=new 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(u=>{u.flag&fd.SPLINE_CONTROL_POINT||(o.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0))}),s){let u=Os.SimplePoly;return t.flag&4&&(t.smoothType==Ys.CUBIC?u=Os.CubicSplinePoly:t.smoothType==Ys.QUADRATIC&&(u=Os.QuadSplinePoly)),new hi(u,o,e)}else{let u=Bn.SimplePoly;return t.flag&2?u=Bn.FitCurvePoly:t.flag&4&&(t.smoothType==Ys.CUBIC?u=Bn.CubicSplinePoly:t.smoothType==Ys.QUADRATIC&&(u=Bn.QuadSplinePoly)),new li(u,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 pi;return(o=t.definitionLines)==null||o.forEach(h=>{e.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new vn;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 dc;g.edges.forEach(f=>{if(f.type==1){const w=f;b.add(new Vi(w.start,w.end))}else if(f.type==2){const w=f;b.add(new Un(w.center,w.radius,Et.degToRad(w.startAngle||0),Et.degToRad(w.endAngle||0),!w.isCCW))}else if(f.type==3){const w=f;new $t().subVectors(w.end,w.center);const E=Math.sqrt(Math.pow(w.end.x,2)+Math.pow(w.end.y,2)),T=E*w.lengthOfMinorAxis;let L=Et.degToRad(w.startAngle||0),z=Et.degToRad(w.endAngle||0);const D=Math.atan2(w.end.y,w.end.x);w.isCCW||(L=Math.PI*2-L,z=Math.PI*2-z),b.add(new Di({...w.center,z:0},E,T,L,z,!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 T=w.controlPoints.map(L=>(L.weight==null&&(E=!1),L.weight||1));b.add(new $r(x,w.knots,E?T:void 0))}else if(w.numberOfFitData>0){const x=w.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new $r(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=Et.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new _i;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=Et.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new $(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=Et.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 Mi(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 Ti(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 Ds;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 Pi;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 Ii;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?Et.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const s=t.length;let o=0;if(s/2==e?o=2:s/3==e&&(o=3),o==0)return;const h=[];for(let u=0,g=s/o;u<g;++u)h.push({x:t[u*o],y:t[u*o+1],z:o==3?t[u*o+2]:0});return h}}class ji extends Zr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _e,this._extents=new Mt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class Ya 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 zi(this._recordsByName)}}class Ic extends Ya{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 Ec extends Zr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class _0{convertLayout(t,e){var o;const s=new ji;return s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,(o=e.tables.BLOCK_RECORD)==null||o.entries.some(h=>h.layoutObjects===t.handle?(s.blockTableRecordId=h.handle,!0):!1),s.limits.min.copy(t.minLimit),s.limits.max.copy(t.maxLimit),s.extents.min.copy(t.minExtent),s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new Ec;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class kc{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,t,e||this.config.workerUrl)}catch(h){const u=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:u}}}async executeInWorker(t,e,s){const o=Date.now();return new Promise((h,u)=>{const g=this.getAvailableWorker(s),b=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(g),u(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),u(x)},timeout:b});const f=x=>{const{id:E,success:T,data:L,error:z}=x.data;if(E!==t)return;this.cleanupTask(t);const D=Date.now()-o;h(T?{success:!0,data:L,duration:D}:{success:!1,error:z,duration:D})},w=x=>{this.cleanupTask(t),u(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 Tc{constructor(t){this.framework=new kc(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Mc(i){return new Tc(i)}class y0{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 Nc extends Ea{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t){if(this.config.useWorker&&this.config.parserWorkerUrl){const e=Mc({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await e.execute(t);if(e.destroy(),s.success)return{model:s.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${s.error}'`)}else return{model:new i0().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,s=u=>{if(u){const g=u.lastIndexOf(".");return g>=0?u.substring(0,g).toLowerCase():u.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(u=>{const g=[];if(u.font){const b=s(u.font);b&&g.push(b)}if(u.bigFont){const b=s(u.bigFont);b&&g.push(b)}if(u.extendedFont){const b=s(u.extendedFont);b&&g.push(b)}e.set(u.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(u=>{if(u.type=="MTEXT"){const g=u;[...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(u.type=="TEXT"){const g=u,b=s.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(u.type=="INSERT"){const b=e[u.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,s,o)}})}async processEntities(t,e,s,o,h){const u=new ll;let g=t.entities;const b=g.length,f=new Aa(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 T=[],L=x<E?g[x].type:"";for(let z=x;z<E;z++){const D=g[z],B=u.convert(D);B&&(this.config.convertByEntityType&&D.type!==L&&(w.appendEntity(T),T=[],L=D.type),T.push(B))}if(w.appendEntity(T),h){let z=o.value+E/b*(100-o.value);z>100&&(z=100),await h(z,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e){const s=new ll,o=t.length,h=[];for(let u=0;u<o;u++){const g=t[u],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 u=e.tables.blockTable.getAt(h.name);u||(u=new Ge,u.objectId=h.handle,u.name=o,u.origin.copy(h.position),e.tables.blockTable.add(u)),h.entities&&this.processEntitiesInBlock(h.entities,u)}}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 u=new Ge;u.objectId=h.handle,u.name=h.name,u.layoutId=h.layoutObjects,e.tables.blockTable.add(u)}))}processObjects(t,e){const s=t.objects.byName,o=new _0;if("LAYOUT"in s){const h=e.dictionaries.layouts;s.LAYOUT.forEach(u=>{const g=o.convertLayout(u,t);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in s){const h=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(u=>{const g=o.convertImageDef(u);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(u=>{const g=new Wc;this.processCommonTableEntryAttrs(u,g),u.circleSides&&(g.circleSides=u.circleSides),g.standardFlag=u.standardFlag,g.center.copy(u.center),g.lowerLeftCorner.copy(u.lowerLeftCorner),g.upperRightCorner.copy(u.upperRightCorner),u.snapBasePoint&&g.snapBase.copy(u.snapBasePoint),u.snapRotationAngle&&(g.snapAngle=u.snapRotationAngle),u.snapSpacing&&g.snapIncrements.copy(u.snapSpacing),u.majorGridLines&&(g.gridMajor=u.majorGridLines),u.gridSpacing&&g.gridIncrements.copy(u.gridSpacing),u.backgroundObjectId&&(g.backgroundObjectId=u.backgroundObjectId),g.gsView.center.copy(u.center),g.gsView.viewDirectionFromTarget.copy(u.viewDirectionFromTarget),g.gsView.viewTarget.copy(u.viewTarget),u.lensLength&&(g.gsView.lensLength=u.lensLength),u.frontClippingPlane&&(g.gsView.frontClippingPlane=u.frontClippingPlane),u.backClippingPlane&&(g.gsView.backClippingPlane=u.backClippingPlane),u.viewHeight&&(g.gsView.viewHeight=u.viewHeight),u.viewTwistAngle&&(g.gsView.viewTwistAngle=u.viewTwistAngle),u.frozenLayers&&(g.gsView.frozenLayers=u.frozenLayers),u.styleSheet&&(g.gsView.styleSheet=u.styleSheet),u.renderMode&&(g.gsView.renderMode=u.renderMode),u.viewMode&&(g.gsView.viewMode=u.viewMode),u.ucsIconSetting&&(g.gsView.ucsIconSetting=u.ucsIconSetting),u.ucsOrigin&&g.gsView.ucsOrigin.copy(u.ucsOrigin),u.ucsXAxis&&g.gsView.ucsXAxis.copy(u.ucsXAxis),u.ucsYAxis&&g.gsView.ucsYAxis.copy(u.ucsYAxis),u.orthographicType&&(g.gsView.orthographicType=u.orthographicType),u.shadePlotSetting&&(g.gsView.shadePlotSetting=u.shadePlotSetting),u.shadePlotObjectId&&(g.gsView.shadePlotObjectId=u.shadePlotObjectId),u.visualStyleObjectId&&(g.gsView.visualStyleObjectId=u.visualStyleObjectId),u.isDefaultLightingOn&&(g.gsView.isDefaultLightingOn=u.isDefaultLightingOn),u.defaultLightingType&&(g.gsView.defaultLightingType=u.defaultLightingType),u.brightness&&(g.gsView.brightness=u.brightness),u.contrast&&(g.gsView.contrast=u.contrast),u.ambientColor&&(g.gsView.ambientColor=u.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(u=>{const g=new Yr;g.colorIndex=u.colorIndex;const b=new Wi({name:u.name,standardFlags:u.standardFlag,linetype:u.lineType,lineWeight:u.lineweight,isOff:u.colorIndex<0,color:g,isPlottable:u.isPlotting});this.processCommonTableEntryAttrs(u,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(u=>{const g=new Rs(u);this.processCommonTableEntryAttrs(u,g),g.name=u.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 u=new qa(h);this.processCommonTableEntryAttrs(h,u),e.tables.textStyleTable.add(u)})}processDimStyles(t,e){var o;const s=(o=t.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const u={name:h.name,ownerId:h.ownerObjectId,dimpost:h.DIMPOST||"",dimapost:h.DIMAPOST||"",dimscale:h.DIMSCALE,dimasz:h.DIMASZ,dimexo:h.DIMEXO,dimdli:h.DIMDLI,dimexe:h.DIMEXE,dimrnd:h.DIMRND,dimdle:h.DIMDLE,dimtp:h.DIMTP,dimtm:h.DIMTM,dimtxt:h.DIMTXT,dimcen:h.DIMCEN,dimtsz:h.DIMTSZ,dimaltf:h.DIMALTF,dimlfac:h.DIMLFAC,dimtvp:h.DIMTVP,dimtfac:h.DIMTFAC,dimgap:h.DIMGAP,dimaltrnd:h.DIMALTRND,dimtol:h.DIMTOL==null||h.DIMTOL==0?0:1,dimlim:h.DIMLIM==null||h.DIMLIM==0?0:1,dimtih:h.DIMTIH==null||h.DIMTIH==0?0:1,dimtoh:h.DIMTOH==null||h.DIMTOH==0?0:1,dimse1:h.DIMSE1==null||h.DIMSE1==0?0:1,dimse2:h.DIMSE2==null||h.DIMSE2==0?0:1,dimtad:h.DIMTAD,dimzin:h.DIMZIN,dimazin:h.DIMAZIN,dimalt:h.DIMALT,dimaltd:h.DIMALTD,dimtofl:h.DIMTOFL,dimsah:h.DIMSAH,dimtix:h.DIMTIX,dimsoxd:h.DIMSOXD,dimclrd:h.DIMCLRD,dimclre:h.DIMCLRE,dimclrt:h.DIMCLRT,dimadec:h.DIMADEC||0,dimunit:h.DIMUNIT||2,dimdec:h.DIMDEC,dimtdec:h.DIMTDEC,dimaltu:h.DIMALTU,dimalttd:h.DIMALTTD,dimaunit:h.DIMAUNIT,dimfrac:h.DIMFRAC,dimlunit:h.DIMLUNIT,dimdsep:h.DIMDSEP,dimtmove:h.DIMTMOVE||0,dimjust:h.DIMJUST,dimsd1:h.DIMSD1,dimsd2:h.DIMSD2,dimtolj:h.DIMTOLJ,dimtzin:h.DIMTZIN,dimaltz:h.DIMALTZ,dimalttz:h.DIMALTTZ,dimfit:h.DIMFIT||0,dimupt:h.DIMUPT,dimatfit:h.DIMATFIT,dimtxsty:h.DIMTXSTY||"Standard",dimldrblk:h.DIMLDRBLK||"",dimblk:h.DIMBLK||"",dimblk1:h.DIMBLK1||"",dimblk2:h.DIMBLK2||"",dimlwd:h.DIMLWD,dimlwe:h.DIMLWE},g=new Vn(u);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 Cc extends Ea{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,s,o,h){let u=t.tables.blockTable.modelSpace.newIterator().toArray();const g=u.length,b=new Aa(g,100-o.value,s);this.config.convertByEntityType&&(u=this.groupAndFlattenByType(u));const f=e.tables.blockTable.modelSpace;await b.processChunk(async(w,x)=>{let E=[],T=w<x?u[w].type:"";for(let L=w;L<x;L++){const z=u[L];this.config.convertByEntityType&&z.type!==T&&(this.triggerEvents(f,E),E=[],T=z.type),E.push(z)}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 hr{constructor(){this.events={registered:new ie,unregistered:new ie},this._converters=new Map,this.register("dxf",new Nc)}static createInstance(){return hr._instance==null&&(hr._instance=new hr),this._instance}static get instance(){return hr._instance||(hr._instance=new hr),hr._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 bn extends Zr{constructor(t,e){t=t||{},Gn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const Wr=class Wr extends bn{static isModelSapceName(t){return t.toLowerCase()==Wr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(Wr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new Y,this._layoutId="",this._entities=new Map}get isModelSapce(){return Wr.isModelSapceName(this.name)}get isPaperSapce(){return Wr.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 zi(this._entities)}getIdAt(t){return this._entities.get(t)}};Wr.MODEL_SPACE_NAME="*MODEL_SPACE",Wr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let Ge=Wr;class xn 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 zi(this._recordsByName)}normalizeName(t){return t}}class Lc extends xn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(Ge.MODEL_SPACE_NAME);return t||(t=new Ge,t.name=Ge.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(Ge.isModelSapceName(t))e=Ge.MODEL_SPACE_NAME;else if(Ge.isPaperSapceName(t)){const s=Ge.PAPER_SPACE_NAME_PREFIX,o=t.substring(s.length);e=s+o}return e}}class Oc extends xn{constructor(t){super(t)}}class Wi extends bn{constructor(t,e){t=t||{},Gn(t,{color:new Yr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class zc extends xn{constructor(t){super(t);const e=new Yr;e.color=16777215;const s=new Wi({name:"0",standardFlags:0,linetype:si,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 Rc extends xn{constructor(t){super(t)}}class Fc extends xn{constructor(t){super(t)}get fonts(){const t=new Set,e=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const u=o.substring(0,h).toLowerCase();t.add(u)}else t.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)e(o.fileName),e(o.bigFontFileName);return Array.from(t)}}class Bc extends xn{constructor(t){super(t)}}class Rs extends bn{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class qa extends bn{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}var Dc=(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))(Dc||{}),Uc=(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))(Uc||{}),Vc=(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))(Vc||{}),Gc=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(Gc||{}),jc=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(jc||{});const Li=class Li extends bn{constructor(t,e){t=t||{},Gn(t,Li.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)}};Li.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 Vn=Li;class v0 extends Zr{constructor(){super(),this.events={dictObjetSet:new ie,dictObjectErased:new ie,entityAppended:new ie,entityModified:new ie,layerAppended:new ie,layerModified:new ie,layerErased:new ie,openProgress:new ie,headerSysVarChanged:new ie},this._version=new ai("AC1014"),this._angBase=0,this._angDir=0,this._aunits=Sa.DecimalDegrees,this._celtscale=1,this._cecolor=new Yr,this._extents=new Mt,this._insunits=Ia.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Lc(this),dimStyleTable:new Oc(this),linetypeTable:new Rc(this),textStyleTable:new Fc(this),layerTable:new zc(this),viewportTable:new Bc(this)},this._dictionaries={layouts:new Ic(this),imageDefs:new Ya(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 ai(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=hr.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,u,g,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:u,subStageStatus:g,data:b}),e&&e.fontLoader&&u=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var T;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 u=0;const g=(T=s.body)==null?void 0:T.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:L,value:z}=await g.read();if(L)break;if(b.push(z),u+=z.length,h!==null){const D=Math.round(u/h*100);this.events.openProgress.dispatch({database:this,percentage:D,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(u);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 Cc(this).read(null,this,500,async(e,s,o,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:s,subStageStatus:o,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){if(t.layer){const e=new Yr;e.colorIndex=7,this._tables.layerTable.add(new Wi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(t.lineType&&(this._tables.linetypeTable.add(new Rs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Rs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Rs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))),t.textStyle&&this._tables.textStyleTable.add(new qa({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),t.dimStyle&&this._tables.dimStyleTable.add(new Vn({name:"Standard",dimtxsty:"Standard"})),t.layout){const e=new ji;e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=this._tables.blockTable.modelSpace.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this._dictionaries.layouts.setAt(e.layoutName,e),this._tables.blockTable.modelSpace.layoutId=e.objectId}}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._dictionaries.layouts.removeAll(),this._currentSpace=void 0,this._extents.makeEmpty()}triggerHeaderSysVarChangedEvent(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}getFileNameFromUri(t){try{const s=new URL(t).pathname.split("/");return s[s.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}const b0={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:ja.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:Wa.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Ha.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Wc extends bn{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=b0}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 Hc{constructor(){this.events={layoutCreated:new ie,layoutRemoved:new ie,layoutRenamed:new ie,layoutSwitched:new ie}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(o,s)}renameLayout(t,e,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return h?(h.layoutName=e,this.events.layoutRenamed.dispatch({layout:h,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).dictionaries.layouts,o=s.getAt(t);let h=!1;return o&&(h=s.remove(t),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(t,e){const s=this.getWorkingDatabase(e),o=new ji;o.layoutName=t,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new Ge;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(t,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Xa().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function Xa(){return Ci.instance}const Oi=class Oi{constructor(){this._workingDatabase=null,this._layoutManager=new Hc}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}};Oi.instance=new Oi;let Ci=Oi;exports.AcCmColor=Yr;exports.AcCmErrors=je;exports.AcCmEventDispatcher=hu;exports.AcCmEventManager=ie;exports.AcCmLoader=_u;exports.AcCmLoadingManager=vl;exports.AcCmObject=gl;exports.AcCmPerformanceCollector=wa;exports.AcCmTask=_l;exports.AcCmTaskScheduler=yl;exports.AcDb2dPolyline=li;exports.AcDb2dVertex=va;exports.AcDb2dVertexType=fc;exports.AcDb3PointAngularDimension=Ei;exports.AcDb3dPolyline=hi;exports.AcDb3dVertex=ba;exports.AcDb3dVertexType=_c;exports.AcDbAlignedDimension=ki;exports.AcDbAngleUnits=Sa;exports.AcDbArc=ci;exports.AcDbArcDimension=xa;exports.AcDbBaseWorker=y0;exports.AcDbBatchProcessing=Aa;exports.AcDbBlockReference=Fs;exports.AcDbBlockTable=Lc;exports.AcDbBlockTableRecord=Ge;exports.AcDbCircle=ui;exports.AcDbCodePage=Pa;exports.AcDbCurve=Se;exports.AcDbDatabase=v0;exports.AcDbDatabaseConverter=Ea;exports.AcDbDatabaseConverterManager=hr;exports.AcDbDiametricDimension=Ti;exports.AcDbDictionary=Ya;exports.AcDbDimArrowType=Al;exports.AcDbDimStyleTable=Oc;exports.AcDbDimStyleTableRecord=Vn;exports.AcDbDimTextHorizontal=Dc;exports.AcDbDimTextVertical=Uc;exports.AcDbDimVerticalJustification=jc;exports.AcDbDimZeroSuppression=Vc;exports.AcDbDimZeroSuppressionAngular=Gc;exports.AcDbDimension=Nr;exports.AcDbDwgVersion=ai;exports.AcDbDxfConverter=Nc;exports.AcDbEllipse=di;exports.AcDbEntity=Ae;exports.AcDbFace=mi;exports.AcDbFileType=zs;exports.AcDbHatch=pi;exports.AcDbHatchPatternType=yc;exports.AcDbHatchStyle=vc;exports.AcDbHostApplicationServices=Ci;exports.AcDbLayerTable=zc;exports.AcDbLayerTableRecord=Wi;exports.AcDbLayout=ji;exports.AcDbLayoutDictionary=Ic;exports.AcDbLayoutManager=Hc;exports.AcDbLeader=gi;exports.AcDbLeaderAnnotationType=bc;exports.AcDbLine=fi;exports.AcDbLineSpacingStyle=Pc;exports.AcDbLinetypeTable=Rc;exports.AcDbLinetypeTableRecord=Rs;exports.AcDbMText=_i;exports.AcDbObject=Zr;exports.AcDbObjectIterator=zi;exports.AcDbOrdinateDimension=Mi;exports.AcDbOsnapMode=pn;exports.AcDbPoint=wi;exports.AcDbPoly2dType=Bn;exports.AcDbPoly3dType=Os;exports.AcDbPolyline=xi;exports.AcDbRadialDimension=Ni;exports.AcDbRasterImage=Ds;exports.AcDbRasterImageClipBoundaryType=Ac;exports.AcDbRasterImageDef=Ec;exports.AcDbRasterImageImageDisplayOpt=Sc;exports.AcDbRay=Ai;exports.AcDbRegenerator=Cc;exports.AcDbRenderingCache=Hr;exports.AcDbSpline=Bs;exports.AcDbSymbolTable=xn;exports.AcDbSymbolTableRecord=bn;exports.AcDbTable=yi;exports.AcDbText=vi;exports.AcDbTextHorizontalMode=xc;exports.AcDbTextStyleTable=Fc;exports.AcDbTextStyleTableRecord=qa;exports.AcDbTextVerticalMode=wc;exports.AcDbTrace=bi;exports.AcDbUnitsValue=Ia;exports.AcDbViewport=Si;exports.AcDbViewportTable=Bc;exports.AcDbViewportTableRecord=Wc;exports.AcDbWipeout=Pi;exports.AcDbWorkerApi=Tc;exports.AcDbWorkerManager=kc;exports.AcDbXline=Ii;exports.AcGeArea2d=Bi;exports.AcGeBox2d=_e;exports.AcGeBox3d=Mt;exports.AcGeCatmullRomCurve3d=pc;exports.AcGeCircArc2d=Un;exports.AcGeCircArc3d=_n;exports.AcGeCurve2d=Wn;exports.AcGeEllipseArc2d=Di;exports.AcGeEllipseArc3d=Ui;exports.AcGeEuler=cc;exports.AcGeGeometryUtil=rc;exports.AcGeLine2d=Vi;exports.AcGeLine3d=Kr;exports.AcGeLoop2d=dc;exports.AcGeMathUtil=Et;exports.AcGeMatrix2d=Fi;exports.AcGeMatrix3d=Xr;exports.AcGeNurbsCurve=yn;exports.AcGePlane=Us;exports.AcGePoint2d=Tt;exports.AcGePoint3d=Y;exports.AcGePolyline2d=vn;exports.AcGeQuaternion=qr;exports.AcGeShape2d=Va;exports.AcGeSpline3d=$r;exports.AcGeTol=Ba;exports.AcGeVector2d=$t;exports.AcGeVector3d=$;exports.AcGiArrowType=Ga;exports.AcGiDefaultLightingType=Ha;exports.AcGiMTextAttachmentPoint=we;exports.AcGiMTextFlowDirection=Mr;exports.AcGiOrthographicType=Wa;exports.AcGiRenderMode=ja;exports.AcGiViewport=Gi;exports.AcTrStringUtil=fu;exports.ByBlock=wl;exports.ByLayer=Qs;exports.DEBUG_MODE=pu;exports.DEFAULT_LINE_TYPE=si;exports.DEFAULT_TOL=Da;exports.DEG2RAD=Ca;exports.DefaultLoadingManager=bl;exports.FLOAT_TOL=mn;exports.ORIGIN_POINT_2D=a0;exports.ORIGIN_POINT_3D=Fa;exports.RAD2DEG=La;exports.TAU=ne;exports.acdbHostApplicationServices=Xa;exports.basisFunction=oi;exports.calculateCurveLength=ac;exports.ceilPowerOfTwo=Xh;exports.clamp=Tr;exports.clone=Ts;exports.createWorkerApi=Mc;exports.damp=Fh;exports.defaults=Gn;exports.degToRad=Hh;exports.dwgCodePageToEncoding=xl;exports.euclideanModulo=Oa;exports.evaluateNurbsPoint=Ls;exports.floorPowerOfTwo=Kh;exports.generateChordKnots=sc;exports.generateSqrtChordKnots=ic;exports.generateUUID=Oh;exports.generateUniformKnots=nc;exports.has=ml;exports.intPartLength=Ra;exports.interpolateControlPoints=o0;exports.inverseLerp=Rh;exports.isBetween=$h;exports.isBetweenAngle=Zh;exports.isEmpty=pl;exports.isEqual=Dn;exports.isImperialUnits=bu;exports.isMetricUnits=vu;exports.isPointInPolygon=Ua;exports.isPolygonIntersect=ec;exports.isPowerOfTwo=qh;exports.lerp=za;exports.log=Ns;exports.mapLinear=zh;exports.normalizeAngle=Cs;exports.pingpong=Bh;exports.radToDeg=Yh;exports.randFloat=Gh;exports.randFloatSpread=jh;exports.randInt=Vh;exports.relativeEps=Qh;exports.seededRandom=Wh;exports.setLogLevel=gu;exports.smootherstep=Uh;exports.smoothstep=Dh;
5
+ `+n+"}",M;case"function":return"<function>";case"string":return r;default:return String(r)}},Nt.__interfLoop=function(r,n){if(r==null)return!1;if(r==n)return!0;var a=r.__interfaces__;if(a!=null)for(var l=0,c=a.length;l<c;){var d=l++,p=a[d];if(p==n||Nt.__interfLoop(p,n))return!0}return Nt.__interfLoop(r.__super__,n)},Nt.__instanceof=function(r,n){if(n==null)return!1;switch(n){case qc:return(r|0)===r;case To:return typeof r=="number";case Mo:return typeof r=="boolean";case String:return typeof r=="string";case Array:return r instanceof Array&&r.__enum__==null;case Xc:return!0;default:if(r!=null){if(typeof n=="function"){if(r instanceof n||Nt.__interfLoop(Nt.getClass(r),n))return!0}else if(typeof n=="object"&&Nt.__isNativeObj(n)&&r instanceof n)return!0}else return!1;return n==No&&r.__name__!=null||n==Co&&r.__ename__!=null?!0:r.__enum__==n}},Nt.__nativeClassName=function(r){var n=Nt.__toStr.call(r).slice(8,-1);return n=="Object"||n=="Function"||n=="Math"||n=="JSON"?null:n},Nt.__isNativeObj=function(r){return Nt.__nativeClassName(r)!=null},Nt.__resolveNativeClass=function(r){return w[r]};var oe=function(r){if(r instanceof Array&&r.__enum__==null)this.a=r,this.byteLength=r.length;else{var n=r;this.a=[];for(var a=0;a<n;){var l=a++;this.a[l]=0}this.byteLength=n}};x["js.html.compat.ArrayBuffer"]=oe,oe.__name__=["js","html","compat","ArrayBuffer"],oe.sliceImpl=function(r,n){var a=new Xi(this,r,n==null?null:n-r),l=new Ws(a.byteLength),c=new Xi(l);return c.set(a),l},oe.prototype={slice:function(r,n){return new oe(this.a.slice(r,n))},__class__:oe};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(Jt.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++],c=this.buf.a[a++],d=this.buf.a[a++],p=this.buf.a[a++];return n?l|c<<8|d<<16|p<<24:p|d<<8|c<<16|l<<24},getUint32:function(r,n){var a=this.getInt32(r,n);return a<0?a+4294967296:a},getFloat32:function(r,n){return ae.i32ToFloat(this.getInt32(r,n))},getFloat64:function(r,n){var a=this.getInt32(r,n),l=this.getInt32(r+4,n);return ae.i64ToDouble(n?a:l,n?l:a)},setInt8:function(r,n){n<0?this.buf.a[r+this.offset]=n+128&255:this.buf.a[r+this.offset]=n&255},setUint8:function(r,n){this.buf.a[r+this.offset]=n&255},setInt16:function(r,n,a){this.setUint16(r,n<0?n+65536:n,a)},setUint16:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l]=n&255,this.buf.a[l++]=n>>8&255):(this.buf.a[l++]=n>>8&255,this.buf.a[l]=n&255)},setInt32:function(r,n,a){this.setUint32(r,n,a)},setUint32:function(r,n,a){var l=r+this.offset;a?(this.buf.a[l++]=n&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>>24):(this.buf.a[l++]=n>>>24,this.buf.a[l++]=n>>16&255,this.buf.a[l++]=n>>8&255,this.buf.a[l++]=n&255)},setFloat32:function(r,n,a){this.setUint32(r,ae.floatToI32(n),a)},setFloat64:function(r,n,a){var l=ae.doubleToI64(n);a?(this.setUint32(r,l.low),this.setUint32(r,l.high)):(this.setUint32(r,l.high),this.setUint32(r,l.low))},__class__:cr};var sr=function(){};x["js.html.compat.Uint8Array"]=sr,sr.__name__=["js","html","compat","Uint8Array"],sr._new=function(r,n,a){var l;if(typeof r=="number"){l=[];for(var c=0;c<r;){var d=c++;l[d]=0}l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l)}else if(Nt.__instanceof(r,oe)){var p=r;n==null&&(n=0),a==null&&(a=p.byteLength-n),n==0?l=p.a:l=p.a.slice(n,n+a),l.byteLength=l.length,l.byteOffset=n,l.buffer=p}else if(r instanceof Array&&r.__enum__==null)l=r.slice(),l.byteLength=l.length,l.byteOffset=0,l.buffer=new oe(l);else throw new Q("TODO "+dt.string(r));return l.subarray=sr._subarray,l.set=sr._set,l},sr._set=function(r,n){var a=this;if(Nt.__instanceof(r.buffer,oe)){var l=r;if(r.byteLength+n>a.byteLength)throw new Q("set() outside of range");for(var c=0,d=r.byteLength;c<d;){var p=c++;a[p+n]=l[p]}}else if(r instanceof Array&&r.__enum__==null){var _=r;if(_.length+n>a.byteLength)throw new Q("set() outside of range");for(var y=0,A=_.length;y<A;){var P=y++;a[P+n]=_[P]}}else throw new Q("TODO")},sr._subarray=function(r,n){var a=this,l=sr._new(a.slice(r,n));return l.byteOffset=r,l};var kt=function(r){this._resolved=!1,this._pending=!1,this._errorPending=!1,this._fulfilled=!1,this._update=[],this._error=[],this._errored=!1,r!=null&&kt.link(r,this,function(n){return n})};x["promhx.base.AsyncBase"]=kt,kt.__name__=["promhx","base","AsyncBase"],kt.link=function(r,n,a){r._update.push({async:n,linkf:function(l){n.handleResolve(a(l))}}),kt.immediateLinkUpdate(r,n,a)},kt.immediateLinkUpdate=function(r,n,a){if(r._errored&&!r._errorPending&&!(r._error.length>0)&&n.handleError(r._errorVal),r._resolved&&!r._pending)try{n.handleResolve(a(r._val))}catch(l){l instanceof Q&&(l=l.val),n.handleError(l)}},kt.linkAll=function(r,n){for(var a=function(d,p,_){if(d.length==0||kt.allFulfilled(d)){for(var y,A=[],P=Ke(r)();P.hasNext();){var S=P.next();A.push(S==p?_:S._val)}y=A,n.handleResolve(y)}},l=Ke(r)();l.hasNext();){var c=l.next();c._update.push({async:n,linkf:function(d,p,_){return function(y){d(p,_,y)}}(a,function(d){for(var p,_=[],y=Ke(r)();y.hasNext();){var A=y.next();A!=c&&_.push(A)}return p=_,p}(),c)})}kt.allFulfilled(r)&&n.handleResolve(function(d){for(var p,_=[],y=Ke(r)();y.hasNext();){var A=y.next();_.push(A._val)}return p=_,p}())},kt.pipeLink=function(r,n,a){var l=!1,c=function(d){if(!l){l=!0;var p=a(d);p._update.push({async:n,linkf:Le(n,n.handleResolve)}),kt.immediateLinkUpdate(p,n,function(_){return _})}};if(r._update.push({async:n,linkf:c}),r._resolved&&!r._pending)try{c(r._val)}catch(d){d instanceof Q&&(d=d.val),n.handleError(d)}},kt.allResolved=function(r){for(var n=Ke(r)();n.hasNext();){var a=n.next();if(!a._resolved)return!1}return!0},kt.allFulfilled=function(r){for(var n=Ke(r)();n.hasNext();){var a=n.next();if(!a._fulfilled)return!1}return!0},kt.prototype={catchError:function(r){return this._error.push(r),this},errorThen:function(r){return this._errorMap=r,this},isResolved:function(){return this._resolved},isErrored:function(){return this._errored},isErrorHandled:function(){return this._error.length>0},isErrorPending:function(){return this._errorPending},isFulfilled:function(){return this._fulfilled},isPending:function(){return this._pending},handleResolve:function(r){this._resolve(r)},_resolve:function(r){var n=this;this._pending?St.enqueue(function(a,l){return function(){a(l)}}(Le(this,this._resolve),r)):(this._resolved=!0,this._pending=!0,St.queue.add(function(){n._val=r;for(var a=0,l=n._update;a<l.length;){var c=l[a];++a;try{c.linkf(r)}catch(d){d instanceof Q&&(d=d.val),c.async.handleError(d)}}n._fulfilled=!0,n._pending=!1}),St.continueOnNextLoop())},handleError:function(r){this._handleError(r)},_handleError:function(r){var n=this,a=function(l){if(n._error.length>0)for(var c=0,d=n._error;c<d.length;){var p=d[c];++c,p(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,St.queue.add(function(){if(n._errorMap!=null)try{n._resolve(n._errorMap(r))}catch(l){l instanceof Q&&(l=l.val),a(l)}else a(r)}),St.continueOnNextLoop())},then:function(r){var n=new kt(null);return kt.link(this,n,r),n},unlink:function(r){var n=this;St.queue.add(function(){n._update=n._update.filter(function(a){return a.async!=r})}),St.continueOnNextLoop()},isLinked:function(r){for(var n=!1,a=0,l=this._update;a<l.length;){var c=l[a];if(++a,c.async==r)return!0}return n},__class__:kt};var wn=f.promhx.Deferred=function(){kt.call(this)};x["promhx.Deferred"]=wn,wn.__name__=["promhx","Deferred"],wn.__super__=kt,wn.prototype=T(kt.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},promise:function(){return new pe(this)},stream:function(){return new Ht(this)},publicStream:function(){return new Cr(this)},__class__:wn});var pe=f.promhx.Promise=function(r){kt.call(this,r),this._rejected=!1};x["promhx.Promise"]=pe,pe.__name__=["promhx","Promise"],pe.whenAll=function(r){var n=new pe(null);return kt.linkAll(r,n),n},pe.promise=function(r){var n=new pe;return n.handleResolve(r),n},pe.__super__=kt,pe.prototype=T(kt.prototype,{isRejected:function(){return this._rejected},reject:function(r){this._rejected=!0,this.handleError(r)},handleResolve:function(r){if(this._resolved){var n="Promise has already been resolved";throw new Q(An.AlreadyResolved(n))}this._resolve(r)},then:function(r){var n=new pe(null);return kt.link(this,n,r),n},unlink:function(r){var n=this;St.queue.add(function(){if(n._fulfilled)n._update=n._update.filter(function(l){return l.async!=r});else{var a="Downstream Promise is not fullfilled";n.handleError(An.DownstreamNotFullfilled(a))}}),St.continueOnNextLoop()},handleError:function(r){this._rejected=!0,this._handleError(r)},pipe:function(r){var n=new pe(null);return kt.pipeLink(this,n,r),n},errorPipe:function(r){var n=new pe;return this.catchError(function(a){var l=r(a);l.then(Le(n,n._resolve))}),this.then(Le(n,n._resolve)),n},__class__:pe});var Ht=f.promhx.Stream=function(r){kt.call(this,r),this._end_promise=new pe};x["promhx.Stream"]=Ht,Ht.__name__=["promhx","Stream"],Ht.foreach=function(r){for(var n=new Ht(null),a=Ke(r)();a.hasNext();){var l=a.next();n.handleResolve(l)}return n.end(),n},Ht.wheneverAll=function(r){var n=new Ht(null);return kt.linkAll(r,n),n},Ht.concatAll=function(r){for(var n=new Ht(null),a=Ke(r)();a.hasNext();){var l=a.next();n.concat(l)}return n},Ht.mergeAll=function(r){for(var n=new Ht(null),a=Ke(r)();a.hasNext();){var l=a.next();n.merge(l)}return n},Ht.stream=function(r){var n=new Ht(null);return n.handleResolve(r),n},Ht.__super__=kt,Ht.prototype=T(kt.prototype,{then:function(r){var n=new Ht(null);return kt.link(this,n,r),this._end_promise._update.push({async:n._end_promise,linkf:function(a){n.end()}}),n},detachStream:function(r){for(var n=[],a=!1,l=0,c=this._update;l<c.length;){var d=c[l];++l,d.async==r?(this._end_promise._update=this._end_promise._update.filter(function(p){return p.async!=r._end_promise}),a=!0):n.push(d)}return this._update=n,a},first:function(){var r=new pe(null);return this.then(function(n){r._resolved||r.handleResolve(n)}),r},handleResolve:function(r){!this._end&&!this._pause&&this._resolve(r)},pause:function(r){r==null&&(r=!this._pause),this._pause=r},pipe:function(r){var n=new Ht(null);return kt.pipeLink(this,n,r),this._end_promise.then(function(a){n.end()}),n},errorPipe:function(r){var n=new Ht(null);return this.catchError(function(a){var l=r(a);l.then(Le(n,n._resolve)),l._end_promise.then((Yi=n._end_promise,Le(Yi,Yi._resolve)))}),this.then(Le(n,n._resolve)),this._end_promise.then(function(a){n.end()}),n},handleEnd:function(){if(this._pending)St.queue.add(Le(this,this.handleEnd)),St.continueOnNextLoop();else{if(this._end_promise._resolved)return;this._end=!0;var r;this._resolved?r=de.Some(this._val):r=de.None,this._end_promise.handleResolve(r),this._update=[],this._error=[]}},end:function(){return St.queue.add(Le(this,this.handleEnd)),St.continueOnNextLoop(),this},endThen:function(r){return this._end_promise.then(r)},filter:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:function(a){r(a)&&n.handleResolve(a)}}),kt.immediateLinkUpdate(this,n,function(a){return a}),n},concat:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:Le(n,n.handleResolve)}),kt.immediateLinkUpdate(this,n,function(a){return a}),this._end_promise.then(function(a){r.pipe(function(l){return n.handleResolve(l),n}),r._end_promise.then(function(l){n.end()})}),n},merge:function(r){var n=new Ht(null);return this._update.push({async:n,linkf:Le(n,n.handleResolve)}),r._update.push({async:n,linkf:Le(n,n.handleResolve)}),kt.immediateLinkUpdate(this,n,function(a){return a}),kt.immediateLinkUpdate(r,n,function(a){return a}),n},__class__:Ht});var Cr=f.promhx.PublicStream=function(r){Ht.call(this,r)};x["promhx.PublicStream"]=Cr,Cr.__name__=["promhx","PublicStream"],Cr.publicstream=function(r){var n=new Cr(null);return n.handleResolve(r),n},Cr.__super__=Ht,Cr.prototype=T(Ht.prototype,{resolve:function(r){this.handleResolve(r)},throwError:function(r){this.handleError(r)},update:function(r){this.handleResolve(r)},__class__:Cr});var St=function(){};x["promhx.base.EventLoop"]=St,St.__name__=["promhx","base","EventLoop"],St.enqueue=function(r){St.queue.add(r),St.continueOnNextLoop()},St.set_nextLoop=function(r){if(St.nextLoop!=null)throw new Q("nextLoop has already been set");return St.nextLoop=r,St.nextLoop},St.queueEmpty=function(){return St.queue.isEmpty()},St.finish=function(r){r==null&&(r=1e3);for(var n=null;r-- >0&&(n=St.queue.pop())!=null;)n();return St.queue.isEmpty()},St.clear=function(){St.queue=new D},St.f=function(){var r=St.queue.pop();r!=null&&r(),St.queue.isEmpty()||St.continueOnNextLoop()},St.continueOnNextLoop=function(){St.nextLoop!=null?St.nextLoop(St.f):setImmediate(St.f)};var An=x["promhx.error.PromiseError"]={__ename__:["promhx","error","PromiseError"],__constructs__:["AlreadyResolved","DownstreamNotFullfilled"]};An.AlreadyResolved=function(r){var n=["AlreadyResolved",0,r];return n.__enum__=An,n.toString=E,n},An.DownstreamNotFullfilled=function(r){var n=["DownstreamNotFullfilled",1,r];return n.__enum__=An,n.toString=E,n};var Gs=function(){};x["verb.Verb"]=Gs,Gs.__name__=["verb","Verb"],Gs.main=function(){b.log("verb 2.1.0")};var Z=function(){};x["verb.core.ArrayExtensions"]=Z,Z.__name__=["verb","core","ArrayExtensions"],Z.alloc=function(r,n){if(!(n<0))for(;r.length<n;)r.push(null)},Z.reversed=function(r){var n=r.slice();return n.reverse(),n},Z.last=function(r){return r[r.length-1]},Z.first=function(r){return r[0]},Z.spliceAndInsert=function(r,n,a,l){r.splice(n,a),r.splice(n,0,l)},Z.left=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(0,n)},Z.right=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n)},Z.rightWithPivot=function(r){if(r.length==0)return[];var n=Math.ceil(r.length/2);return r.slice(n-1)},Z.unique=function(r,n){if(r.length==0)return[];for(var a=[r.pop()];r.length>0;){for(var l=r.pop(),c=!0,d=0;d<a.length;){var p=a[d];if(++d,n(l,p)){c=!1;break}}c&&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,c=1,d=n+1;c<d;){var p=c++;if(Ft.memo_exists(l,p)){r--,a=Ft.get_memo(l,p);continue}a*=r--,a/=p,Ft.memoize(l,p,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,c=n+1;l<c;){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 xt),Ft.memo.h[r].h[n]=a};var Ne=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"]=Ne,Ne.__name__=["verb","core","BoundingBox"],Ne.intervalsOverlap=function(r,n,a,l,c){c==null&&(c=-1);var d;c<-.5?d=rt.TOLERANCE:d=c;var p=Math.min(r,n)-d,_=Math.max(r,n)+d,y=Math.min(a,l)-d,A=Math.max(a,l)+d;return p>=y&&p<=A||_>=y&&_<=A||y>=p&&y<=_||A>=p&&A<=_},Ne.prototype={fromPoint:function(r){return new Ne([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 Ne([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,c=r.min,d=r.max,p=0,_=this.dim;p<_;){var y=p++;if(!Ne.intervalsOverlap(a[y],l[y],c[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 c=a++,d=this.getAxisLength(c);d>r&&(r=d,n=c)}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,c=r.min,d=r.max;if(!this.intersects(r,n))return null;for(var p=[],_=[],y=0,A=this.dim;y<A;){var P=y++;p.push(Math.min(l[P],d[P])),_.push(Math.max(a[P],c[P]))}return new Ne([_,p])},__class__:Ne};var rt=f.core.Constants=function(){};x["verb.core.Constants"]=rt,rt.__name__=["verb","core","Constants"];var Zt=f.core.SerializableBase=function(){};x["verb.core.SerializableBase"]=Zt,Zt.__name__=["verb","core","SerializableBase"],Zt.prototype={serialize:function(){var r=new qt;return r.serialize(this),r.toString()},__class__:Zt};var Hn=f.core.Plane=function(r,n){this.origin=r,this.normal=n};x["verb.core.Plane"]=Hn,Hn.__name__=["verb","core","Plane"],Hn.__super__=Zt,Hn.prototype=T(Zt.prototype,{__class__:Hn});var Sn=f.core.Ray=function(r,n){this.origin=r,this.dir=n};x["verb.core.Ray"]=Sn,Sn.__name__=["verb","core","Ray"],Sn.__super__=Zt,Sn.prototype=T(Zt.prototype,{__class__:Sn});var Gt=f.core.NurbsCurveData=function(r,n,a){this.degree=r,this.controlPoints=a,this.knots=n};x["verb.core.NurbsCurveData"]=Gt,Gt.__name__=["verb","core","NurbsCurveData"],Gt.__super__=Zt,Gt.prototype=T(Zt.prototype,{__class__:Gt});var te=f.core.NurbsSurfaceData=function(r,n,a,l,c){this.degreeU=r,this.degreeV=n,this.knotsU=a,this.knotsV=l,this.controlPoints=c};x["verb.core.NurbsSurfaceData"]=te,te.__name__=["verb","core","NurbsSurfaceData"],te.__super__=Zt,te.prototype=T(Zt.prototype,{__class__:te});var qe=f.core.MeshData=function(r,n,a,l){this.faces=r,this.points=n,this.normals=a,this.uvs=l};x["verb.core.MeshData"]=qe,qe.__name__=["verb","core","MeshData"],qe.empty=function(){return new qe([],[],[],[])},qe.__super__=Zt,qe.prototype=T(Zt.prototype,{__class__:qe});var Yn=f.core.PolylineData=function(r,n){this.points=r,this.params=n};x["verb.core.PolylineData"]=Yn,Yn.__name__=["verb","core","PolylineData"],Yn.__super__=Zt,Yn.prototype=T(Zt.prototype,{__class__:Yn});var qn=f.core.VolumeData=function(r,n,a,l,c,d,p){this.degreeU=r,this.degreeV=n,this.degreeW=a,this.knotsU=l,this.knotsV=c,this.knotsW=d,this.controlPoints=p};x["verb.core.VolumeData"]=qn,qn.__name__=["verb","core","VolumeData"],qn.__super__=Zt,qn.prototype=T(Zt.prototype,{__class__:qn});var ee=f.core.Pair=function(r,n){this.item0=r,this.item1=n};x["verb.core.Pair"]=ee,ee.__name__=["verb","core","Pair"],ee.prototype={__class__:ee};var Pe=f.core.Interval=function(r,n){this.min=r,this.max=n};x["verb.core.Interval"]=Pe,Pe.__name__=["verb","core","Interval"],Pe.prototype={__class__:Pe};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 Xn=f.core.CurveSurfaceIntersection=function(r,n,a,l){this.u=r,this.uv=n,this.curvePoint=a,this.surfacePoint=l};x["verb.core.CurveSurfaceIntersection"]=Xn,Xn.__name__=["verb","core","CurveSurfaceIntersection"],Xn.prototype={__class__:Xn};var Lr=f.core.MeshIntersectionPoint=function(r,n,a,l,c){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"]=Lr,Lr.__name__=["verb","core","MeshIntersectionPoint"],Lr.prototype={__class__:Lr};var Kn=f.core.PolylineMeshIntersection=function(r,n,a,l,c){this.point=r,this.u=n,this.uv=a,this.polylineIndex=l,this.faceIndex=c};x["verb.core.PolylineMeshIntersection"]=Kn,Kn.__name__=["verb","core","PolylineMeshIntersection"],Kn.prototype={__class__:Kn};var $n=f.core.SurfaceSurfaceIntersectionPoint=function(r,n,a,l){this.uv0=r,this.uv1=n,this.point=a,this.dist=l};x["verb.core.SurfaceSurfaceIntersectionPoint"]=$n,$n.__name__=["verb","core","SurfaceSurfaceIntersectionPoint"],$n.prototype={__class__:$n};var Zn=f.core.TriSegmentIntersection=function(r,n,a,l){this.point=r,this.s=n,this.t=a,this.p=l};x["verb.core.TriSegmentIntersection"]=Zn,Zn.__name__=["verb","core","TriSegmentIntersection"],Zn.prototype={__class__:Zn};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 We=function(r,n,a,l,c){c==null&&(c=!1),l==null&&(l=-1),this.uv=a,this.point=r,this.normal=n,this.id=l,this.degen=c};x["verb.core.SurfacePoint"]=We,We.__name__=["verb","core","SurfacePoint"],We.fromUv=function(r,n){return new We(null,null,[r,n])},We.prototype={__class__:We};var js=f.core.CurvePoint=function(r,n){this.u=r,this.pt=n};x["verb.core.CurvePoint"]=js,js.__name__=["verb","core","CurvePoint"],js.prototype={__class__:js};var Qn=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"]=Qn,Qn.__name__=["verb","core","KdTree"],Qn.prototype={buildTree:function(r,n,a){var l=n%this.dim,c,d;return r.length==0?null:r.length==1?new En(r[0],l,a):(r.sort(function(p,_){var y=p.point[l]-_.point[l];return y==0?0:y>0?1:-1}),c=Math.floor(r.length/2),d=new En(r[c],l,a),d.left=this.buildTree(r.slice(0,c),n+1,d),d.right=this.buildTree(r.slice(c+1),n+1,d),d)},nearest:function(r,n,a){var l=this,c=new Jn(function(S){return-S.item1}),d,p=null;p=function(S){for(var I,k=S.dimension,M=l.distanceFunction(r,S.kdPoint.point),O,C=[],F=0,R=l.dim;F<R;)F++,C.push(0);O=C;for(var U,V,q=function(K,tt){c.push(new ee(K,tt)),c.size()>n&&c.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){(c.size()<n||M<c.peek().item1)&&q(S,M);return}S.right==null?I=S.left:S.left==null?I=S.right:r[k]<S.kdPoint.point[k]?I=S.left:I=S.right,p(I),(c.size()<n||M<c.peek().item1)&&q(S,M),(c.size()<n||Math.abs(U)<c.peek().item1)&&(I==S.left?V=S.right:V=S.left,V!=null&&p(V))},d=p;for(var _=0;_<n;)_++,c.push(new ee(null,a));d(this.root);for(var y=[],A=0;A<n;){var P=A++;c.content[P].item0!=null&&y.push(new ee(c.content[P].item0.kdPoint,c.content[P].item1))}return y},__class__:Qn};var Jn=function(r){this.content=[],this.scoreFunction=r};x["verb.core.BinaryHeap"]=Jn,Jn.__name__=["verb","core","BinaryHeap"],Jn.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 c=this.content.pop();l!=n-1&&(this.content[l]=c,this.scoreFunction(c)<this.scoreFunction(r)?this.bubbleUp(l):this.sinkDown(l));return}}throw new Q("Node not found.")},size:function(){return this.content.length},bubbleUp:function(r){for(var 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 c=(r+1)*2,d=c-1,p=-1,_=0;if(d<n){var y=this.content[d];_=this.scoreFunction(y),_<l&&(p=d)}if(c<n){var A=this.content[c],P=this.scoreFunction(A);P<(p==-1?l:_)&&(p=c)}if(p!=-1)this.content[r]=this.content[p],this.content[p]=a,r=p;else break}},__class__:Jn};var In=f.core.KdPoint=function(r,n){this.point=r,this.obj=n};x["verb.core.KdPoint"]=In,In.__name__=["verb","core","KdPoint"],In.prototype={__class__:In};var En=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"]=En,En.__name__=["verb","core","KdNode"],En.prototype={__class__:En};var ur=function(){};x["verb.eval.IBoundingBoxTree"]=ur,ur.__name__=["verb","eval","IBoundingBoxTree"],ur.prototype={__class__:ur};var ir=function(r,n){this._boundingBox=null,this._curve=r,n==null&&(n=m.domain(this._curve.knots)/64),this._knotTol=n};x["verb.core.LazyCurveBoundingBoxTree"]=ir,ir.__name__=["verb","core","LazyCurveBoundingBoxTree"],ir.__interfaces__=[ur],ir.prototype={split:function(){var r=Z.first(this._curve.knots),n=Z.last(this._curve.knots),a=n-r,l=le.curveSplit(this._curve,(n+r)/2+a*.1*Math.random());return new ee(new ir(l[0],this._knotTol),new ir(l[1],this._knotTol))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ne(N.dehomogenize1d(this._curve.controlPoints))),this._boundingBox},yield:function(){return this._curve},indivisible:function(r){return m.domain(this._curve.knots)<this._knotTol},empty:function(){return!1},__class__:ir};var ar=function(r,n){if(this._boundingBox=null,this._mesh=r,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}this._faceIndices=n};x["verb.core.LazyMeshBoundingBoxTree"]=ar,ar.__name__=["verb","core","LazyMeshBoundingBoxTree"],ar.__interfaces__=[ur],ar.prototype={split:function(){var r=re.sortTrianglesOnLongestAxis(this.boundingBox(),this._mesh,this._faceIndices),n=Z.left(r),a=Z.right(r);return new ee(new ar(this._mesh,n),new ar(this._mesh,a))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=re.makeMeshAabb(this._mesh,this._faceIndices)),this._boundingBox},yield:function(){return this._faceIndices[0]},indivisible:function(r){return this._faceIndices.length==1},empty:function(){return this._faceIndices.length==0},__class__:ar};var or=function(r,n){this._boundingBox=null,this._polyline=r,n==null&&(n=new Pe(0,r.points.length!=0?r.points.length-1:0)),this._interval=n};x["verb.core.LazyPolylineBoundingBoxTree"]=or,or.__name__=["verb","core","LazyPolylineBoundingBoxTree"],or.__interfaces__=[ur],or.prototype={split:function(){var r=this._interval.min,n=this._interval.max,a=r+Math.ceil((n-r)/2),l=new Pe(r,a),c=new Pe(a,n);return new ee(new or(this._polyline,l),new or(this._polyline,c))},boundingBox:function(){return this._boundingBox==null&&(this._boundingBox=new Ne(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__:or};var Or=function(r,n,a,l){n==null&&(n=!1),this._boundingBox=null,this._surface=r,this._splitV=n,a==null&&(a=m.domain(r.knotsU)/16),l==null&&(l=m.domain(r.knotsV)/16),this._knotTolU=a,this._knotTolV=l};x["verb.core.LazySurfaceBoundingBoxTree"]=Or,Or.__name__=["verb","core","LazySurfaceBoundingBoxTree"],Or.__interfaces__=[ur],Or.prototype={split:function(){var r,n;this._splitV?(r=Z.first(this._surface.knotsV),n=Z.last(this._surface.knotsV)):(r=Z.first(this._surface.knotsU),n=Z.last(this._surface.knotsU));var a=(r+n)/2,l=le.surfaceSplit(this._surface,a,this._splitV);return new ee(new Or(l[0],!this._splitV,this._knotTolU,this._knotTolV),new Or(l[1],!this._splitV,this._knotTolU,this._knotTolV))},boundingBox:function(){if(this._boundingBox==null){this._boundingBox=new Ne;for(var r=0,n=this._surface.controlPoints;r<n.length;){var a=n[r];++r,this._boundingBox.addRange(N.dehomogenize1d(a))}}return this._boundingBox},yield:function(){return this._surface},indivisible:function(r){return m.domain(this._surface.knotsV)<this._knotTolV&&m.domain(this._surface.knotsU)<this._knotTolU},empty:function(){return!1},__class__:Or};var Lt=f.core.Mat=function(){};x["verb.core.Mat"]=Lt,Lt.__name__=["verb","core","Mat"],Lt.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(m.mul(r,n[d]))}return a},Lt.mult=function(r,n){var a,l,c,d,p,_,y,A;a=r.length,l=n.length,c=n[0].length,d=[];for(var P=a-1,S=0,I=0;P>=0;){for(p=[],_=r[P],I=c-1;I>=0;){for(y=_[l-1]*n[l-1][I],S=l-2;S>=1;)A=S-1,y+=_[S]*n[S][I]+_[A]*n[A][I],S-=2;S==0&&(y+=_[0]*n[0][I]),p[I]=y,I--}d[P]=p,P--}return d},Lt.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.add(r[d],n[d]))}return a},Lt.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.div(r[d],n))}return a},Lt.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.sub(r[d],n[d]))}return a},Lt.dot=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(m.dot(r[d],n))}return a},Lt.identity=function(r){for(var n=m.zeros2d(r,r),a=0;a<r;){var l=a++;n[l][l]=1}return n},Lt.transpose=function(r){if(r.length==0)return[];for(var n=[],a=0,l=r[0].length;a<l;){var c=a++;n.push(function(d){for(var p,_=[],y=0,A=r.length;y<A;){var P=y++;_.push(r[P][c])}return p=_,p}())}return n},Lt.solve=function(r,n){return Lt.LUsolve(Lt.LU(r),n)},Lt.LUsolve=function(r,n){var a,l,c=r.LU,d=c.length,p=n.slice(),_=r.P,y,A,P;for(a=d-1;a!=-1;)p[a]=n[a],--a;for(a=0;a<d;){for(y=_[a],_[a]!=a&&(P=p[a],p[a]=p[y],p[y]=P),A=c[a],l=0;l<a;)p[a]-=p[l]*A[l],++l;++a}for(a=d-1;a>=0;){for(A=c[a],l=a+1;l<d;)p[a]-=p[l]*A[l],++l;p[a]/=A[a],--a}return p},Lt.LU=function(r){for(var n,a,l,c,d,p,_,y,A,P=[],S=0,I=r.length;S<I;){var k=S++;P.push(r[k].slice())}r=P;var M=r.length,O=M-1,C=[];for(l=0;l<M;){for(_=l,p=r[l],A=Math.abs(p[l]),a=l+1;a<M;)c=Math.abs(r[a][l]),A<c&&(A=c,_=a),++a;for(C[l]=_,_!=l&&(r[l]=r[_],r[_]=p,p=r[l]),d=p[l],n=l+1;n<M;)r[n][l]/=d,++n;for(n=l+1;n<M;){for(y=r[n],a=l+1;a<O;)y[a]-=y[l]*p[a],++a,y[a]-=y[l]*p[a],++a;a==O&&(y[a]-=y[l]*p[a]),++n}++l}return new ts(r,C)};var ts=function(r,n){this.LU=r,this.P=n};x["verb.core._Mat.LUDecomp"]=ts,ts.__name__=["verb","core","_Mat","LUDecomp"],ts.prototype={__class__:ts};var re=f.core.Mesh=function(){};x["verb.core.Mesh"]=re,re.__name__=["verb","core","Mesh"],re.getTriangleNorm=function(r,n){var a=r[n[0]],l=r[n[1]],c=r[n[2]],d=m.sub(l,a),p=m.sub(c,a),_=m.cross(d,p);return m.mul(1/m.norm(_),_)},re.makeMeshAabb=function(r,n){for(var a=new Ne,l=0;l<n.length;){var c=n[l];++l,a.add(r.points[r.faces[c][0]]),a.add(r.points[r.faces[c][1]]),a.add(r.points[r.faces[c][2]])}return a},re.sortTrianglesOnLongestAxis=function(r,n,a){for(var l=r.getLongestAxis(),c=[],d=0;d<a.length;){var p=a[d];++d;var _=re.getMinCoordOnAxis(n.points,n.faces[p],l);c.push(new ee(_,p))}c.sort(function(I,k){var M=I.item0,O=k.item0;return M==O?0:M>O?1:-1});for(var y=[],A=0,P=c.length;A<P;){var S=A++;y.push(c[S].item1)}return y},re.getMinCoordOnAxis=function(r,n,a){for(var l=1/0,c=0;c<3;){var d=c++,p=r[n[d]][a];p<l&&(l=p)}return l},re.getTriangleCentroid=function(r,n){for(var a=[0,0,0],l=0;l<3;)for(var c=l++,d=0;d<3;){var p=d++;a[p]+=r[n[c]][p]}for(var _=0;_<3;){var y=_++;a[y]/=3}return a},re.triangleUVFromPoint=function(r,n,a){var l=r.faces[n],c=r.points[l[0]],d=r.points[l[1]],p=r.points[l[2]],_=r.uvs[l[0]],y=r.uvs[l[1]],A=r.uvs[l[2]],P=m.sub(c,a),S=m.sub(d,a),I=m.sub(p,a),k=m.norm(m.cross(m.sub(c,d),m.sub(c,p))),M=m.norm(m.cross(S,I))/k,O=m.norm(m.cross(I,P))/k,C=m.norm(m.cross(P,S))/k;return m.add(m.mul(M,_),m.add(m.mul(O,y),m.mul(C,A)))};var zr=function(r,n){if(this._empty=!1,this._face=-1,n==null){for(var a=[],l=0,c=r.faces.length;l<c;){var d=l++;a.push(d)}n=a}if(this._boundingBox=re.makeMeshAabb(r,n),n.length<1){this._empty=!0;return}else if(n.length<2){this._face=n[0];return}var p=re.sortTrianglesOnLongestAxis(this._boundingBox,r,n),_=Z.left(p),y=Z.right(p);this._children=new ee(new zr(r,_),new zr(r,y))};x["verb.core.MeshBoundingBoxTree"]=zr,zr.__name__=["verb","core","MeshBoundingBoxTree"],zr.__interfaces__=[ur],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 Xe=f.core.Minimizer=function(){};x["verb.core.Minimizer"]=Xe,Xe.__name__=["verb","core","Minimizer"],Xe.uncmin=function(r,n,a,l,c){a==null&&(a=1e-8),l==null&&(l=function(J){return Xe.numericalGradient(r,J)}),c==null&&(c=1e3),n=n.slice(0);var d=n.length,p=r(n),_=p,y;if(isNaN(p))throw new Q("uncmin: f(x0) is a NaN!");a=Math.max(a,rt.EPSILON);var A,P,S,I=Lt.identity(d),k=0,M=[],O,C,F,R,U,V,q="";for(P=l(n);k<c;){if(!m.all(m.finite(P))){q="Gradient has Infinity or NaN";break}if(A=m.neg(Lt.dot(I,P)),!m.all(m.finite(A))){q="Search direction has Infinity or NaN";break}if(V=m.norm(A),V<a){q="Newton step smaller than tol";break}for(U=1,y=m.dot(P,A),O=n;k<c&&!(U*V<a);){if(M=m.mul(U,A),O=m.add(n,M),_=r(O),_-p>=.1*U*y||isNaN(_)){U*=.5,++k;continue}break}if(U*V<a){q="Line search step size smaller than tol";break}if(k==c){q="maxit reached during line search";break}S=l(O),C=m.sub(S,P),R=m.dot(C,M),F=Lt.dot(I,C),I=Lt.sub(Lt.add(I,Lt.mul((R+m.dot(C,F))/(R*R),Xe.tensor(M,M))),Lt.div(Lt.add(Xe.tensor(F,M),Xe.tensor(M,F)),R)),n=O,p=_,P=S,++k}return new es(n,p,P,I,k,q)},Xe.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 c=n.slice(0),d,p,_=[],y,A=.001,P,S,I,k=0,M,O,C,F=0;F<a;)for(var R=F++,U=Math.max(1e-6*l,1e-8);;){if(++k,k>20)throw new Q("Numerical gradient fails");if(c[R]=n[R]+U,d=r(c),c[R]=n[R]-U,p=r(c),c[R]=n[R],isNaN(d)||isNaN(p)){U/=16;continue}if(_[R]=(d-p)/(2*U),P=n[R]-U,S=n[R],I=n[R]+U,M=(d-l)/U,O=(l-p)/U,C=m.max([Math.abs(_[R]),Math.abs(l),Math.abs(d),Math.abs(p),Math.abs(P),Math.abs(S),Math.abs(I),1e-8]),y=Math.min(m.max([Math.abs(M-_[R]),Math.abs(O-_[R]),Math.abs(M-O)])/C,U/C),y>A)U/=16;else break}return _},Xe.tensor=function(r,n){for(var a=r.length,l=n.length,c=[],d,p,_=a-1;_>=0;){d=[],p=r[_];for(var y=l-1;y>=3;)d[y]=p*n[y],--y,d[y]=p*n[y],--y,d[y]=p*n[y],--y,d[y]=p*n[y],--y;for(;y>=0;)d[y]=p*n[y],--y;c[_]=d,_--}return c};var es=function(r,n,a,l,c,d){this.solution=r,this.value=n,this.gradient=a,this.invHessian=l,this.iterations=c,this.message=d};x["verb.core.MinimizationResult"]=es,es.__name__=["verb","core","MinimizationResult"],es.prototype={__class__:es};var kn=function(){};x["verb.core.ISerializable"]=kn,kn.__name__=["verb","core","ISerializable"],kn.prototype={__class__:kn};var Hi=f.core.Deserializer=function(){};x["verb.core.Deserializer"]=Hi,Hi.__name__=["verb","core","Deserializer"],Hi.deserialize=function(r){var n=new Wt(r),a=n.unserialize();return a};var Ce=f.core.Trig=function(){};x["verb.core.Trig"]=Ce,Ce.__name__=["verb","core","Trig"],Ce.isPointInPlane=function(r,n,a){return Math.abs(m.dot(m.sub(r,n.origin),n.normal))<a},Ce.distToSegment=function(r,n,a){var l=Ce.segmentClosestPoint(n,r,a,0,1);return m.dist(n,l.pt)},Ce.rayClosestPoint=function(r,n,a){var l=m.sub(r,n),c=m.dot(l,a),d=m.add(n,m.mul(c,a));return d},Ce.distToRay=function(r,n,a){var l=Ce.rayClosestPoint(r,n,a),c=m.sub(l,r);return m.norm(c)},Ce.threePointsAreFlat=function(r,n,a,l){var c=m.sub(n,r),d=m.sub(a,r),p=m.cross(c,d),_=m.dot(p,p);return _<l},Ce.segmentClosestPoint=function(r,n,a,l,c){var d=m.sub(a,n),p=m.norm(d);if(p<rt.EPSILON)return{u:l,pt:n};var _=n,y=m.mul(1/p,d),A=m.sub(r,_),P=m.dot(A,y);return P<0?{u:l,pt:n}:P>p?{u:c,pt:a}:{u:l+(c-l)*P/p,pt:m.add(_,m.mul(P,y))}};var m=f.core.Vec=function(){};x["verb.core.Vec"]=m,m.__name__=["verb","core","Vec"],m.angleBetween=function(r,n){return Math.acos(m.dot(r,n)/(m.norm(r)*m.norm(n)))},m.positiveAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),y=m.norm(l)/p,A=_/p,P=Math.atan2(y,A),S=m.dot(a,l);return Math.abs(S)<rt.EPSILON||S>0?P:-P},m.signedAngleBetween=function(r,n,a){var l=m.cross(r,n),c=m.norm(r),d=m.norm(n),p=c*d,_=m.dot(r,n),y=m.norm(l)/p,A=_/p,P=Math.atan2(y,A),S=m.dot(a,l);return S>0?P:2*Math.PI-P},m.angleBetweenNormalized2d=function(r,n){var a=r[0]*n[1]-r[1]*n[0];return Math.atan2(a,m.dot(r,n))},m.domain=function(r){return Z.last(r)-Z.first(r)},m.range=function(r){for(var n=[],a=0,l=0;l<r;)l++,n.push(a),a+=1;return n},m.span=function(r,n,a){if(a==null)return[];if(a<rt.EPSILON)return[];if(r>n&&a>0)return[];if(n>r&&a<0)return[];for(var l=[],c=r;c<=n;)l.push(c),c+=a;return l},m.neg=function(r){return r.map(function(n){return-n})},m.min=function(r){return z.fold(r,function(n,a){return Math.min(n,a)},1/0)},m.max=function(r){return z.fold(r,function(n,a){return Math.max(n,a)},-1/0)},m.all=function(r){return z.fold(r,function(n,a){return a&&n},!0)},m.finite=function(r){return r.map(function(n){return isFinite(n)})},m.onRay=function(r,n,a){return m.add(r,m.mul(a,n))},m.lerp=function(r,n,a){return m.add(m.mul(r,n),m.mul(1-r,a))},m.normalized=function(r){return m.div(r,m.norm(r))},m.cross=function(r,n){return[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]},m.dist=function(r,n){return m.norm(m.sub(r,n))},m.distSquared=function(r,n){return m.normSquared(m.sub(r,n))},m.sum=function(r){return z.fold(r,function(n,a){return a+n},0)},m.addAll=function(r){var n=Ke(r)();if(!n.hasNext())return null;var a=n.next().length;return z.fold(r,function(l,c){return m.add(c,l)},m.rep(a,0))},m.addAllMutate=function(r){for(var n=r[0],a=1,l=r.length;a<l;){var c=a++;m.addMutate(n,r[c])}},m.addMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]+n*a[d]}},m.subMulMutate=function(r,n,a){for(var l=0,c=r.length;l<c;){var d=l++;r[d]=r[d]-n*a[d]}},m.addMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]+n[c]}},m.subMutate=function(r,n){for(var a=0,l=r.length;a<l;){var c=a++;r[c]=r[c]-n[c]}},m.mulMutate=function(r,n){for(var a=0,l=n.length;a<l;){var c=a++;n[c]=n[c]*r}},m.norm=function(r){var n=m.normSquared(r);return n!=0?Math.sqrt(n):n},m.normSquared=function(r){return z.fold(r,function(n,a){return a+n*n},0)},m.rep=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(n);return a},m.zeros1d=function(r){for(var n=[],a=0;a<r;)a++,n.push(0);return n},m.zeros2d=function(r,n){for(var a=[],l=0;l<r;)l++,a.push(m.zeros1d(n));return a},m.zeros3d=function(r,n,a){for(var l=[],c=0;c<r;)c++,l.push(m.zeros2d(n,a));return l},m.dot=function(r,n){for(var a=0,l=0,c=r.length;l<c;){var d=l++;a+=r[d]*n[d]}return a},m.add=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]+n[d])}return a},m.mul=function(r,n){for(var a=[],l=0,c=n.length;l<c;){var d=l++;a.push(r*n[d])}return a},m.div=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]/n)}return a},m.sub=function(r,n){for(var a=[],l=0,c=r.length;l<c;){var d=l++;a.push(r[d]-n[d])}return a},m.isZero=function(r){for(var n=0,a=r.length;n<a;){var l=n++;if(Math.abs(r[l])>rt.TOLERANCE)return!1}return!0},m.sortedSetUnion=function(r,n){for(var a=[],l=0,c=0;l<r.length||c<n.length;){if(l>=r.length){a.push(n[c]),c++;continue}else if(c>=n.length){a.push(r[l]),l++;continue}var d=r[l]-n[c];if(Math.abs(d)<rt.EPSILON){a.push(r[l]),l++,c++;continue}if(d>0){a.push(n[c]),c++;continue}a.push(r[l]),l++}return a},m.sortedSetSub=function(r,n){for(var a=[],l=0,c=0;l<r.length;){if(c>=n.length){a.push(r[l]),l++;continue}if(Math.abs(r[l]-n[c])<rt.EPSILON){l++,c++;continue}a.push(r[l]),l++}return a};var vt=f.eval.Analyze=function(){};x["verb.eval.Analyze"]=vt,vt.__name__=["verb","eval","Analyze"],vt.knotMultiplicities=function(r){for(var n=[new Tn(r[0],0)],a=n[0],l=0;l<r.length;){var c=r[l];++l,Math.abs(c-a.knot)>rt.EPSILON&&(a=new Tn(c,0),n.push(a)),a.inc()}return n},vt.isRationalSurfaceClosed=function(r,n){n==null&&(n=!0);var a;n?a=r.controlPoints:a=Lt.transpose(r.controlPoints);for(var l=0,c=a[0].length;l<c;){var d=l++,p=m.dist(Z.first(a)[d],Z.last(a)[d])<rt.EPSILON;if(!p)return!1}return!0},vt.rationalSurfaceClosestPoint=function(r,n){var a=vt.rationalSurfaceClosestParam(r,n);return N.rationalSurfacePoint(r,a[0],a[1])},vt.rationalSurfaceClosestParam=function(r,n){for(var a=5,l=0,c,d=1e-4,p=5e-4,_,y=r.knotsU[0],A=Z.last(r.knotsU),P=r.knotsV[0],S=Z.last(r.knotsV),I=vt.isRationalSurfaceClosed(r),k=vt.isRationalSurfaceClosed(r,!1),M,O=zt.rationalSurfaceAdaptive(r,new Rr),C=1/0,F=0,R=O.points.length;F<R;){var U=F++,V=O.points[U],q=m.normSquared(m.sub(n,V));q<C&&(C=q,M=O.uvs[U])}for(var J=function(jt){return N.rationalSurfaceDerivatives(r,jt[0],jt[1],2)},H=function(jt,Xt,Dt){var Kt=Xt[1][0],Ie=Xt[0][1],Ye=Xt[2][0],ye=Xt[0][2],ge=Xt[1][1],Ee=Xt[1][1],Oe=m.dot(Kt,Dt),$e=m.dot(Ie,Dt),lr=[-Oe,-$e],Ze=m.dot(Kt,Kt)+m.dot(Ye,Dt),Qe=m.dot(Kt,Ie)+m.dot(ge,Dt),Je=m.dot(Kt,Ie)+m.dot(Ee,Dt),mr=m.dot(Ie,Ie)+m.dot(ye,Dt),Ln=[[Ze,Qe],[Je,mr]],tn=Lt.solve(Ln,lr);return m.add(tn,jt)};l<a;){c=J(M),_=m.sub(c[0][0],n);var G=m.norm(_),K=m.dot(c[1][0],_),tt=m.norm(c[1][0])*G,et=m.dot(c[0][1],_),it=m.norm(c[0][1])*G,ht=K/tt,at=et/it,ut=G<d,nt=ht<p,mt=at<p;if(ut&&nt&&mt)return M;var X=H(M,c,_);X[0]<y?I?X=[A-(X[0]-y),X[1]]:X=[y+rt.EPSILON,X[1]]:X[0]>A&&(I?X=[y+(X[0]-A),X[1]]:X=[A-rt.EPSILON,X[1]]),X[1]<P?k?X=[X[0],S-(X[1]-P)]:X=[X[0],P+rt.EPSILON]:X[1]>S&&(k?X=[X[0],P+(X[0]-S)]:X=[X[0],S-rt.EPSILON]);var gt=m.norm(m.mul(X[0]-M[0],c[1][0])),Pt=m.norm(m.mul(X[1]-M[1],c[0][1]));if(gt+Pt<d)return M;M=X,l++}return M},vt.rationalCurveClosestPoint=function(r,n){return N.rationalCurvePoint(r,vt.rationalCurveClosestParam(r,n))},vt.rationalCurveClosestParam=function(r,n){for(var a=1/0,l=0,c=zt.rationalCurveRegularSample(r,r.controlPoints.length*r.degree,!0),d=0,p=c.length-1;d<p;){var _=d++,y=c[_][0],A=c[_+1][0],P=c[_].slice(1),S=c[_+1].slice(1),I=Ce.segmentClosestPoint(n,P,S,y,A),k=m.norm(m.sub(n,I.pt));k<a&&(a=k,l=I.u)}for(var M=5,O=0,C,F=1e-4,R=5e-4,U,V=r.knots[0],q=Z.last(r.knots),J=m.normSquared(m.sub(r.controlPoints[0],Z.last(r.controlPoints)))<rt.EPSILON,H=l,G=function(X){return N.rationalCurveDerivatives(r,X,2)},K=function(X,gt,Pt){var jt=m.dot(gt[1],Pt),Xt=m.dot(gt[2],Pt),Dt=m.dot(gt[1],gt[1]),Kt=Xt+Dt;return X-jt/Kt};O<M;){C=G(H),U=m.sub(C[0],n);var tt=m.norm(U),et=m.dot(C[1],U),it=m.norm(C[1])*tt,ht=et/it,at=tt<F,ut=Math.abs(ht)<R;if(at&&ut)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 mt=m.norm(m.mul(nt-H,C[1]));if(mt<F)return H;H=nt,O++}return H},vt.rationalCurveParamAtArcLength=function(r,n,a,l,c){if(a==null&&(a=.001),n<rt.EPSILON)return r.knots[0];var d;l!=null?d=l:d=ft.decomposeCurveIntoBeziers(r);var p=0;d[p];var _=-rt.EPSILON,y;for(c!=null?y=c:y=[];_<n&&p<d.length;){if(p<y.length?y[p]=y[p]:y[p]=vt.rationalBezierCurveArcLength(r),_+=y[p],n<_+rt.EPSILON)return vt.rationalBezierCurveParamAtArcLength(r,n,a,y[p]);p++}return-1},vt.rationalBezierCurveParamAtArcLength=function(r,n,a,l){if(n<0)return r.knots[0];var c;if(l!=null?c=l:c=vt.rationalBezierCurveArcLength(r),n>c)return Z.last(r.knots);var d=r.knots[0],p=0,_=Z.last(r.knots),y=c,A=0,P=0,S;for(a!=null?S=a:S=rt.TOLERANCE*2;y-p>S;)A=(d+_)/2,P=vt.rationalBezierCurveArcLength(r,A),P>n?(_=A,y=P):(d=A,p=P);return(d+_)/2},vt.rationalCurveArcLength=function(r,n,a){a==null&&(a=16),n==null?n=Z.last(r.knots):n=n;for(var l=ft.decomposeCurveIntoBeziers(r),c=0,d=l[0],p=0;c<l.length&&d.knots[0]+rt.EPSILON<n;){var _=Math.min(Z.last(d.knots),n);p+=vt.rationalBezierCurveArcLength(d,_,a),d=l[++c]}return p},vt.rationalBezierCurveArcLength=function(r,n,a){a==null&&(a=16);var l;n==null?l=Z.last(r.knots):l=n;for(var c=(l-r.knots[0])/2,d=0,p=r.degree+a,_,y,A=0;A<p;){var P=A++;_=c*vt.Tvalues[p][P]+c+r.knots[0],y=N.rationalCurveDerivatives(r,_,1),d+=vt.Cvalues[p][P]*m.norm(y[1])}return c*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 He=f.eval.Check=function(){};x["verb.eval.Check"]=He,He.__name__=["verb","eval","Check"],He.isValidKnotVector=function(r,n){if(r.length==0||r.length<(n+1)*2)return!1;for(var a=Z.first(r),l=0,c=n+1;l<c;){var d=l++;if(Math.abs(r[d]-a)>rt.EPSILON)return!1}a=Z.last(r);for(var p=r.length-n-1,_=r.length;p<_;){var y=p++;if(Math.abs(r[y]-a)>rt.EPSILON)return!1}return He.isNonDecreasing(r)},He.isNonDecreasing=function(r){for(var n=Z.first(r),a=0,l=r.length;a<l;){var c=a++;if(r[c]<n-rt.EPSILON)return!1;n=r[c]}return!0},He.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(!He.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},He.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(!He.isValidKnotVector(r.knotsU,r.degreeU)||!He.isValidKnotVector(r.knotsV,r.degreeV))throw new Q("Invalid knot vector format! Should begin with degree + 1 repeats and end with degree + 1 repeats!");return r};var le=f.eval.Divide=function(){};x["verb.eval.Divide"]=le,le.__name__=["verb","eval","Divide"],le.surfaceSplit=function(r,n,a){a==null&&(a=!1);var l,c,d;a?(d=r.controlPoints,l=r.knotsV,c=r.degreeV):(d=Lt.transpose(r.controlPoints),l=r.knotsU,c=r.degreeU);for(var p,_=[],y=0,A=c+1;y<A;)y++,_.push(n);p=_;for(var P=[],S=[],I=N.knotSpan(c,n,l),k=null,M=0;M<d.length;){var O=d[M];++M,k=ft.curveKnotRefine(new Gt(c,l,O),p),P.push(k.controlPoints.slice(0,I+1)),S.push(k.controlPoints.slice(I+1))}var C=k.knots.slice(0,I+c+2),F=k.knots.slice(I+1);return a?[new te(r.degreeU,c,r.knotsU.slice(),C,P),new te(r.degreeU,c,r.knotsU.slice(),F,S)]:(P=Lt.transpose(P),S=Lt.transpose(S),[new te(c,r.degreeV,C,r.knotsV.slice(),P),new te(c,r.degreeV,F,r.knotsV.slice(),S)])},le.curveSplit=function(r,n){var a=r.degree;r.controlPoints;for(var l=r.knots,c,d=[],p=0,_=a+1;p<_;)p++,d.push(n);c=d;var y=ft.curveKnotRefine(r,c),A=N.knotSpan(a,n,l),P=y.knots.slice(0,A+a+2),S=y.knots.slice(A+1),I=y.controlPoints.slice(0,A+1),k=y.controlPoints.slice(A+1);return[new Gt(a,P,I),new Gt(a,S,k)]},le.rationalCurveByEqualArcLength=function(r,n){var a=vt.rationalCurveArcLength(r),l=a/n;return le.rationalCurveByArcLength(r,l)},le.rationalCurveByArcLength=function(r,n){var a=ft.decomposeCurveIntoBeziers(r),l=a.map(function(I){return vt.rationalBezierCurveArcLength(I)}),c=m.sum(l),d=[new Mn(r.knots[0],0)];if(n>c)return d;for(var p=n,_=0,y=p,A=0,P=0,S;_<a.length;){for(A+=l[_];y<A+rt.EPSILON;)S=vt.rationalBezierCurveParamAtArcLength(a[_],y-P,rt.TOLERANCE,l[_]),d.push(new Mn(S,y)),y+=p;P+=l[_],_++}return d};var Mn=f.eval.CurveLengthSample=function(r,n){this.u=r,this.len=n};x["verb.eval.CurveLengthSample"]=Mn,Mn.__name__=["verb","eval","CurveLengthSample"],Mn.prototype={__class__:Mn};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 m.cross(l[1][0],l[0][1])},N.rationalSurfaceDerivatives=function(r,n,a,l){l==null&&(l=1);for(var c=N.surfaceDerivatives(r,n,a,l),d=N.rational2d(c),p=N.weight2d(c),_=[],y=d[0][0].length,A=0,P=l+1;A<P;){var S=A++;_.push([]);for(var I=0,k=l-S+1;I<k;){for(var M=I++,O=d[S][M],C=1,F=M+1;C<F;){var R=C++;m.subMulMutate(O,Ft.get(M,R)*p[0][R],_[S][M-R])}for(var U=1,V=S+1;U<V;){var q=U++;m.subMulMutate(O,Ft.get(S,q)*p[q][0],_[S-q][M]);for(var J=m.zeros1d(y),H=1,G=M+1;H<G;){var K=H++;m.addMulMutate(J,Ft.get(M,K)*p[q][K],_[S-q][M-K])}m.subMulMutate(O,Ft.get(S,q),J)}m.mulMutate(1/p[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),c=N.rational1d(l),d=N.weight1d(l),p=[],_=0,y=a+1;_<y;){for(var A=_++,P=c[A],S=1,I=A+1;S<I;){var k=S++;m.subMulMutate(P,Ft.get(A,k)*d[k],p[A-k])}m.mulMutate(1/d[0],P),p.push(P)}return p},N.rationalCurvePoint=function(r,n){return N.dehomogenize(N.curvePoint(r,n))},N.surfaceDerivatives=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2;return N.surfaceDerivativesGivenNM(c,d,r,n,a,l)},N.surfaceDerivativesGivenNM=function(r,n,a,l,c,d){var p=a.degreeU,_=a.degreeV,y=a.controlPoints,A=a.knotsU,P=a.knotsV;if(!N.areValidRelations(p,y.length,A.length)||!N.areValidRelations(_,y[0].length,P.length))throw new Q("Invalid relations between control points, knot vector, and n");var S=y[0][0].length,I;d<p?I=d:I=p;var k;d<_?k=d:k=_;for(var M=m.zeros3d(d+1,d+1,S),O=N.knotSpanGivenN(r,p,l,A),C=N.knotSpanGivenN(n,_,c,P),F=N.derivativeBasisFunctionsGivenNI(O,l,p,r,A),R=N.derivativeBasisFunctionsGivenNI(C,c,_,n,P),U=m.zeros2d(_+1,S),V=0,q=0,J=I+1;q<J;){for(var H=q++,G=0,K=_+1;G<K;){var tt=G++;U[tt]=m.zeros1d(S);for(var et=0,it=p+1;et<it;){var ht=et++;m.addMulMutate(U[tt],F[H][ht],y[O-p+ht][C-_+tt])}}var at=d-H;at<k?V=at:V=k;for(var ut=0,nt=V+1;ut<nt;){var mt=ut++;M[H][mt]=m.zeros1d(S);for(var X=0,gt=_+1;X<gt;){var Pt=X++;m.addMulMutate(M[H][mt],R[mt][Pt],U[Pt])}}}return M},N.surfacePoint=function(r,n,a){var l=r.knotsU.length-r.degreeU-2,c=r.knotsV.length-r.degreeV-2;return N.surfacePointGivenNM(l,c,r,n,a)},N.surfacePointGivenNM=function(r,n,a,l,c){var d=a.degreeU,p=a.degreeV,_=a.controlPoints,y=a.knotsU,A=a.knotsV;if(!N.areValidRelations(d,_.length,y.length)||!N.areValidRelations(p,_[0].length,A.length))throw new Q("Invalid relations between control points, knot vector, and n");for(var P=_[0][0].length,S=N.knotSpanGivenN(r,d,l,y),I=N.knotSpanGivenN(n,p,c,A),k=N.basisFunctionsGivenKnotSpanIndex(S,l,d,y),M=N.basisFunctionsGivenKnotSpanIndex(I,c,p,A),O=S-d,C=I,F=m.zeros1d(P),R=m.zeros1d(P),U=0,V=p+1;U<V;){var q=U++;R=m.zeros1d(P),C=I-p+q;for(var J=0,H=d+1;J<H;){var G=J++;m.addMulMutate(R,k[G],_[O+G][C])}m.addMulMutate(F,M[q],R)}return F},N.curveRegularSamplePoints=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),y=m.mul(c*l*.5,a[3]),A=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),I=[],k=0,M=n+1;k<M;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,A,y]),m.addAllMutate([A,P]),m.addAllMutate([_,y]);return I},N.curveRegularSamplePoints2=function(r,n){for(var a=N.curveDerivatives(r,r.knots[0],r.degree),l=1/n,c=l*l,d=a[0],p=m.mul(l,a[1]),_=m.mul(c*.5,a[2]),y=m.mul(c*l*.5,a[3]),A=m.add(_,_),P=m.add(y,y),S=m.mul(.3333333333333333,y),I=[],k=0,M=n+1;k<M;)k++,I.push(N.dehomogenize(d)),m.addAllMutate([d,p,_,S]),m.addAllMutate([p,A,y]),m.addAllMutate([A,P]),m.addAllMutate([_,y]);return I},N.rationalSurfaceRegularSampleDerivatives=function(r,n,a,l){for(var c=N.surfaceRegularSampleDerivatives(r,n,a,l),d=[],p=n+1,_=a+1,y=l+1,A=0;A<p;){var P=A++,S=[];d.push(S);for(var I=0;I<_;){for(var k=I++,M=c[P][k],O=N.rational2d(M),C=N.weight2d(M),F=[],R=O[0][0].length,U=0;U<y;){var V=U++;F.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++;m.subMulMutate(G,Ft.get(H,et)*C[0][et],F[V][H-et])}for(var it=1,ht=V+1;it<ht;){var at=it++;m.subMulMutate(G,Ft.get(V,at)*C[at][0],F[V-at][H]);for(var ut=m.zeros1d(R),nt=1,mt=H+1;nt<mt;){var X=nt++;m.addMulMutate(ut,Ft.get(H,X)*C[at][X],F[V-at][H-X])}m.subMulMutate(G,Ft.get(V,at),ut)}m.mulMutate(1/C[0][0],G),F[V].push(G)}}S.push(F)}}return d},N.surfaceRegularSampleDerivatives=function(r,n,a,l){var c=r.degreeU,d=r.degreeV,p=r.controlPoints,_=r.knotsU,y=r.knotsV,A=p[0][0].length;(Z.last(_)-_[0])/n,(Z.last(y)-y[0])/a;for(var P=N.regularlySpacedDerivativeBasisFunctions(c,_,n),S=P.item0,I=P.item1,k=N.regularlySpacedDerivativeBasisFunctions(d,y,a),M=k.item0,O=k.item1,C=[],F=n+1,R=a+1,U=0;U<F;){var V=U++,q=[];C.push(q);for(var J=0;J<R;){var H=J++;q.push(N.surfaceDerivativesGivenBasesKnotSpans(c,d,p,S[V],M[H],I[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,c=r.degreeV,d=r.controlPoints,p=r.knotsU,_=r.knotsV,y=d[0][0].length;(Z.last(p)-p[0])/n,(Z.last(_)-_[0])/a;for(var A=N.regularlySpacedBasisFunctions(l,p,n),P=A.item0,S=A.item1,I=N.regularlySpacedBasisFunctions(c,_,a),k=I.item0,M=I.item1,O=[],C=n+1,F=a+1,R=0;R<C;){var U=R++,V=[];O.push(V);for(var q=0;q<F;){var J=q++;V.push(N.surfacePointGivenBasesKnotSpans(l,c,d,P[U],k[J],S[U],M[J],y))}}return O},N.regularlySpacedBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=(Z.last(n)-n[0])/a,d=[],p=[],_=n[0],y=N.knotSpanGivenN(l,r,_,n),A=a+1,P=0;P<A;){for(P++;_>=n[y+1];)y++;p.push(y),d.push(N.basisFunctionsGivenKnotSpanIndex(y,_,r,n)),_+=c}return new ee(p,d)},N.regularlySpacedDerivativeBasisFunctions=function(r,n,a){for(var l=n.length-r-2,c=(Z.last(n)-n[0])/a,d=[],p=[],_=n[0],y=N.knotSpanGivenN(l,r,_,n),A=a+1,P=0;P<A;){for(P++;_>=n[y+1];)y++;p.push(y),d.push(N.derivativeBasisFunctionsGivenNI(y,_,r,l,n)),_+=c}return new ee(p,d)},N.surfacePointGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_){for(var y=m.zeros1d(_),A,P=l-r,S=c-n,I=0,k=n+1;I<k;){var M=I++;A=m.zeros1d(_);for(var O=0,C=r+1;O<C;){var F=O++;m.addMulMutate(A,d[F],a[P+F][S])}S++,m.addMulMutate(y,p[M],A)}return y},N.surfaceDerivativesGivenBasesKnotSpans=function(r,n,a,l,c,d,p,_,y){var A=a[0][0].length,P;y<r?P=y:P=r;var S;y<n?S=y:S=n;for(var I=m.zeros3d(P+1,S+1,A),k=m.zeros2d(n+1,A),M=0,O=0,C=P+1;O<C;){for(var F=O++,R=0,U=n+1;R<U;){var V=R++;k[V]=m.zeros1d(A);for(var q=0,J=r+1;q<J;){var H=q++;m.addMulMutate(k[V],d[F][H],a[l-r+H][c-n+V])}}var G=y-F;G<S?M=G:M=S;for(var K=0,tt=M+1;K<tt;){var et=K++;I[F][et]=m.zeros1d(A);for(var it=0,ht=n+1;it<ht;){var at=it++;m.addMulMutate(I[F][et],p[et][at],k[at])}}}return I},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 c=n.degree,d=n.controlPoints,p=n.knots;if(!N.areValidRelations(c,d.length,p.length))throw new Q("Invalid relations between control points, knot vector, and n");var _=d[0].length,y;l<c?y=l:y=c;for(var A=m.zeros2d(l+1,_),P=N.knotSpanGivenN(r,c,a,p),S=N.derivativeBasisFunctionsGivenNI(P,a,c,y,p),I=0,k=y+1;I<k;)for(var M=I++,O=0,C=c+1;O<C;){var F=O++;m.addMulMutate(A[M],S[M][F],d[P-c+F])}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,c=n.controlPoints,d=n.knots;if(!N.areValidRelations(l,c.length,d.length))throw new Q("Invalid relations between control points, knot Array, and n");for(var p=N.knotSpanGivenN(r,l,a,d),_=N.basisFunctionsGivenKnotSpanIndex(p,a,l,d),y=m.zeros1d(c[0].length),A=0,P=l+1;A<P;){var S=A++;m.addMulMutate(y,_[S],c[p-l+S])}return y},N.volumePoint=function(r,n,a,l){var c=r.knotsU.length-r.degreeU-2,d=r.knotsV.length-r.degreeV-2,p=r.knotsW.length-r.degreeW-2;return N.volumePointGivenNML(r,c,d,p,n,a,l)},N.volumePointGivenNML=function(r,n,a,l,c,d,p){if(!N.areValidRelations(r.degreeU,r.controlPoints.length,r.knotsU.length)||!N.areValidRelations(r.degreeV,r.controlPoints[0].length,r.knotsV.length)||!N.areValidRelations(r.degreeW,r.controlPoints[0][0].length,r.knotsW.length))throw new Q("Invalid relations between control points and knot vector");for(var _=r.controlPoints,y=r.degreeU,A=r.degreeV,P=r.degreeW,S=r.knotsU,I=r.knotsV,k=r.knotsW,M=_[0][0][0].length,O=N.knotSpanGivenN(n,y,c,S),C=N.knotSpanGivenN(a,A,d,I),F=N.knotSpanGivenN(l,P,p,k),R=N.basisFunctionsGivenKnotSpanIndex(O,c,y,S),U=N.basisFunctionsGivenKnotSpanIndex(C,d,A,I),V=N.basisFunctionsGivenKnotSpanIndex(F,p,P,k),q=O-y,J=m.zeros1d(M),H=m.zeros1d(M),G=m.zeros1d(M),K=0,tt=P+1;K<tt;){var et=K++;G=m.zeros1d(M);for(var it=F-P+et,ht=0,at=A+1;ht<at;){var ut=ht++;H=m.zeros1d(M);for(var nt=C-A+ut,mt=0,X=y+1;mt<X;){var gt=mt++;m.addMulMutate(H,R[gt],_[q+gt][nt][it])}m.addMulMutate(G,U[ut],H)}m.addMulMutate(J,V[et],G)}return J},N.derivativeBasisFunctions=function(r,n,a){var l=N.knotSpan(n,r,a),c=a.length-1,d=c-n-1;return N.derivativeBasisFunctionsGivenNI(l,r,n,d,a)},N.derivativeBasisFunctionsGivenNI=function(r,n,a,l,c){var d=m.zeros2d(a+1,a+1),p=m.zeros1d(a+1),_=m.zeros1d(a+1),y=0,A=0;d[0][0]=1;for(var P=1,S=a+1;P<S;){var I=P++;p[I]=n-c[r+1-I],_[I]=c[r+I]-n,y=0;for(var k=0;k<I;){var M=k++;d[I][M]=_[M+1]+p[I-M],A=d[M][I-1]/d[I][M],d[M][I]=y+_[M+1]*A,y=p[I-M]*A}d[I][I]=y}for(var O=m.zeros2d(l+1,a+1),C=m.zeros2d(2,a+1),F=0,R=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++;F=0,R=1,C[0][0]=1;for(var at=1,ut=l+1;at<ut;){var nt=at++;U=0,V=ht-nt,q=a-nt,ht>=nt&&(C[R][0]=C[F][0]/d[q+1][V],U=C[R][0]*d[V][q]),V>=-1?J=1:J=-V,ht-1<=q?H=nt-1:H=a-ht;for(var mt=J,X=H+1;mt<X;){var gt=mt++;C[R][gt]=(C[F][gt]-C[F][gt-1])/d[q+1][V+gt],U+=C[R][gt]*d[V+gt][q]}ht<=q&&(C[R][nt]=-C[F][nt-1]/d[q+1][ht],U+=C[R][nt]*d[ht][q]),O[nt][ht]=U;var Pt=F;F=R,R=Pt}}for(var jt=a,Xt=1,Dt=l+1;Xt<Dt;){for(var Kt=Xt++,Ie=0,Ye=a+1;Ie<Ye;){var ye=Ie++;O[Kt][ye]*=jt}jt*=a-Kt}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 c=m.zeros1d(a+1),d=m.zeros1d(a+1),p=m.zeros1d(a+1),_=0,y=0;c[0]=1;for(var A=1,P=a+1;A<P;){var S=A++;d[S]=n-l[r+1-S],p[S]=l[r+S]-n,_=0;for(var I=0;I<S;){var k=I++;y=c[k]/(p[k+1]+d[S-k]),c[k]=_+p[k+1]*y,_=d[S-k]*y}c[S]=_}return c},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 c=n,d=r+1,p=Math.floor((c+d)/2);a<l[p]||a>=l[p+1];)a<l[p]?d=p:c=p,p=Math.floor((c+d)/2);return p},N.dehomogenize=function(r){for(var n=r.length,a=[],l=r[n-1],c=r.length-1,d=0;d<c;){var p=d++;a.push(r[p]/l)}return a},N.rational1d=function(r){var n=r[0].length-1;return r.map(function(a){return a.slice(0,n)})},N.rational2d=function(r){return r.map(N.rational1d)},N.weight1d=function(r){var n=r[0].length-1;return r.map(function(a){return a[n]})},N.weight2d=function(r){return r.map(N.weight1d)},N.dehomogenize1d=function(r){return r.map(N.dehomogenize)},N.dehomogenize2d=function(r){return r.map(N.dehomogenize1d)},N.homogenize1d=function(r,n){var a=r.length,l=r[0].length,c=[],d=0,p=[],_;n!=null?_=n:_=m.rep(r.length,1);for(var y=0;y<a;){var A=y++,P=[];p=r[A],d=_[A];for(var S=0;S<l;){var I=S++;P.push(p[I]*d)}P.push(d),c.push(P)}return c},N.homogenize2d=function(r,n){var a=r.length,l=[],c;if(n!=null)c=n;else{for(var d=[],p=0;p<a;)p++,d.push(m.rep(r[0].length,1));c=d}for(var _=0;_<a;){var y=_++;l.push(N.homogenize1d(r[y],c[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),c=zt.rationalSurfaceAdaptive(n),d=lt.meshes(l,c),p=d.map(function(_){return _.map(function(y){return lt.surfacesAtPointWithEstimate(r,n,y.uv0,y.uv1,a)})});return p.map(function(_){return pt.rationalInterpCurve(_.map(function(y){return y.point}),3)})},lt.surfacesAtPointWithEstimate=function(r,n,a,l,c){var d,p,_,y,A,P,S,I,k,M,O,C,F,R=5,U=0;do{if(d=N.rationalSurfaceDerivatives(r,a[0],a[1],1),p=d[0][0],y=d[1][0],A=d[0][1],_=m.normalized(m.cross(y,A)),P=m.dot(_,p),S=N.rationalSurfaceDerivatives(n,l[0],l[1],1),I=S[0][0],M=S[1][0],O=S[0][1],k=m.normalized(m.cross(M,O)),C=m.dot(k,I),F=m.distSquared(p,I),F<c*c)break;var V=m.normalized(m.cross(_,k)),q=m.dot(V,p),J=lt.threePlanes(_,P,k,C,V,q);if(J==null)throw new Q("panic!");var H=m.sub(J,p),G=m.sub(J,I),K=m.cross(y,_),tt=m.cross(A,_),et=m.cross(M,k),it=m.cross(O,k),ht=m.dot(tt,H)/m.dot(tt,y),at=m.dot(K,H)/m.dot(K,A),ut=m.dot(it,G)/m.dot(it,M),nt=m.dot(et,G)/m.dot(et,O);a=m.add([ht,at],a),l=m.add([ut,nt],l),U++}while(U<R);return new $n(a,l,p,F)},lt.meshes=function(r,n,a,l){a==null&&(a=new ar(r)),l==null&&(l=new ar(n));var c=lt.boundingBoxTrees(a,l,0),d=Z.unique(c.map(function(p){return lt.triangles(r,p.item0,n,p.item1)}).filter(function(p){return p!=null}).filter(function(p){return m.distSquared(p.min.point,p.max.point)>rt.EPSILON}),function(p,_){var y=m.sub(p.min.uv0,_.min.uv0),A=m.dot(y,y),P=m.sub(p.max.uv0,_.max.uv0),S=m.dot(P,P),I=m.sub(p.min.uv0,_.max.uv0),k=m.dot(I,I),M=m.sub(p.max.uv0,_.min.uv0),O=m.dot(M,M);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 c=new zr(r),d=c.boundingBox(),p=d.min[0],_=d.min[1],y=d.max[0],A=d.max[1],P=m.span(n,a,l),S=[],I=0;I<P.length;){var k=P[I];++I;var M=[[p,_,k],[y,_,k],[y,A,k],[p,A,k]],O=[[0,0],[1,0],[1,1],[0,1]],C=[[0,1,2],[0,2,3]],F=new qe(C,M,null,O);S.push(lt.meshes(r,F,c))}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),c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.min),c.push(p.max)}for(var _=0;_<c.length;){var y=c[_];if(++_,y.adj==null){var A=lt.lookupAdjacentSegment(y,l,r.length);A!=null&&A.adj==null&&(y.adj=A,A.adj=y)}}var P=c.filter(function(R){return R.adj==null});P.length==0&&(P=c);for(var S=[],I=0,k=!1;P.length!=0;){var M=P.pop();if(!M.visited){for(var O=[],C=M;C!=null&&!(C.visited||(C.visited=!0,C.opp.visited=!0,O.push(C),I+=2,C=C.opp.adj,C==M)););O.length>0&&(O.push(O[O.length-1].opp),S.push(O))}if(P.length==0&&c.length>0&&(k||I<c.length)){k=!0;var F=c.pop();P.push(F)}}return S},lt.kdTreeFromSegments=function(r){for(var n=[],a=0;a<r.length;){var l=r[a];++a,n.push(new In(l.min.point,l.min)),n.push(new In(l.max.point,l.max))}return new Qn(n,m.distSquared)},lt.lookupAdjacentSegment=function(r,n,a){var l=n.nearest(r.point,a,rt.EPSILON).filter(function(c){return r!=c.item0.obj}).map(function(c){return c.item0.obj});return l.length==1?l[0]:null},lt.curveAndSurface=function(r,n,a,l,c){a==null&&(a=.001),l!=null?l=l:l=new ir(r),c!=null?c=c:c=new Or(n);var d=lt.boundingBoxTrees(l,c,a);return Z.unique(d.map(function(p){var _=p.item0,y=p.item1,A=Z.first(_.knots),P=Z.last(_.knots),S=(A+P)/2,I=Z.first(y.knotsU),k=Z.last(y.knotsU),M=Z.first(y.knotsV),O=Z.last(y.knotsV),C=[(I+k)/2,(M+O)/2];return lt.curveAndSurfaceWithEstimate(_,y,[S].concat(C),a)}).filter(function(p){return m.distSquared(p.curvePoint,p.surfacePoint)<a*a}),function(p,_){return Math.abs(p.u-_.u)<.5*a})},lt.curveAndSurfaceWithEstimate=function(r,n,a,l){l==null&&(l=.001);var c=function(y){var A=N.rationalCurvePoint(r,y[0]),P=N.rationalSurfacePoint(n,y[1],y[2]),S=m.sub(A,P);return m.dot(S,S)},d=function(y){var A=N.rationalCurveDerivatives(r,y[0],1),P=N.rationalSurfaceDerivatives(n,y[1],y[2],1),S=m.sub(P[0][0],A[0]),I=m.mul(-1,A[1]),k=P[1][0],M=P[0][1];return[2*m.dot(I,S),2*m.dot(k,S),2*m.dot(M,S)]},p=Xe.uncmin(c,a,l*l,d),_=p.solution;return new Xn(_[0],[_[1],_[2]],N.rationalCurvePoint(r,_[0]),N.rationalSurfacePoint(n,_[1],_[2]))},lt.polylineAndMesh=function(r,n,a){for(var l=lt.boundingBoxTrees(new or(r),new ar(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,y=p.item1,A=lt.segmentWithTriangle(r.points[_],r.points[_+1],n.points,n.faces[y]);if(A!=null){var P=A.point,S=m.lerp(A.p,[r.params[_]],[r.params[_+1]])[0],I=re.triangleUVFromPoint(n,y,P);c.push(new Kn(P,S,I,_,y))}}return c},lt.boundingBoxTrees=function(r,n,a){a==null&&(a=1e-9);var l=[],c=[];l.push(r),c.push(n);for(var d=[];l.length>0;){var p=l.pop(),_=c.pop();if(!(p.empty()||_.empty())&&p.boundingBox().intersects(_.boundingBox(),a)){var y=p.indivisible(a),A=_.indivisible(a);if(y&&A){d.push(new ee(p.yield(),_.yield()));continue}else if(y&&!A){var P=_.split();l.push(p),c.push(P.item1),l.push(p),c.push(P.item0);continue}else if(!y&&A){var S=p.split();l.push(S.item1),c.push(_),l.push(S.item0),c.push(_);continue}var I=p.split(),k=_.split();l.push(I.item1),c.push(k.item1),l.push(I.item1),c.push(k.item0),l.push(I.item0),c.push(k.item1),l.push(I.item0),c.push(k.item0)}}return d},lt.curves=function(r,n,a){var l=lt.boundingBoxTrees(new ir(r),new ir(n),0);return Z.unique(l.map(function(c){return lt.curvesWithEstimate(r,n,Z.first(c.item0.knots),Z.first(c.item1.knots),a)}).filter(function(c){return m.distSquared(c.point0,c.point1)<a}),function(c,d){return Math.abs(c.u0-d.u0)<a*5})},lt.curvesWithEstimate=function(r,n,a,l,c){var d=function(I){var k=N.rationalCurvePoint(r,I[0]),M=N.rationalCurvePoint(n,I[1]),O=m.sub(k,M);return m.dot(O,O)},p=function(I){var k=N.rationalCurveDerivatives(r,I[0],1),M=N.rationalCurveDerivatives(n,I[1],1),O=m.sub(k[0],M[0]),C=k[1],F=m.mul(-1,M[1]);return[2*m.dot(C,O),2*m.dot(F,O)]},_=Xe.uncmin(d,[a,l],c*c,p),y=_.solution[0],A=_.solution[1],P=N.rationalCurvePoint(r,y),S=N.rationalCurvePoint(n,A);return new Qr(P,S,y,A)},lt.triangles=function(r,n,a,l){var c=r.faces[n],d=a.faces[l],p=re.getTriangleNorm(r.points,c),_=re.getTriangleNorm(a.points,d),y=r.points[c[0]],A=a.points[d[0]],P=lt.planes(y,p,A,_);if(P==null)return null;var S=lt.clipRayInCoplanarTriangle(P,r,n);if(S==null)return null;var I=lt.clipRayInCoplanarTriangle(P,a,l);if(I==null)return null;var k=lt.mergeTriangleClipIntervals(S,I,r,n,a,l);return k==null?null:new Pe(new Lr(k.min.uv0,k.min.uv1,k.min.point,n,l),new Lr(k.max.uv0,k.max.uv1,k.max.point,n,l))},lt.clipRayInCoplanarTriangle=function(r,n,a){for(var l=n.faces[a],c=[n.points[l[0]],n.points[l[1]],n.points[l[2]]],d=[n.uvs[l[0]],n.uvs[l[1]],n.uvs[l[2]]],p=[m.sub(d[1],d[0]),m.sub(d[2],d[1]),m.sub(d[0],d[2])],_=[m.sub(c[1],c[0]),m.sub(c[2],c[1]),m.sub(c[0],c[2])],y=_.map(m.normalized),A=_.map(m.norm),P=null,S=null,I=0;I<3;){var k=I++,M=c[k],O=y[k],C=lt.rays(M,O,r.origin,r.dir);if(C!=null){var F=C.u0,R=C.u1;F<-rt.EPSILON||F>A[k]+rt.EPSILON||((P==null||R<P.u)&&(P=new Pn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],F/A[k]))),(S==null||R>S.u)&&(S=new Pn(R,m.onRay(r.origin,r.dir,R),m.onRay(d[k],p[k],F/A[k]))))}}return S==null||P==null?null:new Pe(P,S)},lt.mergeTriangleClipIntervals=function(r,n,a,l,c,d){if(n.min.u>r.max.u+rt.EPSILON||r.min.u>n.max.u+rt.EPSILON)return null;var p;r.min.u>n.min.u?p=new ee(r.min,0):p=new ee(n.min,1);var _;r.max.u<n.max.u?_=new ee(r.max,0):_=new ee(n.max,1);var y=new Pe(new Lr(null,null,p.item0.point,l,d),new Lr(null,null,_.item0.point,l,d));return p.item1==0?(y.min.uv0=p.item0.uv,y.min.uv1=re.triangleUVFromPoint(c,d,p.item0.point)):(y.min.uv0=re.triangleUVFromPoint(a,l,p.item0.point),y.min.uv1=p.item0.uv),_.item1==0?(y.max.uv0=_.item0.uv,y.max.uv1=re.triangleUVFromPoint(c,d,_.item0.point)):(y.max.uv0=re.triangleUVFromPoint(a,l,_.item0.point),y.max.uv1=_.item0.uv),y},lt.planes=function(r,n,a,l){var c=m.cross(n,l);if(m.dot(c,c)<rt.EPSILON)return null;var d=0,p=Math.abs(c[0]),_=Math.abs(c[1]),y=Math.abs(c[2]);_>p&&(d=1,p=_),y>p&&(d=2,p=y);var A,P,S,I;d==0?(A=n[1],P=n[2],S=l[1],I=l[2]):d==1?(A=n[0],P=n[2],S=l[0],I=l[2]):(A=n[0],P=n[1],S=l[0],I=l[1]);var k=-m.dot(r,n),M=-m.dot(a,l),O=A*I-P*S,C=(P*M-k*I)/O,F=(k*S-A*M)/O,R;return d==0?R=[0,C,F]:d==1?R=[C,0,F]:R=[C,F,0],new Sn(R,m.normalized(c))},lt.threePlanes=function(r,n,a,l,c,d){var p=m.cross(a,c),_=m.dot(r,p);if(Math.abs(_)<rt.EPSILON)return null;var y=m.sub(m.mul(d,a),m.mul(l,c)),A=m.add(m.mul(n,p),m.cross(r,y));return m.mul(1/_,A)},lt.polylines=function(r,n,a){for(var l=lt.boundingBoxTrees(new or(r),new or(n),a),c=[],d=0;d<l.length;){var p=l[d];++d;var _=p.item0,y=p.item1,A=lt.segments(r.points[_],r.points[_+1],n.points[y],n.points[y+1],a);A!=null&&(A.u0=m.lerp(A.u0,[r.params[_]],[r.params[_+1]])[0],A.u1=m.lerp(A.u1,[n.params[y]],[n.params[y+1]])[0],c.push(A))}return c},lt.segments=function(r,n,a,l,c){var d=m.sub(n,r),p=Math.sqrt(m.dot(d,d)),_=m.mul(1/p,d),y=m.sub(l,a),A=Math.sqrt(m.dot(y,y)),P=m.mul(1/A,y),S=lt.rays(r,_,a,P);if(S!=null){var I=Math.min(Math.max(0,S.u0/p),1),k=Math.min(Math.max(0,S.u1/A),1),M=m.onRay(r,d,I),O=m.onRay(a,y,k),C=m.distSquared(M,O);if(C<c*c)return new Qr(M,O,I,k)}return null},lt.rays=function(r,n,a,l){var c=m.dot(n,l),d=m.dot(n,a),p=m.dot(n,r),_=m.dot(l,a),y=m.dot(l,r),A=m.dot(n,n),P=m.dot(l,l),S=A*P-c*c;if(Math.abs(S)<rt.EPSILON)return null;var I=c*(d-p)-A*(_-y),k=I/S,M=(d-p+k*c)/A,O=m.onRay(r,n,M),C=m.onRay(a,l,k);return new Qr(O,C,M,k)},lt.segmentWithTriangle=function(r,n,a,l){var c=a[l[0]],d=a[l[1]],p=a[l[2]],_=m.sub(d,c),y=m.sub(p,c),A=m.cross(_,y),P=m.sub(n,r),S=m.sub(r,c),I=-m.dot(A,S),k=m.dot(A,P);if(Math.abs(k)<rt.EPSILON)return null;var M=I/k;if(M<0||M>1)return null;var O=m.add(r,m.mul(M,P)),C=m.dot(_,y),F=m.dot(_,_),R=m.dot(y,y),U=m.sub(O,c),V=m.dot(U,_),q=m.dot(U,y),J=C*C-F*R;if(Math.abs(J)<rt.EPSILON)return null;var H=(C*q-R*V)/J,G=(C*V-F*q)/J;return H>1+rt.EPSILON||G>1+rt.EPSILON||G<-rt.EPSILON||H<-rt.EPSILON||H+G>1+rt.EPSILON?null:new Zn(O,H,G,M)},lt.segmentAndPlane=function(r,n,a,l){var c=m.dot(l,m.sub(n,r));if(Math.abs(c)<rt.EPSILON)return null;var d=m.dot(l,m.sub(a,r)),p=d/c;return p>1+rt.EPSILON||p<-rt.EPSILON?null:{p}};var pt=f.eval.Make=function(){};x["verb.eval.Make"]=pt,pt.__name__=["verb","eval","Make"],pt.rationalTranslationalSurface=function(r,n){for(var a=N.rationalCurvePoint(n,Z.first(n.knots)),l=Z.first(n.knots),c=Z.last(n.knots),d=2*n.controlPoints.length,p=(c-l)/(d-1),_=[],y=0;y<d;){var A=y++,P=m.sub(N.rationalCurvePoint(n,l+A*p),a),S=ft.rationalCurveTransform(r,[[1,0,0,P[0]],[0,1,0,P[1]],[0,0,1,P[2]],[0,0,0,1]]);_.push(S)}return pt.loftedSurface(_)},pt.surfaceBoundaryCurves=function(r){var n=pt.surfaceIsocurve(r,Z.first(r.knotsU),!1),a=pt.surfaceIsocurve(r,Z.last(r.knotsU),!1),l=pt.surfaceIsocurve(r,Z.first(r.knotsV),!0),c=pt.surfaceIsocurve(r,Z.last(r.knotsV),!0);return[n,a,l,c]},pt.surfaceIsocurve=function(r,n,a){a==null&&(a=!1);var l;a?l=r.knotsV:l=r.knotsU;var c;a?c=r.degreeV:c=r.degreeU;for(var d=vt.knotMultiplicities(l),p=-1,_=0,y=d.length;_<y;){var A=_++;if(Math.abs(n-d[A].knot)<rt.EPSILON){p=A;break}}var P=c+1;p>=0&&(P=P-d[p].mult);var S;P>0?S=ft.surfaceKnotRefine(r,m.rep(P,n),a):S=r;var I=N.knotSpan(c,n,l);return Math.abs(n-Z.first(l))<rt.EPSILON?I=0:Math.abs(n-Z.last(l))<rt.EPSILON&&(I=(a?S.controlPoints[0].length:S.controlPoints.length)-1),a?new Gt(S.degreeU,S.knotsU,function(k){for(var M,O=[],C=0,F=S.controlPoints;C<F.length;){var R=F[C];++C,O.push(R[I])}return M=O,M}()):new Gt(S.degreeV,S.knotsV,S.controlPoints[I])},pt.loftedSurface=function(r,n){r=ft.unifyCurveKnotVectors(r);var a=r[0].degree;n==null&&(n=3),n>r.length-1&&(n=r.length-1);for(var l=r[0].knots,c=[],d=[],p=0,_=r[0].controlPoints.length;p<_;){var y=[p++],A=r.map(function(S){return function(I){return I.controlPoints[S[0]]}}(y)),P=pt.rationalInterpCurve(A,n,!0);d.push(P.controlPoints),c=P.knots}return new te(a,n,l,c,d)},pt.clonedCurve=function(r){return new Gt(r.degree,r.knots.slice(),r.controlPoints.map(function(n){return n.slice()}))},pt.rationalBezierCurve=function(r,n){for(var a=r.length-1,l=[],c=0,d=a+1;c<d;)c++,l.push(0);for(var p=0,_=a+1;p<_;)p++,l.push(1);return n==null&&(n=m.rep(r.length,1)),new Gt(a,l,N.homogenize1d(r,n))},pt.fourPointSurface=function(r,n,a,l,c){c==null&&(c=3);for(var d=c,p=[],_=0,y=c+1;_<y;){for(var A=_++,P=[],S=0,I=c+1;S<I;){var k=S++,M=1-A/d,O=m.lerp(M,r,n),C=m.lerp(M,l,a),F=m.lerp(1-k/d,O,C);F.push(1),P.push(F)}p.push(P)}var R=m.rep(c+1,0),U=m.rep(c+1,1);return new te(c,c,R.concat(U),R.concat(U),p)},pt.ellipseArc=function(r,n,a,l,c){var d=m.norm(n),p=m.norm(a);n=m.normalized(n),a=m.normalized(a),c<l&&(c=2*Math.PI+l);var _=c-l,y=0;_<=Math.PI/2?y=1:_<=Math.PI?y=2:_<=3*Math.PI/2?y=3:y=4;var A=_/y,P=Math.cos(A/2),S=m.add(r,m.add(m.mul(d*Math.cos(l),n),m.mul(p*Math.sin(l),a))),I=m.sub(m.mul(Math.cos(l),a),m.mul(Math.sin(l),n)),k=[],M=m.zeros1d(2*y+3),O=0,C=l,F=m.zeros1d(y*2);k[0]=S,F[0]=1;for(var R=1,U=y+1;R<U;){var V=R++;C+=A;var q=m.add(r,m.add(m.mul(d*Math.cos(C),n),m.mul(p*Math.sin(C),a)));F[O+2]=1,k[O+2]=q;var J=m.sub(m.mul(Math.cos(C),a),m.mul(Math.sin(C),n)),H=lt.rays(S,m.mul(1/m.norm(I),I),q,m.mul(1/m.norm(J),J)),G=m.add(S,m.mul(H.u0,I));F[O+1]=P,k[O+1]=G,O+=2,V<y&&(S=q,I=J)}for(var K=2*y+1,tt=0;tt<3;){var et=tt++;M[et]=0,M[et+K]=1}switch(y){case 2:M[3]=M[4]=.5;break;case 3:M[3]=M[4]=.3333333333333333,M[5]=M[6]=.6666666666666666;break;case 4:M[3]=M[4]=.25,M[5]=M[6]=.5,M[7]=M[8]=.75;break}return new Gt(2,M,N.homogenize1d(k,F))},pt.arc=function(r,n,a,l,c,d){return pt.ellipseArc(r,m.mul(l,m.normalized(n)),m.mul(l,m.normalized(a)),c,d)},pt.polyline=function(r){for(var n=[0,0],a=0,l=0,c=r.length-1;l<c;){var d=l++;a+=m.dist(r[d],r[d+1]),n.push(a)}n.push(a),n=m.mul(1/a,n);for(var p,_=[],y=0,A=r.length;y<A;)y++,_.push(1);return p=_,new Gt(1,n,N.homogenize1d(r.slice(0),p))},pt.extrudedSurface=function(r,n,a){for(var l=[[],[],[]],c=[[],[],[]],d=N.dehomogenize1d(a.controlPoints),p=N.weight1d(a.controlPoints),_=m.mul(n,r),y=m.mul(.5*n,r),A=0,P=d.length;A<P;){var S=A++;l[2][S]=d[S],l[1][S]=m.add(y,d[S]),l[0][S]=m.add(_,d[S]),c[0][S]=p[S],c[1][S]=p[S],c[2][S]=p[S]}return new te(2,a.degree,[0,0,0,1,1,1],a.knots,N.homogenize2d(l,c))},pt.cylindricalSurface=function(r,n,a,l,c){var d=m.cross(r,n),p=pt.arc(a,n,d,c,0,2*Math.PI);return pt.extrudedSurface(r,l,p)},pt.revolvedSurface=function(r,n,a,l){var c=N.dehomogenize1d(r.controlPoints),d=N.weight1d(r.controlPoints),p,_;l<=Math.PI/2?(p=1,_=m.zeros1d(6+2*(p-1))):l<=Math.PI?(p=2,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.5):l<=3*Math.PI/2?(p=3,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.3333333333333333,_[5]=_[6]=.6666666666666666):(p=4,_=m.zeros1d(6+2*(p-1)),_[3]=_[4]=.25,_[5]=_[6]=.5,_[7]=_[8]=.75);for(var y=l/p,A=3+2*(p-1),P=0;P<3;){var S=P++;_[S]=0,_[A+S]=1}for(var I=Math.cos(y/2),k=0,M=m.zeros1d(p+1),O=m.zeros1d(p+1),C=m.zeros3d(2*p+1,c.length,3),F=m.zeros2d(2*p+1,c.length),R=1,U=p+1;R<U;){var V=R++;k+=y,O[V]=Math.cos(k),M[V]=Math.sin(k)}for(var q=0,J=c.length;q<J;){var H=q++,G=Ce.rayClosestPoint(c[H],n,a),K=m.sub(c[H],G),tt=m.norm(K),et=m.cross(a,K);tt>rt.EPSILON&&(K=m.mul(1/tt,K),et=m.mul(1/tt,et)),C[0][H]=c[H];var it=c[H];F[0][H]=d[H];for(var ht=et,at=0,ut=1,nt=p+1;ut<nt;){var mt=ut++,X;tt==0?X=G:X=m.add(G,m.add(m.mul(tt*O[mt],K),m.mul(tt*M[mt],et))),C[at+2][H]=X,F[at+2][H]=d[H];var gt=m.sub(m.mul(O[mt],et),m.mul(M[mt],K));if(tt==0)C[at+1][H]=G;else{var Pt=lt.rays(it,m.mul(1/m.norm(ht),ht),X,m.mul(1/m.norm(gt),gt)),jt=m.add(it,m.mul(Pt.u0,ht));C[at+1][H]=jt}F[at+1][H]=I*d[H],at+=2,mt<p&&(it=X,ht=gt)}}return new te(2,r.degree,_,r.knots,N.homogenize2d(C,F))},pt.sphericalSurface=function(r,n,a,l){var c=pt.arc(r,m.mul(-1,n),a,l,0,Math.PI);return pt.revolvedSurface(c,r,n,2*Math.PI)},pt.conicalSurface=function(r,n,a,l,c){var d=2*Math.PI,p=1,_=[m.add(a,m.mul(l,r)),m.add(a,m.mul(c,n))],y=[0,0,1,1],A=[1,1],P=new Gt(p,y,N.homogenize1d(_,A));return pt.revolvedSurface(P,a,r,d)},pt.rationalInterpCurve=function(r,n,a,l,c){if(a==null&&(a=!1),n==null&&(n=3),r.length<n+1)throw new Q("You need to supply at least degree + 1 points! You only supplied "+r.length+" points.");for(var d=[0],p=1,_=r.length;p<_;){var y=p++,A=m.norm(m.sub(r[y],r[y-1])),P=d[d.length-1];d.push(P+A)}for(var S=d[d.length-1],I=0,k=d.length;I<k;){var M=I++;d[M]=d[M]/S}var O=m.rep(n+1,0),C=l!=null&&c!=null,F;C?F=0:F=1;var R;C?R=d.length-n+1:R=d.length-n;for(var U=F;U<R;){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(m.rep(n+1,1)),K=[],tt;C?tt=r.length+1:tt=r.length-1;var et;C?et=r.length-(n-1):et=r.length-(n+1);for(var it=0;it<d.length;){var ht=d[it];++it;var at=N.knotSpanGivenN(tt,n,ht,G),ut=N.basisFunctionsGivenKnotSpanIndex(at,ht,n,G),nt=at-n,mt=m.zeros1d(nt),X=m.zeros1d(et-nt);K.push(mt.concat(ut).concat(X))}if(C){var gt=K[0].length-2,Pt=[-1,1].concat(m.zeros1d(gt)),jt=m.zeros1d(gt).concat([-1,1]);Z.spliceAndInsert(K,1,0,Pt),Z.spliceAndInsert(K,K.length-1,0,jt)}for(var Xt=r[0].length,Dt=[],Kt=(1-G[G.length-n-2])/n,Ie=G[n+1]/n,Ye=0;Ye<Xt;){var ye=[Ye++],ge;if(!C)ge=r.map(function(Je){return function(mr){return mr[Je[0]]}}(ye));else{ge=[r[0][ye[0]]],ge.push(Ie*l[ye[0]]);for(var Ee=1,Oe=r.length-1;Ee<Oe;){var $e=Ee++;ge.push(r[$e][ye[0]])}ge.push(Kt*c[ye[0]]),ge.push(Z.last(r)[ye[0]])}var lr=Lt.solve(K,ge);Dt.push(lr)}var Ze=Lt.transpose(Dt);if(!a){var Qe=m.rep(Ze.length,1);Ze=N.homogenize1d(Ze,Qe)}return new Gt(n,G,Ze)};var ft=f.eval.Modify=function(){};x["verb.eval.Modify"]=ft,ft.__name__=["verb","eval","Modify"],ft.curveReverse=function(r){return new Gt(r.degree,ft.knotsReverse(r.knots),Z.reversed(r.controlPoints))},ft.surfaceReverse=function(r,n){return n==null&&(n=!1),n?new te(r.degreeU,r.degreeV,r.knotsU,ft.knotsReverse(r.knotsV),function(a){for(var l,c=[],d=0,p=r.controlPoints;d<p.length;){var _=p[d];++d,c.push(Z.reversed(_))}return l=c,l}()):new te(r.degreeU,r.degreeV,ft.knotsReverse(r.knotsU),r.knotsV,Z.reversed(r.controlPoints))},ft.knotsReverse=function(r){var n=Z.first(r);Z.last(r);for(var a=[n],l=r.length,c=1;c<l;){var d=c++;a.push(a[d-1]+(r[l-d]-r[l-d-1]))}return a},ft.unifyCurveKnotVectors=function(r){r=r.map(pt.clonedCurve);for(var n=z.fold(r,function(G,K){return ft.imax(G.degree,K)},0),a=0,l=r.length;a<l;){var c=a++;r[c].degree<n&&(r[c]=ft.curveElevateDegree(r[c],n))}for(var d,p=[],_=0;_<r.length;){var y=r[_];++_,p.push(new Pe(Z.first(y.knots),Z.last(y.knots)))}d=p;for(var A=0,P=r.length;A<P;){var S=A++,I=[d[S].min];r[S].knots=r[S].knots.map(function(G){return function(K){return K-G[0]}}(I))}for(var k=d.map(function(G){return G.max-G.min}),M=z.fold(k,function(G,K){return Math.max(G,K)},0),O=0,C=r.length;O<C;){var F=O++,R=[M/k[F]];r[F].knots=r[F].knots.map(function(G){return function(K){return K*G[0]}}(R))}for(var U=z.fold(r,function(G,K){return m.sortedSetUnion(G.knots,K)},[]),V=0,q=r.length;V<q;){var J=V++,H=m.sortedSetSub(U,r[J].knots);H.length==0&&(r[J]=r[J]),r[J]=ft.curveKnotRefine(r[J],H)}return r},ft.imin=function(r,n){return r<n?r:n},ft.imax=function(r,n){return r>n?r:n},ft.curveElevateDegree=function(r,n){if(n<=r.degree)return r;var a=r.knots.length-r.degree-2,l=r.degree,c=r.knots,d=r.controlPoints,p=n-r.degree,_=r.controlPoints[0].length,y=m.zeros2d(l+p+1,l+1),A=[],P=[],S=[],I=a+l+1,k=n,M=Math.floor(k/2),O=[],C=[];y[0][0]=1,y[k][l]=1;for(var F=1,R=M+1;F<R;)for(var U=F++,V=1/Ft.get(k,U),q=ft.imin(l,U),J=ft.imax(0,U-p),H=q+1;J<H;){var G=J++;y[U][G]=V*Ft.get(l,G)*Ft.get(p,U-G)}for(var K=M+1;K<k;)for(var tt=K++,et=ft.imin(l,tt),it=ft.imax(0,tt-p),ht=et+1;it<ht;){var at=it++;y[tt][at]=y[k-tt][l-at]}var ut=k+1,nt=-1,mt=l,X=l+1,gt=1,Pt=c[0];O[0]=d[0];for(var jt=0,Xt=k+1;jt<Xt;){var Dt=jt++;C[Dt]=Pt}for(var Kt=0,Ie=l+1;Kt<Ie;){var Ye=Kt++;A[Ye]=d[Ye]}for(;X<I;){for(var ye=X;X<I&&c[X]==c[X+1];)X=X+1;var ge=X-ye+1,Ee=c[X],Oe=nt;nt=l-ge;var $e;Oe>0?$e=Math.floor((Oe+2)/2):$e=1;var lr;if(nt>0?lr=Math.floor(k-(nt+1)/2):lr=k,nt>0){for(var Ze=Ee-Pt,Qe=[],Je=l;Je>ge;)Qe[Je-ge-1]=Ze/(c[mt+Je]-Pt),Je--;for(var mr=1,Ln=nt+1;mr<Ln;){for(var tn=mr++,Kc=nt-tn,Ki=ge+tn,en=l;en>=Ki;)A[en]=m.add(m.mul(Qe[en-Ki],A[en]),m.mul(1-Qe[en-Ki],A[en-1])),en--;S[Kc]=A[l]}}for(var Lo=$e,$c=k+1;Lo<$c;){var On=Lo++;P[On]=m.zeros1d(_);for(var Zc=ft.imin(l,On),Oo=ft.imax(0,On-p),Qc=Zc+1;Oo<Qc;){var zo=Oo++;P[On]=m.add(P[On],m.mul(y[On][zo],A[zo]))}}if(Oe>1)for(var $i=ut-2,Zi=ut,Ro=Ee-Pt,Jc=(Ee-C[ut-1])/Ro,Fo=1;Fo<Oe;){for(var Qi=Fo++,pr=$i,rn=Zi,Vr=rn-ut+1;rn-pr>Qi;){if(pr<gt){var tu=(Ee-C[pr])/(Pt-C[pr]);O[pr]=m.lerp(tu,O[pr],O[pr-1])}if(rn>=$e){if(rn-Qi<=ut-k+Oe){var eu=(Ee-C[rn-Qi])/Ro;P[Vr]=m.lerp(eu,P[Vr],P[Vr+1])}}else P[Vr]=m.lerp(Jc,P[Vr],P[Vr+1]);pr=pr+1,rn=rn-1,Vr=Vr-1}$i=$i-1,Zi=Zi+1}if(mt!=l)for(var Bo=0,ru=k-Oe;Bo<ru;)Bo++,C[ut]=Pt,ut=ut+1;for(var Do=$e,nu=lr+1;Do<nu;){var su=Do++;O[gt]=P[su],gt=gt+1}if(X<I){for(var Uo=0;Uo<nt;){var Vo=Uo++;A[Vo]=S[Vo]}for(var Go=nt,iu=l+1;Go<iu;){var jo=Go++;A[jo]=d[X-l+jo]}mt=X,X=X+1,Pt=Ee}else for(var Wo=0,au=k+1;Wo<au;){var ou=Wo++;C[ut+ou]=Ee}}return new Gt(n,C,O)},ft.rationalSurfaceTransform=function(r,n){for(var a=N.dehomogenize2d(r.controlPoints),l=0,c=a.length;l<c;)for(var d=l++,p=0,_=a[d].length;p<_;){var y=p++,A=a[d][y];A.push(1),a[d][y]=Lt.dot(n,A).slice(0,A.length-1)}return new te(r.degreeU,r.degreeV,r.knotsU.slice(),r.knotsV.slice(),N.homogenize2d(a,N.weight2d(r.controlPoints)))},ft.rationalCurveTransform=function(r,n){for(var a=N.dehomogenize1d(r.controlPoints),l=0,c=a.length;l<c;){var d=l++,p=a[d];p.push(1),a[d]=Lt.dot(n,p).slice(0,p.length-1)}return new Gt(r.degree,r.knots.slice(),N.homogenize1d(a,N.weight1d(r.controlPoints)))},ft.surfaceKnotRefine=function(r,n,a){var l=[],c,d,p;a?(p=r.controlPoints,c=r.knotsV,d=r.degreeV):(p=Lt.transpose(r.controlPoints),c=r.knotsU,d=r.degreeU);for(var _=null,y=0;y<p.length;){var A=p[y];++y,_=ft.curveKnotRefine(new Gt(d,c,A),n),l.push(_.controlPoints)}var P=_.knots;return a?new te(r.degreeU,r.degreeV,r.knotsU.slice(),P,l):(l=Lt.transpose(l),new te(r.degreeU,r.degreeV,P,r.knotsV.slice(),l))},ft.decomposeCurveIntoBeziers=function(r){for(var n=r.degree,a=r.controlPoints,l=r.knots,c=vt.knotMultiplicities(l),d=n+1,p=0;p<c.length;){var _=c[p];if(++p,_.mult<d){var y=m.rep(d-_.mult,_.knot),A=ft.curveKnotRefine(new Gt(n,l,a),y);l=A.knots,a=A.controlPoints}}l.length/d-1;for(var P=d*2,S=[],I=0;I<a.length;){var k=l.slice(I,I+P),M=a.slice(I,I+d);S.push(new Gt(n,k,M)),I+=d}return S},ft.curveKnotRefine=function(r,n){if(n.length==0)return pt.clonedCurve(r);for(var a=r.degree,l=r.controlPoints,c=r.knots,d=l.length-1,p=d+a+1,_=n.length-1,y=N.knotSpan(a,n[0],c),A=N.knotSpan(a,n[_],c),P=[],S=[],I=0,k=y-a+1;I<k;){var M=I++;P[M]=l[M]}for(var O=A-1,C=d+1;O<C;){var F=O++;P[F+_+1]=l[F]}for(var R=0,U=y+1;R<U;){var V=R++;S[V]=c[V]}for(var q=A+a,J=p+1;q<J;){var H=q++;S[H+_+1]=c[H]}for(var G=A+a-1,K=A+a+_,tt=_;tt>=0;){for(;n[tt]<=c[G]&&G>y;)P[K-a-1]=l[G-a-1],S[K]=c[G],K=K-1,G=G-1;P[K-a-1]=P[K-a];for(var et=1,it=a+1;et<it;){var ht=et++,at=K-a+ht,ut=S[K+ht]-n[tt];Math.abs(ut)<rt.EPSILON?P[at-1]=P[at]:(ut=ut/(S[K+ht]-c[G-a+ht]),P[at-1]=m.add(m.mul(ut,P[at-1]),m.mul(1-ut,P[at])))}S[K]=n[tt],K=K-1,tt--}return new Gt(a,S,P)},ft.curveKnotInsert=function(r,n,a){for(var l=r.degree,c=r.controlPoints,d=r.knots,p=0,_=c.length,y=N.knotSpan(l,n,d),A=[],P=[],S=[],I=1,k=y+1;I<k;){var M=I++;P[M]=d[M]}for(var O=1,C=a+1;O<C;){var F=O++;P[y+F]=n}for(var R=y+1,U=d.length;R<U;){var V=R++;P[V+a]=d[V]}for(var q=0,J=y-l+1;q<J;){var H=q++;S[H]=c[H]}for(var G=y-p;G<_;){var K=G++;S[K+a]=c[K]}for(var tt=0,et=l-p+1;tt<et;){var it=tt++;A[it]=c[y-l+it]}for(var ht=0,at=0,ut=1,nt=a+1;ut<nt;){var mt=ut++;ht=y-l+mt;for(var X=0,gt=l-mt-p+1;X<gt;){var Pt=X++;at=(n-d[ht+Pt])/(d[Pt+y+1]-d[ht+Pt]),A[Pt]=m.add(m.mul(at,A[Pt+1]),m.mul(1-at,A[Pt]))}S[ht]=A[0],S[y+a-mt-p]=A[l-mt-p]}for(var jt=ht+1,Xt=y-p;jt<Xt;){var Dt=jt++;S[Dt]=A[Dt-ht]}return new Gt(l,P,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],Z.last(r.knots),n,a)},zt.rationalCurveRegularSampleRange=function(r,n,a,l,c){l<1&&(l=2);for(var d=[],p=(a-n)/(l-1),_=0,y=0;y<l;){var A=y++;_=n+p*A,c?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=[],c=0,d=r.controlPoints.length;c<d;){var p=c++;l.push([r.knots[p+1]].concat(N.dehomogenize(r.controlPoints[p])))}return l}else return r.controlPoints.map(N.dehomogenize);return zt.rationalCurveAdaptiveSampleRange(r,r.knots[0],Z.last(r.knots),n,a)},zt.rationalCurveAdaptiveSampleRange=function(r,n,a,l,c){var d=N.rationalCurvePoint(r,n),p=N.rationalCurvePoint(r,a),_=.5+.2*Math.random(),y=n+(a-n)*_,A=N.rationalCurvePoint(r,y),P=m.sub(d,p),S=m.sub(d,A);if(m.dot(P,P)<l&&m.dot(S,S)>l||!Ce.threePointsAreFlat(d,A,p,l)){var I=n+(a-n)*.5,k=zt.rationalCurveAdaptiveSampleRange(r,n,I,l,c),M=zt.rationalCurveAdaptiveSampleRange(r,I,a,l,c);return k.slice(0,-1).concat(M)}else return c?[[n].concat(d),[a].concat(p)]:[d,p]},zt.rationalSurfaceNaive=function(r,n,a){n<1&&(n=1),a<1&&(a=1),r.degreeU,r.degreeV,r.controlPoints;for(var l=r.knotsU,c=r.knotsV,d=Z.last(l)-l[0],p=Z.last(c)-c[0],_=d/n,y=p/a,A=[],P=[],S=[],I=0,k=n+1;I<k;)for(var M=I++,O=0,C=a+1;O<C;){var F=O++,R=M*_,U=F*y;P.push([R,U]);var V=N.rationalSurfaceDerivatives(r,R,U,1),q=V[0][0];A.push(q);var J=m.normalized(m.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,ut=it+1,nt=[it,ht,at],mt=[it,at,ut];H.push(nt),H.push(mt)}return new qe(H,A,S,P)},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,c;n.minDivsU>a?c=n.minDivsU=n.minDivsU:c=n.minDivsU=a;var d;n.minDivsV>l?d=n.minDivsV=n.minDivsV:d=n.minDivsV=l;for(var p=Z.last(r.knotsU),_=r.knotsU[0],y=Z.last(r.knotsV),A=r.knotsV[0],P=(p-_)/c,S=(y-A)/d,I=[],k=[],M=0,O=d+1;M<O;){for(var C=M++,F=[],R=0,U=c+1;R<U;){var V=R++,q=_+P*V,J=A+S*C,H=N.rationalSurfaceDerivatives(r,q,J,1),G=m.normalized(m.cross(H[0][1],H[1][0]));F.push(new We(H[0][0],G,[q,J],-1,m.isZero(G)))}k.push(F)}for(var K=0;K<d;)for(var tt=K++,et=0;et<c;){var it=et++,ht=[k[d-tt-1][it],k[d-tt-1][it+1],k[d-tt][it+1],k[d-tt][it]];I.push(new dr(r,ht))}if(!n.refine)return I;for(var at=0;at<d;)for(var ut=at++,nt=0;nt<c;){var mt=nt++,X=ut*c+mt,gt=zt.north(X,ut,mt,c,d,I),Pt=zt.east(X,ut,mt,c,d,I),jt=zt.south(X,ut,mt,c,d,I),Xt=zt.west(X,ut,mt,c,d,I);I[X].neighbors=[jt,Pt,gt,Xt],I[X].divide(n)}return I},zt.north=function(r,n,a,l,c,d){return n==0?null:d[r-l]},zt.south=function(r,n,a,l,c,d){return n==c-1?null:d[r+l]},zt.east=function(r,n,a,l,c,d){return a==l-1?null:d[r+1]},zt.west=function(r,n,a,l,c,d){return a==0?null:d[r-1]},zt.triangulateAdaptiveRefinementNodeTree=function(r){for(var n=qe.empty(),a=0;a<r.length;){var l=r[a];++a,l.triangulate(n)}return n},zt.rationalSurfaceAdaptive=function(r,n){n!=null?n=n:n=new 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 dr=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],c=Z.last(r.knotsU),d=r.knotsV[0],p=Z.last(r.knotsV);this.corners=[We.fromUv(l,d),We.fromUv(c,d),We.fromUv(c,p),We.fromUv(l,p)]}};x["verb.eval.AdaptiveRefinementNode"]=dr,dr.__name__=["verb","eval","AdaptiveRefinementNode"],dr.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),c=l[0][0],d=m.cross(l[0][1],l[1][0]),p=m.isZero(d);return p||(d=m.normalized(d)),a!=null?(a.degen=p,a.point=c,a.normal=d,a):new We(c,d,[r,n],-1,p)},getEdgeCorners:function(r){if(this.isLeaf())return[this.corners[r]];if(this.horizontal)switch(r){case 0:return this.children[0].getEdgeCorners(0);case 1:return this.children[0].getEdgeCorners(1).concat(this.children[1].getEdgeCorners(1));case 2:return this.children[1].getEdgeCorners(2);case 3:return this.children[1].getEdgeCorners(3).concat(this.children[0].getEdgeCorners(3))}switch(r){case 0:return this.children[0].getEdgeCorners(0).concat(this.children[1].getEdgeCorners(0));case 1:return this.children[1].getEdgeCorners(1);case 2:return this.children[1].getEdgeCorners(2).concat(this.children[0].getEdgeCorners(2));case 3:return this.children[0].getEdgeCorners(3)}return null},getAllCorners:function(r){var n=[this.corners[r]];if(this.neighbors[r]==null)return n;var a=this.neighbors[r].getEdgeCorners((r+2)%4),l=r%2,c=rt.EPSILON,d=this,p=[function(y){return y.uv[0]>d.corners[0].uv[0]+c&&y.uv[0]<d.corners[2].uv[0]-c},function(y){return y.uv[1]>d.corners[0].uv[1]+c&&y.uv[1]<d.corners[2].uv[1]-c}],_=a.filter(p[l]);return _.reverse(),n.concat(_)},midpoint:function(r){if(this.midPoints==null&&(this.midPoints=[null,null,null,null]),this.midPoints[r]!=null)return this.midPoints[r];switch(r){case 0:this.midPoints[0]=this.evalSrf(this.u05,this.corners[0].uv[1]);break;case 1:this.midPoints[1]=this.evalSrf(this.corners[1].uv[0],this.v05);break;case 2:this.midPoints[2]=this.evalSrf(this.u05,this.corners[2].uv[1]);break;case 3:this.midPoints[3]=this.evalSrf(this.corners[0].uv[0],this.v05);break}return this.midPoints[r]},hasBadNormals:function(){return this.corners[0].degen||this.corners[1].degen||this.corners[2].degen||this.corners[3].degen},fixNormals:function(){for(var r=this.corners.length,n=0;n<r;){var a=n++;if(this.corners[a],this.corners[a].degen){var l=this.corners[(a+1)%r],c=this.corners[(a+3)%r];l.degen?this.corners[a].normal=c.normal:this.corners[a].normal=l.normal}}},shouldDivide:function(r,n){if(n<r.minDepth)return!0;if(n>=r.maxDepth)return!1;if(this.hasBadNormals())return this.fixNormals(),!1;if(this.splitVert=m.normSquared(m.sub(this.corners[0].normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(this.corners[2].normal,this.corners[3].normal))>r.normTol,this.splitHoriz=m.normSquared(m.sub(this.corners[1].normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(this.corners[3].normal,this.corners[0].normal))>r.normTol,this.splitVert||this.splitHoriz)return!0;var a=this.center();return m.normSquared(m.sub(a.normal,this.corners[0].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[1].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[2].normal))>r.normTol||m.normSquared(m.sub(a.normal,this.corners[3].normal))>r.normTol},divide:function(r){r==null&&(r=new 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)],c=[this.midpoint(3),this.midpoint(1),this.corners[2],this.corners[3]];this.children=[new dr(this.srf,l),new dr(this.srf,c)],this.children[0].neighbors=[this.neighbors[0],this.neighbors[1],this.children[1],this.neighbors[3]],this.children[1].neighbors=[this.children[0],this.neighbors[1],this.neighbors[2],this.neighbors[3]]}else{var d=[this.corners[0],this.midpoint(0),this.midpoint(2),this.corners[3]],p=[this.midpoint(0),this.corners[1],this.corners[2],this.midpoint(2)];this.children=[new dr(this.srf,d),new dr(this.srf,p)],this.children[0].neighbors=[this.neighbors[0],this.children[1],this.neighbors[2],this.neighbors[3]],this.children[1].neighbors=[this.neighbors[0],this.neighbors[1],this.neighbors[2],this.children[0]]}for(var _=0,y=this.children;_<y.length;){var A=y[_];++_,A._divide(r,n,!a)}}},triangulate:function(r){if(r==null&&(r=qe.empty()),this.isLeaf())return this.triangulateLeaf(r);for(var n=0,a=this.children;n<a.length;){var l=a[n];if(++n,l==null)break;l.triangulate(r)}return r},triangulateLeaf:function(r){for(var n=r.points.length,a=[],l=[],c=0,d=0;d<4;){var p=d++,_=this.getAllCorners(p);_.length==2&&(c=p+1);for(var y=0,A=_.length;y<A;){var P=y++;a.push(_[P])}}for(var S=0;S<a.length;){var I=a[S];if(++S,I.id!=-1){l.push(I.id);continue}r.uvs.push(I.uv),r.points.push(I.point),r.normals.push(I.normal),I.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[c],l[(c+2)%k],l[(c+1)%k]]),r.faces.push([l[(c+4)%k],l[(c+3)%k],l[c]]),r.faces.push([l[c],l[(c+3)%k],l[(c+2)%k]]),r}var M=this.center();r.uvs.push(M.uv),r.points.push(M.point),r.normals.push(M.normal);for(var O=r.points.length-1,C=0,F=a.length-1;C<a.length;)r.faces.push([O,l[C],l[F]]),F=C++;return r},__class__:dr};var wt=f.exe.Dispatcher=function(){};x["verb.exe.Dispatcher"]=wt,wt.__name__=["verb","exe","Dispatcher"],wt.init=function(){wt._init||(wt._workerPool=new Fr(wt.THREADS),wt._init=!0)},wt.dispatchMethod=function(r,n,a){wt.init();var l=new wn,c=function(d){l.resolve(d)};return wt._workerPool.addWork(ct.getClassName(r),n,a,c),new pe(l)};var Fr=f.exe.WorkerPool=function(r,n){n==null&&(n="verb.js"),r==null&&(r=1),this._callbacks=new xt,this._working=new xt,this._pool=[],this._queue=[];for(var a=0;a<r;){a++;var l;try{l=new Worker(Fr.basePath+n)}catch(c){c instanceof Q&&(c=c.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 c=new Jr(r,n,a);this._callbacks.set(c.id,l),this._queue.push(c),this.processQueue()},processQueue:function(){for(var r=this;this._queue.length>0&&this._pool.length>0;){var n=this._queue.shift(),a=[n.id],l=[this._pool.shift()];this._working.h[a[0]]=l[0],l[0].onmessage=function(c,d){return function(p){r._working.remove(d[0]),r._pool.push(c[0]);try{r._callbacks.h.hasOwnProperty(d[0])&&(r._callbacks.h[d[0]](p.data.result),r._callbacks.remove(d[0]))}catch(_){_ instanceof Q&&(_=_.val),b.log(_)}r.processQueue()}}(l,a),l[0].postMessage(n)}},__class__: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 Nn=function(){};x["verb.geom.ICurve"]=Nn,Nn.__name__=["verb","geom","ICurve"],Nn.__interfaces__=[kn],Nn.prototype={__class__:Nn};var Ct=f.geom.NurbsCurve=function(r){this._data=He.isValidNurbsCurveData(r)};x["verb.geom.NurbsCurve"]=Ct,Ct.__name__=["verb","geom","NurbsCurve"],Ct.__interfaces__=[Nn],Ct.byKnotsControlPointsWeights=function(r,n,a,l){return new Ct(new Gt(r,n.slice(),N.homogenize1d(a,l)))},Ct.byPoints=function(r,n){return n==null&&(n=3),new Ct(pt.rationalInterpCurve(r,n))},Ct.__super__=Zt,Ct.prototype=T(Zt.prototype,{degree:function(){return this._data.degree},knots:function(){return this._data.knots.slice(0)},controlPoints:function(){return N.dehomogenize1d(this._data.controlPoints)},weights:function(){return N.weight1d(this._data.controlPoints)},asNurbs:function(){return new Gt(this.degree(),this.knots(),N.homogenize1d(this.controlPoints(),this.weights()))},clone:function(){return new Ct(this._data)},domain:function(){return new Pe(Z.first(this._data.knots),Z.last(this._data.knots))},transform:function(r){return new Ct(ft.rationalCurveTransform(this._data,r))},transformAsync:function(r){return wt.dispatchMethod(ft,"rationalCurveTransform",[this._data,r]).then(function(n){return new Ct(n)})},point:function(r){return N.rationalCurvePoint(this._data,r)},pointAsync:function(r){return wt.dispatchMethod(N,"rationalCurvePoint",[this._data,r])},tangent:function(r){return N.rationalCurveTangent(this._data,r)},tangentAsync:function(r){return wt.dispatchMethod(N,"rationalCurveTangent",[this._data,r])},derivatives:function(r,n){return n==null&&(n=1),N.rationalCurveDerivatives(this._data,r,n)},derivativesAsync:function(r,n){return n==null&&(n=1),wt.dispatchMethod(N,"rationalCurveDerivatives",[this._data,r,n])},closestPoint:function(r){return vt.rationalCurveClosestPoint(this._data,r)},closestPointAsync:function(r){return wt.dispatchMethod(vt,"rationalCurveClosestPoint",[this._data,r])},closestParam:function(r){return vt.rationalCurveClosestParam(this._data,r)},closestParamAsync:function(r){return wt.dispatchMethod(vt,"rationalCurveClosestParam",[this._data,r])},length:function(){return vt.rationalCurveArcLength(this._data)},lengthAsync:function(){return wt.dispatchMethod(vt,"rationalCurveArcLength",[this._data])},lengthAtParam:function(r){return vt.rationalCurveArcLength(this._data,r)},lengthAtParamAsync:function(){return wt.dispatchMethod(vt,"rationalCurveArcLength",[this._data])},paramAtLength:function(r,n){return vt.rationalCurveParamAtArcLength(this._data,r,n)},paramAtLengthAsync:function(r,n){return wt.dispatchMethod(vt,"rationalCurveParamAtArcLength",[this._data,r,n])},divideByEqualArcLength:function(r){return le.rationalCurveByEqualArcLength(this._data,r)},divideByEqualArcLengthAsync:function(r){return wt.dispatchMethod(le,"rationalCurveByEqualArcLength",[this._data,r])},divideByArcLength:function(r){return le.rationalCurveByArcLength(this._data,r)},divideByArcLengthAsync:function(r){return wt.dispatchMethod(le,"rationalCurveByArcLength",[this._data,r])},split:function(r){return le.curveSplit(this._data,r).map(function(n){return new Ct(n)})},splitAsync:function(r){return wt.dispatchMethod(le,"curveSplit",[this._data,r]).then(function(n){return n.map(function(a){return new Ct(a)})})},reverse:function(){return new Ct(ft.curveReverse(this._data))},reverseAsync:function(){return wt.dispatchMethod(ft,"curveReverse",[this._data]).then(function(r){return new Ct(r)})},tessellate:function(r){return zt.rationalCurveAdaptiveSample(this._data,r,!1)},tessellateAsync:function(r){return wt.dispatchMethod(zt,"rationalCurveAdaptiveSample",[this._data,r,!1])},__class__:Ct});var Br=f.geom.Arc=function(r,n,a,l,c,d){Ct.call(this,pt.arc(r,n,a,l,c,d)),this._center=r,this._xaxis=n,this._yaxis=a,this._radius=l,this._minAngle=c,this._maxAngle=d};x["verb.geom.Arc"]=Br,Br.__name__=["verb","geom","Arc"],Br.__super__=Ct,Br.prototype=T(Ct.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},radius:function(){return this._radius},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Br});var rs=f.geom.BezierCurve=function(r,n){Ct.call(this,pt.rationalBezierCurve(r,n))};x["verb.geom.BezierCurve"]=rs,rs.__name__=["verb","geom","BezierCurve"],rs.__super__=Ct,rs.prototype=T(Ct.prototype,{__class__:rs});var ns=f.geom.Circle=function(r,n,a,l){Br.call(this,r,n,a,l,0,Math.PI*2)};x["verb.geom.Circle"]=ns,ns.__name__=["verb","geom","Circle"],ns.__super__=Br,ns.prototype=T(Br.prototype,{__class__:ns});var Cn=function(){};x["verb.geom.ISurface"]=Cn,Cn.__name__=["verb","geom","ISurface"],Cn.__interfaces__=[kn],Cn.prototype={__class__:Cn};var It=f.geom.NurbsSurface=function(r){this._data=He.isValidNurbsSurfaceData(r)};x["verb.geom.NurbsSurface"]=It,It.__name__=["verb","geom","NurbsSurface"],It.__interfaces__=[Cn],It.byKnotsControlPointsWeights=function(r,n,a,l,c,d){return new It(new te(r,n,a,l,N.homogenize2d(c,d)))},It.byCorners=function(r,n,a,l){return new It(pt.fourPointSurface(r,n,a,l))},It.byLoftingCurves=function(r,n){return new It(pt.loftedSurface(function(a){for(var l,c=[],d=0;d<r.length;){var p=r[d];++d,c.push(p.asNurbs())}return l=c,l}(),n))},It.__super__=Zt,It.prototype=T(Zt.prototype,{degreeU:function(){return this._data.degreeU},degreeV:function(){return this._data.degreeV},knotsU:function(){return this._data.knotsU.slice(0)},knotsV:function(){return this._data.knotsV.slice(0)},controlPoints:function(){return N.dehomogenize2d(this._data.controlPoints)},weights:function(){return N.weight2d(this._data.controlPoints)},asNurbs:function(){return new te(this.degreeU(),this.degreeV(),this.knotsU(),this.knotsV(),N.homogenize2d(this.controlPoints(),this.weights()))},clone:function(){return new It(this.asNurbs())},domainU:function(){return new Pe(Z.first(this._data.knotsU),Z.last(this._data.knotsU))},domainV:function(){return new Pe(Z.first(this._data.knotsV),Z.last(this._data.knotsV))},point:function(r,n){return N.rationalSurfacePoint(this._data,r,n)},pointAsync:function(r,n){return wt.dispatchMethod(N,"rationalSurfacePoint",[this._data,r,n])},normal:function(r,n){return N.rationalSurfaceNormal(this._data,r,n)},normalAsync:function(r,n){return wt.dispatchMethod(N,"rationalSurfaceNormal",[this._data,r,n])},derivatives:function(r,n,a){return a==null&&(a=1),N.rationalSurfaceDerivatives(this._data,r,n,a)},derivativesAsync:function(r,n,a){return a==null&&(a=1),wt.dispatchMethod(N,"rationalSurfaceDerivatives",[this._data,r,n,a])},closestParam:function(r){return vt.rationalSurfaceClosestParam(this._data,r)},closestParamAsync:function(r){return wt.dispatchMethod(vt,"rationalSurfaceClosestParam",[this._data,r])},closestPoint:function(r){return vt.rationalSurfaceClosestPoint(this._data,r)},closestPointAsync:function(r){return wt.dispatchMethod(vt,"rationalSurfaceClosestPoint",[this._data,r])},split:function(r,n){return n==null&&(n=!1),le.surfaceSplit(this._data,r,n).map(function(a){return new It(a)})},splitAsync:function(r,n){return n==null&&(n=!1),wt.dispatchMethod(le,"surfaceSplit",[this._data,r,n]).then(function(a){return a.map(function(l){return new It(l)})})},reverse:function(r){return r==null&&(r=!1),new It(ft.surfaceReverse(this._data,r))},reverseAsync:function(r){return r==null&&(r=!1),wt.dispatchMethod(ft,"surfaceReverse",[this._data,r]).then(function(n){return new It(n)})},isocurve:function(r,n){return n==null&&(n=!1),new Ct(pt.surfaceIsocurve(this._data,r,n))},isocurveAsync:function(r,n){return n==null&&(n=!1),wt.dispatchMethod(pt,"surfaceIsocurve",[this._data,r,n]).then(function(a){return new Ct(a)})},boundaries:function(r){return pt.surfaceBoundaryCurves(this._data).map(function(n){return new Ct(n)})},boundariesAsync:function(r){return wt.dispatchMethod(pt,"surfaceBoundaryCurves",[this._data]).then(function(n){return n.map(function(a){return new Ct(a)})})},tessellate:function(r){return zt.rationalSurfaceAdaptive(this._data,r)},tessellateAsync:function(r){return wt.dispatchMethod(zt,"rationalSurfaceAdaptive",[this._data,r])},transform:function(r){return new It(ft.rationalSurfaceTransform(this._data,r))},transformAsync:function(r){return wt.dispatchMethod(ft,"rationalSurfaceTransform",[this._data,r]).then(function(n){return new It(n)})},__class__:It});var ss=f.geom.ConicalSurface=function(r,n,a,l,c){It.call(this,pt.conicalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.ConicalSurface"]=ss,ss.__name__=["verb","geom","ConicalSurface"],ss.__super__=It,ss.prototype=T(It.prototype,{axis:function(){return this._axis},xaxis:function(){return this._xaxis},base:function(){return this._base},height:function(){return this._height},radius:function(){return this._radius},__class__:ss});var is=f.geom.CylindricalSurface=function(r,n,a,l,c){It.call(this,pt.cylindricalSurface(r,n,a,l,c)),this._axis=r,this._xaxis=n,this._base=a,this._height=l,this._radius=c};x["verb.geom.CylindricalSurface"]=is,is.__name__=["verb","geom","CylindricalSurface"],is.__super__=It,is.prototype=T(It.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 Dr=f.geom.EllipseArc=function(r,n,a,l,c){Ct.call(this,pt.ellipseArc(r,n,a,l,c)),this._center=r,this._xaxis=n,this._yaxis=a,this._minAngle=l,this._maxAngle=c};x["verb.geom.EllipseArc"]=Dr,Dr.__name__=["verb","geom","EllipseArc"],Dr.__super__=Ct,Dr.prototype=T(Ct.prototype,{center:function(){return this._center},xaxis:function(){return this._xaxis},yaxis:function(){return this._yaxis},minAngle:function(){return this._minAngle},maxAngle:function(){return this._maxAngle},__class__:Dr});var as=f.geom.Ellipse=function(r,n,a){Dr.call(this,r,n,a,0,Math.PI*2)};x["verb.geom.Ellipse"]=as,as.__name__=["verb","geom","Ellipse"],as.__super__=Dr,as.prototype=T(Dr.prototype,{__class__:as});var os=f.geom.ExtrudedSurface=function(r,n){It.call(this,pt.extrudedSurface(m.normalized(n),m.norm(n),r.asNurbs())),this._profile=r,this._direction=n};x["verb.geom.ExtrudedSurface"]=os,os.__name__=["verb","geom","ExtrudedSurface"],os.__super__=It,os.prototype=T(It.prototype,{profile:function(){return this._profile},direction:function(){return this._direction},__class__:os});var Ur=f.geom.Intersect=function(){};x["verb.geom.Intersect"]=Ur,Ur.__name__=["verb","geom","Intersect"],Ur.curves=function(r,n,a){return a==null&&(a=.001),lt.curves(r.asNurbs(),n.asNurbs(),a)},Ur.curvesAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"curves",[r.asNurbs(),n.asNurbs(),a])},Ur.curveAndSurface=function(r,n,a){return a==null&&(a=.001),lt.curveAndSurface(r.asNurbs(),n.asNurbs(),a)},Ur.curveAndSurfaceAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"curveAndSurface",[r.asNurbs(),n.asNurbs(),a])},Ur.surfaces=function(r,n,a){return a==null&&(a=.001),lt.surfaces(r.asNurbs(),n.asNurbs(),a).map(function(l){return new Ct(l)})},Ur.surfacesAsync=function(r,n,a){return a==null&&(a=.001),wt.dispatchMethod(lt,"surfaces",[r.asNurbs(),n.asNurbs(),a]).then(function(l){return l.map(function(c){return new Ct(c)})})};var ls=f.geom.Line=function(r,n){Ct.call(this,pt.polyline([r,n])),this._start=r,this._end=n};x["verb.geom.Line"]=ls,ls.__name__=["verb","geom","Line"],ls.__super__=Ct,ls.prototype=T(Ct.prototype,{start:function(){return this._start},end:function(){return this._end},__class__:ls});var hs=f.geom.RevolvedSurface=function(r,n,a,l){It.call(this,pt.revolvedSurface(r.asNurbs(),n,a,l)),this._profile=r,this._center=n,this._axis=a,this._angle=l};x["verb.geom.RevolvedSurface"]=hs,hs.__name__=["verb","geom","RevolvedSurface"],hs.__super__=It,hs.prototype=T(It.prototype,{profile:function(){return this._profile},center:function(){return this._center},axis:function(){return this._center},angle:function(){return this._angle},__class__:hs});var cs=f.geom.SphericalSurface=function(r,n){It.call(this,pt.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__=It,cs.prototype=T(It.prototype,{center:function(){return this._center},radius:function(){return this._radius},__class__:cs});var us=f.geom.SweptSurface=function(r,n){It.call(this,pt.rationalTranslationalSurface(r.asNurbs(),n.asNurbs())),this._profile=r,this._rail=n};x["verb.geom.SweptSurface"]=us,us.__name__=["verb","geom","SweptSurface"],us.__super__=It,us.prototype=T(It.prototype,{profile:function(){return this._profile},rail:function(){return this._rail},__class__:us});function Ke(r){return r instanceof Array?function(){return L.iter(r)}:typeof r.iterator=="function"?Le(r,r.iterator):r.iterator}var Yi,Yc=0;function Le(r,n){if(n==null)return null;n.__id__==null&&(n.__id__=Yc++);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 qc=x.Int={__name__:["Int"]},Xc=x.Dynamic={__name__:["Dynamic"]},To=x.Float=Number;To.__name__=["Float"];var Mo=x.Bool=Boolean;Mo.__ename__=["Bool"];var No=x.Class={__name__:["Class"]},Co={};Array.prototype.map==null&&(Array.prototype.map=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++;n[c]=r(this[c])}return n}),Array.prototype.filter==null&&(Array.prototype.filter=function(r){for(var n=[],a=0,l=this.length;a<l;){var c=a++,d=this[c];r(d)&&n.push(d)}return n});var qi={},Ws=w.ArrayBuffer||oe;Ws.prototype.slice==null&&(Ws.prototype.slice=oe.sliceImpl),w.DataView;var Xi=w.Uint8Array||sr._new;(function(r,n){if(r.setImmediate)return;var a=1,l={},c=!1,d=r.document,p;function _(R){return l[a]=y.apply(n,R),a++}function y(R){var U=[].slice.call(arguments,1);return function(){typeof R=="function"?R.apply(n,U):new Function(""+R)()}}function A(R){if(c)setTimeout(y(A,R),0);else{var U=l[R];if(U){c=!0;try{U()}finally{P(R),c=!1}}}}function P(R){delete l[R]}function S(){p=function(){var R=_(arguments);return process.nextTick(y(A,R)),R}}function I(){if(r.postMessage&&!r.importScripts){var R=!0,U=r.onmessage;return r.onmessage=function(){R=!1},r.postMessage("","*"),r.onmessage=U,R}}function k(){var R="setImmediate$"+Math.random()+"$",U=function(V){V.source===r&&typeof V.data=="string"&&V.data.indexOf(R)===0&&A(+V.data.slice(R.length))};r.addEventListener?r.addEventListener("message",U,!1):r.attachEvent("onmessage",U),p=function(){var V=_(arguments);return r.postMessage(R+V,"*"),V}}function M(){var R=new MessageChannel;R.port1.onmessage=function(U){var V=U.data;A(V)},p=function(){var U=_(arguments);return R.port2.postMessage(U),U}}function O(){var R=d.documentElement;p=function(){var U=_(arguments),V=d.createElement("script");return V.onreadystatechange=function(){A(U),V.onreadystatechange=null,R.removeChild(V),V=null},R.appendChild(V),U}}function C(){p=function(){var R=_(arguments);return setTimeout(y(A,R),0),R}}var F=Object.getPrototypeOf&&Object.getPrototypeOf(r);F=F&&F.setTimeout?F:r,{}.toString.call(r.process)==="[object process]"?S():I()?k():r.MessageChannel?M():d&&"onreadystatechange"in d.createElement("script")?O():C(),F.setImmediate=p,F.clearImmediate=P})(new Function("return this")()),qt.USE_CACHE=!1,qt.USE_ENUM_INDEX=!1,qt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Wt.DEFAULT_RESOLVER=ct,Wt.BASE64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:",Ot.count=0,ae.i64tmp=function(r){var n,a=new Vt(0,0);return n=a,n}(),Nt.__toStr={}.toString,sr.BYTES_PER_ELEMENT=1,St.queue=new D,Ft.memo=new xt,rt.TOLERANCE=1e-6,rt.EPSILON=1e-10,rt.VERSION="2.0.0",vt.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]],vt.Cvalues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],wt.THREADS=1,wt._init=!1,Fr.basePath="",Jr.uuid=0,Gs.main()}(typeof console<"u"?console:{log:function(){}},e,typeof u<"u"?u:typeof s<"u"?s:typeof self<"u"?self:this),e})})(mc);var p0=mc.exports;const Fn=m0(p0);class ma{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,o){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-o,this.c3=2*t-2*e+s+o}initCatmullRom(t,e,s,o,h){this.init(e,s,h*(s-t),h*(o-e))}initNonuniformCatmullRom(t,e,s,o,h,u,g){let b=(e-t)/h-(s-t)/(h+u)+(s-e)/u,f=(s-e)/u-(o-e)/(u+g)+(o-s)/g;b*=u,f*=u,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}}class pc extends Vs{constructor(t=[],e=!1,s="centripetal",o=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new $,this._px=new ma,this._py=new ma,this._pz=new ma,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 u=(h-(this._closed?0:1))*t;let g=Math.floor(u),b=u-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 T=this._curveType==="chordal"?.5:.25;let L=Math.pow(f.distanceToSquared(x),T),z=Math.pow(x.distanceToSquared(E),T),D=Math.pow(E.distanceToSquared(w),T);z<1e-4&&(z=1),L<1e-4&&(L=z),D<1e-4&&(D=z),this._px.initNonuniformCatmullRom(f.x,x.x,E.x,w.x,L,z,D),this._py.initNonuniformCatmullRom(f.y,x.y,E.y,w.y,L,z,D),this._pz.initNonuniformCatmullRom(f.z,x.z,E.z,w.z,L,z,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 Mt;const t=new Mt;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 ac(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=sc(e,t);break;case"SqrtChord":o=ic(e,t);break;case"Uniform":default:o=nc(e,t.length);break}const h=t.map(g=>({x:g[0],y:g[1],z:g[2]})),u=new Array(h.length).fill(1);return new yn(e,o,h,u)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:o}=this.getParameterRange();for(let h=0;h<=t;h++){const u=s+(o-s)*(h/t);e.push(this.point(u))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),o=this.point(e),h=this.point(s),u=o[0]-h[0],g=o[1]-h[1],b=o[2]-h[2];return Math.sqrt(u*u+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 pc(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 $r extends Vs{constructor(t,e,s,o,h){super();const u=arguments.length;if(u<2||u>5)throw je.ILLEGAL_PARAMETERS;if(this._degree=3,this._closed=!1,Array.isArray(e)){this._controlPoints=t;let g,b=3,f=!1;if(u>=3&&(Array.isArray(s)?(g=s,u>=4&&(b=o||3),u>=5&&(f=h)):s!==void 0&&(b=s||3,u>=4&&(f=o))),s===void 0&&u>=4&&(b=o||3,u>=5&&(f=h)),this._degree=b,this._closed=f,this._controlPoints.length<this._degree+1)throw je.ILLEGAL_PARAMETERS;const w=this.toVerbPoints(this._controlPoints);this._nurbsCurve=Fn.geom.NurbsCurve.byKnotsControlPointsWeights(this._degree,e,w,g)}else{if(this._fitPoints=t,this._knotParameterization=e,u>=3&&(this._degree=s||3),u>=4&&(this._closed=o),this._fitPoints.length<this._degree+1)throw je.ILLEGAL_PARAMETERS;const g=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Fn.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=Fn.geom.NurbsCurve.byPoints(e,this._degree)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Fn.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=Fn.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=Fn.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(),u=o[h],g=o[o.length-h-1],b=(g-u)/(t-1);for(let f=0;f<t;f++){const w=f===t-1?g:u+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],u=(o[o.length-4]-h)/(e-1);for(let g=0;g<e;g++){const b=h+g*u;s.push(t.point(b))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new Mt().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toVerbPoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,o)=>{e[o]={x:s[0],y:s[1],z:s[2]}}),e}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new $r(t,e,s,!0)}}var gn=256,gc=[],il=256,Ks;for(;gn--;)gc[gn]=(gn+256).toString(16).substring(1);function g0(i){var t=0,e=11;if(!Ks||gn+e>il*2)for(Ks="",gn=0;t<il;t++)Ks+=gc[Math.random()*256|0];return Ks.substring(gn,gn+++e)}class Zr{constructor(t,e){t=t||{},Gn(t,{objectId:g0()}),this._attrs=new gl(t,e)}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get database(){return this._database?this._database:Xa().workingDatabase}set database(t){this._database=t}close(){}}const Ka=class Ka extends Zr{constructor(){super(...arguments),this._layer="0",this._color=new Yr,this._lineType=Qs,this._lineWeight=1,this._linetypeScale=-1,this._visibility=!0,this._transparency=0}get type(){return this.constructor.typeName}get layer(){return this._layer}set layer(t){this._layer=t}get color(){return this._color}set color(t){this._color.copy(t)}get rgbColor(){let t=this.database.cecolor;if(this.color.isByLayer){const e=this.getLayerColor();e&&e.color&&(t=e)}else this.color.isByBlock||this.color.color!=null&&(t=this.color);return t.color==null?16777215:t.color}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Qs}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,h){}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}}}]}}get lineStyle(){var s;const t=this.getLineType(),e=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return e?{...e.linetype,color:this.rgbColor}:{name:t,standardFlag:0,color:this.rgbColor,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Qs){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return t.linetype}else return this.lineType==wl?si:this.lineType;return si}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);if(t==null)console.error(`The layer with name '${this.layer}' not found in drawing database!`);else return t.color;return null}attachEntityInfo(t){t&&(t.objectId=this.objectId,t.ownerId=this.ownerId,t.layerName=this.layer,t.visible=this.visibility)}};Ka.typeName="Entity";let Ae=Ka;const $a=class $a extends Ae{};$a.typeName="Curve";let Se=$a;var Bn=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(Bn||{});const Za=class Za extends Se{constructor(t,e,s=0,o=!1,h=0,u=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 vn(f,o)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){return new Array}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};Za.typeName="2dPolyline";let li=Za;var fc=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(fc||{});const Qa=class Qa extends Ae{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 Mt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};Qa.typeName="2dVertex";let va=Qa;var Os=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(Os||{});const Ja=class Ja extends Se{constructor(t,e,s=!1){super(),this._polyType=t,this._geo=new vn(e,s)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){return new Array}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,0))),t.lines(e,this.lineStyle)}};Ja.typeName="3dPolyline";let hi=Ja;var _c=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(_c||{});const to=class to extends Ae{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 Mt().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}transformBy(t){return this._position.applyMatrix4(t),this}draw(t){}};to.typeName="3dVertex";let ba=to;const eo=class eo extends Se{constructor(t,e,s,o,h=$.Z_AXIS){super(),this._geo=new _n(t,e,s,o,h,$.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,this.lineStyle)}};eo.typeName="Arc";let ci=eo;const ro=class ro extends Ae{constructor(t){super(),this._blockName=t,this._position=new Y,this._rotation=0,this._normal=new $(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 Mt,e=this.blockTableRecord;if(e!=null){const h=e.newIterator();for(const u of h)t.union(u.geometricExtents)}const s=new qr().setFromEuler(new cc(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=Hr.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_AXIS,this.rotation),new Xr().compose(this._position,t,this._scaleFactors)}};ro.typeName="BlockReference";let Fs=ro;const no=class no extends Se{constructor(t,e,s=$.Z_AXIS){super(),this._geo=new _n(t,e,0,ne,s,$.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,this.lineStyle)}};no.typeName="Circle";let ui=no;const so=class so extends Se{constructor(t,e,s,o,h,u,g){super(),this._geo=new Ui(t,e,s,o,h,u,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,this.lineStyle)}};so.typeName="Ellipse";let di=so;const io=class io extends Ae{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 Mt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._vertices.length;++e)t.push(this.getVertexAt(e));return t}draw(t){const e=this._vertices.length,s=new Float32Array(e*3),o=new Uint16Array(e*2);for(let h=0;h<e;h++)s[h*3]=this._vertices[h].x,s[h*3+1]=this._vertices[h].y,s[h*3+2]=this._vertices[h].z,this.isEdgeVisibleAt(h)&&(o[h*2]=h,o[h*2+1]=(h+1)%4);return t.lineSegments(s,3,o,this.lineStyle)}};io.typeName="Face";let mi=io;var yc=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(yc||{}),vc=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(vc||{});const ao=class ao extends Ae{constructor(){super(),this._elevation=0,this._geo=new Bi,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}add(t){this._geo.add(t)}get geometricExtents(){const t=this._geo.box;return new Mt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}draw(t){return t.area(this._geo,{color:this.rgbColor,solidFill:!1,patternAngle:this.patternAngle,patternLines:this.definitionLines})}};ao.typeName="Hatch";let pi=ao;var bc=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(bc||{});const oo=class oo extends Se{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 Mt().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}draw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e,this.lineStyle)}else return t.lines(this._vertices,this.lineStyle)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new $r(this._vertices,"Uniform"),this._updated=!1)}};oo.typeName="Leader";let gi=oo;const lo=class lo extends Se{constructor(t,e){super(),this._geo=new Kr(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,h){const u=this.startPoint,g=this.endPoint;switch(t){case pn.EndPoint:h.push(u),h.push(g);break;case pn.MidPoint:h.push(this.midPoint);break;case pn.Nearest:{const b=this._geo.project(s);h.push(b)}break;case pn.Perpendicular:{const b=this._geo.perpPoint(s);h.push(b)}break;case pn.Tangent:h.push(u);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,this.lineStyle)}};lo.typeName="Line";let fi=lo;var Ga=(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))(Ga||{}),Mr=(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))(Mr||{}),we=(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))(we||{}),ja=(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))(ja||{}),Wa=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(Wa||{}),Ha=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(Ha||{});class Gi{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 _e;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new _e;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Gi;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}}const ho=class ho extends Ae{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=we.TopLeft,this._direction=new $(1,0,0),this._drawingDirection=Mr.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new Mt}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:we[1],value:1},{label:we[2],value:2},{label:we[3],value:3},{label:we[4],value:4},{label:we[5],value:5},{label:we[6],value:6},{label:we[7],value:7},{label:we[8],value:8},{label:we[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Mr[1],value:1},{label:Mr[2],value:2},{label:Mr[3],value:3},{label:Mr[4],value:4},{label:Mr[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(),color:this.rgbColor};return t.mtext(s,o,e)}};ho.typeName="MText";let _i=ho;const co=class co extends Se{constructor(t,e,s,o,h){super();const u=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(o!==void 0)+ +(h!==void 0);if(u<2||u>5)throw je.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new $r(t,e,s,o):this._geo=new $r(t,e,s,o,h)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}draw(t){const e=this._geo.getPoints(100);return t.lines(e,this.lineStyle)}};co.typeName="Spline";let Bs=co;const f0=new $,uo=class uo extends Fs{constructor(t,e,s){super(t),this._attachmentPoint=we.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){return this._cells[t*e].text}setTextString(t,e,s){this._cells[t*e].text=s}isEmpty(t,e){return!this._cells[t*e].text}get geometricExtents(){return new Mt}draw(t){let e=0,s=0;const o=new Uint16Array(this.numColumns*this.numRows*8),h=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let u=0;for(let E=0;E<=this.numRows;E++){e-=E>0?this.rowHeight(E-1):0,s=0;for(let T=0;T<=this.numColumns;T++)s+=T>0?this.columnWidth(T-1):0,h[u++]=s,h[u++]=e,h[u++]=0}const g=[],b=new Array(this.numRows*this.numColumns).fill(!1);s=0,u=0;let f=0;for(let E=0;E<this.numColumns;E++){s+=E>0?this.columnWidth(E-1):0,e=0;for(let T=0;T<this.numRows;T++){e+=T>0?this.rowHeight(T-1):0;const L=this.cell(T*this.numColumns+E);if(f=T*this.numColumns+E,L&&!b[f]){const z=L.borderWidth??1,D=L.borderHeight??1;this.fillVisited(b,f,this.numColumns,z,D),o[u++]=E+T*(this.numColumns+1),o[u++]=E+T*(this.numColumns+1)+z;const B=h[o[u-1]*3]-s,dt=E+(T+D)*(this.numColumns+1)+z;E+z==this.numColumns&&(o[u++]=E+T*(this.numColumns+1)+z,o[u++]=dt);const yt=-h[dt*3+1]-e;if(T+D==this.numRows&&(o[u++]=E+(T+D)*(this.numColumns+1)+D,o[u++]=E+(T+D)*(this.numColumns+1)),o[u++]=E+(T+D)*(this.numColumns+1),o[u++]=E+T*(this.numColumns+1),L.text){const ot=L.attachmentPoint||this.attachmentPoint||we.MiddleCenter,W=this.getTableTextOffset(ot,B,yt),ct={text:L.text,height:L.textHeight,width:B,position:f0.set(s,-e,0).clone().add(W),rotation:this.rotation,attachmentPoint:ot},st={...this.getTextStyle(L),color:this.color.color};g.push(t.mtext(ct,st))}}}}g.push(t.lineSegments(h,3,o,this.lineStyle));const w=t.group(g),x=new qr;return x.setFromAxisAngle($.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 u=0;u<o;++u)for(let g=0;g<h;++g)t[e+u+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 $;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}};uo.typeName="Table";let yi=uo;const al=new Xr;var xc=(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))(xc||{}),wc=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(wc||{});const mo=class mo extends Ae{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 Mt}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:Mr.BOTTOM_TO_TOP,attachmentPoint:we.BottomLeft},o={...this.getTextStyle(),color:this.rgbColor};return t.mtext(s,o,e)}};mo.typeName="Text";let vi=mo;const po=class po extends Se{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 Mt().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;for(let e=0;e<4;++e)t.push(this.getPointAt(e));return t}draw(t){const e=new vn(this._vertices,!0),s=new Bi;return s.add(e),t.area(s,{color:this.rgbColor,solidFill:!0,patternAngle:0,patternLines:[]})}};po.typeName="Trace";let bi=po;const go=class go extends Se{constructor(){super(),this._elevation=0,this._geo=new vn}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 u=o<0?void 0:o,g=h<0?void 0:h,b={x:e.x,y:e.y,bulge:s,startWidth:u,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 Mt({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}draw(t){const e=[];return this._geo.getPoints(100).forEach(o=>e.push(new Y().set(o.x,o.y,this.elevation))),t.lines(e,this.lineStyle)}};go.typeName="Polyline";let xi=go;const fo=class fo extends Ae{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 Mt().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,color:this.rgbColor})}};fo.typeName="Point";let wi=fo;var Ac=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(Ac||{}),Sc=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(Sc||{});const _o=class _o extends Ae{constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new Y,this._scale=new $t(1,1),this._rotation=0,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.dictionaries.imageDefs.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new Mt;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}draw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e,this.lineStyle)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,o=new _e;o.setFromPoints(this._clipBoundary);const h=new Tt;h.setX(this._position.x-o.min.x*e),h.setY(this._position.y-o.min.y*s),this._clipBoundary.forEach(u=>{const g=u.x*e+h.x,b=u.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}};_o.typeName="RasterImage";let Ds=_o;const ol=new Tt,$s=new Tt,yo=class yo extends Se{constructor(){super(),this._basePoint=new Y,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Mt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}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,this.lineStyle)}};yo.typeName="Ray";let Ai=yo;const vo=class vo extends Ae{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 Mt}draw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport(),s=t.group(this.createViewportRect(e,t));return this.attachEntityInfo(s),s}}toGiViewport(){const t=new Gi;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)],this.lineStyle)),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)],this.lineStyle)),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)],this.lineStyle)),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)],this.lineStyle)),s}};vo.typeName="Viewport";let Si=vo;const bo=class bo extends Ds{draw(t){const e=this.boundaryPath(),s=new Bi;return s.add(new vn(e)),t.area(s,{color:0,solidFill:!0,patternAngle:0,patternLines:[]})}};bo.typeName="Wipeout";let Pi=bo;const xo=class xo extends Se{constructor(){super(),this._basePoint=new Y,this._unitDir=new $}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new Mt;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}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,this.lineStyle)}};xo.typeName="Xline";let Ii=xo;var Pc=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(Pc||{});const wo=class wo extends Ae{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 $(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 Vn),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=Hr.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 Hr.instance.draw(t,e,this.rgbColor,!1)}drawSecondArrow(t){const e=this.database.tables.blockTable.getAt(this.secondArrowType);if(e)return Hr.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():Ga.Closed}};wo.typeName="Dimension";let Nr=wo;const Ao=class Ao extends Nr{constructor(t,e,s,o,h=null,u=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=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Mt}};Ao.typeName="3PointAngularDimension";let Ei=Ao;const So=class So extends Nr{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 Mt}get isAppendArrow(){return!1}calculateLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),o=this.findIntersectionPoint(e,this._dimLinePoint),h=this.findIntersectionPoint(s,this._dimLinePoint),u=new Kr(o,h);return t.push(u),e.endPoint=o,this.adjustExtensionLine(e),t.push(e),s.endPoint=h,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Kr(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,o=t.endPoint,h=new $().subVectors(o,s).normalize(),g=new $().subVectors(e,s).dot(h),b=new $().copy(h).multiplyScalar(g);return new $().addVectors(s,b)}};So.typeName="AlignedDimension";let ki=So;const Po=class Po extends Nr{constructor(t,e,s,o,h=null,u=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=u}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get geometricExtents(){return new Mt}};Po.typeName="ArcDimension";let xa=Po;const Io=class Io extends Nr{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 Mt}drawLines(t,e){const s=[],o=e.length;return o==1?s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):o==3?(this.sortLines(e),s.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),s.push(this.drawLine(t,e[1])),s.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(h=>{s.push(this.drawLine(t,h))}),s}drawLine(t,e,s){if(s){const o=[e.startPoint,e.endPoint];return t.lines(o,{...this.lineStyle,arrows:s})}else return e.draw(t)}sortLines(t){const e=(s,o)=>s.x!==o.x?s.x-o.x:s.y!==o.y?s.y-o.y:s.z-o.z;t.sort((s,o)=>{const h=e(s.startPoint,o.startPoint);return h!==0?h:e(s.endPoint,o.endPoint)})}};Io.typeName="DiametricDimension";let Ti=Io;const Eo=class Eo extends Nr{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 Mt}get arrowLineCount(){return 0}};Eo.typeName="OrdinateDimension";let Mi=Eo;const ko=class ko extends Nr{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 Mt}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}};ko.typeName="RadialDimension";let Ni=ko;class ll{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):t.type=="ARC"?this.convertArc(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="POLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertFace(t){const e=new mi;return t.vertices.forEach((s,o)=>e.setVertexAt(o,s)),e}convertArc(t){return new ci(t.center,t.radius,Et.degToRad(t.startAngle),Et.degToRad(t.endAngle),t.extrusionDirection??$.Z_AXIS)}convertCirle(t){return new ui(t.center,t.radius,t.extrusionDirection??$.Z_AXIS)}convertEllipse(t){const e=new $(t.majorAxisEndPoint),s=e.length();return new di(t.center,t.extrusionDirection??$.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 Bs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0){const e=this.numberArrayToPointArray(t.fitPoints,t.numberOfFitPoints);if(e!=null)return new Bs(e,"Uniform",t.degree,!!(t.flag&1))}}catch(e){console.log(`Failed to convert spline with error: ${e}`)}return null}convertPoint(t){const e=new 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(u=>{u.flag&fd.SPLINE_CONTROL_POINT||(o.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0))}),s){let u=Os.SimplePoly;return t.flag&4&&(t.smoothType==Ys.CUBIC?u=Os.CubicSplinePoly:t.smoothType==Ys.QUADRATIC&&(u=Os.QuadSplinePoly)),new hi(u,o,e)}else{let u=Bn.SimplePoly;return t.flag&2?u=Bn.FitCurvePoly:t.flag&4&&(t.smoothType==Ys.CUBIC?u=Bn.CubicSplinePoly:t.smoothType==Ys.QUADRATIC&&(u=Bn.QuadSplinePoly)),new li(u,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 pi;return(o=t.definitionLines)==null||o.forEach(h=>{e.definitionLines.push({angle:h.angle,origin:h.base,delta:h.offset,dashPattern:h.numberOfDashLengths>0?h.dashLengths:[]})}),e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(h=>{if(h.boundaryPathTypeFlag&2){const g=h,b=new vn;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 dc;g.edges.forEach(f=>{if(f.type==1){const w=f;b.add(new Vi(w.start,w.end))}else if(f.type==2){const w=f;b.add(new Un(w.center,w.radius,Et.degToRad(w.startAngle||0),Et.degToRad(w.endAngle||0),!w.isCCW))}else if(f.type==3){const w=f;new $t().subVectors(w.end,w.center);const E=Math.sqrt(Math.pow(w.end.x,2)+Math.pow(w.end.y,2)),T=E*w.lengthOfMinorAxis;let L=Et.degToRad(w.startAngle||0),z=Et.degToRad(w.endAngle||0);const D=Math.atan2(w.end.y,w.end.x);w.isCCW||(L=Math.PI*2-L,z=Math.PI*2-z),b.add(new Di({...w.center,z:0},E,T,L,z,!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 T=w.controlPoints.map(L=>(L.weight==null&&(E=!1),L.weight||1));b.add(new $r(x,w.knots,E?T:void 0))}else if(w.numberOfFitData>0){const x=w.fitDatum.map(E=>({x:E.x,y:E.y,z:0}));b.add(new $r(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=Et.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new _i;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=Et.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new $(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=Et.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 Mi(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 Ti(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 Ds;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 Pi;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 Ii;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?Et.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&(e.color.color=t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName!=null&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=t.isVisible),t.transparency!=null&&(e.transparency=t.transparency)}numberArrayToPointArray(t,e){const s=t.length;let o=0;if(s/2==e?o=2:s/3==e&&(o=3),o==0)return;const h=[];for(let u=0,g=s/o;u<g;++u)h.push({x:t[u*o],y:t[u*o+1],z:o==3?t[u*o+2]:0});return h}}class bn extends Zr{constructor(t,e){t=t||{},Gn(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}}const Wr=class Wr extends bn{static isModelSapceName(t){return t.toLowerCase()==Wr.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(Wr.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new Y,this._layoutId="",this._entities=new Map}get isModelSapce(){return Wr.isModelSapceName(this.name)}get isPaperSapce(){return Wr.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 zi(this._entities)}getIdAt(t){return this._entities.get(t)}};Wr.MODEL_SPACE_NAME="*MODEL_SPACE",Wr.PAPER_SPACE_NAME_PREFIX="*PAPER_SPACE";let Te=Wr;class ji extends Zr{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _e,this._extents=new Mt}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}}class Ya 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 zi(this._recordsByName)}}class Ic extends Ya{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 Ec extends Zr{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}}class _0{convertLayout(t,e){var o,h;const s=new ji;if(s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,t.ownerObjectId?s.blockTableRecordId=t.ownerObjectId:(o=e.tables.BLOCK_RECORD)==null||o.entries.some(u=>u.layoutObjects===t.handle?(s.blockTableRecordId=u.handle,!0):!1),!s.blockTableRecordId&&t.layoutName==="Model"){const u=Te.MODEL_SPACE_NAME;(h=e.tables.BLOCK_RECORD)==null||h.entries.some(g=>g.name.toUpperCase()===u?(s.blockTableRecordId=g.handle,!0):!1)}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 Ec;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class kc{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),o=this.generateTaskId();try{return await this.executeInWorker(o,t,e||this.config.workerUrl)}catch(h){const u=Date.now()-s;return{success:!1,error:h instanceof Error?h.message:String(h),duration:u}}}async executeInWorker(t,e,s){const o=Date.now();return new Promise((h,u)=>{const g=this.getAvailableWorker(s),b=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(g),u(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),u(x)},timeout:b});const f=x=>{const{id:E,success:T,data:L,error:z}=x.data;if(E!==t)return;this.cleanupTask(t);const D=Date.now()-o;h(T?{success:!0,data:L,duration:D}:{success:!1,error:z,duration:D})},w=x=>{this.cleanupTask(t),u(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 Tc{constructor(t){this.framework=new kc(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Mc(i){return new Tc(i)}class y0{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 Nc extends Ea{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t){if(this.config.useWorker&&this.config.parserWorkerUrl){const e=Mc({workerUrl:this.config.parserWorkerUrl,maxConcurrentWorkers:1}),s=await e.execute(t);if(e.destroy(),s.success)return{model:s.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${s.error}'`)}else return{model:new i0().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var h;const e=new Map,s=u=>{if(u){const g=u.lastIndexOf(".");return g>=0?u.substring(0,g).toLowerCase():u.toLowerCase()}};(h=t.tables.STYLE)==null||h.entries.forEach(u=>{const g=[];if(u.font){const b=s(u.font);b&&g.push(b)}if(u.bigFont){const b=s(u.bigFont);b&&g.push(b)}if(u.extendedFont){const b=s(u.extendedFont);b&&g.push(b)}e.set(u.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(u=>{if(u.type=="MTEXT"){const g=u;[...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(u.type=="TEXT"){const g=u,b=s.get(g.styleName);b==null||b.forEach(f=>o.add(f))}else if(u.type=="INSERT"){const b=e[u.name];b&&b.entities&&this.getFontsInBlock(b.entities,e,s,o)}})}async processEntities(t,e,s,o,h){const u=new ll;let g=t.entities;const b=g.length,f=new Aa(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 T=[],L=x<E?g[x].type:"";for(let z=x;z<E;z++){const D=g[z],B=u.convert(D);B&&(this.config.convertByEntityType&&D.type!==L&&(w.appendEntity(T),T=[],L=D.type),T.push(B))}if(w.appendEntity(T),h){let z=o.value+E/b*(100-o.value);z>100&&(z=100),await h(z,"ENTITY","IN-PROGRESS")}})}async processEntitiesInBlock(t,e){const s=new ll,o=t.length,h=[];for(let u=0;u<o;u++){const g=t[u],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 u=e.tables.blockTable.getAt(h.name);u||(u=new Te,u.objectId=h.handle,u.name=o,u.origin.copy(h.position),e.tables.blockTable.add(u)),h.entities&&this.processEntitiesInBlock(h.entities,u)}}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 u=new Te;u.objectId=h.handle,u.name=h.name,u.layoutId=h.layoutObjects,e.tables.blockTable.add(u)}))}processObjects(t,e){const s=t.objects.byName,o=new _0;if("LAYOUT"in s){const h=e.dictionaries.layouts;s.LAYOUT.forEach(u=>{const g=o.convertLayout(u,t);h.setAt(g.layoutName,g)})}if("IMAGEDEF"in s){const h=e.dictionaries.imageDefs;s.IMAGEDEF.forEach(u=>{const g=o.convertImageDef(u);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(u=>{const g=new Wc;this.processCommonTableEntryAttrs(u,g),u.circleSides&&(g.circleSides=u.circleSides),g.standardFlag=u.standardFlag,g.center.copy(u.center),g.lowerLeftCorner.copy(u.lowerLeftCorner),g.upperRightCorner.copy(u.upperRightCorner),u.snapBasePoint&&g.snapBase.copy(u.snapBasePoint),u.snapRotationAngle&&(g.snapAngle=u.snapRotationAngle),u.snapSpacing&&g.snapIncrements.copy(u.snapSpacing),u.majorGridLines&&(g.gridMajor=u.majorGridLines),u.gridSpacing&&g.gridIncrements.copy(u.gridSpacing),u.backgroundObjectId&&(g.backgroundObjectId=u.backgroundObjectId),g.gsView.center.copy(u.center),g.gsView.viewDirectionFromTarget.copy(u.viewDirectionFromTarget),g.gsView.viewTarget.copy(u.viewTarget),u.lensLength&&(g.gsView.lensLength=u.lensLength),u.frontClippingPlane&&(g.gsView.frontClippingPlane=u.frontClippingPlane),u.backClippingPlane&&(g.gsView.backClippingPlane=u.backClippingPlane),u.viewHeight&&(g.gsView.viewHeight=u.viewHeight),u.viewTwistAngle&&(g.gsView.viewTwistAngle=u.viewTwistAngle),u.frozenLayers&&(g.gsView.frozenLayers=u.frozenLayers),u.styleSheet&&(g.gsView.styleSheet=u.styleSheet),u.renderMode&&(g.gsView.renderMode=u.renderMode),u.viewMode&&(g.gsView.viewMode=u.viewMode),u.ucsIconSetting&&(g.gsView.ucsIconSetting=u.ucsIconSetting),u.ucsOrigin&&g.gsView.ucsOrigin.copy(u.ucsOrigin),u.ucsXAxis&&g.gsView.ucsXAxis.copy(u.ucsXAxis),u.ucsYAxis&&g.gsView.ucsYAxis.copy(u.ucsYAxis),u.orthographicType&&(g.gsView.orthographicType=u.orthographicType),u.shadePlotSetting&&(g.gsView.shadePlotSetting=u.shadePlotSetting),u.shadePlotObjectId&&(g.gsView.shadePlotObjectId=u.shadePlotObjectId),u.visualStyleObjectId&&(g.gsView.visualStyleObjectId=u.visualStyleObjectId),u.isDefaultLightingOn&&(g.gsView.isDefaultLightingOn=u.isDefaultLightingOn),u.defaultLightingType&&(g.gsView.defaultLightingType=u.defaultLightingType),u.brightness&&(g.gsView.brightness=u.brightness),u.contrast&&(g.gsView.contrast=u.contrast),u.ambientColor&&(g.gsView.ambientColor=u.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(u=>{const g=new Yr;g.colorIndex=u.colorIndex;const b=new Wi({name:u.name,standardFlags:u.standardFlag,linetype:u.lineType,lineWeight:u.lineweight,isOff:u.colorIndex<0,color:g,isPlottable:u.isPlotting});this.processCommonTableEntryAttrs(u,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(u=>{const g=new Rs(u);this.processCommonTableEntryAttrs(u,g),g.name=u.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 u=new qa(h);this.processCommonTableEntryAttrs(h,u),e.tables.textStyleTable.add(u)})}processDimStyles(t,e){var o;const s=(o=t.tables.DIMSTYLE)==null?void 0:o.entries;s&&s.length>0&&s.forEach(h=>{const u={name:h.name,ownerId:h.ownerObjectId,dimpost:h.DIMPOST||"",dimapost:h.DIMAPOST||"",dimscale:h.DIMSCALE,dimasz:h.DIMASZ,dimexo:h.DIMEXO,dimdli:h.DIMDLI,dimexe:h.DIMEXE,dimrnd:h.DIMRND,dimdle:h.DIMDLE,dimtp:h.DIMTP,dimtm:h.DIMTM,dimtxt:h.DIMTXT,dimcen:h.DIMCEN,dimtsz:h.DIMTSZ,dimaltf:h.DIMALTF,dimlfac:h.DIMLFAC,dimtvp:h.DIMTVP,dimtfac:h.DIMTFAC,dimgap:h.DIMGAP,dimaltrnd:h.DIMALTRND,dimtol:h.DIMTOL==null||h.DIMTOL==0?0:1,dimlim:h.DIMLIM==null||h.DIMLIM==0?0:1,dimtih:h.DIMTIH==null||h.DIMTIH==0?0:1,dimtoh:h.DIMTOH==null||h.DIMTOH==0?0:1,dimse1:h.DIMSE1==null||h.DIMSE1==0?0:1,dimse2:h.DIMSE2==null||h.DIMSE2==0?0:1,dimtad:h.DIMTAD,dimzin:h.DIMZIN,dimazin:h.DIMAZIN,dimalt:h.DIMALT,dimaltd:h.DIMALTD,dimtofl:h.DIMTOFL,dimsah:h.DIMSAH,dimtix:h.DIMTIX,dimsoxd:h.DIMSOXD,dimclrd:h.DIMCLRD,dimclre:h.DIMCLRE,dimclrt:h.DIMCLRT,dimadec:h.DIMADEC||0,dimunit:h.DIMUNIT||2,dimdec:h.DIMDEC,dimtdec:h.DIMTDEC,dimaltu:h.DIMALTU,dimalttd:h.DIMALTTD,dimaunit:h.DIMAUNIT,dimfrac:h.DIMFRAC,dimlunit:h.DIMLUNIT,dimdsep:h.DIMDSEP,dimtmove:h.DIMTMOVE||0,dimjust:h.DIMJUST,dimsd1:h.DIMSD1,dimsd2:h.DIMSD2,dimtolj:h.DIMTOLJ,dimtzin:h.DIMTZIN,dimaltz:h.DIMALTZ,dimalttz:h.DIMALTTZ,dimfit:h.DIMFIT||0,dimupt:h.DIMUPT,dimatfit:h.DIMATFIT,dimtxsty:h.DIMTXSTY||"Standard",dimldrblk:h.DIMLDRBLK||"",dimblk:h.DIMBLK||"",dimblk1:h.DIMBLK1||"",dimblk2:h.DIMBLK2||"",dimlwd:h.DIMLWD,dimlwe:h.DIMLWE},g=new Vn(u);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 Cc extends Ea{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,s,o,h){let u=t.tables.blockTable.modelSpace.newIterator().toArray();const g=u.length,b=new Aa(g,100-o.value,s);this.config.convertByEntityType&&(u=this.groupAndFlattenByType(u));const f=e.tables.blockTable.modelSpace;await b.processChunk(async(w,x)=>{let E=[],T=w<x?u[w].type:"";for(let L=w;L<x;L++){const z=u[L];this.config.convertByEntityType&&z.type!==T&&(this.triggerEvents(f,E),E=[],T=z.type),E.push(z)}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 hr{constructor(){this.events={registered:new ie,unregistered:new ie},this._converters=new Map,this.register("dxf",new Nc)}static createInstance(){return hr._instance==null&&(hr._instance=new hr),this._instance}static get instance(){return hr._instance||(hr._instance=new hr),hr._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 xn 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 zi(this._recordsByName)}normalizeName(t){return t}}class Lc extends xn{constructor(t){super(t)}get modelSpace(){let t=this.getAt(Te.MODEL_SPACE_NAME);return t||(t=new Te,t.name=Te.MODEL_SPACE_NAME,this.add(t)),t}normalizeName(t){let e=t;if(Te.isModelSapceName(t))e=Te.MODEL_SPACE_NAME;else if(Te.isPaperSapceName(t)){const s=Te.PAPER_SPACE_NAME_PREFIX,o=t.substring(s.length);e=s+o}return e}}class Oc extends xn{constructor(t){super(t)}}class Wi extends bn{constructor(t,e){t=t||{},Gn(t,{color:new Yr,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:0,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t)}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}}class zc extends xn{constructor(t){super(t);const e=new Yr;e.color=16777215;const s=new Wi({name:"0",standardFlags:0,linetype:si,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 Rc extends xn{constructor(t){super(t)}}class Fc extends xn{constructor(t){super(t)}get fonts(){const t=new Set,e=o=>{if(o){const h=o.lastIndexOf(".");if(h>=0){const u=o.substring(0,h).toLowerCase();t.add(u)}else t.add(o.toLowerCase())}},s=this.newIterator();for(const o of s)e(o.fileName),e(o.bigFontFileName);return Array.from(t)}}class Bc extends xn{constructor(t){super(t)}}class Rs extends bn{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}}class qa extends bn{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}}var Dc=(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))(Dc||{}),Uc=(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))(Uc||{}),Vc=(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))(Vc||{}),Gc=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(Gc||{}),jc=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(jc||{});const Li=class Li extends bn{constructor(t,e){t=t||{},Gn(t,Li.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)}};Li.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 Vn=Li;class v0 extends Zr{constructor(){super(),this.events={dictObjetSet:new ie,dictObjectErased:new ie,entityAppended:new ie,entityModified:new ie,layerAppended:new ie,layerModified:new ie,layerErased:new ie,openProgress:new ie,headerSysVarChanged:new ie},this._version=new ai("AC1014"),this._angBase=0,this._angDir=0,this._aunits=Sa.DecimalDegrees,this._celtscale=1,this._cecolor=new Yr,this._extents=new Mt,this._insunits=Ia.Millimeters,this._ltscale=1,this._pdmode=0,this._pdsize=0,this._tables={blockTable:new Lc(this),dimStyleTable:new Oc(this),linetypeTable:new Rc(this),textStyleTable:new Fc(this),layerTable:new zc(this),viewportTable:new Bc(this)},this._dictionaries={layouts:new Ic(this),imageDefs:new Ya(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 ai(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=hr.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,u,g,b)=>{if(this.events.openProgress.dispatch({database:this,percentage:h,stage:"CONVERSION",subStage:u,subStageStatus:g,data:b}),e&&e.fontLoader&&u=="FONT"&&g=="END"){const f=b||this.tables.textStyleTable.fonts;await e.fontLoader.load(f)}})}async openUri(t,e){var T;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 u=0;const g=(T=s.body)==null?void 0:T.getReader();if(!g)throw new Error("Failed to get response reader");const b=[];for(;;){const{done:L,value:z}=await g.read();if(L)break;if(b.push(z),u+=z.length,h!==null){const D=Math.round(u/h*100);this.events.openProgress.dispatch({database:this,percentage:D,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const f=new Uint8Array(u);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 Cc(this).read(null,this,500,async(e,s,o,h)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:s,subStageStatus:o,data:h})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){if(t.layer){const e=new Yr;e.colorIndex=7,this._tables.layerTable.add(new Wi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(t.lineType&&(this._tables.linetypeTable.add(new Rs({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Rs({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this._tables.linetypeTable.add(new Rs({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))),t.textStyle&&this._tables.textStyleTable.add(new qa({name:"Standard",standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),t.dimStyle&&this._tables.dimStyleTable.add(new Vn({name:"Standard",dimtxsty:"Standard"})),t.layout){const e=new ji;e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=this._tables.blockTable.modelSpace.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this._dictionaries.layouts.setAt(e.layoutName,e),this._tables.blockTable.modelSpace.layoutId=e.objectId}}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._dictionaries.layouts.removeAll(),this._currentSpace=void 0,this._extents.makeEmpty()}triggerHeaderSysVarChangedEvent(t){this.events.headerSysVarChanged.dispatch({database:this,name:t})}getFileNameFromUri(t){try{const s=new URL(t).pathname.split("/");return s[s.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}const b0={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:ja.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:Wa.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Ha.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0};class Wc extends bn{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=b0}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 Hc{constructor(){this.events={layoutCreated:new ie,layoutRemoved:new ie,layoutRenamed:new ie,layoutSwitched:new ie}}countLayouts(t){return this.getWorkingDatabase(t).dictionaries.layouts.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getBtrIdAt(t);return this.setCurrentLayoutInternal(o,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),o=s.dictionaries.layouts.getAt(t);return this.setCurrentLayoutInternal(o,s)}renameLayout(t,e,s){const h=this.getWorkingDatabase(s).dictionaries.layouts.getAt(t);return h?(h.layoutName=e,this.events.layoutRenamed.dispatch({layout:h,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).dictionaries.layouts.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).dictionaries.layouts,o=s.getAt(t);let h=!1;return o&&(h=s.remove(t),h&&this.events.layoutRemoved.dispatch({layout:o})),h}createLayout(t,e){const s=this.getWorkingDatabase(e),o=new ji;o.layoutName=t,o.tabOrder=s.dictionaries.layouts.maxTabOrder;const h=new Te;return h.name=`*Paper_Space${o.tabOrder}`,s.tables.blockTable.add(h),s.dictionaries.layouts.setAt(t,o),this.events.layoutCreated.dispatch({layout:o}),{layout:o,btr:h}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.dictionaries.layouts.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Xa().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}function Xa(){return Ci.instance}const Oi=class Oi{constructor(){this._workingDatabase=null,this._layoutManager=new Hc}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}};Oi.instance=new Oi;let Ci=Oi;exports.AcCmColor=Yr;exports.AcCmErrors=je;exports.AcCmEventDispatcher=hu;exports.AcCmEventManager=ie;exports.AcCmLoader=_u;exports.AcCmLoadingManager=vl;exports.AcCmObject=gl;exports.AcCmPerformanceCollector=wa;exports.AcCmTask=_l;exports.AcCmTaskScheduler=yl;exports.AcDb2dPolyline=li;exports.AcDb2dVertex=va;exports.AcDb2dVertexType=fc;exports.AcDb3PointAngularDimension=Ei;exports.AcDb3dPolyline=hi;exports.AcDb3dVertex=ba;exports.AcDb3dVertexType=_c;exports.AcDbAlignedDimension=ki;exports.AcDbAngleUnits=Sa;exports.AcDbArc=ci;exports.AcDbArcDimension=xa;exports.AcDbBaseWorker=y0;exports.AcDbBatchProcessing=Aa;exports.AcDbBlockReference=Fs;exports.AcDbBlockTable=Lc;exports.AcDbBlockTableRecord=Te;exports.AcDbCircle=ui;exports.AcDbCodePage=Pa;exports.AcDbCurve=Se;exports.AcDbDatabase=v0;exports.AcDbDatabaseConverter=Ea;exports.AcDbDatabaseConverterManager=hr;exports.AcDbDiametricDimension=Ti;exports.AcDbDictionary=Ya;exports.AcDbDimArrowType=Al;exports.AcDbDimStyleTable=Oc;exports.AcDbDimStyleTableRecord=Vn;exports.AcDbDimTextHorizontal=Dc;exports.AcDbDimTextVertical=Uc;exports.AcDbDimVerticalJustification=jc;exports.AcDbDimZeroSuppression=Vc;exports.AcDbDimZeroSuppressionAngular=Gc;exports.AcDbDimension=Nr;exports.AcDbDwgVersion=ai;exports.AcDbDxfConverter=Nc;exports.AcDbEllipse=di;exports.AcDbEntity=Ae;exports.AcDbFace=mi;exports.AcDbFileType=zs;exports.AcDbHatch=pi;exports.AcDbHatchPatternType=yc;exports.AcDbHatchStyle=vc;exports.AcDbHostApplicationServices=Ci;exports.AcDbLayerTable=zc;exports.AcDbLayerTableRecord=Wi;exports.AcDbLayout=ji;exports.AcDbLayoutDictionary=Ic;exports.AcDbLayoutManager=Hc;exports.AcDbLeader=gi;exports.AcDbLeaderAnnotationType=bc;exports.AcDbLine=fi;exports.AcDbLineSpacingStyle=Pc;exports.AcDbLinetypeTable=Rc;exports.AcDbLinetypeTableRecord=Rs;exports.AcDbMText=_i;exports.AcDbObject=Zr;exports.AcDbObjectIterator=zi;exports.AcDbOrdinateDimension=Mi;exports.AcDbOsnapMode=pn;exports.AcDbPoint=wi;exports.AcDbPoly2dType=Bn;exports.AcDbPoly3dType=Os;exports.AcDbPolyline=xi;exports.AcDbRadialDimension=Ni;exports.AcDbRasterImage=Ds;exports.AcDbRasterImageClipBoundaryType=Ac;exports.AcDbRasterImageDef=Ec;exports.AcDbRasterImageImageDisplayOpt=Sc;exports.AcDbRay=Ai;exports.AcDbRegenerator=Cc;exports.AcDbRenderingCache=Hr;exports.AcDbSpline=Bs;exports.AcDbSymbolTable=xn;exports.AcDbSymbolTableRecord=bn;exports.AcDbTable=yi;exports.AcDbText=vi;exports.AcDbTextHorizontalMode=xc;exports.AcDbTextStyleTable=Fc;exports.AcDbTextStyleTableRecord=qa;exports.AcDbTextVerticalMode=wc;exports.AcDbTrace=bi;exports.AcDbUnitsValue=Ia;exports.AcDbViewport=Si;exports.AcDbViewportTable=Bc;exports.AcDbViewportTableRecord=Wc;exports.AcDbWipeout=Pi;exports.AcDbWorkerApi=Tc;exports.AcDbWorkerManager=kc;exports.AcDbXline=Ii;exports.AcGeArea2d=Bi;exports.AcGeBox2d=_e;exports.AcGeBox3d=Mt;exports.AcGeCatmullRomCurve3d=pc;exports.AcGeCircArc2d=Un;exports.AcGeCircArc3d=_n;exports.AcGeCurve2d=Wn;exports.AcGeEllipseArc2d=Di;exports.AcGeEllipseArc3d=Ui;exports.AcGeEuler=cc;exports.AcGeGeometryUtil=rc;exports.AcGeLine2d=Vi;exports.AcGeLine3d=Kr;exports.AcGeLoop2d=dc;exports.AcGeMathUtil=Et;exports.AcGeMatrix2d=Fi;exports.AcGeMatrix3d=Xr;exports.AcGeNurbsCurve=yn;exports.AcGePlane=Us;exports.AcGePoint2d=Tt;exports.AcGePoint3d=Y;exports.AcGePolyline2d=vn;exports.AcGeQuaternion=qr;exports.AcGeShape2d=Va;exports.AcGeSpline3d=$r;exports.AcGeTol=Ba;exports.AcGeVector2d=$t;exports.AcGeVector3d=$;exports.AcGiArrowType=Ga;exports.AcGiDefaultLightingType=Ha;exports.AcGiMTextAttachmentPoint=we;exports.AcGiMTextFlowDirection=Mr;exports.AcGiOrthographicType=Wa;exports.AcGiRenderMode=ja;exports.AcGiViewport=Gi;exports.AcTrStringUtil=fu;exports.ByBlock=wl;exports.ByLayer=Qs;exports.DEBUG_MODE=pu;exports.DEFAULT_LINE_TYPE=si;exports.DEFAULT_TOL=Da;exports.DEG2RAD=Ca;exports.DefaultLoadingManager=bl;exports.FLOAT_TOL=mn;exports.ORIGIN_POINT_2D=a0;exports.ORIGIN_POINT_3D=Fa;exports.RAD2DEG=La;exports.TAU=ne;exports.acdbHostApplicationServices=Xa;exports.basisFunction=oi;exports.calculateCurveLength=ac;exports.ceilPowerOfTwo=Xh;exports.clamp=Tr;exports.clone=Ts;exports.createWorkerApi=Mc;exports.damp=Fh;exports.defaults=Gn;exports.degToRad=Hh;exports.dwgCodePageToEncoding=xl;exports.euclideanModulo=Oa;exports.evaluateNurbsPoint=Ls;exports.floorPowerOfTwo=Kh;exports.generateChordKnots=sc;exports.generateSqrtChordKnots=ic;exports.generateUUID=Oh;exports.generateUniformKnots=nc;exports.has=ml;exports.intPartLength=Ra;exports.interpolateControlPoints=o0;exports.inverseLerp=Rh;exports.isBetween=$h;exports.isBetweenAngle=Zh;exports.isEmpty=pl;exports.isEqual=Dn;exports.isImperialUnits=bu;exports.isMetricUnits=vu;exports.isPointInPolygon=Ua;exports.isPolygonIntersect=ec;exports.isPowerOfTwo=qh;exports.lerp=za;exports.log=Ns;exports.mapLinear=zh;exports.normalizeAngle=Cs;exports.pingpong=Bh;exports.radToDeg=Yh;exports.randFloat=Gh;exports.randFloatSpread=jh;exports.randInt=Vh;exports.relativeEps=Qh;exports.seededRandom=Wh;exports.setLogLevel=gu;exports.smootherstep=Uh;exports.smoothstep=Dh;