@navaramap/worker 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,4 +8,4 @@
8
8
  `,r+=" spawnfile: `"+o.spawnfile+`\`
9
9
  `,r+=" stdout: `"+o.stdout+`\`
10
10
  `,r+=" stderr: `"+o.stderr+`\`
11
- `,i(new D(r))}),this.processing=Object.create(null),this.tracking=Object.create(null),this.terminating=!1,this.terminated=!1,this.cleaning=!1,this.terminationHandler=null,this.lastId=0}E.prototype.methods=function(){return this.exec(`methods`)},E.prototype.exec=function(e,t,r,i){r||=n.defer();var a=++this.lastId;this.processing[a]={id:a,resolver:r,options:i};var o={message:{id:a,method:e,params:t},transfer:i&&i.transfer};this.terminated?r.reject(new D(`Worker is terminated`)):this.worker.ready?this.worker.send(o.message,o.transfer):this.requestQueue.push(o);var s=this;return r.promise.catch(function(e){if(e instanceof n.CancellationError||e instanceof n.TimeoutError)return s.tracking[a]={id:a,resolver:n.defer(),options:i,error:e},delete s.processing[a],s.tracking[a].resolver.promise=s.tracking[a].resolver.promise.catch(function(e){if(delete s.tracking[a],e instanceof ee)throw e.error;return s.terminateAndNotify(!0).then(function(){throw e},function(e){throw e})}),s.worker.send({id:a,method:l}),s.tracking[a].timeoutId=setTimeout(function(){s.tracking[a].resolver.reject(e)},s.workerTerminateTimeout),s.tracking[a].resolver.promise;throw e})},E.prototype.busy=function(){return this.cleaning||Object.keys(this.processing).length>0||Object.keys(this.tracking).length>0},E.prototype.terminate=function(e,t){var n=this;if(e){for(var r in this.processing)this.processing[r]!==void 0&&this.processing[r].resolver.reject(Error(`Worker terminated`));this.processing=Object.create(null)}for(var i of Object.values(n.tracking))clearTimeout(i.timeoutId),i.resolver.reject(Error(`Worker Terminating`));if(n.tracking=Object.create(null),typeof t==`function`&&(this.terminationHandler=t),this.busy())this.terminating=!0;else{var a=function(e){if(n.terminated=!0,n.cleaning=!1,n.worker!=null&&n.worker.removeAllListeners&&n.worker.removeAllListeners(`message`),n.worker=null,n.terminating=!1,n.terminationHandler)n.terminationHandler(e,n);else if(e)throw e};if(this.worker){if(typeof this.worker.kill==`function`){if(this.worker.killed){a(Error(`worker already killed!`));return}var o=setTimeout(function(){n.worker&&n.worker.kill()},this.workerTerminateTimeout);this.worker.once(`exit`,function(){clearTimeout(o),n.worker&&(n.worker.killed=!0),a()}),this.worker.ready?this.worker.send(c):this.requestQueue.push({message:c}),this.cleaning=!0;return}if(typeof this.worker.terminate==`function`)this.worker.terminate(),this.worker.killed=!0;else throw Error(`Failed to terminate worker`)}a()}},E.prototype.terminateAndNotify=function(e,t){var r=n.defer();return t&&r.promise.timeout(t),this.terminate(e,function(e,t){e?r.reject(e):r.resolve(t)}),r.promise};function ee(e){this.error=e,this.stack=Error().stack}var D=class extends Error{constructor(e,t){super(e||`worker terminated`),this.cause=t}};t.exports=E,t.exports._tryRequireWorkerThreads=f,t.exports._setupProcessWorker=S,t.exports._setupBrowserWorker=b,t.exports._setupWorkerThreadWorker=x,t.exports.ensureWorkerThreads=u,t.exports.TerminateError=D})),b=l(((e,t)=>{function n(){this.tasks=[]}n.prototype.push=function(e){this.tasks.push(e)},n.prototype.pop=function(){return this.tasks.shift()},n.prototype.size=function(){return this.tasks.length},n.prototype.contains=function(e){return this.tasks.includes(e)},n.prototype.clear=function(){this.tasks.length=0};function r(){this.tasks=[]}r.prototype.push=function(e){this.tasks.push(e)},r.prototype.pop=function(){return this.tasks.pop()},r.prototype.size=function(){return this.tasks.length},r.prototype.contains=function(e){return this.tasks.includes(e)},r.prototype.clear=function(){this.tasks.length=0},t.exports={FIFOQueue:n,LIFOQueue:r}})),x=l(((e,t)=>{t.exports=n;function n(){this.ports=Object.create(null),this.length=0}n.prototype.nextAvailableStartingAt=function(e){for(;this.ports[e]===!0;)e++;if(e>=65535)throw Error(`WorkerPool debug port limit reached: `+e+`>= 65535`);return this.ports[e]=!0,this.length++,e},n.prototype.releasePort=function(e){delete this.ports[e],this.length--}})),S=l(((e,t)=>{var{Promise:n}=g(),r=y(),i=h(),{FIFOQueue:a,LIFOQueue:o}=b(),s=new(x());function c(e,t){typeof e==`string`?this.script=e||null:(this.script=null,t=e),this.workers=[],this.taskQueue=this._createQueue(t&&t.queueStrategy||`fifo`),t||={},this.forkArgs=Object.freeze(t.forkArgs||[]),this.forkOpts=Object.freeze(t.forkOpts||{}),this.workerOpts=Object.freeze(t.workerOpts||{}),this.workerThreadOpts=Object.freeze(t.workerThreadOpts||{}),this.debugPortStart=t.debugPortStart||43210,this.nodeWorker=t.nodeWorker,this.workerType=t.workerType||t.nodeWorker||`auto`,this.maxQueueSize=t.maxQueueSize||1/0,this.workerTerminateTimeout=t.workerTerminateTimeout||1e3,this.onCreateWorker=t.onCreateWorker||(()=>null),this.onTerminateWorker=t.onTerminateWorker||(()=>null),this.emitStdStreams=t.emitStdStreams||!1,t&&`maxWorkers`in t?(l(t.maxWorkers),this.maxWorkers=t.maxWorkers):this.maxWorkers=Math.max((i.cpus||4)-1,1),t&&`minWorkers`in t&&(t.minWorkers===`max`?this.minWorkers=this.maxWorkers:(u(t.minWorkers),this.minWorkers=t.minWorkers,this.maxWorkers=Math.max(this.minWorkers,this.maxWorkers)),this._ensureMinWorkers()),this._boundNext=this._next.bind(this),this.workerType===`thread`&&r.ensureWorkerThreads()}c.prototype.exec=function(e,t,r){if(t&&!Array.isArray(t))throw TypeError(`Array expected as argument "params"`);if(typeof e==`string`){var i=n.defer();if(this.taskQueue.size()>=this.maxQueueSize)throw Error(`Max queue size of `+this.maxQueueSize+` reached`);var a={method:e,params:t,resolver:i,timeout:null,options:r};this.taskQueue.push(a);var o=i.promise.timeout,s=this.taskQueue;return i.promise.timeout=function(e){return s.contains(a)?(a.timeout=e,i.promise):o.call(i.promise,e)},this._next(),i.promise}if(typeof e==`function`)return this.exec(`run`,[String(e),t],r);throw TypeError(`Function or string expected as argument "method"`)},c.prototype.proxy=function(){if(arguments.length>0)throw Error(`No arguments expected`);var e=this;return this.exec(`methods`).then(function(t){var n={};return t.forEach(function(t){n[t]=function(){return e.exec(t,Array.prototype.slice.call(arguments))}}),n})},c.prototype._next=function(){if(this.taskQueue.size()>0){var e=this._getWorker();if(e){var t=this,n=this.taskQueue.pop();if(n.resolver.promise.pending){var r=e.exec(n.method,n.params,n.resolver,n.options).then(t._boundNext).catch(function(){if(e.terminated)return t._removeWorker(e)}).then(function(){t._next()});typeof n.timeout==`number`&&r.timeout(n.timeout)}else t._next()}}},c.prototype._getWorker=function(){for(var e=this.workers,t=0;t<e.length;t++){var n=e[t];if(n.busy()===!1)return n}return e.length<this.maxWorkers?(n=this._createWorkerHandler(),e.push(n),n):null},c.prototype._removeWorker=function(e){var t=this;return s.releasePort(e.debugPort),this._removeWorkerFromList(e),this._ensureMinWorkers(),new n(function(n,r){e.terminate(!1,function(i){t.onTerminateWorker({forkArgs:e.forkArgs,forkOpts:e.forkOpts,workerThreadOpts:e.workerThreadOpts,script:e.script}),i?r(i):n(e)})})},c.prototype._removeWorkerFromList=function(e){var t=this.workers.indexOf(e);t!==-1&&this.workers.splice(t,1)},c.prototype.terminate=function(e,t){for(var r=this,i=this.taskQueue;i.size()>0;){var a=i.pop();if(a)a.resolver.reject(Error(`Pool terminated`));else break}i.clear();var o=function(e){s.releasePort(e.debugPort),this._removeWorkerFromList(e)}.bind(this),c=[];return this.workers.slice().forEach(function(n){var i=n.terminateAndNotify(e,t).then(o).always(function(){r.onTerminateWorker({forkArgs:n.forkArgs,forkOpts:n.forkOpts,workerThreadOpts:n.workerThreadOpts,script:n.script})});c.push(i)}),n.all(c)},c.prototype.stats=function(){var e=this.workers.length,t=this.workers.filter(function(e){return e.busy()}).length;return{totalWorkers:e,busyWorkers:t,idleWorkers:e-t,pendingTasks:this.taskQueue.size(),activeTasks:t}},c.prototype._ensureMinWorkers=function(){if(this.minWorkers)for(var e=this.workers.length;e<this.minWorkers;e++)this.workers.push(this._createWorkerHandler())},c.prototype._createWorkerHandler=function(){let e=this.onCreateWorker({forkArgs:this.forkArgs,forkOpts:this.forkOpts,workerOpts:this.workerOpts,workerThreadOpts:this.workerThreadOpts,script:this.script})||{};return new r(e.script||this.script,{forkArgs:e.forkArgs||this.forkArgs,forkOpts:e.forkOpts||this.forkOpts,workerOpts:e.workerOpts||this.workerOpts,workerThreadOpts:e.workerThreadOpts||this.workerThreadOpts,debugPort:s.nextAvailableStartingAt(this.debugPortStart),workerType:this.workerType,workerTerminateTimeout:this.workerTerminateTimeout,emitStdStreams:this.emitStdStreams})},c.prototype._createQueue=function(e){if(typeof e==`string`)switch(e){case`fifo`:return new a;case`lifo`:return new o;default:throw Error(`Unknown queue strategy: `+e)}if(!e)throw Error(`Queue strategy cannot be null or undefined`);for(var t=[`push`,`pop`,`size`,`contains`,`clear`],n=0;n<t.length;n++){var r=t[n];if(typeof e[r]!=`function`)throw Error(`Queue strategy must implement method: `+r)}return e};function l(e){if(!d(e)||!f(e)||e<1)throw TypeError(`Option maxWorkers must be an integer number >= 1`)}function u(e){if(!d(e)||!f(e)||e<0)throw TypeError(`Option minWorkers must be an integer number >= 0`)}function d(e){return typeof e==`number`}function f(e){return Math.round(e)==e}t.exports=c})),C=l(((e,t)=>{function n(e,t){this.message=e,this.transfer=t}t.exports=n})),w=l((e=>{var t=C(),n=g().Promise,r=`__workerpool-terminate__`,i=`__workerpool-cleanup__`,a=1e3,o={exit:function(){}},s={addAbortListener:function(e){o.abortListeners.push(e)},emit:o.emit};if(typeof self<`u`&&typeof postMessage==`function`&&typeof addEventListener==`function`)o.on=function(e,t){addEventListener(e,function(e){t(e.data)})},o.send=function(e,t){t?postMessage(e,t):postMessage(e)};else if(typeof process<`u`){var c;try{c=m()}catch(e){if(!(typeof e==`object`&&e&&e.code===`MODULE_NOT_FOUND`))throw e}if(c&&c.parentPort!==null){var l=c.parentPort;o.send=l.postMessage.bind(l),o.on=l.on.bind(l),o.exit=process.exit.bind(process)}else o.on=process.on.bind(process),o.send=function(e){process.send(e)},o.on(`disconnect`,function(){process.exit(1)}),o.exit=process.exit.bind(process)}else throw Error(`Script must be executed as a worker`);function u(e){return e&&e.toJSON?JSON.parse(JSON.stringify(e)):JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e)))}function d(e){return e&&typeof e.then==`function`&&typeof e.catch==`function`}o.methods={},o.methods.run=function(e,t){var n=Function(`return (`+e+`).apply(this, arguments);`);return n.worker=s,n.apply(n,t)},o.methods.methods=function(){return Object.keys(o.methods)},o.terminationHandler=void 0,o.abortListenerTimeout=a,o.abortListeners=[],o.terminateAndExit=function(e){var t=function(){o.exit(e)};if(!o.terminationHandler)return t();var r=o.terminationHandler(e);return d(r)?(r.then(t,t),r):(t(),new n(function(e,t){t(Error(`Worker terminating`))}))},o.cleanup=function(e){if(!o.abortListeners.length)return o.send({id:e,method:i,error:u(Error(`Worker terminating`))}),new n(function(e){e()});var t=function(){o.exit()},r=function(){o.abortListeners.length&&(o.abortListeners=[])};let a=o.abortListeners.map(e=>e()),s,c=new n((e,t)=>{s=setTimeout(function(){t(Error(`Timeout occurred waiting for abort handler, killing worker`))},o.abortListenerTimeout)}),l=n.all(a).then(function(){clearTimeout(s),r()},function(){clearTimeout(s),t()});return new n(function(e,t){l.then(e,t),c.then(e,t)}).then(function(){o.send({id:e,method:i,error:null})},function(t){o.send({id:e,method:i,error:t?u(t):null})})};var f=null;o.on(`message`,function(e){if(e===r)return o.terminateAndExit(0);if(e.method===i)return o.cleanup(e.id);try{var n=o.methods[e.method];if(n){f=e.id;var a=n.apply(n,e.params);d(a)?a.then(function(n){n instanceof t?o.send({id:e.id,result:n.message,error:null},n.transfer):o.send({id:e.id,result:n,error:null}),f=null}).catch(function(t){o.send({id:e.id,result:null,error:u(t)}),f=null}):(a instanceof t?o.send({id:e.id,result:a.message,error:null},a.transfer):o.send({id:e.id,result:a,error:null}),f=null)}else throw Error(`Unknown method "`+e.method+`"`)}catch(t){o.send({id:e.id,result:null,error:u(t)})}}),o.register=function(e,t){if(e)for(var n in e)e.hasOwnProperty(n)&&(o.methods[n]=e[n],o.methods[n].worker=s);t&&(o.terminationHandler=t.onTerminate,o.abortListenerTimeout=t.abortListenerTimeout||a),o.send(`ready`)},o.emit=function(e){if(f){if(e instanceof t){o.send({id:f,isEvent:!0,payload:e.message},e.transfer);return}o.send({id:f,isEvent:!0,payload:e})}},e!==void 0&&(e.add=o.register,e.emit=o.emit)})),T=d(l((e=>{var{platform:t,isMainThread:n,cpus:r}=h(),{TerminateError:i}=y();function a(e,t){return new(S())(e,t)}e.pool=a;function o(e,t){w().add(e,t)}e.worker=o;var{Promise:s}=g();e.Transfer=C()}))(),1),E=5e3,ee=3e4,D=e=>T.pool(e,{maxWorkers:1,minWorkers:0,workerTerminateTimeout:ee,workerOpts:{type:void 0}}),te=class{url;maxWorkerHeapBytes;slots;idleSweepTimer;terminated=!1;constructor(e,t,n){p(t>0,`maxWorkers must be a positive number.`),this.url=e,this.maxWorkerHeapBytes=n?.maxWorkerHeapBytes??268435456,this.slots=Array.from({length:t},()=>({pool:D(e),tasksSinceSpawn:0,inflight:0,draining:!1,probing:!1,lastHeapBytes:void 0}))}exec(e,t,n){let r=this.pickSlot();r.inflight++;try{return r.pool.exec(e,t,n).then(e=>(this.onSettled(r),e)).catch(e=>{throw this.onSettled(r),e})}catch(e){throw this.onSettled(r),e}}warmUp(){let[e,...t]=this.slots;return this.warmSlot(e).then(()=>{for(let e of t)this.warmSlot(e).catch(()=>void 0)},e=>{if(t.length===0)throw e;return Promise.any(t.map(e=>this.warmSlot(e))).then(()=>void 0)})}canAcceptTasks(){return this.slots.some(e=>!e.draining)}stats(){let e={totalWorkers:0,busyWorkers:0,idleWorkers:0,pendingTasks:0,activeTasks:0,tasksSinceSpawn:0};for(let t of this.slots){let n=t.pool.stats();e.totalWorkers+=n.totalWorkers,e.busyWorkers+=n.busyWorkers,e.idleWorkers+=n.idleWorkers,e.pendingTasks+=n.pendingTasks,e.activeTasks+=n.activeTasks,e.tasksSinceSpawn+=t.tasksSinceSpawn}return e}heapStats(){let e=this.slots.map(e=>e.lastHeapBytes);return{perSlot:e,totalBytes:e.reduce((e,t)=>e+(t??0),0),maxWorkerHeapBytes:this.maxWorkerHeapBytes}}probeHeap(){if(!this.terminated)for(let e of this.slots)e.draining||this.probeSlot(e)}terminate(){this.idleSweepTimer!==void 0&&(clearTimeout(this.idleSweepTimer),this.idleSweepTimer=void 0),this.terminated=!0;for(let e of this.slots)e.pool.terminate()}pickSlot(){let e=this.slots.filter(e=>!e.draining);return(e.length>0?e:this.slots).reduce((e,t)=>t.inflight<e.inflight?t:e)}onSettled(e){e.inflight--,!this.terminated&&(e.tasksSinceSpawn++,e.tasksSinceSpawn>=128&&(e.draining=!0),e.draining&&e.inflight===0?this.recycleSlot(e):e.draining||this.probeSlot(e),this.armIdleSweep())}recycleSlot(e){e.pool.terminate(),e.pool=D(this.url),e.tasksSinceSpawn=0,e.draining=!1,e.lastHeapBytes=void 0,this.warmSlot(e).catch(()=>void 0)}warmSlot(e){e.inflight++;let t=()=>{e.inflight--,!this.terminated&&e.draining&&e.inflight===0&&this.recycleSlot(e)};return new Promise((n,r)=>{try{e.pool.exec(`warmUp`).then(()=>{t(),n()}).catch(e=>{t(),r(e)})}catch(e){t(),r(e)}})}probeSlot(e){if(e.probing)return;e.probing=!0,e.inflight++;let t=t=>{e.probing=!1,e.inflight--,!this.terminated&&(t&&(e.draining=!0),e.draining&&e.inflight===0&&this.recycleSlot(e))};try{e.pool.exec(`getWasmMemoryUsage`).then(n=>{typeof n==`number`&&(e.lastHeapBytes=n),t(typeof n==`number`&&n>=this.maxWorkerHeapBytes)}).catch(()=>{t(!0)})}catch{t(!0)}}armIdleSweep(){this.idleSweepTimer!==void 0&&clearTimeout(this.idleSweepTimer),this.idleSweepTimer=setTimeout(()=>{this.idleSweepTimer=void 0;for(let e of this.slots)e.tasksSinceSpawn>0&&e.inflight===0&&this.recycleSlot(e)},E)}};function ne(e){return e!=null}var re=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},ie=class{vertices;uvs;indices;heights;max_height;min_height;rtc_translation;normals;skirt_vertices;skirt_uvs;skirt_indices;skirt_normals;watermask;constructor(e){this.vertices=e.transferVertices(),this.uvs=e.transferUvs(),this.indices=e.transferIndices(),this.heights=e.transferHeights(),this.max_height=e.max_height,this.min_height=e.min_height,this.rtc_translation=e.rtc_translation?new re(e.rtc_translation):void 0,e.hasNormals()&&(this.normals=e.transferNormals()),e.hasSkirt()&&(this.skirt_vertices=e.transferSkirtVertices(),this.skirt_uvs=e.transferSkirtUvs(),this.skirt_indices=e.transferSkirtIndices(),this.skirt_normals=e.transferSkirtNormals()),e.hasWatermask()&&(this.watermask=e.transferWatermask())}transferVertices(){throw Error()}transferUvs(){throw Error()}transferIndices(){throw Error()}transferHeights(){throw Error()}transferNormals(){throw Error()}transferSkirtVertices(){throw Error()}transferSkirtUvs(){throw Error()}transferSkirtIndices(){throw Error()}transferSkirtNormals(){throw Error()}transferWatermask(){throw Error()}hasSkirt(){return this.skirt_vertices!==void 0&&this.skirt_uvs!==void 0&&this.skirt_indices!==void 0}hasNormals(){return this.normals!==void 0}hasWatermask(){return this.watermask!==void 0}},ae=class{east;north;south;west;constructor(e){this.east=e.east,this.north=e.north,this.south=e.south,this.west=e.west}},oe=class{extent;position_3d_high;position_3d_high_size;position_3d_low;position_3d_low_size;position;position_size;normal;normal_size;scale_normal_and_cap;scale_normal_and_cap_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;rtc_translation;outline_position;outline_position_size;outline_position_3d_high;outline_position_3d_high_size;outline_position_3d_low;outline_position_3d_low_size;outline_scale_normal_and_cap;outline_scale_normal_and_cap_size;outline_skip_indices;outline_batch_index;outline_batch_index_size;constructor(e){let t=e.extent;this.extent=t?new ae(t):void 0,this.position_3d_high=e.position_3d_high()?.slice(),this.position_3d_high_size=e.position_3d_high_size(),this.position_3d_low=e.position_3d_low()?.slice(),this.position_3d_low_size=e.position_3d_low_size(),this.position=e.position()?.slice(),this.position_size=e.position_size(),this.normal=e.normal()?.slice(),this.normal_size=e.normal_size(),this.scale_normal_and_cap=e.scale_normal_and_cap()?.slice(),this.scale_normal_and_cap_size=e.scale_normal_and_cap_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice(),this.rtc_translation=e.rtc_translation?new re(e.rtc_translation):void 0;let n=e.outline();n&&(this.outline_position=n.position()?.slice(),this.outline_position_size=n.position_size(),this.outline_position_3d_high=n.position_3d_high()?.slice(),this.outline_position_3d_high_size=n.position_3d_high_size(),this.outline_position_3d_low=n.position_3d_low()?.slice(),this.outline_position_3d_low_size=n.position_3d_low_size(),this.outline_scale_normal_and_cap=n.scale_normal_and_cap()?.slice(),this.outline_scale_normal_and_cap_size=n.scale_normal_and_cap_size(),this.outline_skip_indices=n.skip_indices()?.slice(),this.outline_batch_index=n.batch_index()?.slice(),this.outline_batch_index_size=n.batch_index_size(),n.free())}},se=class{extent;position;position_size;position_high;position_high_size;position_low;position_low_size;start;start_size;start_high;start_high_size;start_low;start_low_size;forward_offset;forward_offset_size;end_high;end_high_size;end_low;end_low_size;start_normals;start_normals_size;end_normal_and_texture_coordinate_normalization_x;end_normal_and_texture_coordinate_normalization_x_size;right_normal_and_texture_coordinate_normalization_y;right_normal_and_texture_coordinate_normalization_y_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;constructor(e){let t=e.extent;this.extent=t?new ae(t):void 0,this.position=e.position().slice(),this.position_size=e.position_size(),this.position_high=e.position_high()?.slice(),this.position_high_size=e.position_high_size(),this.position_low=e.position_low()?.slice(),this.position_low_size=e.position_low_size(),this.start=e.start()?.slice(),this.start_size=e.start_size(),this.start_high=e.start_high()?.slice(),this.start_high_size=e.start_high_size(),this.start_low=e.start_low()?.slice(),this.start_low_size=e.start_low_size(),this.forward_offset=e.forward_offset()?.slice(),this.forward_offset_size=e.forward_offset_size(),this.end_high=e.end_high()?.slice(),this.end_high_size=e.end_high_size(),this.end_low=e.end_low()?.slice(),this.end_low_size=e.end_low_size(),this.start_normals=e.start_normals()?.slice(),this.start_normals_size=e.start_normals_size(),this.end_normal_and_texture_coordinate_normalization_x=e.end_normal_and_texture_coordinate_normalization_x()?.slice(),this.end_normal_and_texture_coordinate_normalization_x_size=e.end_normal_and_texture_coordinate_normalization_x_size(),this.right_normal_and_texture_coordinate_normalization_y=e.right_normal_and_texture_coordinate_normalization_y().slice(),this.right_normal_and_texture_coordinate_normalization_y_size=e.right_normal_and_texture_coordinate_normalization_y_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice()}};function ce(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function le(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ue(e){let t,n,r;e.length===2?(t=e===ce||e===le?e:de,n=e,r=e):(t=ce,n=(t,n)=>ce(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function de(){return 0}function fe(e){return e===null?NaN:+e}var pe=ue(ce);pe.right,pe.left,ue(fe).center;var me={value:()=>{}};function he(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new ge(n)}function ge(e){this._=e}function _e(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}ge.prototype=he.prototype={constructor:ge,on:function(e,t){var n=this._,r=_e(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=ve(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=ye(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ye(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ge(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function ve(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function ye(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=me,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var be={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function xe(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),be.hasOwnProperty(t)?{space:be[t],local:e}:e}function Se(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Ce(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function we(e){var t=xe(e);return(t.local?Ce:Se)(t)}function Te(){}function Ee(e){return e==null?Te:function(){return this.querySelector(e)}}function De(e){typeof e!=`function`&&(e=Ee(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new k(r,this._parents)}function Oe(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ke(){return[]}function Ae(e){return e==null?ke:function(){return this.querySelectorAll(e)}}function je(e){return function(){return Oe(e.apply(this,arguments))}}function Me(e){e=typeof e==`function`?je(e):Ae(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new k(r,i)}function Ne(e){return function(){return this.matches(e)}}function Pe(e){return function(t){return t.matches(e)}}var Fe=Array.prototype.find;function Ie(e){return function(){return Fe.call(this.children,e)}}function Le(){return this.firstElementChild}function Re(e){return this.select(e==null?Le:Ie(typeof e==`function`?e:Pe(e)))}var ze=Array.prototype.filter;function Be(){return Array.from(this.children)}function Ve(e){return function(){return ze.call(this.children,e)}}function He(e){return this.selectAll(e==null?Be:Ve(typeof e==`function`?e:Pe(e)))}function Ue(e){typeof e!=`function`&&(e=Ne(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new k(r,this._parents)}function We(e){return Array(e.length)}function Ge(){return new k(this._enter||this._groups.map(We),this._parents)}function Ke(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ke.prototype={constructor:Ke,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function qe(e){return function(){return e}}function Je(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Ke(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Ye(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Ke(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Xe(e){return e.__data__}function Ze(e,t){if(!arguments.length)return Array.from(this,Xe);var n=t?Ye:Je,r=this._parents,i=this._groups;typeof e!=`function`&&(e=qe(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=Qe(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new k(o,r),o._enter=s,o._exit=c,o}function Qe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function $e(){return new k(this._exit||this._groups.map(We),this._parents)}function et(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function tt(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new k(s,this._parents)}function nt(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function rt(e){e||=it;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new k(i,this._parents).order()}function it(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function at(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ot(){return Array.from(this)}function st(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function ct(){let e=0;for(let t of this)++e;return e}function lt(){return!this.node()}function ut(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function dt(e){return function(){this.removeAttribute(e)}}function ft(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pt(e,t){return function(){this.setAttribute(e,t)}}function mt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ht(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function gt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function _t(e,t){var n=xe(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?ft:dt:typeof t==`function`?n.local?gt:ht:n.local?mt:pt)(n,t))}function vt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function yt(e){return function(){this.style.removeProperty(e)}}function bt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xt(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function St(e,t,n){return arguments.length>1?this.each((t==null?yt:typeof t==`function`?xt:bt)(e,t,n??``)):O(this.node(),e)}function O(e,t){return e.style.getPropertyValue(t)||vt(e).getComputedStyle(e,null).getPropertyValue(t)}function Ct(e){return function(){delete this[e]}}function wt(e,t){return function(){this[e]=t}}function Tt(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Et(e,t){return arguments.length>1?this.each((t==null?Ct:typeof t==`function`?Tt:wt)(e,t)):this.node()[e]}function Dt(e){return e.trim().split(/^|\s+/)}function Ot(e){return e.classList||new kt(e)}function kt(e){this._node=e,this._names=Dt(e.getAttribute(`class`)||``)}kt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function At(e,t){for(var n=Ot(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function jt(e,t){for(var n=Ot(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Mt(e){return function(){At(this,e)}}function Nt(e){return function(){jt(this,e)}}function Pt(e,t){return function(){(t.apply(this,arguments)?At:jt)(this,e)}}function Ft(e,t){var n=Dt(e+``);if(arguments.length<2){for(var r=Ot(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?Pt:t?Mt:Nt)(n,t))}function It(){this.textContent=``}function Lt(e){return function(){this.textContent=e}}function Rt(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function zt(e){return arguments.length?this.each(e==null?It:(typeof e==`function`?Rt:Lt)(e)):this.node().textContent}function Bt(){this.innerHTML=``}function Vt(e){return function(){this.innerHTML=e}}function Ht(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function Ut(e){return arguments.length?this.each(e==null?Bt:(typeof e==`function`?Ht:Vt)(e)):this.node().innerHTML}function Wt(){this.nextSibling&&this.parentNode.appendChild(this)}function Gt(){return this.each(Wt)}function Kt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qt(){return this.each(Kt)}function Jt(e){var t=typeof e==`function`?e:we(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Yt(){return null}function Xt(e,t){var n=typeof e==`function`?e:we(e),r=t==null?Yt:typeof t==`function`?t:Ee(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Zt(){var e=this.parentNode;e&&e.removeChild(this)}function Qt(){return this.each(Zt)}function $t(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function en(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tn(e){return this.select(e?en:$t)}function nn(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function rn(e){return function(t){e.call(this,t,this.__data__)}}function an(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function on(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function sn(e,t,n){return function(){var r=this.__on,i,a=rn(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function cn(e,t,n){var r=an(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?sn:on,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function ln(e,t,n){var r=vt(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function un(e,t){return function(){return ln(this,e,t)}}function dn(e,t){return function(){return ln(this,e,t.apply(this,arguments))}}function fn(e,t){return this.each((typeof t==`function`?dn:un)(e,t))}function*pn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var mn=[null];function k(e,t){this._groups=e,this._parents=t}function A(){return new k([[document.documentElement]],mn)}function hn(){return this}k.prototype=A.prototype={constructor:k,select:De,selectAll:Me,selectChild:Re,selectChildren:He,filter:Ue,data:Ze,enter:Ge,exit:$e,join:et,merge:tt,selection:hn,order:nt,sort:rt,call:at,nodes:ot,node:st,size:ct,empty:lt,each:ut,attr:_t,style:St,property:Et,classed:Ft,text:zt,html:Ut,raise:Gt,lower:qt,append:Jt,insert:Xt,remove:Qt,clone:tn,datum:nn,on:cn,dispatch:fn,[Symbol.iterator]:pn};function gn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _n(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function j(){}var M=.7,vn=1/M,N=`\\s*([+-]?\\d+)\\s*`,P=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,F=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,yn=/^#([0-9a-f]{3,8})$/,bn=RegExp(`^rgb\\(${N},${N},${N}\\)$`),xn=RegExp(`^rgb\\(${F},${F},${F}\\)$`),Sn=RegExp(`^rgba\\(${N},${N},${N},${P}\\)$`),Cn=RegExp(`^rgba\\(${F},${F},${F},${P}\\)$`),wn=RegExp(`^hsl\\(${P},${F},${F}\\)$`),Tn=RegExp(`^hsla\\(${P},${F},${F},${P}\\)$`),En={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,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,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,slategray:7372944,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};gn(j,I,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Dn,formatHex:Dn,formatHex8:On,formatHsl:kn,formatRgb:An,toString:An});function Dn(){return this.rgb().formatHex()}function On(){return this.rgb().formatHex8()}function kn(){return Bn(this).formatHsl()}function An(){return this.rgb().formatRgb()}function I(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=yn.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jn(t):n===3?new L(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=bn.exec(e))?new L(t[1],t[2],t[3],1):(t=xn.exec(e))?new L(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Sn.exec(e))?Mn(t[1],t[2],t[3],t[4]):(t=Cn.exec(e))?Mn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=wn.exec(e))?zn(t[1],t[2]/100,t[3]/100,1):(t=Tn.exec(e))?zn(t[1],t[2]/100,t[3]/100,t[4]):En.hasOwnProperty(e)?jn(En[e]):e===`transparent`?new L(NaN,NaN,NaN,0):null}function jn(e){return new L(e>>16&255,e>>8&255,e&255,1)}function Mn(e,t,n,r){return r<=0&&(e=t=n=NaN),new L(e,t,n,r)}function Nn(e){return e instanceof j||(e=I(e)),e?(e=e.rgb(),new L(e.r,e.g,e.b,e.opacity)):new L}function Pn(e,t,n,r){return arguments.length===1?Nn(e):new L(e,t,n,r??1)}function L(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gn(L,Pn,_n(j,{brighter(e){return e=e==null?vn:vn**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?M:M**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new L(R(this.r),R(this.g),R(this.b),Rn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Fn,formatHex:Fn,formatHex8:In,formatRgb:Ln,toString:Ln}));function Fn(){return`#${z(this.r)}${z(this.g)}${z(this.b)}`}function In(){return`#${z(this.r)}${z(this.g)}${z(this.b)}${z((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ln(){let e=Rn(this.opacity);return`${e===1?`rgb(`:`rgba(`}${R(this.r)}, ${R(this.g)}, ${R(this.b)}${e===1?`)`:`, ${e})`}`}function Rn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function R(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function z(e){return e=R(e),(e<16?`0`:``)+e.toString(16)}function zn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new B(e,t,n,r)}function Bn(e){if(e instanceof B)return new B(e.h,e.s,e.l,e.opacity);if(e instanceof j||(e=I(e)),!e)return new B;if(e instanceof B)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new B(o,s,c,e.opacity)}function Vn(e,t,n,r){return arguments.length===1?Bn(e):new B(e,t,n,r??1)}function B(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gn(B,Vn,_n(j,{brighter(e){return e=e==null?vn:vn**+e,new B(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?M:M**+e,new B(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new L(Wn(e>=240?e-240:e+120,i,r),Wn(e,i,r),Wn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new B(Hn(this.h),Un(this.s),Un(this.l),Rn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Rn(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Hn(this.h)}, ${Un(this.s)*100}%, ${Un(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Hn(e){return e=(e||0)%360,e<0?e+360:e}function Un(e){return Math.max(0,Math.min(1,e||0))}function Wn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Gn=e=>()=>e;function Kn(e,t){return function(n){return e+n*t}}function qn(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Jn(e){return(e=+e)==1?Yn:function(t,n){return n-t?qn(t,n,e):Gn(isNaN(t)?n:t)}}function Yn(e,t){var n=t-e;return n?Kn(e,n):Gn(isNaN(e)?t:e)}var Xn=(function e(t){var n=Jn(t);function r(e,t){var r=n((e=Pn(e)).r,(t=Pn(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Yn(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function V(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Zn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qn=new RegExp(Zn.source,`g`);function $n(e){return function(){return e}}function er(e){return function(t){return e(t)+``}}function tr(e,t){var n=Zn.lastIndex=Qn.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=Zn.exec(e))&&(i=Qn.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:V(r,i)})),n=Qn.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?er(c[0].x):$n(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}var nr=180/Math.PI,rr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ir(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*nr,skewX:Math.atan(c)*nr,scaleX:o,scaleY:s}}var ar;function or(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?rr:ir(t.a,t.b,t.c,t.d,t.e,t.f)}function sr(e){return e==null||(ar||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),ar.setAttribute(`transform`,e),!(e=ar.transform.baseVal.consolidate()))?rr:(e=e.matrix,ir(e.a,e.b,e.c,e.d,e.e,e.f))}function cr(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:V(e,i)},{i:c-2,x:V(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:V(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:V(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:V(e,n)},{i:s-2,x:V(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var lr=cr(or,`px, `,`px)`,`deg)`),ur=cr(sr,`, `,`)`,`)`),H=0,dr=0,fr=0,pr=1e3,mr,U,hr=0,W=0,gr=0,G=typeof performance==`object`&&performance.now?performance:Date,_r=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function vr(){return W||=(_r(yr),G.now()+gr)}function yr(){W=0}function br(){this._call=this._time=this._next=null}br.prototype=xr.prototype={constructor:br,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?vr():+n)+(t==null?0:+t),!this._next&&U!==this&&(U?U._next=this:mr=this,U=this),this._call=e,this._time=n,Er()},stop:function(){this._call&&(this._call=null,this._time=1/0,Er())}};function xr(e,t,n){var r=new br;return r.restart(e,t,n),r}function Sr(){vr(),++H;for(var e=mr,t;e;)(t=W-e._time)>=0&&e._call.call(void 0,t),e=e._next;--H}function Cr(){W=(hr=G.now())+gr,H=dr=0;try{Sr()}finally{H=0,Tr(),W=0}}function wr(){var e=G.now(),t=e-hr;t>pr&&(gr-=t,hr=e)}function Tr(){for(var e,t=mr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:mr=n);U=e,Er(r)}function Er(e){H||(dr&&=clearTimeout(dr),e-W>24?(e<1/0&&(dr=setTimeout(Cr,e-G.now()-gr)),fr&&=clearInterval(fr)):(fr||=(hr=G.now(),setInterval(wr,pr)),H=1,_r(Cr)))}function Dr(e,t,n){var r=new br;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Or=he(`start`,`end`,`cancel`,`interrupt`),kr=[];function Ar(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Mr(e,n,{name:t,index:r,group:i,on:Or,tween:kr,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function jr(e,t){var n=q(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function K(e,t){var n=q(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function q(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Mr(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=xr(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Dr(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Dr(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function Nr(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Pr(e){return this.each(function(){Nr(this,e)})}function Fr(e,t){var n,r;return function(){var i=K(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Ir(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=K(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function Lr(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=q(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Fr:Ir)(n,e,t))}function Rr(e,t,n){var r=e._id;return e.each(function(){var e=K(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return q(e,r).value[t]}}function zr(e,t){var n;return(typeof t==`number`?V:t instanceof I?Xn:(n=I(t))?(t=n,Xn):tr)(e,t)}function Br(e){return function(){this.removeAttribute(e)}}function Vr(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hr(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Ur(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function Wr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Gr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Kr(e,t){var n=xe(e),r=n===`transform`?ur:zr;return this.attrTween(e,typeof t==`function`?(n.local?Gr:Wr)(n,r,Rr(this,`attr.`+e,t)):t==null?(n.local?Vr:Br)(n):(n.local?Ur:Hr)(n,r,t))}function qr(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Jr(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Yr(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Jr(e,i)),n}return i._value=t,i}function Xr(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&qr(e,i)),n}return i._value=t,i}function Zr(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=xe(e);return this.tween(n,(r.local?Yr:Xr)(r,t))}function Qr(e,t){return function(){jr(this,e).delay=+t.apply(this,arguments)}}function $r(e,t){return t=+t,function(){jr(this,e).delay=t}}function ei(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Qr:$r)(t,e)):q(this.node(),t).delay}function ti(e,t){return function(){K(this,e).duration=+t.apply(this,arguments)}}function ni(e,t){return t=+t,function(){K(this,e).duration=t}}function ri(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?ti:ni)(t,e)):q(this.node(),t).duration}function ii(e,t){if(typeof t!=`function`)throw Error();return function(){K(this,e).ease=t}}function ai(e){var t=this._id;return arguments.length?this.each(ii(t,e)):q(this.node(),t).ease}function oi(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();K(this,e).ease=n}}function si(e){if(typeof e!=`function`)throw Error();return this.each(oi(this._id,e))}function ci(e){typeof e!=`function`&&(e=Ne(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new J(r,this._parents,this._name,this._id)}function li(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new J(o,this._parents,this._name,this._id)}function ui(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function di(e,t,n){var r,i,a=ui(t)?jr:K;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function fi(e,t){var n=this._id;return arguments.length<2?q(this.node(),n).on.on(e):this.each(di(n,e,t))}function pi(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function mi(){return this.on(`end.remove`,pi(this._id))}function hi(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ee(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Ar(l[f],t,n,f,l,q(u,n)));return new J(a,this._parents,t,n)}function gi(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ae(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=q(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Ar(p,t,n,h,f,m);a.push(f),o.push(u)}return new J(a,o,t,n)}var _i=A.prototype.constructor;function vi(){return new _i(this._groups,this._parents)}function yi(e,t){var n,r,i;return function(){var a=O(this,e),o=(this.style.removeProperty(e),O(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function bi(e){return function(){this.style.removeProperty(e)}}function xi(e,t,n){var r,i=n+``,a;return function(){var o=O(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Si(e,t,n){var r,i,a;return function(){var o=O(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),O(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Ci(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=K(this,e),l=c.on,u=c.value[a]==null?s||=bi(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function wi(e,t,n){var r=(e+=``)==`transform`?lr:zr;return t==null?this.styleTween(e,yi(e,r)).on(`end.style.`+e,bi(e)):typeof t==`function`?this.styleTween(e,Si(e,r,Rr(this,`style.`+e,t))).each(Ci(this._id,e)):this.styleTween(e,xi(e,r,t),n).on(`end.style.`+e,null)}function Ti(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Ei(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Ti(e,a,n)),r}return a._value=t,a}function Di(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Ei(e,t,n??``))}function Oi(e){return function(){this.textContent=e}}function ki(e){return function(){var t=e(this);this.textContent=t??``}}function Ai(e){return this.tween(`text`,typeof e==`function`?ki(Rr(this,`text`,e)):Oi(e==null?``:e+``))}function ji(e){return function(t){this.textContent=e.call(this,t)}}function Mi(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ji(r)),t}return r._value=e,r}function Ni(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Mi(e))}function Pi(){for(var e=this._name,t=this._id,n=Li(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=q(c,t);Ar(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new J(r,this._parents,e,n)}function Fi(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=K(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Ii=0;function J(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Li(){return++Ii}var Y=A.prototype;J.prototype={constructor:J,select:hi,selectAll:gi,selectChild:Y.selectChild,selectChildren:Y.selectChildren,filter:ci,merge:li,selection:vi,transition:Pi,call:Y.call,nodes:Y.nodes,node:Y.node,size:Y.size,empty:Y.empty,each:Y.each,on:fi,attr:Kr,attrTween:Zr,style:wi,styleTween:Di,text:Ai,textTween:Ni,remove:mi,tween:Lr,delay:ei,duration:ri,ease:ai,easeVarying:si,end:Fi,[Symbol.iterator]:Y[Symbol.iterator]};function Ri(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zi={time:null,delay:0,duration:250,ease:Ri};function Bi(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function Vi(e){var t,n;e instanceof J?(t=e._id,e=e._name):(t=Li(),(n=zi).time=vr(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Ar(c,e,t,l,o,n||Bi(c,t));return new J(r,this._parents,e,t)}A.prototype.interrupt=Pr,A.prototype.transition=Vi;var{abs:Hi,max:Ui,min:Wi}=Math;[`w`,`e`].map(Gi),[`n`,`s`].map(Gi),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(Gi);function Gi(e){return{type:e}}function Ki(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function qi(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Ji(e){return e=qi(Math.abs(e)),e?e[1]:NaN}function Yi(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function Xi(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var Zi=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Qi(e){if(!(t=Zi.exec(e)))throw Error(`invalid format: `+e);var t;return new $i({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Qi.prototype=$i.prototype;function $i(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}$i.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function ea(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var ta;function na(e,t){var n=qi(e,t);if(!n)return ta=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(ta=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+qi(e,Math.max(0,t+a-1))[0]}function ra(e,t){var n=qi(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var ia={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Ki,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ra(e*100,t),r:ra,s:na,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function aa(e){return e}var oa=Array.prototype.map,sa=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function ca(e){var t=e.grouping===void 0||e.thousands===void 0?aa:Yi(oa.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?aa:Xi(oa.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=Qi(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):ia[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=ia[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=ea(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&ta!==void 0?sa[8+ta/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(Ji(t)/3)))*3,r=10**-n,i=l((e=Qi(e),e.type=`f`,e),{suffix:sa[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var la;ua({thousands:`,`,grouping:[3],currency:[`$`,``]});function ua(e){return la=ca(e),la.format,la.formatPrefix,la}function X(e,t,n){this.k=e,this.x=t,this.y=n}X.prototype={constructor:X,scale:function(e){return e===1?this:new X(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new X(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var da=new X(1,0,0);fa.prototype=X.prototype;function fa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return da;return e.__zoom}function pa(e){let t=new oe(e);return{result:t,transfers:[t.batch_id?.buffer,t.batch_index?.buffer,t.normal?.buffer,t.position_3d_high?.buffer,t.position_3d_low?.buffer,t.position?.buffer,t.scale_normal_and_cap?.buffer,t.indices.buffer,t.outline_position?.buffer,t.outline_position_3d_high?.buffer,t.outline_position_3d_low?.buffer,t.outline_scale_normal_and_cap?.buffer,t.outline_skip_indices?.buffer,t.outline_batch_index?.buffer].filter(ne)}}function Z(e){return new n.TransferableTile(ma(e.coords),e.max_height,e.min_height,e.cached_mesh_handle?ha(e.cached_mesh_handle):void 0)}function ma(e){return new n.TileXYZ(e.x,e.y,e.z)}function ha(e){return new n.CachedMeshHandle(e.vertices,e.indices,e.uvs,e.heights)}function ga(e){return new n.UpsamplableTerrainGeometry(e.uvs,e.indices,e.heights,e.normals,e.watermask)}function _a(e){return new n.ExtentRadianF32(e.west,e.south,e.east,e.north)}function va(e){return new n.PolygonMaterial(e.show,e.castShadow,e.receiveShadow,e.color,e.clampToGround,e.tiled,e.height,e.extrudedHeight,e.wireframe,e.outline,e.perPositionHeight,e.__internal__)}function ya(e){let t=new n.TransferablePolygonBatchedFeature(e.crs,e.length);return t.setOuterRing(e.outer_ring.length,t=>{t.set(e.outer_ring)}),t.setOuterRingSizes(e.outer_ring_sizes.length,t=>{t.set(e.outer_ring_sizes)}),t.setHoles(e.holes.length,t=>{t.set(e.holes)}),t.setHolesSizes(e.holes_sizes.length,t=>{t.set(e.holes_sizes)}),t.setHolesTotalSizes(e.holes_total_sizes.length,t=>{t.set(e.holes_total_sizes)}),t.setHolesBoundaries(e.holes_boundaries.length,t=>{t.set(e.holes_boundaries)}),t.setExpectedWindingOrders(e.expected_winding_orders.length,t=>{t.set(e.expected_winding_orders)}),t.setBatchIds(e.batch_ids.length,t=>{t.set(e.batch_ids)}),t.setBatchIndices(e.batch_indices.length,t=>{t.set(e.batch_indices)}),t}var ba;async function Q(){return ba??=(0,n.default)(),ba}async function xa(){if(!ba)return 0;let{memory:e}=await ba;return e.buffer.byteLength}async function Sa(e,t,r,i){await Q();let a=(0,n.constructPolygonBatchedFeature)(ya(e),va(t),r,i?_a(i):void 0);if(!a)return;let{result:o,transfers:s}=pa(a);return a.free(),$(o,s)}function Ca(e){let t=new se(e);return{result:t,transfers:[t.position.buffer,t.position_high?.buffer,t.position_low?.buffer,t.start?.buffer,t.start_high?.buffer,t.start_low?.buffer,t.end_high?.buffer,t.end_low?.buffer,t.start_normals?.buffer,t.forward_offset?.buffer,t.end_normal_and_texture_coordinate_normalization_x?.buffer,t.right_normal_and_texture_coordinate_normalization_y.buffer,t.batch_id?.buffer,t.batch_index?.buffer,t.indices.buffer].filter(ne)}}function wa(e){return new n.PolylineMaterial(e.show,e.castShadow,e.receiveShadow,e.color,e.clampToGround,e.tiled,e.height,e.width,e.maxWidth,e.__internal__)}function Ta(e){let t=new n.TransferablePolylineBatchedFeature(e.crs,e.length);return t.setPoints(e.points.length,t=>{t.set(e.points)}),t.setPointsSizes(e.points_sizes.length,t=>{t.set(e.points_sizes)}),t.setBatchIds(e.batch_ids.length,t=>{t.set(e.batch_ids)}),t.setBatchIndices(e.batch_indices.length,t=>{t.set(e.batch_indices)}),t}async function Ea(e,t,r){await Q();let i=(0,n.constructPolylineBatchedFeature)(Ta(e),wa(t),r);if(!i)return;let{result:a,transfers:o}=Ca(i);return i.free(),$(a,o)}function Da(e){let t=new ie(e),n=[t.vertices.buffer,t.uvs.buffer,t.indices.buffer,t.heights.buffer];return t.normals&&n.push(t.normals.buffer),t.skirt_vertices&&n.push(t.skirt_vertices.buffer),t.skirt_uvs&&n.push(t.skirt_uvs.buffer),t.skirt_indices&&n.push(t.skirt_indices.buffer),t.skirt_normals&&n.push(t.skirt_normals.buffer),t.watermask&&n.push(t.watermask.buffer),{result:t,transfers:n}}async function Oa(e,t,r,i,a,o){await Q();let s=(0,n.constructQuantizedMeshTerrainMesh)(e,Z(t),r,i,a,o),{result:c,transfers:l}=Da(s);return s.free(),$({result:c},[...l])}function ka(e){return new n.TransferableRasterDEMData(new n.ElevationDecoder(e.decoder.r_scaler,e.decoder.g_scaler,e.decoder.b_scaler,e.decoder.offset,e.decoder.max_offset,e.decoder.min_offset,e.decoder.boundary,e.decoder.epsilon))}async function Aa(e,t,r,i,a,o){await Q();let s=i+1,c=n.TransferableMartini.fromSize(s),l=(0,n.constructTerrainMesh)(e,Z(t),ka(r),c,a,o),{result:u,transfers:d}=Da(l);return l.free(),$({result:u},[...d])}async function ja(e){let t=await createImageBitmap(e);try{let e=new OffscreenCanvas(t.width,t.height).getContext(`2d`);if(e===null)throw Error(`failed to get context of canvas`);e.drawImage(t,0,0);let n=e.getImageData(0,0,t.width,t.height).data;return $(n,[n.buffer])}finally{t.close()}}async function Ma(e,t){try{let n=t.getContext(`2d`);if(n===null)throw Error(`failed to get context of canvas`);return n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height).data}finally{e.close()}}async function Na(e,t,r,i,a,o,s){await Q();let c=(0,n.parseMvtTile)(e,t,r,i,a?_a(a):void 0,o,s),l,u,d,f,p;try{l=c.f64_stream(),u=c.f32_stream(),d=c.u32_stream(),f=c.u8_stream(),p=c.meta()}finally{c.free()}return $({f64_stream:l,f32_stream:u,u32_stream:d,u8_stream:f,meta:p},[l.buffer,u.buffer,d.buffer,f.buffer])}async function Pa(e,t,r,i,a,o,s){await Q();let c=(0,n.upsampleQuantizedMeshTerrainMesh)(Z(e),Z(t),ga(r),i,a,o,s),{result:l,transfers:u}=Da(c);return c.free(),$(l,u)}async function Fa(e,t,r,i,a,o,s){await Q();let c=(0,n.upsampleTerrainMesh)(Z(e),Z(t),ka(r),ga(i),a,o,s),{result:l,transfers:u}=Da(c);return c.free(),$(l,u)}async function Ia(){await Q()}var La={constructTerrainMesh:Aa,constructQuantizedMeshTerrainMesh:Oa,upsampleTerrainMesh:Fa,upsampleQuantizedMeshTerrainMesh:Pa,getImageDataFromImageBitmap:Ma,getImageDataFromBlob:ja,constructPolygonBatchedFeature:Sa,constructPolylineBatchedFeature:Ea,parseMvtTile:Na,warmUp:Ia,getWasmMemoryUsage:xa},$=(e,t)=>new T.Transfer(e,t),Ra=!1,za=(...e)=>(Ra||=(T.worker(La),Ba(),!0),T.worker(...e));function Ba(){La.warmUp.worker?.addAbortListener(async()=>{})}var{initializeWorkerPool:Va,terminateWorkerPool:Ha,warmUpWorkerPool:Ua,worker:Wa,workerPoolStats:Ga,workerPoolHeapStats:Ka,probeWorkerPoolHeap:qa}=(()=>{let e;return{initializeWorkerPool:(t,n,r)=>{if(e)throw Error(`Worker pool has already been initialized.`);e={pool:new te(t,n.total,r),manager:n}},terminateWorkerPool:()=>{e&&=(e.pool.terminate(),void 0)},warmUpWorkerPool:()=>(p(e,`initializeWorkerPool() must be invoked first.`),e.pool.warmUp()),worker:()=>(p(e,`initializeWorkerPool() must be invoked first.`),{pool:e.pool,manager:e.manager}),workerPoolStats:()=>e?.pool.stats(),workerPoolHeapStats:()=>e?.pool.heapStats(),probeWorkerPoolHeap:()=>e?.pool.probeHeap()}})(),Ja=()=>{let{pool:e,manager:t}=Wa();return t.canIncrement()&&e.canAcceptTasks()};function Ya(e,t,n){let{pool:r,manager:i}=Wa();i.increment();try{return r.exec(e,t,n).then(e=>(i.decrement(),e)).catch(e=>{throw i.decrement(),e})}catch(e){throw i.decrement(),e}}e.canWorkerProcessImmediately=Ja,e.createConcurrencyManager=e=>{let t=0,n=()=>t!==e,r=()=>t!==0;return{total:e,actives:()=>t,idles:()=>e-t,increment:()=>{n()&&t++},decrement:()=>{r()&&t--},canIncrement:n,canDecrement:r,reset:()=>{t=0}}},e.initializeWorkerPool=Va,e.probeWorkerPoolHeap=qa,e.queueTask=Ya,e.registerTasks=za,e.terminateWorkerPool=Ha,e.transfer=$,e.warmUpWorkerPool=Ua,e.workerPoolHeapStats=Ka,e.workerPoolStats=Ga});
11
+ `,i(new D(r))}),this.processing=Object.create(null),this.tracking=Object.create(null),this.terminating=!1,this.terminated=!1,this.cleaning=!1,this.terminationHandler=null,this.lastId=0}E.prototype.methods=function(){return this.exec(`methods`)},E.prototype.exec=function(e,t,r,i){r||=n.defer();var a=++this.lastId;this.processing[a]={id:a,resolver:r,options:i};var o={message:{id:a,method:e,params:t},transfer:i&&i.transfer};this.terminated?r.reject(new D(`Worker is terminated`)):this.worker.ready?this.worker.send(o.message,o.transfer):this.requestQueue.push(o);var s=this;return r.promise.catch(function(e){if(e instanceof n.CancellationError||e instanceof n.TimeoutError)return s.tracking[a]={id:a,resolver:n.defer(),options:i,error:e},delete s.processing[a],s.tracking[a].resolver.promise=s.tracking[a].resolver.promise.catch(function(e){if(delete s.tracking[a],e instanceof ee)throw e.error;return s.terminateAndNotify(!0).then(function(){throw e},function(e){throw e})}),s.worker.send({id:a,method:l}),s.tracking[a].timeoutId=setTimeout(function(){s.tracking[a].resolver.reject(e)},s.workerTerminateTimeout),s.tracking[a].resolver.promise;throw e})},E.prototype.busy=function(){return this.cleaning||Object.keys(this.processing).length>0||Object.keys(this.tracking).length>0},E.prototype.terminate=function(e,t){var n=this;if(e){for(var r in this.processing)this.processing[r]!==void 0&&this.processing[r].resolver.reject(Error(`Worker terminated`));this.processing=Object.create(null)}for(var i of Object.values(n.tracking))clearTimeout(i.timeoutId),i.resolver.reject(Error(`Worker Terminating`));if(n.tracking=Object.create(null),typeof t==`function`&&(this.terminationHandler=t),this.busy())this.terminating=!0;else{var a=function(e){if(n.terminated=!0,n.cleaning=!1,n.worker!=null&&n.worker.removeAllListeners&&n.worker.removeAllListeners(`message`),n.worker=null,n.terminating=!1,n.terminationHandler)n.terminationHandler(e,n);else if(e)throw e};if(this.worker){if(typeof this.worker.kill==`function`){if(this.worker.killed){a(Error(`worker already killed!`));return}var o=setTimeout(function(){n.worker&&n.worker.kill()},this.workerTerminateTimeout);this.worker.once(`exit`,function(){clearTimeout(o),n.worker&&(n.worker.killed=!0),a()}),this.worker.ready?this.worker.send(c):this.requestQueue.push({message:c}),this.cleaning=!0;return}if(typeof this.worker.terminate==`function`)this.worker.terminate(),this.worker.killed=!0;else throw Error(`Failed to terminate worker`)}a()}},E.prototype.terminateAndNotify=function(e,t){var r=n.defer();return t&&r.promise.timeout(t),this.terminate(e,function(e,t){e?r.reject(e):r.resolve(t)}),r.promise};function ee(e){this.error=e,this.stack=Error().stack}var D=class extends Error{constructor(e,t){super(e||`worker terminated`),this.cause=t}};t.exports=E,t.exports._tryRequireWorkerThreads=f,t.exports._setupProcessWorker=S,t.exports._setupBrowserWorker=b,t.exports._setupWorkerThreadWorker=x,t.exports.ensureWorkerThreads=u,t.exports.TerminateError=D})),b=l(((e,t)=>{function n(){this.tasks=[]}n.prototype.push=function(e){this.tasks.push(e)},n.prototype.pop=function(){return this.tasks.shift()},n.prototype.size=function(){return this.tasks.length},n.prototype.contains=function(e){return this.tasks.includes(e)},n.prototype.clear=function(){this.tasks.length=0};function r(){this.tasks=[]}r.prototype.push=function(e){this.tasks.push(e)},r.prototype.pop=function(){return this.tasks.pop()},r.prototype.size=function(){return this.tasks.length},r.prototype.contains=function(e){return this.tasks.includes(e)},r.prototype.clear=function(){this.tasks.length=0},t.exports={FIFOQueue:n,LIFOQueue:r}})),x=l(((e,t)=>{t.exports=n;function n(){this.ports=Object.create(null),this.length=0}n.prototype.nextAvailableStartingAt=function(e){for(;this.ports[e]===!0;)e++;if(e>=65535)throw Error(`WorkerPool debug port limit reached: `+e+`>= 65535`);return this.ports[e]=!0,this.length++,e},n.prototype.releasePort=function(e){delete this.ports[e],this.length--}})),S=l(((e,t)=>{var{Promise:n}=g(),r=y(),i=h(),{FIFOQueue:a,LIFOQueue:o}=b(),s=new(x());function c(e,t){typeof e==`string`?this.script=e||null:(this.script=null,t=e),this.workers=[],this.taskQueue=this._createQueue(t&&t.queueStrategy||`fifo`),t||={},this.forkArgs=Object.freeze(t.forkArgs||[]),this.forkOpts=Object.freeze(t.forkOpts||{}),this.workerOpts=Object.freeze(t.workerOpts||{}),this.workerThreadOpts=Object.freeze(t.workerThreadOpts||{}),this.debugPortStart=t.debugPortStart||43210,this.nodeWorker=t.nodeWorker,this.workerType=t.workerType||t.nodeWorker||`auto`,this.maxQueueSize=t.maxQueueSize||1/0,this.workerTerminateTimeout=t.workerTerminateTimeout||1e3,this.onCreateWorker=t.onCreateWorker||(()=>null),this.onTerminateWorker=t.onTerminateWorker||(()=>null),this.emitStdStreams=t.emitStdStreams||!1,t&&`maxWorkers`in t?(l(t.maxWorkers),this.maxWorkers=t.maxWorkers):this.maxWorkers=Math.max((i.cpus||4)-1,1),t&&`minWorkers`in t&&(t.minWorkers===`max`?this.minWorkers=this.maxWorkers:(u(t.minWorkers),this.minWorkers=t.minWorkers,this.maxWorkers=Math.max(this.minWorkers,this.maxWorkers)),this._ensureMinWorkers()),this._boundNext=this._next.bind(this),this.workerType===`thread`&&r.ensureWorkerThreads()}c.prototype.exec=function(e,t,r){if(t&&!Array.isArray(t))throw TypeError(`Array expected as argument "params"`);if(typeof e==`string`){var i=n.defer();if(this.taskQueue.size()>=this.maxQueueSize)throw Error(`Max queue size of `+this.maxQueueSize+` reached`);var a={method:e,params:t,resolver:i,timeout:null,options:r};this.taskQueue.push(a);var o=i.promise.timeout,s=this.taskQueue;return i.promise.timeout=function(e){return s.contains(a)?(a.timeout=e,i.promise):o.call(i.promise,e)},this._next(),i.promise}if(typeof e==`function`)return this.exec(`run`,[String(e),t],r);throw TypeError(`Function or string expected as argument "method"`)},c.prototype.proxy=function(){if(arguments.length>0)throw Error(`No arguments expected`);var e=this;return this.exec(`methods`).then(function(t){var n={};return t.forEach(function(t){n[t]=function(){return e.exec(t,Array.prototype.slice.call(arguments))}}),n})},c.prototype._next=function(){if(this.taskQueue.size()>0){var e=this._getWorker();if(e){var t=this,n=this.taskQueue.pop();if(n.resolver.promise.pending){var r=e.exec(n.method,n.params,n.resolver,n.options).then(t._boundNext).catch(function(){if(e.terminated)return t._removeWorker(e)}).then(function(){t._next()});typeof n.timeout==`number`&&r.timeout(n.timeout)}else t._next()}}},c.prototype._getWorker=function(){for(var e=this.workers,t=0;t<e.length;t++){var n=e[t];if(n.busy()===!1)return n}return e.length<this.maxWorkers?(n=this._createWorkerHandler(),e.push(n),n):null},c.prototype._removeWorker=function(e){var t=this;return s.releasePort(e.debugPort),this._removeWorkerFromList(e),this._ensureMinWorkers(),new n(function(n,r){e.terminate(!1,function(i){t.onTerminateWorker({forkArgs:e.forkArgs,forkOpts:e.forkOpts,workerThreadOpts:e.workerThreadOpts,script:e.script}),i?r(i):n(e)})})},c.prototype._removeWorkerFromList=function(e){var t=this.workers.indexOf(e);t!==-1&&this.workers.splice(t,1)},c.prototype.terminate=function(e,t){for(var r=this,i=this.taskQueue;i.size()>0;){var a=i.pop();if(a)a.resolver.reject(Error(`Pool terminated`));else break}i.clear();var o=function(e){s.releasePort(e.debugPort),this._removeWorkerFromList(e)}.bind(this),c=[];return this.workers.slice().forEach(function(n){var i=n.terminateAndNotify(e,t).then(o).always(function(){r.onTerminateWorker({forkArgs:n.forkArgs,forkOpts:n.forkOpts,workerThreadOpts:n.workerThreadOpts,script:n.script})});c.push(i)}),n.all(c)},c.prototype.stats=function(){var e=this.workers.length,t=this.workers.filter(function(e){return e.busy()}).length;return{totalWorkers:e,busyWorkers:t,idleWorkers:e-t,pendingTasks:this.taskQueue.size(),activeTasks:t}},c.prototype._ensureMinWorkers=function(){if(this.minWorkers)for(var e=this.workers.length;e<this.minWorkers;e++)this.workers.push(this._createWorkerHandler())},c.prototype._createWorkerHandler=function(){let e=this.onCreateWorker({forkArgs:this.forkArgs,forkOpts:this.forkOpts,workerOpts:this.workerOpts,workerThreadOpts:this.workerThreadOpts,script:this.script})||{};return new r(e.script||this.script,{forkArgs:e.forkArgs||this.forkArgs,forkOpts:e.forkOpts||this.forkOpts,workerOpts:e.workerOpts||this.workerOpts,workerThreadOpts:e.workerThreadOpts||this.workerThreadOpts,debugPort:s.nextAvailableStartingAt(this.debugPortStart),workerType:this.workerType,workerTerminateTimeout:this.workerTerminateTimeout,emitStdStreams:this.emitStdStreams})},c.prototype._createQueue=function(e){if(typeof e==`string`)switch(e){case`fifo`:return new a;case`lifo`:return new o;default:throw Error(`Unknown queue strategy: `+e)}if(!e)throw Error(`Queue strategy cannot be null or undefined`);for(var t=[`push`,`pop`,`size`,`contains`,`clear`],n=0;n<t.length;n++){var r=t[n];if(typeof e[r]!=`function`)throw Error(`Queue strategy must implement method: `+r)}return e};function l(e){if(!d(e)||!f(e)||e<1)throw TypeError(`Option maxWorkers must be an integer number >= 1`)}function u(e){if(!d(e)||!f(e)||e<0)throw TypeError(`Option minWorkers must be an integer number >= 0`)}function d(e){return typeof e==`number`}function f(e){return Math.round(e)==e}t.exports=c})),C=l(((e,t)=>{function n(e,t){this.message=e,this.transfer=t}t.exports=n})),w=l((e=>{var t=C(),n=g().Promise,r=`__workerpool-terminate__`,i=`__workerpool-cleanup__`,a=1e3,o={exit:function(){}},s={addAbortListener:function(e){o.abortListeners.push(e)},emit:o.emit};if(typeof self<`u`&&typeof postMessage==`function`&&typeof addEventListener==`function`)o.on=function(e,t){addEventListener(e,function(e){t(e.data)})},o.send=function(e,t){t?postMessage(e,t):postMessage(e)};else if(typeof process<`u`){var c;try{c=m()}catch(e){if(!(typeof e==`object`&&e&&e.code===`MODULE_NOT_FOUND`))throw e}if(c&&c.parentPort!==null){var l=c.parentPort;o.send=l.postMessage.bind(l),o.on=l.on.bind(l),o.exit=process.exit.bind(process)}else o.on=process.on.bind(process),o.send=function(e){process.send(e)},o.on(`disconnect`,function(){process.exit(1)}),o.exit=process.exit.bind(process)}else throw Error(`Script must be executed as a worker`);function u(e){return e&&e.toJSON?JSON.parse(JSON.stringify(e)):JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e)))}function d(e){return e&&typeof e.then==`function`&&typeof e.catch==`function`}o.methods={},o.methods.run=function(e,t){var n=Function(`return (`+e+`).apply(this, arguments);`);return n.worker=s,n.apply(n,t)},o.methods.methods=function(){return Object.keys(o.methods)},o.terminationHandler=void 0,o.abortListenerTimeout=a,o.abortListeners=[],o.terminateAndExit=function(e){var t=function(){o.exit(e)};if(!o.terminationHandler)return t();var r=o.terminationHandler(e);return d(r)?(r.then(t,t),r):(t(),new n(function(e,t){t(Error(`Worker terminating`))}))},o.cleanup=function(e){if(!o.abortListeners.length)return o.send({id:e,method:i,error:u(Error(`Worker terminating`))}),new n(function(e){e()});var t=function(){o.exit()},r=function(){o.abortListeners.length&&(o.abortListeners=[])};let a=o.abortListeners.map(e=>e()),s,c=new n((e,t)=>{s=setTimeout(function(){t(Error(`Timeout occurred waiting for abort handler, killing worker`))},o.abortListenerTimeout)}),l=n.all(a).then(function(){clearTimeout(s),r()},function(){clearTimeout(s),t()});return new n(function(e,t){l.then(e,t),c.then(e,t)}).then(function(){o.send({id:e,method:i,error:null})},function(t){o.send({id:e,method:i,error:t?u(t):null})})};var f=null;o.on(`message`,function(e){if(e===r)return o.terminateAndExit(0);if(e.method===i)return o.cleanup(e.id);try{var n=o.methods[e.method];if(n){f=e.id;var a=n.apply(n,e.params);d(a)?a.then(function(n){n instanceof t?o.send({id:e.id,result:n.message,error:null},n.transfer):o.send({id:e.id,result:n,error:null}),f=null}).catch(function(t){o.send({id:e.id,result:null,error:u(t)}),f=null}):(a instanceof t?o.send({id:e.id,result:a.message,error:null},a.transfer):o.send({id:e.id,result:a,error:null}),f=null)}else throw Error(`Unknown method "`+e.method+`"`)}catch(t){o.send({id:e.id,result:null,error:u(t)})}}),o.register=function(e,t){if(e)for(var n in e)e.hasOwnProperty(n)&&(o.methods[n]=e[n],o.methods[n].worker=s);t&&(o.terminationHandler=t.onTerminate,o.abortListenerTimeout=t.abortListenerTimeout||a),o.send(`ready`)},o.emit=function(e){if(f){if(e instanceof t){o.send({id:f,isEvent:!0,payload:e.message},e.transfer);return}o.send({id:f,isEvent:!0,payload:e})}},e!==void 0&&(e.add=o.register,e.emit=o.emit)})),T=d(l((e=>{var{platform:t,isMainThread:n,cpus:r}=h(),{TerminateError:i}=y();function a(e,t){return new(S())(e,t)}e.pool=a;function o(e,t){w().add(e,t)}e.worker=o;var{Promise:s}=g();e.Transfer=C()}))(),1),E=5e3,ee=3e4,D=e=>T.pool(e,{maxWorkers:1,minWorkers:0,workerTerminateTimeout:ee,workerOpts:{type:void 0}}),te=class{url;maxWorkerHeapBytes;slots;idleSweepTimer;terminated=!1;constructor(e,t,n){p(t>0,`maxWorkers must be a positive number.`),this.url=e,this.maxWorkerHeapBytes=n?.maxWorkerHeapBytes??268435456,this.slots=Array.from({length:t},()=>({pool:D(e),tasksSinceSpawn:0,inflight:0,draining:!1,probing:!1,lastHeapBytes:void 0}))}exec(e,t,n){let r=this.pickSlot();r.inflight++;try{return r.pool.exec(e,t,n).then(e=>(this.onSettled(r),e)).catch(e=>{throw this.onSettled(r),e})}catch(e){throw this.onSettled(r),e}}warmUp(){let[e,...t]=this.slots;return this.warmSlot(e).then(()=>{for(let e of t)this.warmSlot(e).catch(()=>void 0)},e=>{if(t.length===0)throw e;return Promise.any(t.map(e=>this.warmSlot(e))).then(()=>void 0)})}canAcceptTasks(){return this.slots.some(e=>!e.draining)}stats(){let e={totalWorkers:0,busyWorkers:0,idleWorkers:0,pendingTasks:0,activeTasks:0,tasksSinceSpawn:0};for(let t of this.slots){let n=t.pool.stats();e.totalWorkers+=n.totalWorkers,e.busyWorkers+=n.busyWorkers,e.idleWorkers+=n.idleWorkers,e.pendingTasks+=n.pendingTasks,e.activeTasks+=n.activeTasks,e.tasksSinceSpawn+=t.tasksSinceSpawn}return e}heapStats(){let e=this.slots.map(e=>e.lastHeapBytes);return{perSlot:e,totalBytes:e.reduce((e,t)=>e+(t??0),0),maxWorkerHeapBytes:this.maxWorkerHeapBytes}}probeHeap(){if(!this.terminated)for(let e of this.slots)e.draining||this.probeSlot(e)}terminate(){this.idleSweepTimer!==void 0&&(clearTimeout(this.idleSweepTimer),this.idleSweepTimer=void 0),this.terminated=!0;for(let e of this.slots)e.pool.terminate()}pickSlot(){let e=this.slots.filter(e=>!e.draining);return(e.length>0?e:this.slots).reduce((e,t)=>t.inflight<e.inflight?t:e)}onSettled(e){e.inflight--,!this.terminated&&(e.tasksSinceSpawn++,e.tasksSinceSpawn>=128&&(e.draining=!0),e.draining&&e.inflight===0?this.recycleSlot(e):e.draining||this.probeSlot(e),this.armIdleSweep())}recycleSlot(e){e.pool.terminate(),e.pool=D(this.url),e.tasksSinceSpawn=0,e.draining=!1,e.lastHeapBytes=void 0,this.warmSlot(e).catch(()=>void 0)}warmSlot(e){e.inflight++;let t=()=>{e.inflight--,!this.terminated&&e.draining&&e.inflight===0&&this.recycleSlot(e)};return new Promise((n,r)=>{try{e.pool.exec(`warmUp`).then(()=>{t(),n()}).catch(e=>{t(),r(e)})}catch(e){t(),r(e)}})}probeSlot(e){if(e.probing)return;e.probing=!0,e.inflight++;let t=t=>{e.probing=!1,e.inflight--,!this.terminated&&(t&&(e.draining=!0),e.draining&&e.inflight===0&&this.recycleSlot(e))};try{e.pool.exec(`getWasmMemoryUsage`).then(n=>{typeof n==`number`&&(e.lastHeapBytes=n),t(typeof n==`number`&&n>=this.maxWorkerHeapBytes)}).catch(()=>{t(!0)})}catch{t(!0)}}armIdleSweep(){this.idleSweepTimer!==void 0&&clearTimeout(this.idleSweepTimer),this.idleSweepTimer=setTimeout(()=>{this.idleSweepTimer=void 0;for(let e of this.slots)e.tasksSinceSpawn>0&&e.inflight===0&&this.recycleSlot(e)},E)}};function ne(e){return e!=null}var re=class{x;y;z;constructor(e){this.x=e.x,this.y=e.y,this.z=e.z}},ie=class{vertices;uvs;indices;heights;max_height;min_height;rtc_translation;normals;skirt_vertices;skirt_uvs;skirt_indices;skirt_normals;watermask;constructor(e){this.vertices=e.transferVertices(),this.uvs=e.transferUvs(),this.indices=e.transferIndices(),this.heights=e.transferHeights(),this.max_height=e.max_height,this.min_height=e.min_height,this.rtc_translation=e.rtc_translation?new re(e.rtc_translation):void 0,e.hasNormals()&&(this.normals=e.transferNormals()),e.hasSkirt()&&(this.skirt_vertices=e.transferSkirtVertices(),this.skirt_uvs=e.transferSkirtUvs(),this.skirt_indices=e.transferSkirtIndices(),this.skirt_normals=e.transferSkirtNormals()),e.hasWatermask()&&(this.watermask=e.transferWatermask())}transferVertices(){throw Error()}transferUvs(){throw Error()}transferIndices(){throw Error()}transferHeights(){throw Error()}transferNormals(){throw Error()}transferSkirtVertices(){throw Error()}transferSkirtUvs(){throw Error()}transferSkirtIndices(){throw Error()}transferSkirtNormals(){throw Error()}transferWatermask(){throw Error()}hasSkirt(){return this.skirt_vertices!==void 0&&this.skirt_uvs!==void 0&&this.skirt_indices!==void 0}hasNormals(){return this.normals!==void 0}hasWatermask(){return this.watermask!==void 0}},ae=class{east;north;south;west;constructor(e){this.east=e.east,this.north=e.north,this.south=e.south,this.west=e.west}},oe=class{extent;position_3d_high;position_3d_high_size;position_3d_low;position_3d_low_size;position;position_size;normal;normal_size;scale_normal_and_cap;scale_normal_and_cap_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;rtc_translation;outline_position;outline_position_size;outline_position_3d_high;outline_position_3d_high_size;outline_position_3d_low;outline_position_3d_low_size;outline_scale_normal_and_cap;outline_scale_normal_and_cap_size;outline_skip_indices;outline_batch_index;outline_batch_index_size;constructor(e){let t=e.extent;this.extent=t?new ae(t):void 0,this.position_3d_high=e.position_3d_high()?.slice(),this.position_3d_high_size=e.position_3d_high_size(),this.position_3d_low=e.position_3d_low()?.slice(),this.position_3d_low_size=e.position_3d_low_size(),this.position=e.position()?.slice(),this.position_size=e.position_size(),this.normal=e.normal()?.slice(),this.normal_size=e.normal_size(),this.scale_normal_and_cap=e.scale_normal_and_cap()?.slice(),this.scale_normal_and_cap_size=e.scale_normal_and_cap_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice(),this.rtc_translation=e.rtc_translation?new re(e.rtc_translation):void 0;let n=e.outline();n&&(this.outline_position=n.position()?.slice(),this.outline_position_size=n.position_size(),this.outline_position_3d_high=n.position_3d_high()?.slice(),this.outline_position_3d_high_size=n.position_3d_high_size(),this.outline_position_3d_low=n.position_3d_low()?.slice(),this.outline_position_3d_low_size=n.position_3d_low_size(),this.outline_scale_normal_and_cap=n.scale_normal_and_cap()?.slice(),this.outline_scale_normal_and_cap_size=n.scale_normal_and_cap_size(),this.outline_skip_indices=n.skip_indices()?.slice(),this.outline_batch_index=n.batch_index()?.slice(),this.outline_batch_index_size=n.batch_index_size(),n.free())}},se=class{extent;position;position_size;position_high;position_high_size;position_low;position_low_size;start;start_size;start_high;start_high_size;start_low;start_low_size;forward_offset;forward_offset_size;end_high;end_high_size;end_low;end_low_size;start_normals;start_normals_size;end_normal_and_texture_coordinate_normalization_x;end_normal_and_texture_coordinate_normalization_x_size;right_normal_and_texture_coordinate_normalization_y;right_normal_and_texture_coordinate_normalization_y_size;batch_id;batch_id_size;batch_index;batch_index_size;indices;constructor(e){let t=e.extent;this.extent=t?new ae(t):void 0,this.position=e.position().slice(),this.position_size=e.position_size(),this.position_high=e.position_high()?.slice(),this.position_high_size=e.position_high_size(),this.position_low=e.position_low()?.slice(),this.position_low_size=e.position_low_size(),this.start=e.start()?.slice(),this.start_size=e.start_size(),this.start_high=e.start_high()?.slice(),this.start_high_size=e.start_high_size(),this.start_low=e.start_low()?.slice(),this.start_low_size=e.start_low_size(),this.forward_offset=e.forward_offset()?.slice(),this.forward_offset_size=e.forward_offset_size(),this.end_high=e.end_high()?.slice(),this.end_high_size=e.end_high_size(),this.end_low=e.end_low()?.slice(),this.end_low_size=e.end_low_size(),this.start_normals=e.start_normals()?.slice(),this.start_normals_size=e.start_normals_size(),this.end_normal_and_texture_coordinate_normalization_x=e.end_normal_and_texture_coordinate_normalization_x()?.slice(),this.end_normal_and_texture_coordinate_normalization_x_size=e.end_normal_and_texture_coordinate_normalization_x_size(),this.right_normal_and_texture_coordinate_normalization_y=e.right_normal_and_texture_coordinate_normalization_y().slice(),this.right_normal_and_texture_coordinate_normalization_y_size=e.right_normal_and_texture_coordinate_normalization_y_size(),this.batch_id=e.batch_id()?.slice(),this.batch_id_size=e.batch_id_size(),this.batch_index=e.batch_index()?.slice(),this.batch_index_size=e.batch_index_size(),this.indices=e.indices().slice()}};function ce(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function le(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ue(e){let t,n,r;e.length===2?(t=e===ce||e===le?e:de,n=e,r=e):(t=ce,n=(t,n)=>ce(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function de(){return 0}function fe(e){return e===null?NaN:+e}var pe=ue(ce);pe.right,pe.left,ue(fe).center;var me={value:()=>{}};function he(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new ge(n)}function ge(e){this._=e}function _e(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}ge.prototype=he.prototype={constructor:ge,on:function(e,t){var n=this._,r=_e(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=ve(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=ye(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ye(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ge(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function ve(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function ye(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=me,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var be={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function xe(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),be.hasOwnProperty(t)?{space:be[t],local:e}:e}function Se(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Ce(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function we(e){var t=xe(e);return(t.local?Ce:Se)(t)}function Te(){}function Ee(e){return e==null?Te:function(){return this.querySelector(e)}}function De(e){typeof e!=`function`&&(e=Ee(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new k(r,this._parents)}function Oe(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ke(){return[]}function Ae(e){return e==null?ke:function(){return this.querySelectorAll(e)}}function je(e){return function(){return Oe(e.apply(this,arguments))}}function Me(e){e=typeof e==`function`?je(e):Ae(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new k(r,i)}function Ne(e){return function(){return this.matches(e)}}function Pe(e){return function(t){return t.matches(e)}}var Fe=Array.prototype.find;function Ie(e){return function(){return Fe.call(this.children,e)}}function Le(){return this.firstElementChild}function Re(e){return this.select(e==null?Le:Ie(typeof e==`function`?e:Pe(e)))}var ze=Array.prototype.filter;function Be(){return Array.from(this.children)}function Ve(e){return function(){return ze.call(this.children,e)}}function He(e){return this.selectAll(e==null?Be:Ve(typeof e==`function`?e:Pe(e)))}function Ue(e){typeof e!=`function`&&(e=Ne(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new k(r,this._parents)}function We(e){return Array(e.length)}function Ge(){return new k(this._enter||this._groups.map(We),this._parents)}function Ke(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ke.prototype={constructor:Ke,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function qe(e){return function(){return e}}function Je(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Ke(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Ye(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Ke(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Xe(e){return e.__data__}function Ze(e,t){if(!arguments.length)return Array.from(this,Xe);var n=t?Ye:Je,r=this._parents,i=this._groups;typeof e!=`function`&&(e=qe(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=Qe(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new k(o,r),o._enter=s,o._exit=c,o}function Qe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function $e(){return new k(this._exit||this._groups.map(We),this._parents)}function et(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function tt(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new k(s,this._parents)}function nt(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function rt(e){e||=it;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new k(i,this._parents).order()}function it(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function at(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ot(){return Array.from(this)}function st(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function ct(){let e=0;for(let t of this)++e;return e}function lt(){return!this.node()}function ut(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function dt(e){return function(){this.removeAttribute(e)}}function ft(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pt(e,t){return function(){this.setAttribute(e,t)}}function mt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ht(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function gt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function _t(e,t){var n=xe(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?ft:dt:typeof t==`function`?n.local?gt:ht:n.local?mt:pt)(n,t))}function vt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function yt(e){return function(){this.style.removeProperty(e)}}function bt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xt(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function St(e,t,n){return arguments.length>1?this.each((t==null?yt:typeof t==`function`?xt:bt)(e,t,n??``)):O(this.node(),e)}function O(e,t){return e.style.getPropertyValue(t)||vt(e).getComputedStyle(e,null).getPropertyValue(t)}function Ct(e){return function(){delete this[e]}}function wt(e,t){return function(){this[e]=t}}function Tt(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Et(e,t){return arguments.length>1?this.each((t==null?Ct:typeof t==`function`?Tt:wt)(e,t)):this.node()[e]}function Dt(e){return e.trim().split(/^|\s+/)}function Ot(e){return e.classList||new kt(e)}function kt(e){this._node=e,this._names=Dt(e.getAttribute(`class`)||``)}kt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function At(e,t){for(var n=Ot(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function jt(e,t){for(var n=Ot(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Mt(e){return function(){At(this,e)}}function Nt(e){return function(){jt(this,e)}}function Pt(e,t){return function(){(t.apply(this,arguments)?At:jt)(this,e)}}function Ft(e,t){var n=Dt(e+``);if(arguments.length<2){for(var r=Ot(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?Pt:t?Mt:Nt)(n,t))}function It(){this.textContent=``}function Lt(e){return function(){this.textContent=e}}function Rt(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function zt(e){return arguments.length?this.each(e==null?It:(typeof e==`function`?Rt:Lt)(e)):this.node().textContent}function Bt(){this.innerHTML=``}function Vt(e){return function(){this.innerHTML=e}}function Ht(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function Ut(e){return arguments.length?this.each(e==null?Bt:(typeof e==`function`?Ht:Vt)(e)):this.node().innerHTML}function Wt(){this.nextSibling&&this.parentNode.appendChild(this)}function Gt(){return this.each(Wt)}function Kt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qt(){return this.each(Kt)}function Jt(e){var t=typeof e==`function`?e:we(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Yt(){return null}function Xt(e,t){var n=typeof e==`function`?e:we(e),r=t==null?Yt:typeof t==`function`?t:Ee(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Zt(){var e=this.parentNode;e&&e.removeChild(this)}function Qt(){return this.each(Zt)}function $t(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function en(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tn(e){return this.select(e?en:$t)}function nn(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function rn(e){return function(t){e.call(this,t,this.__data__)}}function an(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function on(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function sn(e,t,n){return function(){var r=this.__on,i,a=rn(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function cn(e,t,n){var r=an(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?sn:on,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function ln(e,t,n){var r=vt(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function un(e,t){return function(){return ln(this,e,t)}}function dn(e,t){return function(){return ln(this,e,t.apply(this,arguments))}}function fn(e,t){return this.each((typeof t==`function`?dn:un)(e,t))}function*pn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var mn=[null];function k(e,t){this._groups=e,this._parents=t}function A(){return new k([[document.documentElement]],mn)}function hn(){return this}k.prototype=A.prototype={constructor:k,select:De,selectAll:Me,selectChild:Re,selectChildren:He,filter:Ue,data:Ze,enter:Ge,exit:$e,join:et,merge:tt,selection:hn,order:nt,sort:rt,call:at,nodes:ot,node:st,size:ct,empty:lt,each:ut,attr:_t,style:St,property:Et,classed:Ft,text:zt,html:Ut,raise:Gt,lower:qt,append:Jt,insert:Xt,remove:Qt,clone:tn,datum:nn,on:cn,dispatch:fn,[Symbol.iterator]:pn};function gn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _n(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function j(){}var M=.7,vn=1/M,N=`\\s*([+-]?\\d+)\\s*`,P=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,F=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,yn=/^#([0-9a-f]{3,8})$/,bn=RegExp(`^rgb\\(${N},${N},${N}\\)$`),xn=RegExp(`^rgb\\(${F},${F},${F}\\)$`),Sn=RegExp(`^rgba\\(${N},${N},${N},${P}\\)$`),Cn=RegExp(`^rgba\\(${F},${F},${F},${P}\\)$`),wn=RegExp(`^hsl\\(${P},${F},${F}\\)$`),Tn=RegExp(`^hsla\\(${P},${F},${F},${P}\\)$`),En={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,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,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,slategray:7372944,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};gn(j,I,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Dn,formatHex:Dn,formatHex8:On,formatHsl:kn,formatRgb:An,toString:An});function Dn(){return this.rgb().formatHex()}function On(){return this.rgb().formatHex8()}function kn(){return Bn(this).formatHsl()}function An(){return this.rgb().formatRgb()}function I(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=yn.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jn(t):n===3?new L(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=bn.exec(e))?new L(t[1],t[2],t[3],1):(t=xn.exec(e))?new L(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Sn.exec(e))?Mn(t[1],t[2],t[3],t[4]):(t=Cn.exec(e))?Mn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=wn.exec(e))?zn(t[1],t[2]/100,t[3]/100,1):(t=Tn.exec(e))?zn(t[1],t[2]/100,t[3]/100,t[4]):En.hasOwnProperty(e)?jn(En[e]):e===`transparent`?new L(NaN,NaN,NaN,0):null}function jn(e){return new L(e>>16&255,e>>8&255,e&255,1)}function Mn(e,t,n,r){return r<=0&&(e=t=n=NaN),new L(e,t,n,r)}function Nn(e){return e instanceof j||(e=I(e)),e?(e=e.rgb(),new L(e.r,e.g,e.b,e.opacity)):new L}function Pn(e,t,n,r){return arguments.length===1?Nn(e):new L(e,t,n,r??1)}function L(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gn(L,Pn,_n(j,{brighter(e){return e=e==null?vn:vn**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?M:M**+e,new L(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new L(R(this.r),R(this.g),R(this.b),Rn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Fn,formatHex:Fn,formatHex8:In,formatRgb:Ln,toString:Ln}));function Fn(){return`#${z(this.r)}${z(this.g)}${z(this.b)}`}function In(){return`#${z(this.r)}${z(this.g)}${z(this.b)}${z((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ln(){let e=Rn(this.opacity);return`${e===1?`rgb(`:`rgba(`}${R(this.r)}, ${R(this.g)}, ${R(this.b)}${e===1?`)`:`, ${e})`}`}function Rn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function R(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function z(e){return e=R(e),(e<16?`0`:``)+e.toString(16)}function zn(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new B(e,t,n,r)}function Bn(e){if(e instanceof B)return new B(e.h,e.s,e.l,e.opacity);if(e instanceof j||(e=I(e)),!e)return new B;if(e instanceof B)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new B(o,s,c,e.opacity)}function Vn(e,t,n,r){return arguments.length===1?Bn(e):new B(e,t,n,r??1)}function B(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gn(B,Vn,_n(j,{brighter(e){return e=e==null?vn:vn**+e,new B(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?M:M**+e,new B(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new L(Wn(e>=240?e-240:e+120,i,r),Wn(e,i,r),Wn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new B(Hn(this.h),Un(this.s),Un(this.l),Rn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Rn(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Hn(this.h)}, ${Un(this.s)*100}%, ${Un(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Hn(e){return e=(e||0)%360,e<0?e+360:e}function Un(e){return Math.max(0,Math.min(1,e||0))}function Wn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Gn=e=>()=>e;function Kn(e,t){return function(n){return e+n*t}}function qn(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Jn(e){return(e=+e)==1?Yn:function(t,n){return n-t?qn(t,n,e):Gn(isNaN(t)?n:t)}}function Yn(e,t){var n=t-e;return n?Kn(e,n):Gn(isNaN(e)?t:e)}var Xn=(function e(t){var n=Jn(t);function r(e,t){var r=n((e=Pn(e)).r,(t=Pn(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Yn(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function V(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Zn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qn=new RegExp(Zn.source,`g`);function $n(e){return function(){return e}}function er(e){return function(t){return e(t)+``}}function tr(e,t){var n=Zn.lastIndex=Qn.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=Zn.exec(e))&&(i=Qn.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:V(r,i)})),n=Qn.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?er(c[0].x):$n(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}var nr=180/Math.PI,rr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ir(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*nr,skewX:Math.atan(c)*nr,scaleX:o,scaleY:s}}var ar;function or(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?rr:ir(t.a,t.b,t.c,t.d,t.e,t.f)}function sr(e){return e==null||(ar||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),ar.setAttribute(`transform`,e),!(e=ar.transform.baseVal.consolidate()))?rr:(e=e.matrix,ir(e.a,e.b,e.c,e.d,e.e,e.f))}function cr(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:V(e,i)},{i:c-2,x:V(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:V(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:V(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:V(e,n)},{i:s-2,x:V(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var lr=cr(or,`px, `,`px)`,`deg)`),ur=cr(sr,`, `,`)`,`)`),H=0,dr=0,fr=0,pr=1e3,mr,U,hr=0,W=0,gr=0,G=typeof performance==`object`&&performance.now?performance:Date,_r=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function vr(){return W||=(_r(yr),G.now()+gr)}function yr(){W=0}function br(){this._call=this._time=this._next=null}br.prototype=xr.prototype={constructor:br,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?vr():+n)+(t==null?0:+t),!this._next&&U!==this&&(U?U._next=this:mr=this,U=this),this._call=e,this._time=n,Er()},stop:function(){this._call&&(this._call=null,this._time=1/0,Er())}};function xr(e,t,n){var r=new br;return r.restart(e,t,n),r}function Sr(){vr(),++H;for(var e=mr,t;e;)(t=W-e._time)>=0&&e._call.call(void 0,t),e=e._next;--H}function Cr(){W=(hr=G.now())+gr,H=dr=0;try{Sr()}finally{H=0,Tr(),W=0}}function wr(){var e=G.now(),t=e-hr;t>pr&&(gr-=t,hr=e)}function Tr(){for(var e,t=mr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:mr=n);U=e,Er(r)}function Er(e){H||(dr&&=clearTimeout(dr),e-W>24?(e<1/0&&(dr=setTimeout(Cr,e-G.now()-gr)),fr&&=clearInterval(fr)):(fr||=(hr=G.now(),setInterval(wr,pr)),H=1,_r(Cr)))}function Dr(e,t,n){var r=new br;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Or=he(`start`,`end`,`cancel`,`interrupt`),kr=[];function Ar(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Mr(e,n,{name:t,index:r,group:i,on:Or,tween:kr,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function jr(e,t){var n=q(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function K(e,t){var n=q(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function q(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Mr(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=xr(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Dr(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Dr(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function Nr(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Pr(e){return this.each(function(){Nr(this,e)})}function Fr(e,t){var n,r;return function(){var i=K(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Ir(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=K(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function Lr(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=q(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Fr:Ir)(n,e,t))}function Rr(e,t,n){var r=e._id;return e.each(function(){var e=K(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return q(e,r).value[t]}}function zr(e,t){var n;return(typeof t==`number`?V:t instanceof I?Xn:(n=I(t))?(t=n,Xn):tr)(e,t)}function Br(e){return function(){this.removeAttribute(e)}}function Vr(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hr(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Ur(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function Wr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Gr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Kr(e,t){var n=xe(e),r=n===`transform`?ur:zr;return this.attrTween(e,typeof t==`function`?(n.local?Gr:Wr)(n,r,Rr(this,`attr.`+e,t)):t==null?(n.local?Vr:Br)(n):(n.local?Ur:Hr)(n,r,t))}function qr(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Jr(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Yr(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Jr(e,i)),n}return i._value=t,i}function Xr(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&qr(e,i)),n}return i._value=t,i}function Zr(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=xe(e);return this.tween(n,(r.local?Yr:Xr)(r,t))}function Qr(e,t){return function(){jr(this,e).delay=+t.apply(this,arguments)}}function $r(e,t){return t=+t,function(){jr(this,e).delay=t}}function ei(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Qr:$r)(t,e)):q(this.node(),t).delay}function ti(e,t){return function(){K(this,e).duration=+t.apply(this,arguments)}}function ni(e,t){return t=+t,function(){K(this,e).duration=t}}function ri(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?ti:ni)(t,e)):q(this.node(),t).duration}function ii(e,t){if(typeof t!=`function`)throw Error();return function(){K(this,e).ease=t}}function ai(e){var t=this._id;return arguments.length?this.each(ii(t,e)):q(this.node(),t).ease}function oi(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();K(this,e).ease=n}}function si(e){if(typeof e!=`function`)throw Error();return this.each(oi(this._id,e))}function ci(e){typeof e!=`function`&&(e=Ne(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new J(r,this._parents,this._name,this._id)}function li(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new J(o,this._parents,this._name,this._id)}function ui(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function di(e,t,n){var r,i,a=ui(t)?jr:K;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function fi(e,t){var n=this._id;return arguments.length<2?q(this.node(),n).on.on(e):this.each(di(n,e,t))}function pi(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function mi(){return this.on(`end.remove`,pi(this._id))}function hi(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ee(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Ar(l[f],t,n,f,l,q(u,n)));return new J(a,this._parents,t,n)}function gi(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ae(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=q(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Ar(p,t,n,h,f,m);a.push(f),o.push(u)}return new J(a,o,t,n)}var _i=A.prototype.constructor;function vi(){return new _i(this._groups,this._parents)}function yi(e,t){var n,r,i;return function(){var a=O(this,e),o=(this.style.removeProperty(e),O(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function bi(e){return function(){this.style.removeProperty(e)}}function xi(e,t,n){var r,i=n+``,a;return function(){var o=O(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Si(e,t,n){var r,i,a;return function(){var o=O(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),O(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Ci(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=K(this,e),l=c.on,u=c.value[a]==null?s||=bi(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function wi(e,t,n){var r=(e+=``)==`transform`?lr:zr;return t==null?this.styleTween(e,yi(e,r)).on(`end.style.`+e,bi(e)):typeof t==`function`?this.styleTween(e,Si(e,r,Rr(this,`style.`+e,t))).each(Ci(this._id,e)):this.styleTween(e,xi(e,r,t),n).on(`end.style.`+e,null)}function Ti(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Ei(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Ti(e,a,n)),r}return a._value=t,a}function Di(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Ei(e,t,n??``))}function Oi(e){return function(){this.textContent=e}}function ki(e){return function(){var t=e(this);this.textContent=t??``}}function Ai(e){return this.tween(`text`,typeof e==`function`?ki(Rr(this,`text`,e)):Oi(e==null?``:e+``))}function ji(e){return function(t){this.textContent=e.call(this,t)}}function Mi(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ji(r)),t}return r._value=e,r}function Ni(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Mi(e))}function Pi(){for(var e=this._name,t=this._id,n=Li(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=q(c,t);Ar(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new J(r,this._parents,e,n)}function Fi(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=K(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Ii=0;function J(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Li(){return++Ii}var Y=A.prototype;J.prototype={constructor:J,select:hi,selectAll:gi,selectChild:Y.selectChild,selectChildren:Y.selectChildren,filter:ci,merge:li,selection:vi,transition:Pi,call:Y.call,nodes:Y.nodes,node:Y.node,size:Y.size,empty:Y.empty,each:Y.each,on:fi,attr:Kr,attrTween:Zr,style:wi,styleTween:Di,text:Ai,textTween:Ni,remove:mi,tween:Lr,delay:ei,duration:ri,ease:ai,easeVarying:si,end:Fi,[Symbol.iterator]:Y[Symbol.iterator]};function Ri(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zi={time:null,delay:0,duration:250,ease:Ri};function Bi(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function Vi(e){var t,n;e instanceof J?(t=e._id,e=e._name):(t=Li(),(n=zi).time=vr(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Ar(c,e,t,l,o,n||Bi(c,t));return new J(r,this._parents,e,t)}A.prototype.interrupt=Pr,A.prototype.transition=Vi;var{abs:Hi,max:Ui,min:Wi}=Math;[`w`,`e`].map(Gi),[`n`,`s`].map(Gi),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(Gi);function Gi(e){return{type:e}}function Ki(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function qi(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Ji(e){return e=qi(Math.abs(e)),e?e[1]:NaN}function Yi(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function Xi(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var Zi=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Qi(e){if(!(t=Zi.exec(e)))throw Error(`invalid format: `+e);var t;return new $i({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Qi.prototype=$i.prototype;function $i(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}$i.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function ea(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var ta;function na(e,t){var n=qi(e,t);if(!n)return ta=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(ta=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+qi(e,Math.max(0,t+a-1))[0]}function ra(e,t){var n=qi(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var ia={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Ki,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ra(e*100,t),r:ra,s:na,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function aa(e){return e}var oa=Array.prototype.map,sa=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function ca(e){var t=e.grouping===void 0||e.thousands===void 0?aa:Yi(oa.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?aa:Xi(oa.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=Qi(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):ia[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=ia[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=ea(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&ta!==void 0?sa[8+ta/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(Ji(t)/3)))*3,r=10**-n,i=l((e=Qi(e),e.type=`f`,e),{suffix:sa[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var la;ua({thousands:`,`,grouping:[3],currency:[`$`,``]});function ua(e){return la=ca(e),la.format,la.formatPrefix,la}function X(e,t,n){this.k=e,this.x=t,this.y=n}X.prototype={constructor:X,scale:function(e){return e===1?this:new X(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new X(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var da=new X(1,0,0);fa.prototype=X.prototype;function fa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return da;return e.__zoom}function pa(e){let t=new oe(e);return{result:t,transfers:[t.batch_id?.buffer,t.batch_index?.buffer,t.normal?.buffer,t.position_3d_high?.buffer,t.position_3d_low?.buffer,t.position?.buffer,t.scale_normal_and_cap?.buffer,t.indices.buffer,t.outline_position?.buffer,t.outline_position_3d_high?.buffer,t.outline_position_3d_low?.buffer,t.outline_scale_normal_and_cap?.buffer,t.outline_skip_indices?.buffer,t.outline_batch_index?.buffer].filter(ne)}}function Z(e){return new n.TransferableTile(ma(e.coords),e.max_height,e.min_height,e.cached_mesh_handle?ha(e.cached_mesh_handle):void 0)}function ma(e){return new n.TileXYZ(e.x,e.y,e.z)}function ha(e){return new n.CachedMeshHandle(e.vertices,e.indices,e.uvs,e.heights)}function ga(e){return new n.UpsamplableTerrainGeometry(e.uvs,e.indices,e.heights,e.normals,e.watermask)}function _a(e){return new n.ExtentRadianF32(e.west,e.south,e.east,e.north)}function va(e){return new n.PolygonMaterial(e.show,e.castShadow,e.receiveShadow,e.color,e.clampToGround,e.tiled,e.height,e.extrudedHeight,e.wireframe,e.outline,e.perPositionHeight,e.__internal__)}function ya(e){let t=new n.TransferablePolygonBatchedFeature(e.crs,e.length);return t.setOuterRing(e.outer_ring.length,t=>{t.set(e.outer_ring)}),t.setOuterRingSizes(e.outer_ring_sizes.length,t=>{t.set(e.outer_ring_sizes)}),t.setHoles(e.holes.length,t=>{t.set(e.holes)}),t.setHolesSizes(e.holes_sizes.length,t=>{t.set(e.holes_sizes)}),t.setHolesTotalSizes(e.holes_total_sizes.length,t=>{t.set(e.holes_total_sizes)}),t.setHolesBoundaries(e.holes_boundaries.length,t=>{t.set(e.holes_boundaries)}),t.setExpectedWindingOrders(e.expected_winding_orders.length,t=>{t.set(e.expected_winding_orders)}),t.setBatchIds(e.batch_ids.length,t=>{t.set(e.batch_ids)}),t.setBatchIndices(e.batch_indices.length,t=>{t.set(e.batch_indices)}),t}var ba;async function Q(){return ba??=(0,n.default)(),ba}var xa=[];function Sa(e){xa.push(e)}async function Ca(){let e=ba?(await ba).memory.buffer.byteLength:0;for(let t of xa)e+=t();return e}async function wa(e,t,r,i){await Q();let a=(0,n.constructPolygonBatchedFeature)(ya(e),va(t),r,i?_a(i):void 0);if(!a)return;let{result:o,transfers:s}=pa(a);return a.free(),$(o,s)}function Ta(e){let t=new se(e);return{result:t,transfers:[t.position.buffer,t.position_high?.buffer,t.position_low?.buffer,t.start?.buffer,t.start_high?.buffer,t.start_low?.buffer,t.end_high?.buffer,t.end_low?.buffer,t.start_normals?.buffer,t.forward_offset?.buffer,t.end_normal_and_texture_coordinate_normalization_x?.buffer,t.right_normal_and_texture_coordinate_normalization_y.buffer,t.batch_id?.buffer,t.batch_index?.buffer,t.indices.buffer].filter(ne)}}function Ea(e){return new n.PolylineMaterial(e.show,e.castShadow,e.receiveShadow,e.color,e.clampToGround,e.tiled,e.height,e.width,e.maxWidth,e.__internal__)}function Da(e){let t=new n.TransferablePolylineBatchedFeature(e.crs,e.length);return t.setPoints(e.points.length,t=>{t.set(e.points)}),t.setPointsSizes(e.points_sizes.length,t=>{t.set(e.points_sizes)}),t.setBatchIds(e.batch_ids.length,t=>{t.set(e.batch_ids)}),t.setBatchIndices(e.batch_indices.length,t=>{t.set(e.batch_indices)}),t.setRingFlags(e.ring_flags.length,t=>{t.set(e.ring_flags)}),t}async function Oa(e,t,r){await Q();let i=(0,n.constructPolylineBatchedFeature)(Da(e),Ea(t),r);if(!i)return;let{result:a,transfers:o}=Ta(i);return i.free(),$(a,o)}function ka(e){let t=new ie(e),n=[t.vertices.buffer,t.uvs.buffer,t.indices.buffer,t.heights.buffer];return t.normals&&n.push(t.normals.buffer),t.skirt_vertices&&n.push(t.skirt_vertices.buffer),t.skirt_uvs&&n.push(t.skirt_uvs.buffer),t.skirt_indices&&n.push(t.skirt_indices.buffer),t.skirt_normals&&n.push(t.skirt_normals.buffer),t.watermask&&n.push(t.watermask.buffer),{result:t,transfers:n}}async function Aa(e,t,r,i,a,o,s,c){await Q();let l=(0,n.constructQuantizedMeshTerrainMesh)(e,Z(t),r,i,a,o,s,c),{result:u,transfers:d}=ka(l);return l.free(),$({result:u},[...d])}function ja(e){return new n.TransferableRasterDEMData(new n.ElevationDecoder(e.decoder.r_scaler,e.decoder.g_scaler,e.decoder.b_scaler,e.decoder.offset,e.decoder.max_offset,e.decoder.min_offset,e.decoder.boundary,e.decoder.epsilon))}async function Ma(e,t,r,i,a,o,s,c){await Q();let l=(0,n.constructTerrainMesh)(e,Z(t),ja(r),i+1,a,o,s,c),{result:u,transfers:d}=ka(l);return l.free(),$({result:u},[...d])}async function Na(e){let t=await createImageBitmap(e);try{let e=new OffscreenCanvas(t.width,t.height).getContext(`2d`);if(e===null)throw Error(`failed to get context of canvas`);e.drawImage(t,0,0);let n=e.getImageData(0,0,t.width,t.height).data;return $(n,[n.buffer])}finally{t.close()}}async function Pa(e,t){try{let n=t.getContext(`2d`);if(n===null)throw Error(`failed to get context of canvas`);return n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height).data}finally{e.close()}}async function Fa(e,t,r,i,a,o,s){await Q();let c=(0,n.parseMvtTile)(e,t,r,i,a?_a(a):void 0,o,s),l,u,d,f,p;try{l=c.f64_stream(),u=c.f32_stream(),d=c.u32_stream(),f=c.u8_stream(),p=c.meta()}finally{c.free()}return $({f64_stream:l,f32_stream:u,u32_stream:d,u8_stream:f,meta:p},[l.buffer,u.buffer,d.buffer,f.buffer])}async function Ia(e,t,r,i,a,o,s,c,l){await Q();let u=(0,n.upsampleQuantizedMeshTerrainMesh)(Z(e),Z(t),ga(r),i,a,o,s,c,l),{result:d,transfers:f}=ka(u);return u.free(),$(d,f)}async function La(e,t,r,i,a,o,s,c,l,u){await Q();let d=(0,n.upsampleTerrainMesh)(Z(e),Z(t),ja(r),i,a+1,o,s,c,l,u),{result:f,transfers:p}=ka(d);return d.free(),$(f,p)}async function Ra(){await Q()}var za={constructTerrainMesh:Ma,constructQuantizedMeshTerrainMesh:Aa,upsampleTerrainMesh:La,upsampleQuantizedMeshTerrainMesh:Ia,getImageDataFromImageBitmap:Pa,getImageDataFromBlob:Na,constructPolygonBatchedFeature:wa,constructPolylineBatchedFeature:Oa,parseMvtTile:Fa,warmUp:Ra,getWasmMemoryUsage:Ca},$=(e,t)=>new T.Transfer(e,t),Ba=!1,Va=(...e)=>(Ba||=(T.worker(za),Ha(),!0),T.worker(...e));function Ha(){za.warmUp.worker?.addAbortListener(async()=>{})}var{initializeWorkerPool:Ua,terminateWorkerPool:Wa,warmUpWorkerPool:Ga,worker:Ka,workerPoolStats:qa,workerPoolHeapStats:Ja,probeWorkerPoolHeap:Ya}=(()=>{let e;return{initializeWorkerPool:(t,n,r)=>{if(e)throw Error(`Worker pool has already been initialized.`);e={pool:new te(t,n.total,r),manager:n}},terminateWorkerPool:()=>{e&&=(e.pool.terminate(),void 0)},warmUpWorkerPool:()=>(p(e,`initializeWorkerPool() must be invoked first.`),e.pool.warmUp()),worker:()=>(p(e,`initializeWorkerPool() must be invoked first.`),{pool:e.pool,manager:e.manager}),workerPoolStats:()=>e?.pool.stats(),workerPoolHeapStats:()=>e?.pool.heapStats(),probeWorkerPoolHeap:()=>e?.pool.probeHeap()}})(),Xa=()=>{let{pool:e,manager:t}=Ka();return t.canIncrement()&&e.canAcceptTasks()};function Za(e,t,n){let{pool:r,manager:i}=Ka();i.increment();try{return r.exec(e,t,n).then(e=>(i.decrement(),e)).catch(e=>{throw i.decrement(),e})}catch(e){throw i.decrement(),e}}e.canWorkerProcessImmediately=Xa,e.createConcurrencyManager=e=>{let t=0,n=()=>t!==e,r=()=>t!==0;return{total:e,actives:()=>t,idles:()=>e-t,increment:()=>{n()&&t++},decrement:()=>{r()&&t--},canIncrement:n,canDecrement:r,reset:()=>{t=0}}},e.initializeWorkerPool=Ua,e.probeWorkerPoolHeap=Ya,e.queueTask=Za,e.registerTasks=Va,e.registerWasmMemoryProbe=Sa,e.terminateWorkerPool=Wa,e.transfer=$,e.warmUpWorkerPool=Ga,e.workerPoolHeapStats=Ja,e.workerPoolStats=qa});
@@ -1,4 +1,4 @@
1
1
  import { ReturnedConstructedTerrainMeshLike, TransferableTileLike } from '@navaramap/core';
2
- export declare function constructQuantizedMeshTerrainMesh(bytes: Uint8Array, tile: TransferableTileLike, skirt: boolean, skirtExaggeration: number, geographic: boolean, tms: boolean): Promise<{
2
+ export declare function constructQuantizedMeshTerrainMesh(bytes: Uint8Array, tile: TransferableTileLike, skirt: boolean, skirtExaggeration: number, poleNorth: boolean, poleSouth: boolean, geographic: boolean, tms: boolean): Promise<{
3
3
  result: ReturnedConstructedTerrainMeshLike;
4
4
  }>;
@@ -1,4 +1,4 @@
1
1
  import { TransferableTileLike, TransferableRasterDEMDataLike, ReturnedConstructedTerrainMeshLike } from '@navaramap/core';
2
- export declare function constructTerrainMesh(bytes: Uint8Array, tile: TransferableTileLike, rasterDEMData: TransferableRasterDEMDataLike, size: number, skirt: boolean, skirtExaggeration: number): Promise<{
2
+ export declare function constructTerrainMesh(bytes: Uint8Array, tile: TransferableTileLike, rasterDEMData: TransferableRasterDEMDataLike, size: number, skirt: boolean, skirtExaggeration: number, poleNorth: boolean, poleSouth: boolean): Promise<{
3
3
  result: ReturnedConstructedTerrainMeshLike;
4
4
  }>;
@@ -1,2 +1,2 @@
1
1
  import { ReturnedConstructedTerrainMeshLike, TransferableTileLike, UpsamplableTerrainGeometryLike } from '@navaramap/core';
2
- export declare function upsampleQuantizedMeshTerrainMesh(tile: TransferableTileLike, parentTile: TransferableTileLike, upsamplableGeometry: UpsamplableTerrainGeometryLike, skirt: boolean, skirtExaggeration: number, geographic: boolean, tms: boolean): Promise<ReturnedConstructedTerrainMeshLike>;
2
+ export declare function upsampleQuantizedMeshTerrainMesh(tile: TransferableTileLike, parentTile: TransferableTileLike, upsamplableGeometry: UpsamplableTerrainGeometryLike, skirt: boolean, skirtExaggeration: number, poleNorth: boolean, poleSouth: boolean, geographic: boolean, tms: boolean): Promise<ReturnedConstructedTerrainMeshLike>;
@@ -1,2 +1,7 @@
1
- import { ReturnedConstructedTerrainMeshLike, TransferableRasterDEMDataLike, TransferableTileLike, UpsamplableTerrainGeometryLike } from '@navaramap/core';
2
- export declare function upsampleTerrainMesh(tile: TransferableTileLike, parentTile: TransferableTileLike, rasterDEMData: TransferableRasterDEMDataLike, upsamplableGeometry: UpsamplableTerrainGeometryLike, skirt: boolean, skirtExaggeration: number, tms: boolean): Promise<ReturnedConstructedTerrainMeshLike>;
1
+ import { ReturnedConstructedTerrainMeshLike, TransferableRasterDEMDataLike, TransferableTileLike } from '@navaramap/core';
2
+ /**
3
+ * Upsample a raster-DEM tile from a real-DEM ancestor's pixels, resampled
4
+ * down to the tile and meshed at the tile's own level, like a
5
+ * lower-resolution real tile.
6
+ */
7
+ export declare function upsampleTerrainMesh(tile: TransferableTileLike, sourceTile: TransferableTileLike, rasterDEMData: TransferableRasterDEMDataLike, sourceBytes: Uint8Array, size: number, skirt: boolean, skirtExaggeration: number, poleNorth: boolean, poleSouth: boolean, tms: boolean): Promise<ReturnedConstructedTerrainMeshLike>;
@@ -1,7 +1,12 @@
1
1
  import { InitOutput } from '@navaramap/engine-worker';
2
2
  export declare function waitWasm(): Promise<InitOutput>;
3
3
  /**
4
- * Reports this worker's WASM linear memory size in bytes (0 when WASM is not
4
+ * Adds another WASM module's linear memory (e.g. a decoder a task module
5
+ * instantiates in this worker) to {@link getWasmMemoryUsage}.
6
+ */
7
+ export declare function registerWasmMemoryProbe(probe: () => number): void;
8
+ /**
9
+ * Reports this worker's WASM linear memory size in bytes (0 when no WASM is
5
10
  * initialized yet). Linear memory only grows, so the main thread probes this
6
11
  * after settled tasks to decide when to recycle the worker.
7
12
  */
@@ -1,4 +1,5 @@
1
1
  import { default as workerpool } from 'workerpool';
2
2
  export { type CommonTasks } from '../tasks';
3
3
  export * from './transfer';
4
+ export { registerWasmMemoryProbe } from '../tasks/waitWasm';
4
5
  export declare const registerTasks: (...args: Parameters<typeof workerpool.worker>) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@navaramap/worker",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.2.1",
5
5
  "main": "dist/index.umd.cjs",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "license": "MIT OR Apache-2.0",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git+https://github.com/reearth/navara.git",
15
+ "url": "git+https://github.com/maplibre/navara.git",
16
16
  "directory": "web/navara_worker"
17
17
  },
18
18
  "publishConfig": {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "workerpool": "10.0.3",
23
- "@navaramap/core": "0.1.1",
24
- "@navaramap/engine-worker": "0.1.1"
23
+ "@navaramap/core": "0.2.1",
24
+ "@navaramap/engine-worker": "0.2.1"
25
25
  },
26
26
  "scripts": {
27
27
  "type-check": "tsc && tsc -p tsconfig.node.json",
@@ -88,7 +88,7 @@ const createPool = (url: string) =>
88
88
  workerpool.pool(url, {
89
89
  // One worker per pool so each worker can be recycled independently.
90
90
  maxWorkers: 1,
91
- // Avoid oversubscribing CPU when combined with other systems (e.g., DRACO loader).
91
+ // Avoid oversubscribing CPU when combined with other systems (e.g., the font worker).
92
92
  minWorkers: 0,
93
93
  workerTerminateTimeout: WORKER_TERMINATE_TIMEOUT_MS,
94
94
  workerOpts: {
@@ -15,6 +15,8 @@ export async function constructQuantizedMeshTerrainMesh(
15
15
  tile: TransferableTileLike,
16
16
  skirt: boolean,
17
17
  skirtExaggeration: number,
18
+ poleNorth: boolean,
19
+ poleSouth: boolean,
18
20
  geographic: boolean,
19
21
  tms: boolean,
20
22
  ): Promise<{
@@ -27,6 +29,8 @@ export async function constructQuantizedMeshTerrainMesh(
27
29
  toTransferableTile(tile),
28
30
  skirt,
29
31
  skirtExaggeration,
32
+ poleNorth,
33
+ poleSouth,
30
34
  geographic,
31
35
  tms,
32
36
  );
@@ -3,10 +3,7 @@ import type {
3
3
  TransferableRasterDEMDataLike,
4
4
  ReturnedConstructedTerrainMeshLike,
5
5
  } from "@navaramap/core";
6
- import {
7
- constructTerrainMesh as constructTerrainMeshImpl,
8
- TransferableMartini,
9
- } from "@navaramap/engine-worker";
6
+ import { constructTerrainMesh as constructTerrainMeshImpl } from "@navaramap/engine-worker";
10
7
 
11
8
  import { transfer } from "..";
12
9
  import { transferReturnedConstructedTerrainMesh } from "../helpers/transferReturnedConstructedTerrainMesh";
@@ -22,21 +19,22 @@ export async function constructTerrainMesh(
22
19
  size: number,
23
20
  skirt: boolean,
24
21
  skirtExaggeration: number,
22
+ poleNorth: boolean,
23
+ poleSouth: boolean,
25
24
  ): Promise<{
26
25
  result: ReturnedConstructedTerrainMeshLike;
27
26
  }> {
28
27
  await waitWasm();
29
28
 
30
- const tileSizeWithBoundary = size + 1;
31
- const martini = TransferableMartini.fromSize(tileSizeWithBoundary);
32
-
33
29
  const mesh = constructTerrainMeshImpl(
34
30
  bytes,
35
31
  toTransferableTile(tile),
36
32
  toTransferableRasterDEMDataLike(rasterDEMData),
37
- martini,
33
+ size + 1,
38
34
  skirt,
39
35
  skirtExaggeration,
36
+ poleNorth,
37
+ poleSouth,
40
38
  );
41
39
  const { result, transfers } = transferReturnedConstructedTerrainMesh(mesh);
42
40
  mesh.free();
@@ -17,6 +17,8 @@ export async function upsampleQuantizedMeshTerrainMesh(
17
17
  upsamplableGeometry: UpsamplableTerrainGeometryLike,
18
18
  skirt: boolean,
19
19
  skirtExaggeration: number,
20
+ poleNorth: boolean,
21
+ poleSouth: boolean,
20
22
  geographic: boolean,
21
23
  tms: boolean,
22
24
  ): Promise<ReturnedConstructedTerrainMeshLike> {
@@ -28,6 +30,8 @@ export async function upsampleQuantizedMeshTerrainMesh(
28
30
  toUpsamplableTerrainGeometry(upsamplableGeometry),
29
31
  skirt,
30
32
  skirtExaggeration,
33
+ poleNorth,
34
+ poleSouth,
31
35
  geographic,
32
36
  tms,
33
37
  );
@@ -2,35 +2,45 @@ import {
2
2
  ReturnedConstructedTerrainMeshLike,
3
3
  TransferableRasterDEMDataLike,
4
4
  TransferableTileLike,
5
- UpsamplableTerrainGeometryLike,
6
5
  } from "@navaramap/core";
7
6
  import { upsampleTerrainMesh as upsampleTerrainMeshImpl } from "@navaramap/engine-worker";
8
7
 
9
8
  import { transfer } from "..";
10
9
  import { transferReturnedConstructedTerrainMesh } from "../helpers/transferReturnedConstructedTerrainMesh";
11
- import { toTransferableTile, toUpsamplableTerrainGeometry } from "../utils";
10
+ import { toTransferableTile } from "../utils";
12
11
  import { toTransferableRasterDEMDataLike } from "../utils/toTransferableRasterDEMDataLike";
13
12
 
14
13
  import { waitWasm } from "./waitWasm";
15
14
 
15
+ /**
16
+ * Upsample a raster-DEM tile from a real-DEM ancestor's pixels, resampled
17
+ * down to the tile and meshed at the tile's own level, like a
18
+ * lower-resolution real tile.
19
+ */
16
20
  export async function upsampleTerrainMesh(
17
21
  tile: TransferableTileLike,
18
- parentTile: TransferableTileLike,
22
+ sourceTile: TransferableTileLike,
19
23
  rasterDEMData: TransferableRasterDEMDataLike,
20
- upsamplableGeometry: UpsamplableTerrainGeometryLike,
24
+ sourceBytes: Uint8Array,
25
+ size: number,
21
26
  skirt: boolean,
22
27
  skirtExaggeration: number,
28
+ poleNorth: boolean,
29
+ poleSouth: boolean,
23
30
  tms: boolean,
24
31
  ): Promise<ReturnedConstructedTerrainMeshLike> {
25
32
  await waitWasm();
26
33
 
27
34
  const mesh = upsampleTerrainMeshImpl(
28
35
  toTransferableTile(tile),
29
- toTransferableTile(parentTile),
36
+ toTransferableTile(sourceTile),
30
37
  toTransferableRasterDEMDataLike(rasterDEMData),
31
- toUpsamplableTerrainGeometry(upsamplableGeometry),
38
+ sourceBytes,
39
+ size + 1,
32
40
  skirt,
33
41
  skirtExaggeration,
42
+ poleNorth,
43
+ poleSouth,
34
44
  tms,
35
45
  );
36
46
  const { result, transfers } = transferReturnedConstructedTerrainMesh(mesh);
@@ -7,13 +7,25 @@ export async function waitWasm(): Promise<InitOutput> {
7
7
  return WASM;
8
8
  }
9
9
 
10
+ const extraWasmMemoryProbes: (() => number)[] = [];
11
+
12
+ /**
13
+ * Adds another WASM module's linear memory (e.g. a decoder a task module
14
+ * instantiates in this worker) to {@link getWasmMemoryUsage}.
15
+ */
16
+ export function registerWasmMemoryProbe(probe: () => number) {
17
+ extraWasmMemoryProbes.push(probe);
18
+ }
19
+
10
20
  /**
11
- * Reports this worker's WASM linear memory size in bytes (0 when WASM is not
21
+ * Reports this worker's WASM linear memory size in bytes (0 when no WASM is
12
22
  * initialized yet). Linear memory only grows, so the main thread probes this
13
23
  * after settled tasks to decide when to recycle the worker.
14
24
  */
15
25
  export async function getWasmMemoryUsage(): Promise<number> {
16
- if (!WASM) return 0;
17
- const { memory } = await WASM;
18
- return memory.buffer.byteLength;
26
+ let bytes = WASM ? (await WASM).memory.buffer.byteLength : 0;
27
+ for (const probe of extraWasmMemoryProbes) {
28
+ bytes += probe();
29
+ }
30
+ return bytes;
19
31
  }
@@ -17,5 +17,8 @@ export function toTransferablePolylineBatchedFeatureLike(
17
17
  t.setBatchIndices(like.batch_indices.length, (b: Uint32Array) => {
18
18
  b.set(like.batch_indices);
19
19
  });
20
+ t.setRingFlags(like.ring_flags.length, (b: Uint8Array) => {
21
+ b.set(like.ring_flags);
22
+ });
20
23
  return t;
21
24
  }
@@ -5,6 +5,7 @@ import { commonTasks } from "../tasks";
5
5
  export { type CommonTasks } from "../tasks";
6
6
 
7
7
  export * from "./transfer";
8
+ export { registerWasmMemoryProbe } from "../tasks/waitWasm";
8
9
 
9
10
  let isInitialized = false;
10
11
  export const registerTasks = (