mirror of
https://github.com/w3reality/three-geo.git
synced 2026-01-25 14:57:51 +00:00
2 lines
202 KiB
JavaScript
2 lines
202 KiB
JavaScript
/*! For license information please see three-geo.min.js.LICENSE.txt */
|
||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("THREE")):"function"==typeof define&&define.amd?define(["THREE"],e):"object"==typeof exports?exports.ThreeGeo=e(require("THREE")):t.ThreeGeo=e(t.THREE)}("undefined"!=typeof self?self:this,(function(t){return(()=>{var e={5550:t=>{"use strict";function e(t,e){this.x=t,this.y=e}t.exports=e,e.prototype={clone:function(){return new e(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=e*this.x-r*this.y,i=r*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.x+r*(this.x-e.x)-n*(this.y-e.y),o=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=i,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t}},3673:(t,e)=>{var r=function(){var t={},e=Math.PI/180,r=180/Math.PI,n=6378137,i=20037508.342789244;function o(t){return Number(t)===t&&t%1!=0}function a(e){if(e=e||{},this.size=e.size||256,this.expansion=!0===e.antimeridian?2:1,!t[this.size]){var r=this.size,n=t[this.size]={};n.Bc=[],n.Cc=[],n.zc=[],n.Ac=[];for(var i=0;i<30;i++)n.Bc.push(r/360),n.Cc.push(r/(2*Math.PI)),n.zc.push(r/2),n.Ac.push(r),r*=2}this.Bc=t[this.size].Bc,this.Cc=t[this.size].Cc,this.zc=t[this.size].zc,this.Ac=t[this.size].Ac}return a.prototype.px=function(t,r){if(o(r)){var n=this.size*Math.pow(2,r),i=n/2,a=n/360,s=n/(2*Math.PI),u=n,f=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),l=i+t[0]*a,h=i+.5*Math.log((1+f)/(1-f))*-s;return l>u*this.expansion&&(l=u*this.expansion),h>u&&(h=u),[l,h]}i=this.zc[r],f=Math.min(Math.max(Math.sin(e*t[1]),-.9999),.9999),l=Math.round(i+t[0]*this.Bc[r]),h=Math.round(i+.5*Math.log((1+f)/(1-f))*-this.Cc[r]);return l>this.Ac[r]*this.expansion&&(l=this.Ac[r]*this.expansion),h>this.Ac[r]&&(h=this.Ac[r]),[l,h]},a.prototype.ll=function(t,e){if(o(e)){var n=this.size*Math.pow(2,e),i=n/360,a=n/(2*Math.PI),s=n/2,u=(t[1]-s)/-a;return[(t[0]-s)/i,r*(2*Math.atan(Math.exp(u))-.5*Math.PI)]}u=(t[1]-this.zc[e])/-this.Cc[e];return[(t[0]-this.zc[e])/this.Bc[e],r*(2*Math.atan(Math.exp(u))-.5*Math.PI)]},a.prototype.bbox=function(t,e,r,n,i){n&&(e=Math.pow(2,r)-1-e);var o=[t*this.size,(+e+1)*this.size],a=[(+t+1)*this.size,e*this.size],s=this.ll(o,r).concat(this.ll(a,r));return"900913"===i?this.convert(s,"900913"):s},a.prototype.xyz=function(t,e,r,n){"900913"===n&&(t=this.convert(t,"WGS84"));var i=[t[0],t[1]],o=[t[2],t[3]],a=this.px(i,e),s=this.px(o,e),u=[Math.floor(a[0]/this.size),Math.floor((s[0]-1)/this.size)],f=[Math.floor(s[1]/this.size),Math.floor((a[1]-1)/this.size)],l={minX:Math.min.apply(Math,u)<0?0:Math.min.apply(Math,u),minY:Math.min.apply(Math,f)<0?0:Math.min.apply(Math,f),maxX:Math.max.apply(Math,u),maxY:Math.max.apply(Math,f)};if(r){var h={minY:Math.pow(2,e)-1-l.maxY,maxY:Math.pow(2,e)-1-l.minY};l.minY=h.minY,l.maxY=h.maxY}return l},a.prototype.convert=function(t,e){return"900913"===e?this.forward(t.slice(0,2)).concat(this.forward(t.slice(2,4))):this.inverse(t.slice(0,2)).concat(this.inverse(t.slice(2,4)))},a.prototype.forward=function(t){var r=[n*t[0]*e,n*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return r[0]>i&&(r[0]=i),r[0]<-i&&(r[0]=-i),r[1]>i&&(r[1]=i),r[1]<-i&&(r[1]=-i),r},a.prototype.inverse=function(t){return[t[0]*r/n,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/n)))*r]},a}();t.exports=r},7701:(t,e,r)=>{"use strict";var n=r(2768);function i(t){return{type:"Feature",geometry:n.tileToGeoJSON(t),properties:{}}}function o(t,e){var r,i,o=t.coordinates,s=e.max_zoom,h={},c=[];if("Point"===t.type)return[n.pointToTile(o[0],o[1],s)];if("MultiPoint"===t.type)for(r=0;r<o.length;r++)h[l((i=n.pointToTile(o[r][0],o[r][1],s))[0],i[1],i[2])]=!0;else if("LineString"===t.type)u(h,o,s);else if("MultiLineString"===t.type)for(r=0;r<o.length;r++)u(h,o[r],s);else if("Polygon"===t.type)a(h,c,o,s);else{if("MultiPolygon"!==t.type)throw new Error("Geometry type not implemented");for(r=0;r<o.length;r++)a(h,c,o[r],s)}if(e.min_zoom!==s){var p=c.length;for(f(h,c),r=0;r<p;r++){var d=c[r];h[l(d[0],d[1],d[2])]=!0}return function(t,e,r){for(var n=[],i=r.max_zoom;i>r.min_zoom;i--){for(var o={},a=[],s=0;s<e.length;s++){var u=e[s];if(u[0]%2==0&&u[1]%2==0){var f=l(u[0]+1,u[1],i),h=l(u[0],u[1]+1,i),c=l(u[0]+1,u[1]+1,i);if(t[f]&&t[h]&&t[c]){t[l(u[0],u[1],u[2])]=!1,t[f]=!1,t[h]=!1,t[c]=!1;var p=[u[0]/2,u[1]/2,i-1];i-1===r.min_zoom?n.push(p):(o[l(u[0]/2,u[1]/2,i-1)]=!0,a.push(p))}}}for(s=0;s<e.length;s++)t[l((u=e[s])[0],u[1],u[2])]&&n.push(u);t=o,e=a}return n}(h,c,e)}return f(h,c),c}function a(t,e,r,n){for(var i=[],o=0;o<r.length;o++){var a=[];u(t,r[o],n,a);for(var f=0,h=a.length,c=h-1;f<h;c=f++){var p=(f+1)%h,d=a[f][1];(d>a[c][1]||d>a[p][1])&&(d<a[c][1]||d<a[p][1])&&d!==a[p][1]&&i.push(a[f])}}for(i.sort(s),o=0;o<i.length;o+=2){d=i[o][1];for(var y=i[o][0]+1;y<i[o+1][0];y++){t[l(y,d,n)]||e.push([y,d,n])}}}function s(t,e){return t[1]-e[1]||t[0]-e[0]}function u(t,e,r,i){for(var o,a,s=0;s<e.length-1;s++){var u=n.pointToTileFraction(e[s][0],e[s][1],r),f=n.pointToTileFraction(e[s+1][0],e[s+1][1],r),h=u[0],c=u[1],p=f[0]-h,d=f[1]-c;if(0!==d||0!==p){var y=p>0?1:-1,g=d>0?1:-1,v=Math.floor(h),b=Math.floor(c),m=0===p?1/0:Math.abs(((p>0?1:0)+v-h)/p),w=0===d?1/0:Math.abs(((d>0?1:0)+b-c)/d),x=Math.abs(y/p),_=Math.abs(g/d);for(v===o&&b===a||(t[l(v,b,r)]=!0,i&&b!==a&&i.push([v,b]),o=v,a=b);m<1||w<1;)m<w?(m+=x,v+=y):(w+=_,b+=g),t[l(v,b,r)]=!0,i&&b!==a&&i.push([v,b]),o=v,a=b}}i&&b===i[0][1]&&i.pop()}function f(t,e){for(var r,n,i,o,a,s=Object.keys(t),u=0;u<s.length;u++)e.push((r=+s[u],n=void 0,i=void 0,o=void 0,a=void 0,void 0,[a=(o=(r-(n=r%32))/32)%(i=2*(1<<n)),(o-a)/i%i,n]))}function l(t,e,r){return 32*(2*(1<<r)*e+t)+r}e.geojson=function(t,e){return{type:"FeatureCollection",features:o(t,e).map(i)}},e.tiles=o,e.indexes=function(t,e){return o(t,e).map(n.tileToQuadkey)}},2768:t=>{"use strict";var e=Math.PI/180,r=180/Math.PI;function n(t){var e=i(t[0]+1,t[2]);return[i(t[0],t[2]),o(t[1]+1,t[2]),e,o(t[1],t[2])]}function i(t,e){return t/Math.pow(2,e)*360-180}function o(t,e){var n=Math.PI-2*Math.PI*t/Math.pow(2,e);return r*Math.atan(.5*(Math.exp(n)-Math.exp(-n)))}function a(t,e,r){var n=c(t,e,r);return n[0]=Math.floor(n[0]),n[1]=Math.floor(n[1]),n}function s(t){return[[2*t[0],2*t[1],t[2]+1],[2*t[0]+1,2*t[1],t[2]+1],[2*t[0]+1,2*t[1]+1,t[2]+1],[2*t[0],2*t[1]+1,t[2]+1]]}function u(t){return[t[0]>>1,t[1]>>1,t[2]-1]}function f(t){return s(u(t))}function l(t,e){for(var r=0;r<t.length;r++)if(h(t[r],e))return!0;return!1}function h(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function c(t,r,n){var i=Math.sin(r*e),o=Math.pow(2,n),a=o*(t/360+.5);return(a%=o)<0&&(a+=o),[a,o*(.5-.25*Math.log((1+i)/(1-i))/Math.PI),n]}t.exports={tileToGeoJSON:function(t){var e=n(t);return{type:"Polygon",coordinates:[[[e[0],e[3]],[e[0],e[1]],[e[2],e[1]],[e[2],e[3]],[e[0],e[3]]]]}},tileToBBOX:n,getChildren:s,getParent:u,getSiblings:f,hasTile:l,hasSiblings:function(t,e){for(var r=f(t),n=0;n<r.length;n++)if(!l(e,r[n]))return!1;return!0},tilesEqual:h,tileToQuadkey:function(t){for(var e="",r=t[2];r>0;r--){var n=0,i=1<<r-1;0!=(t[0]&i)&&n++,0!=(t[1]&i)&&(n+=2),e+=n.toString()}return e},quadkeyToTile:function(t){for(var e=0,r=0,n=t.length,i=n;i>0;i--){var o=1<<i-1,a=+t[n-i];1===a&&(e|=o),2===a&&(r|=o),3===a&&(e|=o,r|=o)}return[e,r,n]},pointToTile:a,bboxToTile:function(t){var e=a(t[0],t[1],32),r=a(t[2],t[3],32),n=[e[0],e[1],r[0],r[1]],i=function(t){for(var e=28,r=0;r<e;r++){var n=1<<32-(r+1);if((t[0]&n)!=(t[2]&n)||(t[1]&n)!=(t[3]&n))return r}return e}(n);return 0===i?[0,0,0]:[n[0]>>>32-i,n[1]>>>32-i,i]},pointToTileFraction:c}},8929:(t,e,r)=>{t.exports.VectorTile=r(2779),r(6024),r(9701)},2779:(t,e,r)=>{"use strict";var n=r(9701);function i(t,e,r){if(3===t){var i=new n(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}t.exports=function(t,e){this.layers=t.readFields(i,{},e)}},6024:(t,e,r)=>{"use strict";var n=r(5550);function i(t,e,r,n,i){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=i,t.readFields(o,this,e)}function o(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){var r=t.readVarint()+t.pos;for(;t.pos<r;){var n=e._keys[t.readVarint()],i=e._values[t.readVarint()];e.properties[n]=i}}(r,e):3==t?e.type=r.readVarint():4==t&&(e._geometry=r.pos)}function a(t){for(var e,r,n=0,i=0,o=t.length,a=o-1;i<o;a=i++)e=t[i],n+=((r=t[a]).x-e.x)*(e.y+r.y);return n}t.exports=i,i.types=["Unknown","Point","LineString","Polygon"],i.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,r=t.readVarint()+t.pos,i=1,o=0,a=0,s=0,u=[];t.pos<r;){if(o<=0){var f=t.readVarint();i=7&f,o=f>>3}if(o--,1===i||2===i)a+=t.readSVarint(),s+=t.readSVarint(),1===i&&(e&&u.push(e),e=[]),e.push(new n(a,s));else{if(7!==i)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&u.push(e),u},i.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,o=0,a=1/0,s=-1/0,u=1/0,f=-1/0;t.pos<e;){if(n<=0){var l=t.readVarint();r=7&l,n=l>>3}if(n--,1===r||2===r)(i+=t.readSVarint())<a&&(a=i),i>s&&(s=i),(o+=t.readSVarint())<u&&(u=o),o>f&&(f=o);else if(7!==r)throw new Error("unknown command "+r)}return[a,u,s,f]},i.prototype.toGeoJSON=function(t,e,r){var n,o,s=this.extent*Math.pow(2,r),u=this.extent*t,f=this.extent*e,l=this.loadGeometry(),h=i.types[this.type];function c(t){for(var e=0;e<t.length;e++){var r=t[e],n=180-360*(r.y+f)/s;t[e]=[360*(r.x+u)/s-180,360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90]}}switch(this.type){case 1:var p=[];for(n=0;n<l.length;n++)p[n]=l[n][0];c(l=p);break;case 2:for(n=0;n<l.length;n++)c(l[n]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var r,n,i=[],o=0;o<e;o++){var s=a(t[o]);0!==s&&(void 0===n&&(n=s<0),n===s<0?(r&&i.push(r),r=[t[o]]):r.push(t[o]))}r&&i.push(r);return i}(l),n=0;n<l.length;n++)for(o=0;o<l[n].length;o++)c(l[n][o])}1===l.length?l=l[0]:h="Multi"+h;var d={type:"Feature",geometry:{type:h,coordinates:l},properties:this.properties};return"id"in this&&(d.id=this.id),d}},9701:(t,e,r)=>{"use strict";var n=r(6024);function i(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(o,this,e),this.length=this._features.length}function o(t,e,r){15===t?e.version=r.readVarint():1===t?e.name=r.readString():5===t?e.extent=r.readVarint():2===t?e._features.push(r.pos):3===t?e._keys.push(r.readString()):4===t&&e._values.push(function(t){var e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){var n=t.readVarint()>>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}t.exports=i,i.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new n(this._pbf,e,this.extent,this._keys,this._values)}},6239:(t,e,r)=>{"use strict";var n=r(5081);function i(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}t.exports=function(t){var e=new i;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var o=0;o<r.length;++o){var a=r[o];if("array"===a||"object"==typeof a&&a.blockIndices){if(e.argTypes[o]="array",e.arrayArgs.push(o),e.arrayBlockIndices.push(a.blockIndices?a.blockIndices:0),e.shimArgs.push("array"+o),o<e.pre.args.length&&e.pre.args[o].count>0)throw new Error("cwise: pre() block may not reference array args");if(o<e.post.args.length&&e.post.args[o].count>0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)e.scalarArgs.push(o),e.shimArgs.push("scalar"+o);else if("index"===a){if(e.indexArgs.push(o),o<e.pre.args.length&&e.pre.args[o].count>0)throw new Error("cwise: pre() block may not reference array index");if(o<e.body.args.length&&e.body.args[o].lvalue)throw new Error("cwise: body() block may not write to array index");if(o<e.post.args.length&&e.post.args[o].count>0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(e.shapeArgs.push(o),o<e.pre.args.length&&e.pre.args[o].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(o<e.body.args.length&&e.body.args[o].lvalue)throw new Error("cwise: body() block may not write to array shape");if(o<e.post.args.length&&e.post.args[o].lvalue)throw new Error("cwise: post() block may not write to array shape")}else{if("object"!=typeof a||!a.offset)throw new Error("cwise: Unknown argument type "+r[o]);e.argTypes[o]="offset",e.offsetArgs.push({array:a.array,offset:a.offset}),e.offsetArgIndex.push(o)}}if(e.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(e.pre.args.length>r.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,n(e)}},1984:(t,e,r)=>{"use strict";var n=r(8706);function i(t,e,r){var n,i,o=t.length,a=e.arrayArgs.length,s=e.indexArgs.length>0,u=[],f=[],l=0,h=0;for(n=0;n<o;++n)f.push(["i",n,"=0"].join(""));for(i=0;i<a;++i)for(n=0;n<o;++n)h=l,l=t[n],0===n?f.push(["d",i,"s",n,"=t",i,"p",l].join("")):f.push(["d",i,"s",n,"=(t",i,"p",l,"-s",h,"*t",i,"p",h,")"].join(""));for(f.length>0&&u.push("var "+f.join(",")),n=o-1;n>=0;--n)l=t[n],u.push(["for(i",n,"=0;i",n,"<s",l,";++i",n,"){"].join(""));for(u.push(r),n=0;n<o;++n){for(h=l,l=t[n],i=0;i<a;++i)u.push(["p",i,"+=d",i,"s",n].join(""));s&&(n>0&&u.push(["index[",h,"]-=s",h].join("")),u.push(["++index[",l,"]"].join(""))),u.push("}")}return u.join("\n")}function o(t,e,r){for(var n=t.body,i=[],o=[],a=0;a<t.args.length;++a){var s=t.args[a];if(!(s.count<=0)){var u=new RegExp(s.name,"g"),f="",l=e.arrayArgs.indexOf(a);switch(e.argTypes[a]){case"offset":var h=e.offsetArgIndex.indexOf(a);l=e.offsetArgs[h].array,f="+q"+h;case"array":f="p"+l+f;var c="l"+a,p="a"+l;if(0===e.arrayBlockIndices[l])1===s.count?"generic"===r[l]?s.lvalue?(i.push(["var ",c,"=",p,".get(",f,")"].join("")),n=n.replace(u,c),o.push([p,".set(",f,",",c,")"].join(""))):n=n.replace(u,[p,".get(",f,")"].join("")):n=n.replace(u,[p,"[",f,"]"].join("")):"generic"===r[l]?(i.push(["var ",c,"=",p,".get(",f,")"].join("")),n=n.replace(u,c),s.lvalue&&o.push([p,".set(",f,",",c,")"].join(""))):(i.push(["var ",c,"=",p,"[",f,"]"].join("")),n=n.replace(u,c),s.lvalue&&o.push([p,"[",f,"]=",c].join("")));else{for(var d=[s.name],y=[f],g=0;g<Math.abs(e.arrayBlockIndices[l]);g++)d.push("\\s*\\[([^\\]]+)\\]"),y.push("$"+(g+1)+"*t"+l+"b"+g);if(u=new RegExp(d.join(""),"g"),f=y.join("+"),"generic"===r[l])throw new Error("cwise: Generic arrays not supported in combination with blocks!");n=n.replace(u,[p,"[",f,"]"].join(""))}break;case"scalar":n=n.replace(u,"Y"+e.scalarArgs.indexOf(a));break;case"index":n=n.replace(u,"index");break;case"shape":n=n.replace(u,"shape")}}}return[i.join("\n"),n,o.join("\n")].join("\n").trim()}function a(t){for(var e=new Array(t.length),r=!0,n=0;n<t.length;++n){var i=t[n],o=i.match(/\d+/);o=o?o[0]:"",0===i.charAt(0)?e[n]="u"+i.charAt(1)+o:e[n]=i.charAt(0)+o,n>0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}t.exports=function(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,s=new Array(t.arrayArgs.length),u=new Array(t.arrayArgs.length),f=0;f<t.arrayArgs.length;++f)u[f]=e[2*f],s[f]=e[2*f+1];var l=[],h=[],c=[],p=[],d=[];for(f=0;f<t.arrayArgs.length;++f){t.arrayBlockIndices[f]<0?(c.push(0),p.push(r),l.push(r),h.push(r+t.arrayBlockIndices[f])):(c.push(t.arrayBlockIndices[f]),p.push(t.arrayBlockIndices[f]+r),l.push(0),h.push(t.arrayBlockIndices[f]));for(var y=[],g=0;g<s[f].length;g++)c[f]<=s[f][g]&&s[f][g]<p[f]&&y.push(s[f][g]-c[f]);d.push(y)}var v=["SS"],b=["'use strict'"],m=[];for(g=0;g<r;++g)m.push(["s",g,"=SS[",g,"]"].join(""));for(f=0;f<t.arrayArgs.length;++f){v.push("a"+f),v.push("t"+f),v.push("p"+f);for(g=0;g<r;++g)m.push(["t",f,"p",g,"=t",f,"[",c[f]+g,"]"].join(""));for(g=0;g<Math.abs(t.arrayBlockIndices[f]);++g)m.push(["t",f,"b",g,"=t",f,"[",l[f]+g,"]"].join(""))}for(f=0;f<t.scalarArgs.length;++f)v.push("Y"+f);if(t.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),t.indexArgs.length>0){var w=new Array(r);for(f=0;f<r;++f)w[f]="0";m.push(["index=[",w.join(","),"]"].join(""))}for(f=0;f<t.offsetArgs.length;++f){var x=t.offsetArgs[f],_=[];for(g=0;g<x.offset.length;++g)0!==x.offset[g]&&(1===x.offset[g]?_.push(["t",x.array,"p",g].join("")):_.push([x.offset[g],"*t",x.array,"p",g].join("")));0===_.length?m.push("q"+f+"=0"):m.push(["q",f,"=",_.join("+")].join(""))}var E=n([].concat(t.pre.thisVars).concat(t.body.thisVars).concat(t.post.thisVars));for((m=m.concat(E)).length>0&&b.push("var "+m.join(",")),f=0;f<t.arrayArgs.length;++f)b.push("p"+f+"|=0");t.pre.body.length>3&&b.push(o(t.pre,t,u));var S=o(t.body,t,u),k=function(t){for(var e=0,r=t[0].length;e<r;){for(var n=1;n<t.length;++n)if(t[n][e]!==t[0][e])return e;++e}return e}(d);k<r?b.push(function(t,e,r,n){for(var o=e.length,a=r.arrayArgs.length,s=r.blockSize,u=r.indexArgs.length>0,f=[],l=0;l<a;++l)f.push(["var offset",l,"=p",l].join(""));for(l=t;l<o;++l)f.push(["for(var j"+l+"=SS[",e[l],"]|0;j",l,">0;){"].join("")),f.push(["if(j",l,"<",s,"){"].join("")),f.push(["s",e[l],"=j",l].join("")),f.push(["j",l,"=0"].join("")),f.push(["}else{s",e[l],"=",s].join("")),f.push(["j",l,"-=",s,"}"].join("")),u&&f.push(["index[",e[l],"]=j",l].join(""));for(l=0;l<a;++l){for(var h=["offset"+l],c=t;c<o;++c)h.push(["j",c,"*t",l,"p",e[c]].join(""));f.push(["p",l,"=(",h.join("+"),")"].join(""))}for(f.push(i(e,r,n)),l=t;l<o;++l)f.push("}");return f.join("\n")}(k,d[0],t,S)):b.push(i(d[0],t,S)),t.post.body.length>3&&b.push(o(t.post,t,u)),t.debug&&b.join("\n");var M=[t.funcName||"unnamed","_cwise_loop_",s[0].join("s"),"m",k,a(u)].join("");return new Function(["function ",M,"(",v.join(","),"){",b.join("\n"),"} return ",M].join(""))()}},5081:(t,e,r)=>{"use strict";var n=r(1984);t.exports=function(t){var e=["'use strict'","var CACHED={}"],r=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var o=[],a=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],u=[],f=[],l=0;l<t.arrayArgs.length;++l){var h=t.arrayArgs[l];r.push(["t",h,"=array",h,".dtype,","r",h,"=array",h,".order"].join("")),o.push("t"+h),o.push("r"+h),a.push("t"+h),a.push("r"+h+".join()"),s.push("array"+h+".data"),s.push("array"+h+".stride"),s.push("array"+h+".offset|0"),l>0&&(u.push("array"+t.arrayArgs[0]+".shape.length===array"+h+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[l]))),f.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+h+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[l])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+f.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),l=0;l<t.scalarArgs.length;++l)s.push("scalar"+t.scalarArgs[l]);return r.push(["type=[",a.join(","),"].join()"].join("")),r.push("proc=CACHED[type]"),e.push("var "+r.join(",")),e.push(["if(!proc){","CACHED[type]=proc=compile([",o.join(","),"])}","return proc(",s.join(","),")}"].join("")),t.debug&&e.join("\n"),new Function("compile",e.join("\n"))(n.bind(void 0,t))}},858:(t,e,r)=>{var n=r(1664).Buffer;t.exports=function(t){if(!/^data\:/i.test(t))throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');var e=(t=t.replace(/\r?\n/g,"")).indexOf(",");if(-1===e||e<=4)throw new TypeError("malformed data: URI");for(var r=t.substring(5,e).split(";"),i=!1,o="US-ASCII",a=0;a<r.length;a++)"base64"==r[a]?i=!0:0==r[a].indexOf("charset=")&&(o=r[a].substring(8));var s=unescape(t.substring(e+1)),u=new n(s,i?"base64":"ascii");return u.type=r[0]||"text/plain",u.charset=o,u}},8197:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=u(t),a=o[0],s=o[1],f=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),l=0,h=s>0?a-4:a;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],f[l++]=e>>16&255,f[l++]=e>>8&255,f[l++]=255&e;2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[l++]=255&e);1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[l++]=e>>8&255,f[l++]=255&e);return f},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,u=n-i;s<u;s+=a)o.push(f(t,s,s+a>u?u:s+a));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=o.length;a<s;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},1664:(t,e,r)=>{"use strict";const n=r(8197),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(X(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(X(t,SharedArrayBuffer)||t&&X(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||J(t.length)?s(0):c(t);if("Buffer"===t.type&&Array.isArray(t.data))return c(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return l(t),s(t<0?0:0|d(t))}function c(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(i)return n?-1:H(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,r);case"utf8":case"utf-8":return M(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return j(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(f(t,o)===f(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(f(t,o+n)!==f(e,n)){r=!1;break}if(r)return o}return-1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(J(n))return a;t[r+a]=n}return a}function x(t,e,r,n){return $(H(e,t.length-r),t,r,n)}function _(t,e,r,n){return $(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return $(Y(e),t,r,n)}function S(t,e,r,n){return $(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function M(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=R));return r}(n)}e.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return f(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return h(t)},u.allocUnsafeSlow=function(t){return h(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(X(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)v(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?M(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),f=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<s;++t)if(f[t]!==l[t]){o=f[t],a=l[t];break}return o<a?-1:a<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return x(this,t,e,r);case"ascii":case"latin1":case"binary":return _(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function j(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function T(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Z[t[n]];return i}function P(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function I(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function L(t,e,r,n,i){q(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function O(t,e,r,n,i){q(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=K((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),u.prototype.readBigUInt64BE=K((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||I(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||I(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=K((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=K((function(t){z(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||I(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||I(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||I(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||I(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){B(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){B(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=K((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=K((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);B(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);B(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=K((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=K((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const U={};function D(t,e,r){U[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function V(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function q(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new U.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1))}(n,i,o)}function z(t,e){if("number"!=typeof t)throw new U.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw z(t,r),new U.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new U.ERR_BUFFER_OUT_OF_BOUNDS;throw new U.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=V(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=V(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function H(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Y(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function $(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function K(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},7988:t=>{"use strict";var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&y(t,"error",e,r)}(t,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var i,o,a,f;if(s(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(t))>0&&a.length>i&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=a.length,f=l,console&&console.warn&&console.warn(f)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function c(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):d(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){n.once&&t.removeEventListener(e,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var f=u.length,l=d(u,f);for(r=0;r<f;++r)n(l[r],this,e)}return!0},o.prototype.addListener=function(t,e){return f(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return f(this,t,e,!0)},o.prototype.once=function(t,e){return s(e),this.on(t,h(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return s(e),this.prependListener(t,h(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,a;if(s(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,a||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return c(this,t,!0)},o.prototype.rawListeners=function(t){return c(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},9530:t=>{"use strict";function e(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function r(t,e){for(var r,n="",i=0,o=-1,a=0,s=0;s<=t.length;++s){if(s<t.length)r=t.charCodeAt(s);else{if(47===r)break;r=47}if(47===r){if(o===s-1||1===a);else if(o!==s-1&&2===a){if(n.length<2||2!==i||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var u=n.lastIndexOf("/");if(u!==n.length-1){-1===u?(n="",i=0):i=(n=n.slice(0,u)).length-1-n.lastIndexOf("/"),o=s,a=0;continue}}else if(2===n.length||1===n.length){n="",i=0,o=s,a=0;continue}e&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+t.slice(o+1,s):n=t.slice(o+1,s),i=s-o-1;o=s,a=0}else 46===r&&-1!==a?++a:a=-1}return n}var n={resolve:function(){for(var t,n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var a;o>=0?a=arguments[o]:(void 0===t&&(t=process.cwd()),a=t),e(a),0!==a.length&&(n=a+"/"+n,i=47===a.charCodeAt(0))}return n=r(n,!i),i?n.length>0?"/"+n:"/":n.length>0?n:"."},normalize:function(t){if(e(t),0===t.length)return".";var n=47===t.charCodeAt(0),i=47===t.charCodeAt(t.length-1);return 0!==(t=r(t,!n)).length||n||(t="."),t.length>0&&i&&(t+="/"),n?"/"+t:t},isAbsolute:function(t){return e(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var t,r=0;r<arguments.length;++r){var i=arguments[r];e(i),i.length>0&&(void 0===t?t=i:t+="/"+i)}return void 0===t?".":n.normalize(t)},relative:function(t,r){if(e(t),e(r),t===r)return"";if((t=n.resolve(t))===(r=n.resolve(r)))return"";for(var i=1;i<t.length&&47===t.charCodeAt(i);++i);for(var o=t.length,a=o-i,s=1;s<r.length&&47===r.charCodeAt(s);++s);for(var u=r.length-s,f=a<u?a:u,l=-1,h=0;h<=f;++h){if(h===f){if(u>f){if(47===r.charCodeAt(s+h))return r.slice(s+h+1);if(0===h)return r.slice(s+h)}else a>f&&(47===t.charCodeAt(i+h)?l=h:0===h&&(l=0));break}var c=t.charCodeAt(i+h);if(c!==r.charCodeAt(s+h))break;47===c&&(l=h)}var p="";for(h=i+l+1;h<=o;++h)h!==o&&47!==t.charCodeAt(h)||(0===p.length?p+="..":p+="/..");return p.length>0?p+r.slice(s+l):(s+=l,47===r.charCodeAt(s)&&++s,r.slice(s))},_makeLong:function(t){return t},dirname:function(t){if(e(t),0===t.length)return".";for(var r=t.charCodeAt(0),n=47===r,i=-1,o=!0,a=t.length-1;a>=1;--a)if(47===(r=t.charCodeAt(a))){if(!o){i=a;break}}else o=!1;return-1===i?n?"/":".":n&&1===i?"//":t.slice(0,i)},basename:function(t,r){if(void 0!==r&&"string"!=typeof r)throw new TypeError('"ext" argument must be a string');e(t);var n,i=0,o=-1,a=!0;if(void 0!==r&&r.length>0&&r.length<=t.length){if(r.length===t.length&&r===t)return"";var s=r.length-1,u=-1;for(n=t.length-1;n>=0;--n){var f=t.charCodeAt(n);if(47===f){if(!a){i=n+1;break}}else-1===u&&(a=!1,u=n+1),s>=0&&(f===r.charCodeAt(s)?-1==--s&&(o=n):(s=-1,o=u))}return i===o?o=u:-1===o&&(o=t.length),t.slice(i,o)}for(n=t.length-1;n>=0;--n)if(47===t.charCodeAt(n)){if(!a){i=n+1;break}}else-1===o&&(a=!1,o=n+1);return-1===o?"":t.slice(i,o)},extname:function(t){e(t);for(var r=-1,n=0,i=-1,o=!0,a=0,s=t.length-1;s>=0;--s){var u=t.charCodeAt(s);if(47!==u)-1===i&&(o=!1,i=s+1),46===u?-1===r?r=s:1!==a&&(a=1):-1!==r&&(a=-1);else if(!o){n=s+1;break}}return-1===r||-1===i||0===a||1===a&&r===i-1&&r===n+1?"":t.slice(r,i)},format:function(t){if(null===t||"object"!=typeof t)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return function(t,e){var r=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return r?r===e.root?r+n:r+t+n:n}("/",t)},parse:function(t){e(t);var r={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return r;var n,i=t.charCodeAt(0),o=47===i;o?(r.root="/",n=1):n=0;for(var a=-1,s=0,u=-1,f=!0,l=t.length-1,h=0;l>=n;--l)if(47!==(i=t.charCodeAt(l)))-1===u&&(f=!1,u=l+1),46===i?-1===a?a=l:1!==h&&(h=1):-1!==a&&(h=-1);else if(!f){s=l+1;break}return-1===a||-1===u||0===h||1===h&&a===u-1&&a===s+1?-1!==u&&(r.base=r.name=0===s&&o?t.slice(1,u):t.slice(s,u)):(0===s&&o?(r.name=t.slice(1,a),r.base=t.slice(1,u)):(r.name=t.slice(s,a),r.base=t.slice(s,u)),r.ext=t.slice(a,u)),s>0?r.dir=t.slice(0,s-1):o&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};n.posix=n,t.exports=n},8870:t=>{"use strict";var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,a,s;if("string"==typeof e&&(o="not ",e.substr(!a||a<0?0:+a,o.length)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))s="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";s='The "'.concat(t,'" ').concat(u," ").concat(i," ").concat(n(e,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.q=e},3536:(t,e,r)=>{"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var i=r(4459),o=r(4987);r(5717)(f,i);for(var a=n(o.prototype),s=0;s<a.length;s++){var u=a[s];f.prototype[u]||(f.prototype[u]=o.prototype[u])}function f(t){if(!(this instanceof f))return new f(t);i.call(this,t),o.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||process.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},8373:(t,e,r)=>{"use strict";t.exports=i;var n=r(6695);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(5717)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},4459:(t,e,r)=>{"use strict";var n;t.exports=S,S.ReadableState=E;r(7988).EventEmitter;var i=function(t,e){return t.listeners(e).length},o=r(4150),a=r(1664).Buffer,s=r.g.Uint8Array||function(){};var u,f=r(6023);u=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,c,p=r(1396),d=r(8522),y=r(1379).getHighWaterMark,g=r(8870).q,v=g.ERR_INVALID_ARG_TYPE,b=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,w=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5717)(S,o);var x=d.errorOrDestroy,_=["error","close","destroy","pause","resume"];function E(t,e,i){n=n||r(3536),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=r(140).s),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function S(t){if(n=n||r(3536),!(this instanceof S))return new S(t);var e=this instanceof n;this._readableState=new E(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function k(t,e,r,n,i){u("readableAddChunk",e);var o,f=t._readableState;if(null===e)f.reading=!1,function(t,e){if(u("onEofChunk"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?j(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,T(t)))}(t,f);else if(i||(o=function(t,e){var r;n=e,a.isBuffer(n)||n instanceof s||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e));var n;return r}(f,e)),o)x(t,o);else if(f.objectMode||e&&e.length>0)if("string"==typeof e||f.objectMode||Object.getPrototypeOf(e)===a.prototype||(e=function(t){return a.from(t)}(e)),n)f.endEmitted?x(t,new w):M(t,f,e,!0);else if(f.ended)x(t,new b);else{if(f.destroyed)return!1;f.reading=!1,f.decoder&&!r?(e=f.decoder.write(e),f.objectMode||0!==e.length?M(t,f,e,!1):P(t,f)):M(t,f,e,!1)}else n||(f.reading=!1,P(t,f));return!f.ended&&(f.length<f.highWaterMark||0===f.length)}function M(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&j(t)),P(t,e)}Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),S.prototype.destroy=d.destroy,S.prototype._undestroy=d.undestroy,S.prototype._destroy=function(t,e){e(t)},S.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=a.from(t,e),e=""),r=!0),k(this,t,e,!1,r)},S.prototype.unshift=function(t){return k(this,t,null,!0,!1)},S.prototype.isPaused=function(){return!1===this._readableState.flowing},S.prototype.setEncoding=function(t){l||(l=r(140).s);var e=new l(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var R=1073741824;function A(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=R?t=R:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function j(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(T,t))}function T(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function P(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(I,t,e))}function I(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(u("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function B(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function L(t){u("readable nexttick read 0"),t.read(0)}function O(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function N(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function F(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(U,e,t))}function U(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function D(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}S.prototype.read=function(t){u("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):j(this),null;if(0===(t=A(t,e))&&e.ended)return 0===e.length&&F(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&u("length less than watermark",i=!0),e.ended||e.reading?u("reading or ended",i=!1):i&&(u("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=A(r,e))),null===(n=t>0?N(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&F(this)),null!==n&&this.emit("data",n),n},S.prototype._read=function(t){x(this,new m("_read()"))},S.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,u("pipe count=%d opts=%j",n.pipesCount,e);var o=(!e||!1!==e.end)&&t!==process.stdout&&t!==process.stderr?s:y;function a(e,i){u("onunpipe"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",f),t.removeListener("error",c),t.removeListener("unpipe",a),r.removeListener("end",s),r.removeListener("end",y),r.removeListener("data",h),l=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function s(){u("onend"),t.end()}n.endEmitted?process.nextTick(o):r.once("end",o),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",f);var l=!1;function h(e){u("ondata");var i=t.write(e);u("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==D(n.pipes,t))&&!l&&(u("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function c(e){u("onerror",e),y(),t.removeListener("error",c),0===i(t,"error")&&x(t,e)}function p(){t.removeListener("finish",d),y()}function d(){u("onfinish"),t.removeListener("close",p),y()}function y(){u("unpipe"),r.unpipe(t)}return r.on("data",h),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",c),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(u("pipe resume"),r.resume()),t},S.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=D(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},S.prototype.on=function(t,e){var r=o.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,u("on readable",n.length,n.reading),n.length?j(this):n.reading||process.nextTick(L,this))),r},S.prototype.addListener=S.prototype.on,S.prototype.removeListener=function(t,e){var r=o.prototype.removeListener.call(this,t,e);return"readable"===t&&process.nextTick(B,this),r},S.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||process.nextTick(B,this),e},S.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(O,t,e))}(this,t)),t.paused=!1,this},S.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},S.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o<_.length;o++)t.on(_[o],this.emit.bind(this,_[o]));return this._read=function(e){u("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(S.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(6492)),h(this)}),Object.defineProperty(S.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(S.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(S.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),S._fromList=N,Object.defineProperty(S.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(S.from=function(t,e){return void 0===c&&(c=r(8881)),c(S,t,e)})},6695:(t,e,r)=>{"use strict";t.exports=l;var n=r(8870).q,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(3536);function f(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(t){if(!(this instanceof l))return new l(t);u.call(this,t),this._transformState={afterTransform:f.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",h)}function h(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?c(this,null,null):this._flush((function(e,r){c(t,e,r)}))}function c(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new s;if(t._transformState.transforming)throw new a;return t.push(null)}r(5717)(l,u),l.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},l.prototype._transform=function(t,e,r){r(new i("_transform()"))},l.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},l.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},4987:(t,e,r)=>{"use strict";function n(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;t.entry=null;for(;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=S,S.WritableState=E;var o={deprecate:r(8526)},a=r(4150),s=r(1664).Buffer,u=r.g.Uint8Array||function(){};var f,l=r(8522),h=r(1379).getHighWaterMark,c=r(8870).q,p=c.ERR_INVALID_ARG_TYPE,d=c.ERR_METHOD_NOT_IMPLEMENTED,y=c.ERR_MULTIPLE_CALLBACK,g=c.ERR_STREAM_CANNOT_PIPE,v=c.ERR_STREAM_DESTROYED,b=c.ERR_STREAM_NULL_VALUES,m=c.ERR_STREAM_WRITE_AFTER_END,w=c.ERR_UNKNOWN_ENCODING,x=l.errorOrDestroy;function _(){}function E(t,e,o){i=i||r(3536),t=t||{},"boolean"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if("function"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(T,t,e),t._writableState.errorEmitted=!0,x(t,n)):(i(n),t._writableState.errorEmitted=!0,x(t,n),T(t,e))}(t,r,n,e,i);else{var o=A(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||R(t,r),n?process.nextTick(M,t,r,o,i):M(t,r,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function S(t){var e=this instanceof(i=i||r(3536));if(!e&&!f.call(S,this))return new S(t);this._writableState=new E(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function k(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function M(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),T(t,e)}function R(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,o=new Array(i),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)o[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;o.allBuffers=u,k(t,e,!0,e.length,o,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new n(e),e.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,h=r.callback;if(k(t,e,!1,e.objectMode?1:f.length,f,l,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function A(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function j(t,e){t._final((function(r){e.pendingcb--,r&&x(t,r),e.prefinished=!0,t.emit("prefinish"),T(t,e)}))}function T(t,e){var r=A(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,process.nextTick(j,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(5717)(S,a),E.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(E.prototype,"buffer",{get:o.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(S,Symbol.hasInstance,{value:function(t){return!!f.call(this,t)||this===S&&(t&&t._writableState instanceof E)}})):f=function(t){return t instanceof this},S.prototype.pipe=function(){x(this,new g)},S.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,a=!i.objectMode&&(n=t,s.isBuffer(n)||n instanceof u);return a&&!s.isBuffer(t)&&(t=function(t){return s.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=_),i.ending?function(t,e){var r=new m;x(t,r),process.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i;return null===r?i=new b:"string"==typeof r||e.objectMode||(i=new p("chunk",["string","Buffer"],r)),!i||(x(t,i),process.nextTick(n,i),!1)}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=s.from(e,r));return e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var u=e.objectMode?1:n.length;e.length+=u;var f=e.length<e.highWaterMark;f||(e.needDrain=!0);if(e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(t,e,!1,u,n,i,o);return f}(this,i,a,t,e,r)),o},S.prototype.cork=function(){this._writableState.corked++},S.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||R(this,t))},S.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(S.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(S.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),S.prototype._write=function(t,e,r){r(new d("_write()"))},S.prototype._writev=null,S.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,T(t,e),r&&(e.finished?process.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(S.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),S.prototype.destroy=l.destroy,S.prototype._undestroy=l.undestroy,S.prototype._destroy=function(t,e){e(t)}},6492:(t,e,r)=>{"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(3790),a=Symbol("lastResolve"),s=Symbol("lastReject"),u=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),c=Symbol("stream");function p(t,e){return{value:t,done:e}}function d(t){var e=t[a];if(null!==e){var r=t[c].read();null!==r&&(t[l]=null,t[a]=null,t[s]=null,e(p(r,!1)))}}function y(t){process.nextTick(d,t)}var g=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((i(n={get stream(){return this[c]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(p(void 0,!0));if(this[c].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[u]?r(t[u]):e(p(void 0,!0))}))}));var r,n=this[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?r(p(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var i=this[c].read();if(null!==i)return Promise.resolve(p(i,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,(function(){return this})),i(n,"return",(function(){var t=this;return new Promise((function(e,r){t[c].destroy(null,(function(t){t?r(t):e(p(void 0,!0))}))}))})),n),g);t.exports=function(t){var e,r=Object.create(v,(i(e={},c,{value:t,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,f,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var n=r[c].read();n?(r[l]=null,r[a]=null,r[s]=null,t(p(n,!1))):(r[a]=t,r[s]=e)},writable:!0}),e));return r[l]=null,o(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[s];return null!==e&&(r[l]=null,r[a]=null,r[s]=null,e(t)),void(r[u]=t)}var n=r[a];null!==n&&(r[l]=null,r[a]=null,r[s]=null,n(p(void 0,!0))),r[f]=!0})),t.on("readable",y.bind(null,r)),r}},1396:(t,e,r)=>{"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var a=r(1664).Buffer,s=r(9031).inspect,u=s&&s.custom||"inspect";t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r,f;return e=t,r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return a.alloc(0);for(var e,r,n,i=a.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,a.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=a.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:u,value:function(t,e){return s(this,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},e,{depth:0,customInspect:!1}))}}],r&&o(e.prototype,r),f&&o(e,f),t}()},8522:t=>{"use strict";function e(t,e){n(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function n(t,e){t.emit("error",e)}t.exports={destroy:function(t,i){var o=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(e,o,t)):process.nextTick(e,o,t):i?(process.nextTick(r,o),i(t)):process.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},3790:(t,e,r)=>{"use strict";var n=r(8870).q.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||l()},f=e._writableState&&e._writableState.finished,l=function(){s=!1,f=!0,a||o.call(e)},h=e._readableState&&e._readableState.endEmitted,c=function(){a=!1,h=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!h?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!f?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",l)};return!function(t){return t.setHeader&&"function"==typeof t.abort}(e)?s&&!e._writableState&&(e.on("end",u),e.on("close",u)):(e.on("complete",l),e.on("abort",d),e.req?y():e.on("request",y)),e.on("end",c),e.on("finish",l),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",l),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",l),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("end",c),e.removeListener("error",p),e.removeListener("close",d)}}},8881:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},8155:(t,e,r)=>{"use strict";var n;var i=r(8870).q,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(t){if(t)throw t}function u(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var s=!1;t.on("close",(function(){s=!0})),void 0===n&&(n=r(3790)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);s=!0,o()}));var u=!1;return function(e){if(!s&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new a("pipe"))}}function f(t){t()}function l(t,e){return t.pipe(e)}function h(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}t.exports=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n,i=h(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var a=e.map((function(t,r){var o=r<e.length-1;return u(t,o,r>0,(function(t){n||(n=t),t&&a.forEach(f),o||(a.forEach(f),i(n))}))}));return e.reduce(l)}},1379:(t,e,r)=>{"use strict";var n=r(8870).q.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},4150:(t,e,r)=>{t.exports=r(7988).EventEmitter},8043:(t,e,r)=>{t.exports=i;var n=r(7988).EventEmitter;function i(){n.call(this)}r(5717)(i,n),i.Readable=r(4459),i.Writable=r(4987),i.Duplex=r(3536),i.Transform=r(6695),i.PassThrough=r(8373),i.finished=r(3790),i.pipeline=r(8155),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function f(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",f),t.removeListener("error",f),r.removeListener("end",l),r.removeListener("close",l),t.removeListener("close",l)}return r.on("error",f),t.on("error",f),r.on("end",l),r.on("close",l),t.on("close",l),t.emit("pipe",r),t}},140:(t,e,r)=>{"use strict";var n=r(9509).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=f,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=l,this.end=h,e=3;break;default:return this.write=c,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"<22>";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"<22>";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"<22>"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function f(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function l(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function h(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function c(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.s=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"<22>":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);if(i>=0)return i>0&&(t.lastNeed=i-1),i;if(--n<r||-2===i)return 0;if((i=a(e[n]))>=0)return i>0&&(t.lastNeed=i-2),i;if(--n<r||-2===i)return 0;if((i=a(e[n]))>=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},8526:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},747:(t,e,r)=>{"use strict";var n=r(1664).Buffer,i=r(9530),o=r(2861),a=r(1494).N,s=(r(1943),r(6547),r(858));function u(t,e){var r;try{r=new a(t)}catch(t){return void e(t)}if(r.numFrames()>0){var n=[r.numFrames(),r.height,r.width,4],i=new Uint8Array(n[0]*n[1]*n[2]*n[3]),s=o(i,n);try{for(var u=0;u<r.numFrames();++u)r.decodeAndBlitFrameRGBA(u,i.subarray(s.index(u,0,0,0),s.index(u+1,0,0,0)))}catch(t){return void e(t)}e(null,s.transpose(0,2,1))}else{n=[r.height,r.width,4],i=new Uint8Array(n[0]*n[1]*n[2]),s=o(i,n);try{r.decodeAndBlitFrameRGBA(0,i)}catch(t){return void e(t)}e(null,s.transpose(1,0))}}function f(t,e){process.nextTick((function(){try{var r=s(t);r?u(function(t){if(void 0===t[0]){for(var e=t.length,r=new Uint8Array(e),n=0;n<e;++n)r[n]=t.get(n);return r}return new Uint8Array(t)}(r),e):e(new Error("Error parsing data URI"))}catch(t){e(t)}}))}t.exports=function(t,e,r){r||(r=e,e="");var a=i.extname(t);if(".GIF"===(e||a.toUpperCase()))!function(t,e){var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.overrideMimeType&&r.overrideMimeType("application/binary"),r.onerror=function(t){e(t)},r.onload=function(){4===r.readyState&&u(new Uint8Array(r.response),e)},r.send()}(t,r);else n.isBuffer(t)&&(t="data:"+e+";base64,"+t.toString("base64")),0===t.indexOf("data:image/gif;")?f(t,r):function(t,e){var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){var t=document.createElement("canvas");t.width=r.width,t.height=r.height;var n=t.getContext("2d");n.drawImage(r,0,0);var i=n.getImageData(0,0,r.width,r.height);e(null,o(new Uint8Array(i.data),[r.width,r.height,4],[4,4*r.width,1],0))},r.onerror=function(t){e(t)},r.src=t}(t,r)}},8908:(t,e,r)=>{var n;n="undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},t.exports=n},645:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,f=u>>1,l=-7,h=r?i-1:0,c=r?-1:1,p=t[e+h];for(h+=c,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+t[e+h],h+=c,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+t[e+h],h+=c,l-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=f}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,f=8*o-i-1,l=(1<<f)-1,h=l>>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+h>=1?c/u:c*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=l?(s=0,a=l):a+h>=1?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,f+=i;f>0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*y}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},6907:t=>{"use strict";t.exports=function(t){for(var e=new Array(t),r=0;r<t;++r)e[r]=r;return e}},8738:t=>{function e(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}t.exports=function(t){return null!=t&&(e(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&e(t.slice(0,0))}(t)||!!t._isBuffer)}},7376:t=>{t.exports=function(t){if(!t)return!1;var r=e.call(t);return"[object Function]"===r||"function"==typeof t&&"[object RegExp]"!==r||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)};var e=Object.prototype.toString},1943:(t,e,r)=>{"use strict";var n=r(2861),i=r(1895);t.exports=function(t,e){for(var r=[],o=t,a=1;Array.isArray(o);)r.push(o.length),a*=o.length,o=o[0];return 0===r.length?n():(e||(e=n(new Float64Array(a),r)),i(e,t),e)}},1895:(t,e,r)=>{t.exports=r(6239)({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},2861:(t,e,r)=>{var n=r(6907),i=r(8738),o="undefined"!=typeof Float64Array;function a(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,r=new Array(e.length);for(t=0;t<r.length;++t)r[t]=[Math.abs(e[t]),t];r.sort(a);var n=new Array(r.length);for(t=0;t<n.length;++t)n[t]=r[t][1];return n}function u(t,e){var r=["View",e,"d",t].join("");e<0&&(r="View_Nil"+t);var i="generic"===t;if(-1===e){var o="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}";return new Function(o)()}if(0===e){o="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}";return new Function("TrivialArray",o)(f[t][0])}o=["'use strict'"];var a=n(e),u=a.map((function(t){return"i"+t})),l="this.offset+"+a.map((function(t){return"this.stride["+t+"]*i"+t})).join("+"),h=a.map((function(t){return"b"+t})).join(","),c=a.map((function(t){return"c"+t})).join(",");o.push("function "+r+"(a,"+h+","+c+",d){this.data=a","this.shape=["+h+"]","this.stride=["+c+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),o.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+a.map((function(t){return"this.shape["+t+"]"})).join("*"),"}})"),1===e?o.push("proto.order=[0]"):(o.push("Object.defineProperty(proto,'order',{get:"),e<4?(o.push("function "+r+"_order(){"),2===e?o.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&o.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):o.push("ORDER})")),o.push("proto.set=function "+r+"_set("+u.join(",")+",v){"),i?o.push("return this.data.set("+l+",v)}"):o.push("return this.data["+l+"]=v}"),o.push("proto.get=function "+r+"_get("+u.join(",")+"){"),i?o.push("return this.data.get("+l+")}"):o.push("return this.data["+l+"]}"),o.push("proto.index=function "+r+"_index(",u.join(),"){return "+l+"}"),o.push("proto.hi=function "+r+"_hi("+u.join(",")+"){return new "+r+"(this.data,"+a.map((function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")})).join(",")+","+a.map((function(t){return"this.stride["+t+"]"})).join(",")+",this.offset)}");var p=a.map((function(t){return"a"+t+"=this.shape["+t+"]"})),d=a.map((function(t){return"c"+t+"=this.stride["+t+"]"}));o.push("proto.lo=function "+r+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+d.join(","));for(var y=0;y<e;++y)o.push("if(typeof i"+y+"==='number'&&i"+y+">=0){d=i"+y+"|0;b+=c"+y+"*d;a"+y+"-=d}");o.push("return new "+r+"(this.data,"+a.map((function(t){return"a"+t})).join(",")+","+a.map((function(t){return"c"+t})).join(",")+",b)}"),o.push("proto.step=function "+r+"_step("+u.join(",")+"){var "+a.map((function(t){return"a"+t+"=this.shape["+t+"]"})).join(",")+","+a.map((function(t){return"b"+t+"=this.stride["+t+"]"})).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(y=0;y<e;++y)o.push("if(typeof i"+y+"==='number'){d=i"+y+"|0;if(d<0){c+=b"+y+"*(a"+y+"-1);a"+y+"=ceil(-a"+y+"/d)}else{a"+y+"=ceil(a"+y+"/d)}b"+y+"*=d}");o.push("return new "+r+"(this.data,"+a.map((function(t){return"a"+t})).join(",")+","+a.map((function(t){return"b"+t})).join(",")+",c)}");var g=new Array(e),v=new Array(e);for(y=0;y<e;++y)g[y]="a[i"+y+"]",v[y]="b[i"+y+"]";o.push("proto.transpose=function "+r+"_transpose("+u+"){"+u.map((function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"})).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+g.join(",")+","+v.join(",")+",this.offset)}"),o.push("proto.pick=function "+r+"_pick("+u+"){var a=[],b=[],c=this.offset");for(y=0;y<e;++y)o.push("if(typeof i"+y+"==='number'&&i"+y+">=0){c=(c+this.stride["+y+"]*i"+y+")|0}else{a.push(this.shape["+y+"]);b.push(this.stride["+y+"])}");return o.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),o.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+a.map((function(t){return"shape["+t+"]"})).join(",")+","+a.map((function(t){return"stride["+t+"]"})).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",o.join("\n"))(f[t],s)}var f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};t.exports=function(t,e,r,n){if(void 0===t)return(0,f.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var a=e.length;if(void 0===r){r=new Array(a);for(var s=a-1,l=1;s>=0;--s)r[s]=l,l*=e[s]}if(void 0===n){n=0;for(s=0;s<a;++s)r[s]<0&&(n-=(e[s]-1)*r[s])}for(var h=function(t){if(i(t))return"buffer";if(o)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(t)?"array":"generic"}(t),c=f[h];c.length<=a+1;)c.push(u(h,c.length-1));return(0,c[a+1])(t,e,r,n)}},1494:(t,e)=>{"use strict";function r(t,e,r,n){for(var i=t[e++],o=1<<i,a=o+1,s=a+1,u=i+1,f=(1<<u)-1,l=0,h=0,c=0,p=t[e++],d=new Int32Array(4096),y=null;;){for(;l<16&&0!==p;)h|=t[e++]<<l,l+=8,1===p?p=t[e++]:--p;if(l<u)break;var g=h&f;if(h>>=u,l-=u,g!==o){if(g===a)break;for(var v=g<s?g:y,b=0,m=v;m>o;)m=d[m]>>8,++b;var w=m;if(c+b+(v!==g?1:0)>n)return;r[c++]=w;var x=c+=b;for(v!==g&&(r[c++]=w),m=v;b--;)m=d[m],r[--x]=255&m,m>>=8;null!==y&&s<4096&&(d[s++]=y<<8|w,s>=f+1&&u<12&&(++u,f=f<<1|1)),y=g}else s=a+1,f=(1<<(u=i+1))-1,y=null}return r}try{(function(t,e,r,n){var i=0,o=void 0===(n=void 0===n?{}:n).loop?null:n.loop,a=void 0===n.palette?null:n.palette;if(e<=0||r<=0||e>65535||r>65535)throw new Error("Width/Height invalid.");function s(t){var e=t.length;if(e<2||e>256||e&e-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return e}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;var u=0,f=0;if(null!==a){for(var l=s(a);l>>=1;)++u;if(l=1<<u,--u,void 0!==n.background){if((f=n.background)>=l)throw new Error("Background index out of range.");if(0===f)throw new Error("Background index explicitly passed as 0.")}}if(t[i++]=255&e,t[i++]=e>>8&255,t[i++]=255&r,t[i++]=r>>8&255,t[i++]=(null!==a?128:0)|u,t[i++]=f,t[i++]=0,null!==a)for(var h=0,c=a.length;h<c;++h){var p=a[h];t[i++]=p>>16&255,t[i++]=p>>8&255,t[i++]=255&p}if(null!==o){if(o<0||o>65535)throw new Error("Loop count invalid.");t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=255&o,t[i++]=o>>8&255,t[i++]=0}var d=!1;this.addFrame=function(e,r,n,o,u,f){if(!0===d&&(--i,d=!1),f=void 0===f?{}:f,e<0||r<0||e>65535||r>65535)throw new Error("x/y invalid.");if(n<=0||o<=0||n>65535||o>65535)throw new Error("Width/Height invalid.");if(u.length<n*o)throw new Error("Not enough pixels for the frame size.");var l=!0,h=f.palette;if(null==h&&(l=!1,h=a),null==h)throw new Error("Must supply either a local or global palette.");for(var c=s(h),p=0;c>>=1;)++p;c=1<<p;var y=void 0===f.delay?0:f.delay,g=void 0===f.disposal?0:f.disposal;if(g<0||g>3)throw new Error("Disposal out of range.");var v=!1,b=0;if(void 0!==f.transparent&&null!==f.transparent&&(v=!0,(b=f.transparent)<0||b>=c))throw new Error("Transparent color index.");if((0!==g||v||0!==y)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=g<<2|(!0===v?1:0),t[i++]=255&y,t[i++]=y>>8&255,t[i++]=b,t[i++]=0),t[i++]=44,t[i++]=255&e,t[i++]=e>>8&255,t[i++]=255&r,t[i++]=r>>8&255,t[i++]=255&n,t[i++]=n>>8&255,t[i++]=255&o,t[i++]=o>>8&255,t[i++]=!0===l?128|p-1:0,!0===l)for(var m=0,w=h.length;m<w;++m){var x=h[m];t[i++]=x>>16&255,t[i++]=x>>8&255,t[i++]=255&x}return i=function(t,e,r,n){t[e++]=r;var i=e++,o=1<<r,a=o-1,s=o+1,u=s+1,f=r+1,l=0,h=0;function c(r){for(;l>=r;)t[e++]=255&h,h>>=8,l-=8,e===i+256&&(t[i]=255,i=e++)}function p(t){h|=t<<l,l+=f,c(8)}var d=n[0]&a,y={};p(o);for(var g=1,v=n.length;g<v;++g){var b=n[g]&a,m=d<<8|b,w=y[m];if(void 0===w){for(h|=d<<l,l+=f;l>=8;)t[e++]=255&h,h>>=8,l-=8,e===i+256&&(t[i]=255,i=e++);4096===u?(p(o),u=s+1,f=r+1,y={}):(u>=1<<f&&++f,y[m]=u++),d=b}else d=w}return p(d),p(s),c(1),i+1===e?t[i]=0:(t[i]=e-i-1,t[e++]=0),e}(t,i,p<2?2:p,u),i},this.end=function(){return!1===d&&(t[i++]=59,d=!0),i},this.getOutputBuffer=function(){return t},this.setOutputBuffer=function(e){t=e},this.getOutputBufferPosition=function(){return i},this.setOutputBufferPosition=function(t){i=t}}),e.N=function(t){var e=0;if(71!==t[e++]||73!==t[e++]||70!==t[e++]||56!==t[e++]||56!=(t[e++]+1&253)||97!==t[e++])throw new Error("Invalid GIF 87a/89a header.");var n=t[e++]|t[e++]<<8,i=t[e++]|t[e++]<<8,o=t[e++],a=o>>7,s=1<<1+(7&o);t[e++],t[e++];var u=null,f=null;a&&(u=e,f=s,e+=3*s);var l=!0,h=[],c=0,p=null,d=0,y=null;for(this.width=n,this.height=i;l&&e<t.length;)switch(t[e++]){case 33:switch(t[e++]){case 255:if(11!==t[e]||78==t[e+1]&&69==t[e+2]&&84==t[e+3]&&83==t[e+4]&&67==t[e+5]&&65==t[e+6]&&80==t[e+7]&&69==t[e+8]&&50==t[e+9]&&46==t[e+10]&&48==t[e+11]&&3==t[e+12]&&1==t[e+13]&&0==t[e+16])e+=14,y=t[e++]|t[e++]<<8,e++;else for(e+=12;;){if(!((A=t[e++])>=0))throw Error("Invalid block size");if(0===A)break;e+=A}break;case 249:if(4!==t[e++]||0!==t[e+4])throw new Error("Invalid graphics extension block.");var g=t[e++];c=t[e++]|t[e++]<<8,p=t[e++],0==(1&g)&&(p=null),d=g>>2&7,e++;break;case 254:for(;;){if(!((A=t[e++])>=0))throw Error("Invalid block size");if(0===A)break;e+=A}break;default:throw new Error("Unknown graphic control label: 0x"+t[e-1].toString(16))}break;case 44:var v=t[e++]|t[e++]<<8,b=t[e++]|t[e++]<<8,m=t[e++]|t[e++]<<8,w=t[e++]|t[e++]<<8,x=t[e++],_=x>>6&1,E=1<<1+(7&x),S=u,k=f,M=!1;x>>7&&(M=!0,S=e,k=E,e+=3*E);var R=e;for(e++;;){var A;if(!((A=t[e++])>=0))throw Error("Invalid block size");if(0===A)break;e+=A}h.push({x:v,y:b,width:m,height:w,has_local_palette:M,palette_offset:S,palette_size:k,data_offset:R,data_length:e-R,transparent_index:p,interlaced:!!_,delay:c,disposal:d});break;case 59:l=!1;break;default:throw new Error("Unknown gif block: 0x"+t[e-1].toString(16))}this.numFrames=function(){return h.length},this.loopCount=function(){return y},this.frameInfo=function(t){if(t<0||t>=h.length)throw new Error("Frame index out of range.");return h[t]},this.decodeAndBlitFrameBGRA=function(e,i){var o=this.frameInfo(e),a=o.width*o.height,s=new Uint8Array(a);r(t,o.data_offset,s,a);var u=o.palette_offset,f=o.transparent_index;null===f&&(f=256);var l=o.width,h=n-l,c=l,p=4*(o.y*n+o.x),d=4*((o.y+o.height)*n+o.x),y=p,g=4*h;!0===o.interlaced&&(g+=4*n*7);for(var v=8,b=0,m=s.length;b<m;++b){var w=s[b];if(0===c&&(c=l,(y+=g)>=d&&(g=4*h+4*n*(v-1),y=p+(l+h)*(v<<1),v>>=1)),w===f)y+=4;else{var x=t[u+3*w],_=t[u+3*w+1],E=t[u+3*w+2];i[y++]=E,i[y++]=_,i[y++]=x,i[y++]=255}--c}},this.decodeAndBlitFrameRGBA=function(e,i){var o=this.frameInfo(e),a=o.width*o.height,s=new Uint8Array(a);r(t,o.data_offset,s,a);var u=o.palette_offset,f=o.transparent_index;null===f&&(f=256);var l=o.width,h=n-l,c=l,p=4*(o.y*n+o.x),d=4*((o.y+o.height)*n+o.x),y=p,g=4*h;!0===o.interlaced&&(g+=4*n*7);for(var v=8,b=0,m=s.length;b<m;++b){var w=s[b];if(0===c&&(c=l,(y+=g)>=d&&(g=4*h+4*n*(v-1),y=p+(l+h)*(v<<1),v>>=1)),w===f)y+=4;else{var x=t[u+3*w],_=t[u+3*w+1],E=t[u+3*w+2];i[y++]=x,i[y++]=_,i[y++]=E,i[y++]=255}--c}}}}catch(t){}},4947:t=>{var e=function(t){return t.replace(/^\s+|\s+$/g,"")};t.exports=function(t){if(!t)return{};for(var r,n={},i=e(t).split("\n"),o=0;o<i.length;o++){var a=i[o],s=a.indexOf(":"),u=e(a.slice(0,s)).toLowerCase(),f=e(a.slice(s+1));void 0===n[u]?n[u]=f:(r=n[u],"[object Array]"===Object.prototype.toString.call(r)?n[u].push(f):n[u]=[n[u],f])}return n}},3614:(t,e,r)=>{"use strict";t.exports=i;var n=r(645);function i(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}i.Varint=0,i.Fixed64=1,i.Bytes=2,i.Fixed32=5;var o=4294967296,a=1/o,s="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function u(t){return t.type===i.Bytes?t.readVarint()+t.pos:t.pos+1}function f(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function l(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function h(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function c(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function p(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function d(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function y(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function g(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function v(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function b(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function m(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function w(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function x(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function _(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}i.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),i=n>>3,o=this.pos;this.type=7&n,t(i,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=w(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=_(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=w(this.buf,this.pos)+w(this.buf,this.pos+4)*o;return this.pos+=8,t},readSFixed64:function(){var t=w(this.buf,this.pos)+_(this.buf,this.pos+4)*o;return this.pos+=8,t},readFloat:function(){var t=n.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=n.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,o=r.buf;if(i=o[r.pos++],n=(112&i)>>4,i<128)return f(t,n,e);if(i=o[r.pos++],n|=(127&i)<<3,i<128)return f(t,n,e);if(i=o[r.pos++],n|=(127&i)<<10,i<128)return f(t,n,e);if(i=o[r.pos++],n|=(127&i)<<17,i<128)return f(t,n,e);if(i=o[r.pos++],n|=(127&i)<<24,i<128)return f(t,n,e);if(i=o[r.pos++],n|=(1&i)<<31,i<128)return f(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&s?function(t,e,r){return s.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){var n="",i=e;for(;i<r;){var o,a,s,u=t[i],f=null,l=u>239?4:u>223?3:u>191?2:1;if(i+l>r)break;1===l?u<128&&(f=u):2===l?128==(192&(o=t[i+1]))&&(f=(31&u)<<6|63&o)<=127&&(f=null):3===l?(o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&((f=(15&u)<<12|(63&o)<<6|63&a)<=2047||f>=55296&&f<=57343)&&(f=null)):4===l&&(o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&((f=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||f>=1114112)&&(f=null)),null===f?(f=65533,l=1):f>65535&&(f-=65536,n+=String.fromCharCode(f>>>10&1023|55296),f=56320|1023&f),n+=String.fromCharCode(f),i+=l}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==i.Bytes)return t.push(this.readVarint(e));var r=u(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==i.Bytes)return t.push(this.readSVarint());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==i.Bytes)return t.push(this.readBoolean());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==i.Bytes)return t.push(this.readFloat());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==i.Bytes)return t.push(this.readDouble());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==i.Bytes)return t.push(this.readFixed32());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==i.Bytes)return t.push(this.readSFixed32());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==i.Bytes)return t.push(this.readFixed64());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==i.Bytes)return t.push(this.readSFixed64());var e=u(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===i.Varint)for(;this.buf[this.pos++]>127;);else if(e===i.Bytes)this.pos=this.readVarint()+this.pos;else if(e===i.Fixed32)this.pos+=4;else{if(e!==i.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),x(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),x(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),x(this.buf,-1&t,this.pos),x(this.buf,Math.floor(t*a),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),x(this.buf,-1&t,this.pos),x(this.buf,Math.floor(t*a),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var r,n;t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos]=127&t}(r,0,e),function(t,e){var r=(7&t)<<4;if(e.buf[e.pos++]|=r|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,o=0;o<e.length;o++){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){n>56319||o+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&l(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),n.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),n.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var n=this.pos-r;n>=128&&l(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,i.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,y,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,g,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,v,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,b,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writeBytesField:function(t,e){this.writeTag(t,i.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,i.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,i.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,i.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,i.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,i.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,i.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,i.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,i.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,i.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}}},2676:function(t){t.exports=function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}var n=function(){function t(t,e){this.next=null,this.key=t,this.data=e,this.left=null,this.right=null}return t}();function i(t,e){return t>e?1:t<e?-1:0}function o(t,e,r){for(var i=new n(null,null),o=i,a=i;;){var s=r(t,e.key);if(s<0){if(null===e.left)break;if(r(t,e.left.key)<0){var u=e.left;if(e.left=u.right,u.right=e,null===(e=u).left)break}a.left=e,a=e,e=e.left}else{if(!(s>0))break;if(null===e.right)break;if(r(t,e.right.key)>0&&(u=e.right,e.right=u.left,u.left=e,null===(e=u).right))break;o.right=e,o=e,e=e.right}}return o.right=e.left,a.left=e.right,e.left=i.right,e.right=i.left,e}function a(t,e,r,i){var a=new n(t,e);if(null===r)return a.left=a.right=null,a;var s=i(t,(r=o(t,r,i)).key);return s<0?(a.left=r.left,a.right=r,r.left=null):s>=0&&(a.right=r.right,a.left=r,r.right=null),a}function s(t,e,r){var n=null,i=null;if(e){var a=r((e=o(t,e,r)).key,t);0===a?(n=e.left,i=e.right):a<0?(i=e.right,e.right=null,n=e):(n=e.left,e.left=null,i=e)}return{left:n,right:i}}function u(t,e,r){return null===e?t:(null===t||((e=o(t.key,e,r)).left=t),e)}function f(t,e,r,n,i){if(t){n(e+(r?"└── ":"├── ")+i(t)+"\n");var o=e+(r?" ":"│ ");t.left&&f(t.left,o,!1,n,i),t.right&&f(t.right,o,!0,n,i)}}var l=function(){function t(t){void 0===t&&(t=i),this._root=null,this._size=0,this._comparator=t}return t.prototype.insert=function(t,e){return this._size++,this._root=a(t,e,this._root,this._comparator)},t.prototype.add=function(t,e){var r=new n(t,e);null===this._root&&(r.left=r.right=null,this._size++,this._root=r);var i=this._comparator,a=o(t,this._root,i),s=i(t,a.key);return 0===s?this._root=a:(s<0?(r.left=a.left,r.right=a,a.left=null):s>0&&(r.right=a.right,r.left=a,a.right=null),this._size++,this._root=r),this._root},t.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},t.prototype._remove=function(t,e,r){var n;return null===e?null:0===r(t,(e=o(t,e,r)).key)?(null===e.left?n=e.right:(n=o(t,e.left,r)).right=e.right,this._size--,n):e},t.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=o(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data}}return null},t.prototype.findStatic=function(t){for(var e=this._root,r=this._comparator;e;){var n=r(t,e.key);if(0===n)return e;e=n<0?e.left:e.right}return null},t.prototype.find=function(t){return this._root&&(this._root=o(t,this._root,this._comparator),0!==this._comparator(t,this._root.key))?null:this._root},t.prototype.contains=function(t){for(var e=this._root,r=this._comparator;e;){var n=r(t,e.key);if(0===n)return!0;e=n<0?e.left:e.right}return!1},t.prototype.forEach=function(t,e){for(var r=this._root,n=[],i=!1;!i;)null!==r?(n.push(r),r=r.left):0!==n.length?(r=n.pop(),t.call(e,r),r=r.right):i=!0;return this},t.prototype.range=function(t,e,r,n){for(var i=[],o=this._comparator,a=this._root;0!==i.length||a;)if(a)i.push(a),a=a.left;else{if(o((a=i.pop()).key,e)>0)break;if(o(a.key,t)>=0&&r.call(n,a))return this;a=a.right}return this},t.prototype.keys=function(){var t=[];return this.forEach((function(e){var r=e.key;return t.push(r)})),t},t.prototype.values=function(){var t=[];return this.forEach((function(e){var r=e.data;return t.push(r)})),t},t.prototype.min=function(){return this._root?this.minNode(this._root).key:null},t.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},t.prototype.minNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.left;)t=t.left;return t},t.prototype.maxNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.right;)t=t.right;return t},t.prototype.at=function(t){for(var e=this._root,r=!1,n=0,i=[];!r;)if(e)i.push(e),e=e.left;else if(i.length>0){if(e=i.pop(),n===t)return e;n++,e=e.right}else r=!0;return null},t.prototype.next=function(t){var e=this._root,r=null;if(t.right){for(r=t.right;r.left;)r=r.left;return r}for(var n=this._comparator;e;){var i=n(t.key,e.key);if(0===i)break;i<0?(r=e,e=e.left):e=e.right}return r},t.prototype.prev=function(t){var e=this._root,r=null;if(null!==t.left){for(r=t.left;r.right;)r=r.right;return r}for(var n=this._comparator;e;){var i=n(t.key,e.key);if(0===i)break;i<0?e=e.left:(r=e,e=e.right)}return r},t.prototype.clear=function(){return this._root=null,this._size=0,this},t.prototype.toList=function(){return p(this._root)},t.prototype.load=function(t,e,r){void 0===e&&(e=[]),void 0===r&&(r=!1);var n=t.length,i=this._comparator;if(r&&g(t,e,0,n-1,i),null===this._root)this._root=h(t,e,0,n),this._size=n;else{var o=y(this.toList(),c(t,e),i);n=this._size+n,this._root=d({head:o},0,n)}return this},t.prototype.isEmpty=function(){return null===this._root},Object.defineProperty(t.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),t.prototype.toString=function(t){void 0===t&&(t=function(t){return String(t.key)});var e=[];return f(this._root,"",!0,(function(t){return e.push(t)}),t),e.join("")},t.prototype.update=function(t,e,r){var n=this._comparator,i=s(t,this._root,n),o=i.left,f=i.right;n(t,e)<0?f=a(e,r,f,n):o=a(e,r,o,n),this._root=u(o,f,n)},t.prototype.split=function(t){return s(t,this._root,this._comparator)},t}();function h(t,e,r,i){var o=i-r;if(o>0){var a=r+Math.floor(o/2),s=t[a],u=e[a],f=new n(s,u);return f.left=h(t,e,r,a),f.right=h(t,e,a+1,i),f}return null}function c(t,e){for(var r=new n(null,null),i=r,o=0;o<t.length;o++)i=i.next=new n(t[o],e[o]);return i.next=null,r.next}function p(t){for(var e=t,r=[],i=!1,o=new n(null,null),a=o;!i;)e?(r.push(e),e=e.left):r.length>0?e=(e=a=a.next=r.pop()).right:i=!0;return a.next=null,o.next}function d(t,e,r){var n=r-e;if(n>0){var i=e+Math.floor(n/2),o=d(t,e,i),a=t.head;return a.left=o,t.head=t.head.next,a.right=d(t,i+1,r),a}return null}function y(t,e,r){for(var i=new n(null,null),o=i,a=t,s=e;null!==a&&null!==s;)r(a.key,s.key)<0?(o.next=a,a=a.next):(o.next=s,s=s.next),o=o.next;return null!==a?o.next=a:null!==s&&(o.next=s),i.next}function g(t,e,r,n,i){if(!(r>=n)){for(var o=t[r+n>>1],a=r-1,s=n+1;;){do{a++}while(i(t[a],o)<0);do{s--}while(i(t[s],o)>0);if(a>=s)break;var u=t[a];t[a]=t[s],t[s]=u,u=e[a],e[a]=e[s],e[s]=u}g(t,e,r,s,i),g(t,e,s+1,n,i)}}var v=function(t,e){return t.ll.x<=e.x&&e.x<=t.ur.x&&t.ll.y<=e.y&&e.y<=t.ur.y},b=function(t,e){if(e.ur.x<t.ll.x||t.ur.x<e.ll.x||e.ur.y<t.ll.y||t.ur.y<e.ll.y)return null;var r=t.ll.x<e.ll.x?e.ll.x:t.ll.x,n=t.ur.x<e.ur.x?t.ur.x:e.ur.x;return{ll:{x:r,y:t.ll.y<e.ll.y?e.ll.y:t.ll.y},ur:{x:n,y:t.ur.y<e.ur.y?t.ur.y:e.ur.y}}},m=Number.EPSILON;void 0===m&&(m=Math.pow(2,-52));var w=m*m,x=function(t,e){if(-m<t&&t<m&&-m<e&&e<m)return 0;var r=t-e;return r*r<w*t*e?0:t<e?-1:1},_=function(){function e(){t(this,e),this.reset()}return r(e,[{key:"reset",value:function(){this.xRounder=new E,this.yRounder=new E}},{key:"round",value:function(t,e){return{x:this.xRounder.round(t),y:this.yRounder.round(e)}}}]),e}(),E=function(){function e(){t(this,e),this.tree=new l,this.round(0)}return r(e,[{key:"round",value:function(t){var e=this.tree.add(t),r=this.tree.prev(e);if(null!==r&&0===x(e.key,r.key))return this.tree.remove(t),r.key;var n=this.tree.next(e);return null!==n&&0===x(e.key,n.key)?(this.tree.remove(t),n.key):t}}]),e}(),S=new _,k=function(t,e){return t.x*e.y-t.y*e.x},M=function(t,e){return t.x*e.x+t.y*e.y},R=function(t,e,r){var n={x:e.x-t.x,y:e.y-t.y},i={x:r.x-t.x,y:r.y-t.y},o=k(n,i);return x(o,0)},A=function(t){return Math.sqrt(M(t,t))},j=function(t,e,r){var n={x:e.x-t.x,y:e.y-t.y},i={x:r.x-t.x,y:r.y-t.y};return k(i,n)/A(i)/A(n)},T=function(t,e,r){var n={x:e.x-t.x,y:e.y-t.y},i={x:r.x-t.x,y:r.y-t.y};return M(i,n)/A(i)/A(n)},P=function(t,e,r){return 0===e.y?null:{x:t.x+e.x/e.y*(r-t.y),y:r}},I=function(t,e,r){return 0===e.x?null:{x:r,y:t.y+e.y/e.x*(r-t.x)}},B=function(t,e,r,n){if(0===e.x)return I(r,n,t.x);if(0===n.x)return I(t,e,r.x);if(0===e.y)return P(r,n,t.y);if(0===n.y)return P(t,e,r.y);var i=k(e,n);if(0==i)return null;var o={x:r.x-t.x,y:r.y-t.y},a=k(o,e)/i,s=k(o,n)/i;return{x:(t.x+s*e.x+(r.x+a*n.x))/2,y:(t.y+s*e.y+(r.y+a*n.y))/2}},L=function(){function e(r,n){t(this,e),void 0===r.events?r.events=[this]:r.events.push(this),this.point=r,this.isLeft=n}return r(e,null,[{key:"compare",value:function(t,r){var n=e.comparePoints(t.point,r.point);return 0!==n?n:(t.point!==r.point&&t.link(r),t.isLeft!==r.isLeft?t.isLeft?1:-1:C.compare(t.segment,r.segment))}},{key:"comparePoints",value:function(t,e){return t.x<e.x?-1:t.x>e.x?1:t.y<e.y?-1:t.y>e.y?1:0}}]),r(e,[{key:"link",value:function(t){if(t.point===this.point)throw new Error("Tried to link already linked events");for(var e=t.point.events,r=0,n=e.length;r<n;r++){var i=e[r];this.point.events.push(i),i.point=this.point}this.checkForConsuming()}},{key:"checkForConsuming",value:function(){for(var t=this.point.events.length,e=0;e<t;e++){var r=this.point.events[e];if(void 0===r.segment.consumedBy)for(var n=e+1;n<t;n++){var i=this.point.events[n];void 0===i.consumedBy&&r.otherSE.point.events===i.otherSE.point.events&&r.segment.consume(i.segment)}}}},{key:"getAvailableLinkedEvents",value:function(){for(var t=[],e=0,r=this.point.events.length;e<r;e++){var n=this.point.events[e];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&t.push(n)}return t}},{key:"getLeftmostComparator",value:function(t){var e=this,r=new Map,n=function(n){var i=n.otherSE;r.set(n,{sine:j(e.point,t.point,i.point),cosine:T(e.point,t.point,i.point)})};return function(t,e){r.has(t)||n(t),r.has(e)||n(e);var i=r.get(t),o=i.sine,a=i.cosine,s=r.get(e),u=s.sine,f=s.cosine;return o>=0&&u>=0?a<f?1:a>f?-1:0:o<0&&u<0?a<f?-1:a>f?1:0:u<o?-1:u>o?1:0}}}]),e}(),O=0,C=function(){function e(r,n,i,o){t(this,e),this.id=++O,this.leftSE=r,r.segment=this,r.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=r,this.rings=i,this.windings=o}return r(e,null,[{key:"compare",value:function(t,e){var r=t.leftSE.point.x,n=e.leftSE.point.x,i=t.rightSE.point.x,o=e.rightSE.point.x;if(o<r)return 1;if(i<n)return-1;var a=t.leftSE.point.y,s=e.leftSE.point.y,u=t.rightSE.point.y,f=e.rightSE.point.y;if(r<n){if(s<a&&s<u)return 1;if(s>a&&s>u)return-1;var l=t.comparePoint(e.leftSE.point);if(l<0)return 1;if(l>0)return-1;var h=e.comparePoint(t.rightSE.point);return 0!==h?h:-1}if(r>n){if(a<s&&a<f)return-1;if(a>s&&a>f)return 1;var c=e.comparePoint(t.leftSE.point);if(0!==c)return c;var p=t.comparePoint(e.rightSE.point);return p<0?1:p>0?-1:1}if(a<s)return-1;if(a>s)return 1;if(i<o){var d=e.comparePoint(t.rightSE.point);if(0!==d)return d}if(i>o){var y=t.comparePoint(e.rightSE.point);if(y<0)return 1;if(y>0)return-1}if(i!==o){var g=u-a,v=i-r,b=f-s,m=o-n;if(g>v&&b<m)return 1;if(g<v&&b>m)return-1}return i>o?1:i<o||u<f?-1:u>f?1:t.id<e.id?-1:t.id>e.id?1:0}}]),r(e,[{key:"replaceRightSE",value:function(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:t<e?t:e},ur:{x:this.rightSE.point.x,y:t>e?t:e}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(t){return t.x===this.leftSE.point.x&&t.y===this.leftSE.point.y||t.x===this.rightSE.point.x&&t.y===this.rightSE.point.y}},{key:"comparePoint",value:function(t){if(this.isAnEndpoint(t))return 0;var e=this.leftSE.point,r=this.rightSE.point,n=this.vector();if(e.x===r.x)return t.x===e.x?0:t.x<e.x?1:-1;var i=(t.y-e.y)/n.y,o=e.x+i*n.x;if(t.x===o)return 0;var a=(t.x-e.x)/n.x,s=e.y+a*n.y;return t.y===s?0:t.y<s?-1:1}},{key:"getIntersection",value:function(t){var e=this.bbox(),r=t.bbox(),n=b(e,r);if(null===n)return null;var i=this.leftSE.point,o=this.rightSE.point,a=t.leftSE.point,s=t.rightSE.point,u=v(e,a)&&0===this.comparePoint(a),f=v(r,i)&&0===t.comparePoint(i),l=v(e,s)&&0===this.comparePoint(s),h=v(r,o)&&0===t.comparePoint(o);if(f&&u)return h&&!l?o:!h&&l?s:null;if(f)return l&&i.x===s.x&&i.y===s.y?null:i;if(u)return h&&o.x===a.x&&o.y===a.y?null:a;if(h&&l)return null;if(h)return o;if(l)return s;var c=B(i,this.vector(),a,t.vector());return null===c?null:v(n,c)?S.round(c.x,c.y):null}},{key:"split",value:function(t){var r=[],n=void 0!==t.events,i=new L(t,!0),o=new L(t,!1),a=this.rightSE;this.replaceRightSE(o),r.push(o),r.push(i);var s=new e(i,a,this.rings.slice(),this.windings.slice());return L.comparePoints(s.leftSE.point,s.rightSE.point)>0&&s.swapEvents(),L.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(i.checkForConsuming(),o.checkForConsuming()),r}},{key:"swapEvents",value:function(){var t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var e=0,r=this.windings.length;e<r;e++)this.windings[e]*=-1}},{key:"consume",value:function(t){for(var r=this,n=t;r.consumedBy;)r=r.consumedBy;for(;n.consumedBy;)n=n.consumedBy;var i=e.compare(r,n);if(0!==i){if(i>0){var o=r;r=n,n=o}if(r.prev===n){var a=r;r=n,n=a}for(var s=0,u=n.rings.length;s<u;s++){var f=n.rings[s],l=n.windings[s],h=r.rings.indexOf(f);-1===h?(r.rings.push(f),r.windings.push(l)):r.windings[h]+=l}n.rings=null,n.windings=null,n.consumedBy=r,n.leftSE.consumedBy=r.leftSE,n.rightSE.consumedBy=r.rightSE}}},{key:"prevInResult",value:function(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}},{key:"beforeState",value:function(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){var t=this.prev.consumedBy||this.prev;this._beforeState=t.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}},{key:"afterState",value:function(){if(void 0!==this._afterState)return this._afterState;var t=this.beforeState();this._afterState={rings:t.rings.slice(0),windings:t.windings.slice(0),multiPolys:[]};for(var e=this._afterState.rings,r=this._afterState.windings,n=this._afterState.multiPolys,i=0,o=this.rings.length;i<o;i++){var a=this.rings[i],s=this.windings[i],u=e.indexOf(a);-1===u?(e.push(a),r.push(s)):r[u]+=s}for(var f=[],l=[],h=0,c=e.length;h<c;h++)if(0!==r[h]){var p=e[h],d=p.poly;if(-1===l.indexOf(d))if(p.isExterior)f.push(d);else{-1===l.indexOf(d)&&l.push(d);var y=f.indexOf(p.poly);-1!==y&&f.splice(y,1)}}for(var g=0,v=f.length;g<v;g++){var b=f[g].multiPoly;-1===n.indexOf(b)&&n.push(b)}return this._afterState}},{key:"isInResult",value:function(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;var t=this.beforeState().multiPolys,e=this.afterState().multiPolys;switch(H.type){case"union":var r=0===t.length,n=0===e.length;this._isInResult=r!==n;break;case"intersection":var i,o;t.length<e.length?(i=t.length,o=e.length):(i=e.length,o=t.length),this._isInResult=o===H.numMultiPolys&&i<o;break;case"xor":var a=Math.abs(t.length-e.length);this._isInResult=a%2==1;break;case"difference":var s=function(t){return 1===t.length&&t[0].isSubject};this._isInResult=s(t)!==s(e);break;default:throw new Error("Unrecognized operation type found ".concat(H.type))}return this._isInResult}}],[{key:"fromRing",value:function(t,r,n){var i,o,a,s=L.comparePoints(t,r);if(s<0)i=t,o=r,a=1;else{if(!(s>0))throw new Error("Tried to create degenerate segment at [".concat(t.x,", ").concat(t.y,"]"));i=r,o=t,a=-1}return new e(new L(i,!0),new L(o,!1),[n],[a])}}]),e}(),N=function(){function e(r,n,i){if(t(this,e),!Array.isArray(r)||0===r.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=i,this.segments=[],"number"!=typeof r[0][0]||"number"!=typeof r[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var o=S.round(r[0][0],r[0][1]);this.bbox={ll:{x:o.x,y:o.y},ur:{x:o.x,y:o.y}};for(var a=o,s=1,u=r.length;s<u;s++){if("number"!=typeof r[s][0]||"number"!=typeof r[s][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var f=S.round(r[s][0],r[s][1]);f.x===a.x&&f.y===a.y||(this.segments.push(C.fromRing(a,f,this)),f.x<this.bbox.ll.x&&(this.bbox.ll.x=f.x),f.y<this.bbox.ll.y&&(this.bbox.ll.y=f.y),f.x>this.bbox.ur.x&&(this.bbox.ur.x=f.x),f.y>this.bbox.ur.y&&(this.bbox.ur.y=f.y),a=f)}o.x===a.x&&o.y===a.y||this.segments.push(C.fromRing(a,o,this))}return r(e,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,r=this.segments.length;e<r;e++){var n=this.segments[e];t.push(n.leftSE),t.push(n.rightSE)}return t}}]),e}(),F=function(){function e(r,n){if(t(this,e),!Array.isArray(r))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new N(r[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(var i=1,o=r.length;i<o;i++){var a=new N(r[i],this,!1);a.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=a.bbox.ll.x),a.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=a.bbox.ll.y),a.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=a.bbox.ur.x),a.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=a.bbox.ur.y),this.interiorRings.push(a)}this.multiPoly=n}return r(e,[{key:"getSweepEvents",value:function(){for(var t=this.exteriorRing.getSweepEvents(),e=0,r=this.interiorRings.length;e<r;e++)for(var n=this.interiorRings[e].getSweepEvents(),i=0,o=n.length;i<o;i++)t.push(n[i]);return t}}]),e}(),U=function(){function e(r,n){if(t(this,e),!Array.isArray(r))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof r[0][0][0]&&(r=[r])}catch(t){}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(var i=0,o=r.length;i<o;i++){var a=new F(r[i],this);a.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=a.bbox.ll.x),a.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=a.bbox.ll.y),a.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=a.bbox.ur.x),a.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=a.bbox.ur.y),this.polys.push(a)}this.isSubject=n}return r(e,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,r=this.polys.length;e<r;e++)for(var n=this.polys[e].getSweepEvents(),i=0,o=n.length;i<o;i++)t.push(n[i]);return t}}]),e}(),D=function(){function e(r){t(this,e),this.events=r;for(var n=0,i=r.length;n<i;n++)r[n].segment.ringOut=this;this.poly=null}return r(e,null,[{key:"factory",value:function(t){for(var r=[],n=0,i=t.length;n<i;n++){var o=t[n];if(o.isInResult()&&!o.ringOut){for(var a=null,s=o.leftSE,u=o.rightSE,f=[s],l=s.point,h=[];a=s,s=u,f.push(s),s.point!==l;)for(;;){var c=s.getAvailableLinkedEvents();if(0===c.length){var p=f[0].point,d=f[f.length-1].point;throw new Error("Unable to complete output ring starting at [".concat(p.x,",")+" ".concat(p.y,"]. Last matching segment found ends at")+" [".concat(d.x,", ").concat(d.y,"]."))}if(1===c.length){u=c[0].otherSE;break}for(var y=null,g=0,v=h.length;g<v;g++)if(h[g].point===s.point){y=g;break}if(null===y){h.push({index:f.length,point:s.point});var b=s.getLeftmostComparator(a);u=c.sort(b)[0].otherSE;break}var m=h.splice(y)[0],w=f.splice(m.index);w.unshift(w[0].otherSE),r.push(new e(w.reverse()))}r.push(new e(f))}}return r}}]),r(e,[{key:"getGeom",value:function(){for(var t=this.events[0].point,e=[t],r=1,n=this.events.length-1;r<n;r++){var i=this.events[r].point,o=this.events[r+1].point;0!==R(i,t,o)&&(e.push(i),t=i)}if(1===e.length)return null;var a=e[0],s=e[1];0===R(a,t,s)&&e.shift(),e.push(e[0]);for(var u=this.isExteriorRing()?1:-1,f=this.isExteriorRing()?0:e.length-1,l=this.isExteriorRing()?e.length:-1,h=[],c=f;c!=l;c+=u)h.push([e[c].x,e[c].y]);return h}},{key:"isExteriorRing",value:function(){if(void 0===this._isExteriorRing){var t=this.enclosingRing();this._isExteriorRing=!t||!t.isExteriorRing()}return this._isExteriorRing}},{key:"enclosingRing",value:function(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}},{key:"_calcEnclosingRing",value:function(){for(var t=this.events[0],e=1,r=this.events.length;e<r;e++){var n=this.events[e];L.compare(t,n)>0&&(t=n)}for(var i=t.segment.prevInResult(),o=i?i.prevInResult():null;;){if(!i)return null;if(!o)return i.ringOut;if(o.ringOut!==i.ringOut)return o.ringOut.enclosingRing()!==i.ringOut?i.ringOut:i.ringOut.enclosingRing();i=o.prevInResult(),o=i?i.prevInResult():null}}}]),e}(),V=function(){function e(r){t(this,e),this.exteriorRing=r,r.poly=this,this.interiorRings=[]}return r(e,[{key:"addInterior",value:function(t){this.interiorRings.push(t),t.poly=this}},{key:"getGeom",value:function(){var t=[this.exteriorRing.getGeom()];if(null===t[0])return null;for(var e=0,r=this.interiorRings.length;e<r;e++){var n=this.interiorRings[e].getGeom();null!==n&&t.push(n)}return t}}]),e}(),q=function(){function e(r){t(this,e),this.rings=r,this.polys=this._composePolys(r)}return r(e,[{key:"getGeom",value:function(){for(var t=[],e=0,r=this.polys.length;e<r;e++){var n=this.polys[e].getGeom();null!==n&&t.push(n)}return t}},{key:"_composePolys",value:function(t){for(var e=[],r=0,n=t.length;r<n;r++){var i=t[r];if(!i.poly)if(i.isExteriorRing())e.push(new V(i));else{var o=i.enclosingRing();o.poly||e.push(new V(o)),o.poly.addInterior(i)}}return e}}]),e}(),z=function(){function e(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:C.compare;t(this,e),this.queue=r,this.tree=new l(n),this.segments=[]}return r(e,[{key:"process",value:function(t){var e=t.segment,r=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),r;var n=t.isLeft?this.tree.insert(e):this.tree.find(e);if(!n)throw new Error("Unable to find segment #".concat(e.id," ")+"[".concat(e.leftSE.point.x,", ").concat(e.leftSE.point.y,"] -> ")+"[".concat(e.rightSE.point.x,", ").concat(e.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var i=n,o=n,a=void 0,s=void 0;void 0===a;)null===(i=this.tree.prev(i))?a=null:void 0===i.key.consumedBy&&(a=i.key);for(;void 0===s;)null===(o=this.tree.next(o))?s=null:void 0===o.key.consumedBy&&(s=o.key);if(t.isLeft){var u=null;if(a){var f=a.getIntersection(e);if(null!==f&&(e.isAnEndpoint(f)||(u=f),!a.isAnEndpoint(f)))for(var l=this._splitSafely(a,f),h=0,c=l.length;h<c;h++)r.push(l[h])}var p=null;if(s){var d=s.getIntersection(e);if(null!==d&&(e.isAnEndpoint(d)||(p=d),!s.isAnEndpoint(d)))for(var y=this._splitSafely(s,d),g=0,v=y.length;g<v;g++)r.push(y[g])}if(null!==u||null!==p){var b=null;b=null===u?p:null===p||L.comparePoints(u,p)<=0?u:p,this.queue.remove(e.rightSE),r.push(e.rightSE);for(var m=e.split(b),w=0,x=m.length;w<x;w++)r.push(m[w])}r.length>0?(this.tree.remove(e),r.push(t)):(this.segments.push(e),e.prev=a)}else{if(a&&s){var _=a.getIntersection(s);if(null!==_){if(!a.isAnEndpoint(_))for(var E=this._splitSafely(a,_),S=0,k=E.length;S<k;S++)r.push(E[S]);if(!s.isAnEndpoint(_))for(var M=this._splitSafely(s,_),R=0,A=M.length;R<A;R++)r.push(M[R])}}this.tree.remove(e)}return r}},{key:"_splitSafely",value:function(t,e){this.tree.remove(t);var r=t.rightSE;this.queue.remove(r);var n=t.split(e);return n.push(r),void 0===t.consumedBy&&this.tree.insert(t),n}}]),e}(),G="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,W="undefined"!=typeof process&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6,H=new(function(){function e(){t(this,e)}return r(e,[{key:"run",value:function(t,e,r){H.type=t,S.reset();for(var n=[new U(e,!0)],i=0,o=r.length;i<o;i++)n.push(new U(r[i],!1));if(H.numMultiPolys=n.length,"difference"===H.type)for(var a=n[0],s=1;s<n.length;)null!==b(n[s].bbox,a.bbox)?s++:n.splice(s,1);if("intersection"===H.type)for(var u=0,f=n.length;u<f;u++)for(var h=n[u],c=u+1,p=n.length;c<p;c++)if(null===b(h.bbox,n[c].bbox))return[];for(var d=new l(L.compare),y=0,g=n.length;y<g;y++)for(var v=n[y].getSweepEvents(),m=0,w=v.length;m<w;m++)if(d.insert(v[m]),d.size>G)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var x=new z(d),_=d.size,E=d.pop();E;){var k=E.key;if(d.size===_){var M=k.segment;throw new Error("Unable to pop() ".concat(k.isLeft?"left":"right"," SweepEvent ")+"[".concat(k.point.x,", ").concat(k.point.y,"] from segment #").concat(M.id," ")+"[".concat(M.leftSE.point.x,", ").concat(M.leftSE.point.y,"] -> ")+"[".concat(M.rightSE.point.x,", ").concat(M.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(d.size>G)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(x.segments.length>W)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var R=x.process(k),A=0,j=R.length;A<j;A++){var T=R[A];void 0===T.consumedBy&&d.insert(T)}_=d.size,E=d.pop()}S.reset();var P=D.factory(x.segments);return new q(P).getGeom()}}]),e}()),Y=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return H.run("union",t,r)},$=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return H.run("intersection",t,r)},X=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return H.run("xor",t,r)},J=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return H.run("difference",t,r)};return{union:Y,intersection:$,xor:X,difference:J}}()},5666:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,o=Object.create(i.prototype),a=new A(n||[]);return o._invoke=function(t,e,r){var n=h;return function(i,o){if(n===p)throw new Error("Generator is already running");if(n===d){if("throw"===i)throw o;return T()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=k(a,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=l(t,e,r);if("normal"===u.type){if(n=r.done?d:c,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=d,r.method="throw",r.arg=u.arg)}}}(t,r,a),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h="suspendedStart",c="suspendedYield",p="executing",d="completed",y={};function g(){}function v(){}function b(){}var m={};u(m,o,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(j([])));x&&x!==r&&n.call(x,o)&&(m=x);var _=b.prototype=g.prototype=Object.create(m);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var f=u.arg,h=f.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(h).then((function(t){f.value=t,a(f)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function k(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var i=l(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function M(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(M,this),this.reset(!0)}function j(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:T}}function T(){return{value:e,done:!0}}return v.prototype=b,u(_,"constructor",b),u(b,"constructor",v),v.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,s,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},E(S.prototype),u(S.prototype,a,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new S(f(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(_),u(_,s,"Generator"),u(_,o,(function(){return this})),u(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=j,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),f=n.call(a,"finallyLoc");if(u&&f){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!f)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),R(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;R(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},9509:(t,e,r)=>{var n=r(1664),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},6547:(t,e,r)=>{var n=r(8043);function i(t,e,r){t=t||function(t){this.queue(t)},e=e||function(){this.queue(null)};var i=!1,o=!1,a=[],s=!1,u=new n;function f(){for(;a.length&&!u.paused;){var t=a.shift();if(null===t)return u.emit("end");u.emit("data",t)}}function l(){u.writable=!1,e.call(u),!u.readable&&u.autoDestroy&&u.destroy()}return u.readable=u.writable=!0,u.paused=!1,u.autoDestroy=!(r&&!1===r.autoDestroy),u.write=function(e){return t.call(this,e),!u.paused},u.queue=u.push=function(t){return s||(null===t&&(s=!0),a.push(t),f()),u},u.on("end",(function(){u.readable=!1,!u.writable&&u.autoDestroy&&process.nextTick((function(){u.destroy()}))})),u.end=function(t){if(!i)return i=!0,arguments.length&&u.write(t),l(),u},u.destroy=function(){if(!o)return o=!0,i=!0,a.length=0,u.writable=u.readable=!1,u.emit("close"),u},u.pause=function(){if(!u.paused)return u.paused=!0,u},u.resume=function(){return u.paused&&(u.paused=!1,u.emit("resume")),f(),u.paused||u.emit("drain"),u},u}t.exports=i,i.through=i},8706:t=>{"use strict";t.exports=function(t,e,r){return 0===t.length?t:e?(r||t.sort(e),function(t,e){for(var r=1,n=t.length,i=t[0],o=t[0],a=1;a<n;++a)if(o=i,e(i=t[a],o)){if(a===r){r++;continue}t[r++]=i}return t.length=r,t}(t,e)):(r||t.sort(),function(t){for(var e=1,r=t.length,n=t[0],i=t[0],o=1;o<r;++o,i=n)if(i=n,(n=t[o])!==i){if(o===e){e++;continue}t[e++]=n}return t.length=e,t}(t))}},1875:(t,e,r)=>{"use strict";var n=r(8908),i=r(7376),o=r(4947),a=r(7529);function s(t,e,r){var n=t;return i(e)?(r=e,"string"==typeof t&&(n={uri:t})):n=a(e,{uri:t}),n.callback=r,n}function u(t,e,r){return f(e=s(t,e,r))}function f(t){if(void 0===t.callback)throw new Error("callback argument missing");var e=!1,r=function(r,n,i){e||(e=!0,t.callback(r,n,i))};function n(){var t=void 0;if(t=l.response?l.response:l.responseText||function(t){try{if("document"===t.responseType)return t.responseXML;var e=t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;if(""===t.responseType&&!e)return t.responseXML}catch(t){}return null}(l),v)try{t=JSON.parse(t)}catch(t){}return t}function i(t){return clearTimeout(h),t instanceof Error||(t=new Error(""+(t||"Unknown XMLHttpRequest Error"))),t.statusCode=0,r(t,b)}function a(){if(!f){var e;clearTimeout(h),e=t.useXDR&&void 0===l.status?200:1223===l.status?204:l.status;var i=b,a=null;return 0!==e?(i={body:n(),statusCode:e,method:p,headers:{},url:c,rawRequest:l},l.getAllResponseHeaders&&(i.headers=o(l.getAllResponseHeaders()))):a=new Error("Internal XMLHttpRequest Error"),r(a,i,i.body)}}var s,f,l=t.xhr||null;l||(l=t.cors||t.useXDR?new u.XDomainRequest:new u.XMLHttpRequest);var h,c=l.url=t.uri||t.url,p=l.method=t.method||"GET",d=t.body||t.data,y=l.headers=t.headers||{},g=!!t.sync,v=!1,b={body:void 0,headers:{},statusCode:0,method:p,url:c,rawRequest:l};if("json"in t&&!1!==t.json&&(v=!0,y.accept||y.Accept||(y.Accept="application/json"),"GET"!==p&&"HEAD"!==p&&(y["content-type"]||y["Content-Type"]||(y["Content-Type"]="application/json"),d=JSON.stringify(!0===t.json?d:t.json))),l.onreadystatechange=function(){4===l.readyState&&setTimeout(a,0)},l.onload=a,l.onerror=i,l.onprogress=function(){},l.onabort=function(){f=!0},l.ontimeout=i,l.open(p,c,!g,t.username,t.password),g||(l.withCredentials=!!t.withCredentials),!g&&t.timeout>0&&(h=setTimeout((function(){if(!f){f=!0,l.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",i(t)}}),t.timeout)),l.setRequestHeader)for(s in y)y.hasOwnProperty(s)&&l.setRequestHeader(s,y[s]);else if(t.headers&&!function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(l.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(l),l.send(d||null),l}t.exports=u,t.exports.default=u,u.XMLHttpRequest=n.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:n.XDomainRequest,function(t,e){for(var r=0;r<t.length;r++)e(t[r])}(["get","put","post","patch","head","delete"],(function(t){u["delete"===t?"del":t]=function(e,r,n){return(r=s(e,r,n)).method=t.toUpperCase(),f(r)}}))},7529:t=>{t.exports=function(){for(var t={},r=0;r<arguments.length;r++){var n=arguments[r];for(var i in n)e.call(n,i)&&(t[i]=n[i])}return t};var e=Object.prototype.hasOwnProperty},824:e=>{"use strict";e.exports=t},9031:()=>{},6023:()=>{}},r={};function n(t){var i=r[t];if(void 0!==i)return i.exports;var o=r[t]={exports:{}};return e[t].call(o.exports,o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};return(()=>{"use strict";n.d(i,{default:()=>Zt});n(5666);var t=n(824),e=n(7701),r=n(1875),o=n.n(r),a=n(3614),s=n.n(a),u=n(8929),f=n(747),l=n.n(f);class h{static async nodeRequire(t,e){const r="function"==typeof t.require?t.require:null,n="function"==typeof t.import?t.import:null;if(!r&&!n)throw new Error("Neither NodeJS `require` or `import` is available. (If in test environment, maybe, you should add `global.require = require;`.");return r?r(e):(await n(e)).default}}h.Delta=class{constructor(){this.perf=null,this.start=0}static async new(t={nodejs:!1}){return await(new this).init(t)}async init(t={nodejs:!1}){if(t.nodejs){const{performance:t}=await h.nodeRequire(n.g,"perf_hooks");this.perf=t}else this.perf=window.performance;return this.start=this.perf.now(),this}_checkInit(){if(!this.perf)throw new Error("Do call `async .init()` first.")}get(){return this._checkInit(),(this.perf.now()-this.start)/1e3}print(t="delta:"){this._checkInit(),this.get().toFixed(3)}};const c=h;var p=n(2768),d=n.n(p);const y="1.2.3";class g extends t.Line{constructor(e,r=16711680){const n=new t.BufferGeometry;n.setAttribute("position",new t.BufferAttribute(new Float32Array(3*e),3)),super(n,new t.LineBasicMaterial({color:r})),this._maxPoints=e,this._numPoints=0}setColor(t){this.material.color.setHex(t)}getColor(){return this.material.color}getPoints(){let e=this.geometry.attributes.position.array,r=[];for(let n=0;n<this._numPoints;n++)r.push(new t.Vector3(e[3*n],e[3*n+1],e[3*n+2]));return r}static flattenPoints(t){return t.map((t=>[t.x,t.y,t.z])).reduce(((t,e)=>t.concat(e)))}updatePoints(t,e=!1){e||(t=v.flattenPoints(t));let r=this.geometry.attributes.position,n=r.count,i=t.length/3;i>n&&(i=n);for(let e=0;e<i;e++)r.array[3*e]=t[3*e],r.array[3*e+1]=t[3*e+1],r.array[3*e+2]=t[3*e+2];r.needsUpdate=!0,this.geometry.setDrawRange(0,i),this._frustumCullingWorkaround(),this._numPoints=i}clearPoints(){this.updatePoints([],!0)}updatePointsRandomWalk(t){this.updatePoints(g._getPointsRandomWalk(t),!0)}static _getPointsRandomWalk(t){let e=[],r=0,n=0,i=0;for(let o=0;o<t;o++)e.push(r),e.push(n),e.push(i),r+=2*(Math.random()-.5),n+=2*(Math.random()-.5),i+=2*(Math.random()-.5);return e}_frustumCullingWorkaround(){this.geometry.computeBoundingSphere()}}class v extends g{constructor(e={}){const r=Object.assign({},{color:16711680,maxPoints:256,infLength:9999},e);super(r.maxPoints,r.color),console.info(`Laser 1.2.3 with THREE r${t.REVISION}`),this.version=y,this._src=new t.Vector3(0,0,0),this._raycaster=new t.Raycaster,this._infLen=r.infLength,this._meshes=[]}setSource(t,e=null){this._src=e?t.clone().applyMatrix4(e.matrixWorld):t.clone()}getSource(){return this._src.clone()}static direct(t,e){return e.clone().sub(t).normalize()}static reflect(t,e){return t.clone().sub(e.clone().multiplyScalar(2*t.dot(e)))}_raycast(t,e,r){let n=this._raycaster.intersectObjects(t,e);if(r){for(let t=0;t<n.length;t++)if(n[t].face!==r)return n[t];return null}return n.length>0?n[0]:null}raycast(t,e,r,n=null,i=!1){return this._raycaster.set(t,e),this._raycast(r,i,n)}raycastFromCamera(e,r,n,i,o,a,s=!1){let u=new t.Vector2(e/n*2-1,-r/i*2+1);return this._raycaster.setFromCamera(u,o),this._raycast(a,s,null)}getMeshesHit(){return this._meshes}point(t,e=null){this.updatePoints([this._src.x,this._src.y,this._src.z,t.x,t.y,t.z],!0),this._meshes.length=0,e&&this.material.color.setHex(e)}pointWithRaytrace(t,e=[],r=null,n=16){if(this.point(t,r),n<1)return;let i=this.getSource(),o=v.direct(i,t),a=this.raycast(i,o,e);if(!a)return;let s=this.computeReflections(t,o,a,e,n);this.updatePoints([i.x,i.y,i.z,t.x,t.y,t.z,...s],!0)}_computeReflectionsRecursive(e,r,n,i,o){const a=[],s=this;return function e(r,n,u){let f=(new t.Matrix3).getNormalMatrix(u.object.matrixWorld),l=u.face.normal.clone().applyMatrix3(f).normalize(),h=v.reflect(n,l),c=s.raycast(r,h,i,u.face);if(c){let t=c.point;a.push(t.x,t.y,t.z),a.length/3<o&&e(t,h,c)}else{let t=r.clone().add(h.multiplyScalar(s._infLen));a.push(t.x,t.y,t.z)}}(e,r,n),a}_computeReflections(e,r,n,i,o){const a=[];for(this._meshes=[n.object];;){let s=(new t.Matrix3).getNormalMatrix(n.object.matrixWorld),u=n.face.normal.clone().applyMatrix3(s).normalize(),f=v.reflect(r,u),l=this.raycast(e,f,i,n.face);if(l){let t=l.point;if(a.push(t.x,t.y,t.z),this._meshes.push(l.object),a.length/3<o){e=t,r=f,n=l;continue}break}{let t=e.clone().add(f.multiplyScalar(this._infLen));a.push(t.x,t.y,t.z);break}}return a}computeReflections(t,e,r,n,i){return this._computeReflections(t,e,r,n,i)}}const b=v;var m=6371008.8,w={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*m,kilometers:6371.0088,kilometres:6371.0088,meters:m,metres:m,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:m/1852,radians:1,yards:6967335.223679999};function x(t,e,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=t,n}function _(t,e,r){if(void 0===r&&(r={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!T(t[0])||!T(t[1]))throw new Error("coordinates must contain numbers");return x({type:"Point",coordinates:t},e,r)}function E(t,e,r){void 0===r&&(r={});for(var n=0,i=t;n<i.length;n++){var o=i[n];if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<o[o.length-1].length;a++)if(o[o.length-1][a]!==o[0][a])throw new Error("First and last Position are not equivalent.")}return x({type:"Polygon",coordinates:t},e,r)}function S(t,e){void 0===e&&(e={});var r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function k(t,e,r){return void 0===r&&(r={}),x({type:"MultiPolygon",coordinates:t},e,r)}function M(t,e){void 0===e&&(e="kilometers");var r=w[e];if(!r)throw new Error(e+" units is invalid");return t/r}function R(t){return 180*(t%(2*Math.PI))/Math.PI}function A(t){return t%360*Math.PI/180}function j(t,e,r){if(void 0===e&&(e="kilometers"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("length must be a positive number");return function(t,e){void 0===e&&(e="kilometers");var r=w[e];if(!r)throw new Error(e+" units is invalid");return t*r}(M(t,e),r)}function T(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function P(t){return!!t&&t.constructor===Object}function I(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function B(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function L(t){return"Feature"===t.type?t.geometry:t}function O(t,e,r,n){void 0===n&&(n={});var i=I(t),o=A(i[0]),a=A(i[1]),s=A(r),u=M(e,n.units),f=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return _([R(o+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(f))),R(f)],n.properties)}function C(t,e,r){if(null!==t)for(var n,i,o,a,s,u,f,l,h=0,c=0,p=t.type,d="FeatureCollection"===p,y="Feature"===p,g=d?t.features.length:1,v=0;v<g;v++){s=(l=!!(f=d?t.features[v].geometry:y?t.geometry:t)&&"GeometryCollection"===f.type)?f.geometries.length:1;for(var b=0;b<s;b++){var m=0,w=0;if(null!==(a=l?f.geometries[b]:f)){u=a.coordinates;var x=a.type;switch(h=!r||"Polygon"!==x&&"MultiPolygon"!==x?0:1,x){case null:break;case"Point":if(!1===e(u,c,v,m,w))return!1;c++,m++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===e(u[n],c,v,m,w))return!1;c++,"MultiPoint"===x&&m++}"LineString"===x&&m++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(i=0;i<u[n].length-h;i++){if(!1===e(u[n][i],c,v,m,w))return!1;c++}"MultiLineString"===x&&m++,"Polygon"===x&&w++}"Polygon"===x&&m++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(w=0,i=0;i<u[n].length;i++){for(o=0;o<u[n][i].length-h;o++){if(!1===e(u[n][i][o],c,v,m,w))return!1;c++}w++}m++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===C(a.geometries[n],e,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function N(t,e){var r,n,i,o,a,s,u,f,l,h,c=0,p="FeatureCollection"===t.type,d="Feature"===t.type,y=p?t.features.length:1;for(r=0;r<y;r++){for(s=p?t.features[r].geometry:d?t.geometry:t,f=p?t.features[r].properties:d?t.properties:{},l=p?t.features[r].bbox:d?t.bbox:void 0,h=p?t.features[r].id:d?t.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,i=0;i<a;i++)if(null!==(o=u?s.geometries[i]:s))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(o,c,f,l,h))return!1;break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(!1===e(o.geometries[n],c,f,l,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,c,f,l,h))return!1;c++}}function F(t){var e={type:"Feature"};return Object.keys(t).forEach((function(r){switch(r){case"type":case"properties":case"geometry":return;default:e[r]=t[r]}})),e.properties=U(t.properties),e.geometry=D(t.geometry),e}function U(t){var e={};return t?(Object.keys(t).forEach((function(r){var n=t[r];"object"==typeof n?null===n?e[r]=null:n.length?e[r]=n.map((function(t){return t})):e[r]=U(n):e[r]=n})),e):e}function D(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map((function(t){return D(t)})),e):(e.coordinates=V(t.coordinates),e)}function V(t){return"object"!=typeof t[0]?t.slice():t.map((function(t){return V(t)}))}const q=function(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return F(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};return Object.keys(t).forEach((function(r){switch(r){case"type":case"features":return;default:e[r]=t[r]}})),e.features=t.features.map((function(t){return F(t)})),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return D(t);default:throw new Error("unknown GeoJSON type")}};const z=function(t,e,r,n){if(!P(n=n||{}))throw new Error("options is invalid");var i=n.units,o=n.properties;if(!t)throw new Error("origin is required");if(null==e)throw new Error("distance is required");if(null==r)throw new Error("bearing is required");if(!(e>=0))throw new Error("distance must be greater than 0");var a=j(e,i,"meters"),s=I(t),u=function(t,e,r,n){n=void 0===n?m:Number(n);var i=e/n,o=t[0]*Math.PI/180,a=A(t[1]),s=A(r),u=i*Math.cos(s),f=a+u;Math.abs(f)>Math.PI/2&&(f=f>0?Math.PI-f:-Math.PI-f);var l=Math.log(Math.tan(f/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),h=Math.abs(l)>1e-11?u/l:Math.cos(a),c=i*Math.sin(s)/h;return[(180*(o+c)/Math.PI+540)%360-180,180*f/Math.PI]}(s,a,r);return u[0]+=u[0]-s[0]>180?-360:s[0]-u[0]>180?360:0,_(u,o)};const G=function(t,e,r,n){if(!P(n=n||{}))throw new Error("options is invalid");var i=n.units,o=n.zTranslation,a=n.mutate;if(!t)throw new Error("geojson is required");if(null==e||isNaN(e))throw new Error("distance is required");if(o&&"number"!=typeof o&&isNaN(o))throw new Error("zTranslation is not a number");if(o=void 0!==o?o:0,0===e&&0===o)return t;if(null==r||isNaN(r))throw new Error("direction is required");return e<0&&(e=-e,r=-r),!1!==a&&void 0!==a||(t=q(t)),C(t,(function(t){var n=B(z(t,e,r,{units:i}));t[0]=n[0],t[1]=n[1],o&&3===t.length&&(t[2]+=o)})),t};const W=function(t,e){var r=0,n=0,i=0;return C(t,(function(t){r+=t[0],n+=t[1],i++}),!0),_([r/i,n/i],e)};function H(t,e){var r=A(t[1]),n=A(e[1]),i=A(e[0]-t[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);var o=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(r/2+Math.PI/4));return(R(Math.atan2(i,o))+360)%360}const Y=function(t,e,r){if(!P(r=r||{}))throw new Error("options is invalid");var n,i=r.final;if(!t)throw new Error("start point is required");if(!e)throw new Error("end point is required");return(n=i?H(I(e),I(t)):H(I(t),I(e)))>180?-(360-n):n};const $=function(t,e,r){if(!P(r=r||{}))throw new Error("options is invalid");var n=r.units;if(!t)throw new Error("from point is required");if(!e)throw new Error("to point is required");var i=I(t),o=I(e);o[0]+=o[0]-i[0]>180?-360:i[0]-o[0]>180?360:0;var a=function(t,e,r){var n=r=void 0===r?m:Number(r),i=t[1]*Math.PI/180,o=e[1]*Math.PI/180,a=o-i,s=Math.abs(e[0]-t[0])*Math.PI/180;s>Math.PI&&(s-=2*Math.PI);var u=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),f=Math.abs(u)>1e-11?a/u:Math.cos(i);return Math.sqrt(a*a+f*f*s*s)*n}(i,o);return j(a,"meters",n)};const X=function(t,e,r){if(!P(r=r||{}))throw new Error("options is invalid");var n=r.pivot,i=r.mutate;if(!t)throw new Error("geojson is required");if(null==e||isNaN(e))throw new Error("angle is required");return 0===e||(n||(n=W(t)),!1!==i&&void 0!==i||(t=q(t)),C(t,(function(t){var r=Y(n,t)+e,i=$(n,t),o=B(z(n,i,r));t[0]=o[0],t[1]=o[1]}))),t};function J(t){return function(t){if(Array.isArray(t))return rt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||et(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Z(t,e,r){return Z=K()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&Q(i,r.prototype),i},Z.apply(null,arguments)}function K(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Q(t,e){return Q=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Q(t,e)}function tt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(t,e)||et(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function et(t,e){if(t){if("string"==typeof t)return rt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rt(t,e):void 0}}function rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var it=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n,i;return r=e,i=[{key:"createLine",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{color:16711680,maxPoints:256},r=new b(e);return r.updatePoints(t),r}},{key:"bboxToWireframe",value:function(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={offsetZ:0,color:52428,height:.001},a=Object.assign({},o,i),s=tt(e,4),u=s[0],f=s[1],l=s[2],h=s[3],c=r([(f+h)/2,(u+l)/2]),p=r([h,u]),d=tt(p,2),y=d[0],g=d[1],v=r([f,l]),b=tt(v,2),m=b[0],w=b[1],x=[m-y,g-w],_=a.height,E=new t.LineSegments(new t.EdgesGeometry(Z(t.BoxBufferGeometry,x.concat([_]))),new t.LineBasicMaterial({color:a.color}));return(n=E.position).set.apply(n,J(c).concat([-_/2+a.offsetZ])),E.name="bbox-".concat(window.performance.now()),{obj:E,offset:[].concat(J(c),[a.offsetZ]),size:[].concat(x,[a.height])}}},{key:"tileToBbox",value:function(t){return d().tileToBBOX(t)}},{key:"_resolveTri",value:function(e,r,n,i,o){var a=(new b).raycast(new t.Vector3(e,r,12e3),new t.Vector3(0,0,-1),n);if(!a)return null;var s=a.faceIndex,u=a.object.geometry.index.array,f=a.object.geometry.attributes.position,l=[0,1,2].map((function(e){return(new t.Vector3).fromBufferAttribute(f,u[3*s+e]).multiplyScalar(i).add(new t.Vector3(0,0,o||-a.point.z))}));return{faceIndex:a.faceIndex,isectPoint:a.point.clone(),tri:l,normal:a.face.normal.clone()}}},{key:"createTurfPoint",value:function(t){return _([t[1],t[0]])}},{key:"originRadiusToBbox",value:function(t,e){var r=tt(O(this.createTurfPoint(t),e,-45,{units:"kilometers"}).geometry.coordinates,2),n=r[0],i=r[1],o=tt(O(this.createTurfPoint(t),e,135,{units:"kilometers"}).geometry.coordinates,2),a=o[0];return[n,o[1],a,i]}},{key:"translateTurfObject",value:function(e,r,n,i,o){var a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],s=new t.Vector2(r,n).divideScalar(o),u=90-180*s.angle()/Math.PI;return G(e,s.length(),u,{units:"meters",zTranslation:i/o,mutate:a})}},{key:"rotateTurfObject",value:function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return X(t,e,{pivot:[r[1],r[0]],mutate:n})}}],(n=null)&&nt(r.prototype,n),i&&nt(r,i),Object.defineProperty(r,"prototype",{writable:!1}),e}();it.Meta=c;const ot=it;function at(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function st(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){at(o,n,i,a,s,"next",t)}function s(t){at(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var ft=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,r,i,a,f,h,c;return e=t,r=null,i=[{key:"getUriCustom",value:function(t,e){var r,n=t.split("/");switch(n=n.length?n[n.length-1]:"Oops"){case"custom-terrain-vector":r="pbf";break;case"custom-terrain-rgb":r="png";break;case"custom-satellite":r="jpg";break;default:return""}return"".concat(t,"-").concat(e.join("-"),".").concat(r)}},{key:"getUriMapbox",value:function(t,e,r){var n,i="";switch(e){case"mapbox-terrain-vector":n="https://api.mapbox.com/v4/mapbox.mapbox-terrain-v2",i=".vector.pbf";break;case"mapbox-terrain-rgb":n="https://api.mapbox.com/v4/mapbox.terrain-rgb",i="@2x.pngraw";break;case"mapbox-satellite":n="https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles";break;default:return""}return"".concat(n,"/").concat(r.join("/")).concat(i,"?access_token=").concat(t)}},{key:"dumpBufferAsBlob",value:function(t,e){var r=new Blob([t],{type:"application/octet-stream"}),n=document.createElement("a");n.href=URL.createObjectURL(r),n.download=e,document.body.appendChild(n),n.click()}},{key:"dumpBlob",value:(c=st(regeneratorRuntime.mark((function t(e,r,n,i){var o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.req(e,r);case 3:o=t.sent,this.dumpBufferAsBlob(o,"".concat(n,"-").concat(i.join("-"),".blob")),t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),console.error("dumpBlob(): err",t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])}))),function(t,e,r,n){return c.apply(this,arguments)})},{key:"getRgbTile",value:(h=st(regeneratorRuntime.mark((function t(e,r,i){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r){t.next=6;break}return t.next=3,ot.Meta.nodeRequire(n.g,"get-pixels/node-pixels");case 3:t.t0=t.sent,t.next=7;break;case 6:t.t0=l();case 7:(0,t.t0)(e,(function(t,e){return i(t?null:e)}));case 9:case"end":return t.stop()}}),t)}))),function(t,e,r){return h.apply(this,arguments)})},{key:"getVectorTile",value:(f=st(regeneratorRuntime.mark((function t(e,r,i){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r||e.startsWith("http://")||e.startsWith("https://")){t.next=7;break}return t.next=3,ot.Meta.nodeRequire(n.g,"fs");case 3:t.sent.readFile(e,(function(t,e){return i(t?null:new u.VectorTile(new(s())(e.buffer)))})),t.next=16;break;case 7:return t.t0=i,t.t1=u.VectorTile,t.t2=s(),t.next=12,this.req(e,r);case 12:t.t3=t.sent,t.t4=new t.t2(t.t3),t.t5=new t.t1(t.t4),(0,t.t0)(t.t5);case 16:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return f.apply(this,arguments)})},{key:"req",value:(a=st(regeneratorRuntime.mark((function t(e,r){var i,a=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r){t.next=6;break}return t.next=3,ot.Meta.nodeRequire(n.g,"request");case 3:t.t0=t.sent,t.next=7;break;case 6:t.t0=o();case 7:return i=t.t0,t.abrupt("return",new Promise((function(t,r){i({uri:e,responseType:"arraybuffer"},(function(e,n,i){var o=e||!a.isAjaxSuccessful(n.statusCode);o?r(o):t(i)}))})));case 9:case"end":return t.stop()}}),t)}))),function(t,e){return a.apply(this,arguments)})},{key:"isAjaxSuccessful",value:function(t){return t>=200&&t<300||304===t}},{key:"getZoomposEle",value:function(t){var e={};return t.forEach((function(t){var r=[t[0]-2,Math.floor(t[1]/4),Math.floor(t[2]/4)];e[r]?e[r].push(t):e[r]=[t]})),Object.keys(e).map((function(t){return t.split(",").map((function(t){return parseFloat(t)}))}))}},{key:"fetchTile",value:function(t,e,r,n){var i=this,o="fetchTile()",a=e.startsWith("mapbox-")?this.getUriMapbox(r,e,t):this.getUriCustom(e,t);"".concat(o,": uri: ").concat(a);var s=function(t){var r=null;return e.includes("mapbox-terrain-vector")||e.includes("custom-terrain-vector")?r=i.getVectorTile(a,n,t):(e.includes("mapbox-terrain-rgb")||e.includes("mapbox-satellite")||e.includes("custom-terrain-rgb")||e.includes("custom-satellite"))&&(r=i.getRgbTile(a,n,t)),r};return new Promise(function(){var t=st(regeneratorRuntime.mark((function t(r,n){var i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,null===(i=s(r))){t.next=7;break}return t.next=5,i;case 5:t.next=8;break;case 7:throw new Error("".concat(o,": unsupported api: ").concat(e));case 8:t.next=14;break;case 10:t.prev=10,t.t0=t.catch(0),console.warn("".concat(o,": err: ").concat(t.t0)),r(null);case 14:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,r){return t.apply(this,arguments)}}())}}],r&&ut(e.prototype,r),i&&ut(e,i),Object.defineProperty(e,"prototype",{writable:!1}),t}();const lt=ft;var ht=n(3673);function ct(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(t,e)||dt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pt(t){return function(t){if(Array.isArray(t))return yt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||dt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function dt(t,e){if(t){if("string"==typeof t)return yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yt(t,e):void 0}}function yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function gt(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){gt(o,n,i,a,s,"next",t)}function s(t){gt(o,n,i,a,s,"throw",t)}a(void 0)}))}}function bt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var mt=128,wt=new(n.n(ht)())({size:128}),xt=function(t){for(var e=384,r=[[],[],[],[]],n=0;n<e;n+=3)r[0].push(n+1+t),r[1].push(n/3*e+1+t),r[2].push(n+1+49152-e+t),r[3].push((n/3+1)*e-2+t);return r}(1),_t=function(){for(var t=[],e=0;e<4;e++)for(var r=0;r<4;r++)t.push([[127*r+r,512*(r+1)/4],[127*e+e,512*(e+1)/4]]);return t}(),Et=function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.unitsPerMeter=t.unitsPerMeter,this.projectCoord=t.projectCoord,this.token=t.token,this.isNode=t.isNode,this.isDebug=t.isDebug,this.apiRgb=t.apiRgb,this.apiSatellite=t.apiSatellite,this.onRgbDem=t.onRgbDem,this.onSatelliteMat=t.onSatelliteMat,this.watcher=t.watcher,this.dataEleCovered=[]}var r,n,i,o;return r=e,n=[{key:"fetch",value:function(t,e){var r=this,n=lt.getZoomposEle(t),i=0;n.forEach(function(){var o=vt(regeneratorRuntime.mark((function o(a){var s;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,lt.fetchTile(a,r.apiRgb,r.token,r.isNode);case 2:null!==(s=o.sent)?r.addTile(s,a,t,e):"fetchTile() failed for rgb dem of zp: ".concat(a," (count: ").concat(i,"/").concat(n.length,")"),++i===n.length&&r.build();case 6:case"end":return o.stop()}}),o)})));return function(t){return o.apply(this,arguments)}}())}},{key:"addTile",value:function(t,e,r,n){this.dataEleCovered=this.dataEleCovered.concat(this._addTile(t,e,r,n)),"now ".concat(this.dataEleCovered.length," satellite tiles in dataEleCovered")}},{key:"_addTile",value:function(t,e,r,n){var i=this.unitsPerMeter,o=this.projectCoord,a=[];if(t)for(var s,u,f,l=0;l<t.data.length;l+=4)s=t.data[l],u=t.data[l+1],f=t.data[l+2],a.push(.1*(256*s*256+256*u+f)-1e4);else a=new Array(262144).fill(0);for(var h=[],c=0;c<4;c++)for(var p=0;p<4;p++)h.push([e[0]+2,4*e[1]+c,4*e[2]+p].join("/"));var d=r.map((function(t){return t.join("/")})),y=[];return h.forEach((function(t,r){if(d.includes(t)){for(var s=t.split("/").map((function(t){return parseInt(t)})),u=_t[r],f=[],l=u[0][0];l<u[0][1];l++)for(var h=u[1][0];h<u[1][1];h++)f.push(a[512*l+h]);for(var c=[],p=0,g=0;g<mt;g++)for(var v=0;v<mt;v++){var b=wt.ll([128*s[1]+v,128*s[2]+g],s[0]);c.push.apply(c,pt(o(b,n.northWest,n.southEast)).concat([f[p]*i])),p++}y.push([s,c,e])}})),y}},{key:"build",value:function(){var t=this,r=this.isDebug?{}:void 0;if(this.dataEleCovered,0===this.dataEleCovered.length){var n=[];return this.onRgbDem(n),void this.watcher({what:"dem-rgb",data:n,debug:r})}var i=null;if(this.onSatelliteMat){var o=0;i=function(e,n){o++,t.onSatelliteMat(e),o===t.dataEleCovered.length&&t.watcher({what:"dem-rgb",data:n,debug:r})}}var a=e._build(this.dataEleCovered,this.apiSatellite,this.token,this.isNode,i);this.onRgbDem(a),i||this.watcher({what:"dem-rgb",data:a,debug:r})}}],i=[{key:"_stitchWithNei2",value:function(t,e){for(var r=0;r<mt;r++){var n=xt[2][r]+384,i=xt[0][r];t[n-2]=e[i-2],t[n-1]=e[i-1],t[n]=e[i]}}},{key:"_stitchWithNei3",value:function(t,e){for(var r=0;r<mt;r++){var n=xt[3][r]+3*(1+r),i=xt[1][r];t.splice(n-2,0,e[i-2]),t.splice(n-1,0,e[i-1]),t.splice(n,0,e[i])}}},{key:"resolveSeams",value:function(t,e){var r=this,n=[127,127];if(Object.entries(e).forEach((function(e){var i=ct(e,2),o=i[0],a=i[1];"2"===o?(r._stitchWithNei2(t,a),n[1]++):"3"===o&&(r._stitchWithNei3(t,a),n[0]++)})),n[0]===mt&&n[1]===mt){var i=e[6];if(i)t.push(i[0],i[1],i[2]);else{var o=t.length;t.push(t[o-3],t[o-2],t[o-1])}}return n}},{key:"createDataFlipY",value:function(t,e){for(var r=ct(e,3),n=r[0],i=r[1],o=r[2],a=new Uint8Array(t.length),s=0;s<i;s++)for(var u=0;u<n*o;u+=o)for(var f=0;f<o;f++)a[(i-1-s)*n*o+u+f]=t[s*n*o+u+f];return a}},{key:"getNeighborsInfo",value:function(t,e,r){var n={};return this.getNeighbors8(r).forEach((function(r,i){var o=r.join("/");if(o in e){var a=t[e[o]][1];n[i]=a}})),n}},{key:"getNeighbors8",value:function(t){var e=[];return[[0,0,-1],[0,-1,0],[0,0,1],[0,1,0],[0,-1,-1],[0,-1,1],[0,1,1],[0,1,-1]].forEach((function(r){var n=r.map((function(e,r){return e+t[r]}));e.push(n)})),e}},{key:"_build",value:function(e,r,n,i,o){var a=this;e.sort((function(t,e){return t[0].join("/")>e[0].join("/")?1:-1}));var s={};e.forEach((function(t,e){s[t[0].join("/")]=e}));var u=[];return e.forEach((function(f){var l=ct(f,3),h=l[0],c=l[1],p=l[2];if(49152===c.length){var d=a.resolveSeams(c,a.getNeighborsInfo(e,s,h)),y=new t.PlaneBufferGeometry(1,1,d[0],d[1]);y.attributes.position.array=new Float32Array(c);var g=new t.Mesh(y,new t.MeshBasicMaterial({wireframe:!0,color:13421772}));g.name="dem-rgb-".concat(h.join("/"));var v=function(t){return[t[1],t[2],t[0]]};g.userData.threeGeo={tile:v(h),srcDem:{tile:v(p),uri:lt.getUriMapbox(n,"mapbox-terrain-rgb",p)}},u.push(g),a.resolveTex(h,r,n,i,(function(e){e&&(g.material=new t.MeshBasicMaterial({side:t.FrontSide,map:e})),o&&o(g,u)}))}})),u}},{key:"resolveTex",value:(o=vt(regeneratorRuntime.mark((function e(r,n,i,o,a){var s,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,lt.fetchTile(r,n,i,o);case 2:s=e.sent,u=null,null!==s?(u=new t.DataTexture(this.createDataFlipY(s.data,s.shape),s.shape[0],s.shape[1],t.RGBAFormat)).needsUpdate=!0:"fetchTile() failed for tex of zp: ".concat(r),a&&a(u);case 6:case"end":return e.stop()}}),e,this)}))),function(t,e,r,n,i){return o.apply(this,arguments)})}],n&&bt(r.prototype,n),i&&bt(r,i),Object.defineProperty(r,"prototype",{writable:!1}),e}();const St=Et;var kt=6378137;function Mt(t){return function(t,e,r){var n=r;return N(t,(function(t,i,o,a,s){n=0===i&&void 0===r?t:e(n,t,i,o,a,s)})),n}(t,(function(t,e){return t+function(t){var e,r=0;switch(t.type){case"Polygon":return Rt(t.coordinates);case"MultiPolygon":for(e=0;e<t.coordinates.length;e++)r+=Rt(t.coordinates[e]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)}),0)}function Rt(t){var e=0;if(t&&t.length>0){e+=Math.abs(At(t[0]));for(var r=1;r<t.length;r++)e-=Math.abs(At(t[r]))}return e}function At(t){var e,r,n,i,o,a,s=0,u=t.length;if(u>2){for(a=0;a<u;a++)a===u-2?(n=u-2,i=u-1,o=0):a===u-1?(n=u-1,i=0,o=1):(n=a,i=a+1,o=a+2),e=t[n],r=t[i],s+=(jt(t[o][0])-jt(e[0]))*Math.sin(jt(r[1]));s=s*kt*kt/2}return s}function jt(t){return t*Math.PI/180}var Tt=n(2676),Pt=n.n(Tt);const It=function(t,e,r){void 0===r&&(r={});var n=L(t),i=L(e),o=Pt().union(n.coordinates,i.coordinates);return 0===o.length?null:1===o.length?E(o[0],r.properties):k(o,r.properties)};var Bt=n(8706),Lt=n.n(Bt);function Ot(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return Ct(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ct(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ct(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Nt(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var Ut=function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.unitsPerMeter=t.unitsPerMeter,this.projectCoord=t.projectCoord,this.token=t.token,this.isNode=t.isNode,this.isDebug=t.isDebug,this.apiVector=t.apiVector,this.onVectorDem=t.onVectorDem,this.watcher=t.watcher,this.bottomTiles=[],this.geojson={type:"FeatureCollection",features:[]},this.isDebug&&(this.tiles={})}var r,n,i;return r=e,n=[{key:"fetch",value:function(t,e,r){var n=this,i=lt.getZoomposEle(t),o=0;i.forEach(function(){var t,a=(t=regeneratorRuntime.mark((function t(a){var s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,lt.fetchTile(a,n.apiVector,n.token,n.isNode);case 2:null!==(s=t.sent)?n.addTile(s,a):"fetchTile() failed for vector dem of zp: ".concat(a," (count: ").concat(o,"/").concat(i.length,")"),++o===i.length&&n.build(e,r);case 6:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Nt(o,n,i,a,s,"next",t)}function s(t){Nt(o,n,i,a,s,"throw",t)}a(void 0)}))});return function(t){return a.apply(this,arguments)}}())}},{key:"addTile",value:function(t,e){var r=this;if(this.isDebug&&(this.tiles[e.join("-")]=t),t.layers.contour)for(var n=function(n){var i=t.layers.contour.feature(n).toGeoJSON(e[1],e[2],e[0]);0===n&&r.bottomTiles.push(i),"MultiPolygon"===i.geometry.type?i.geometry.coordinates.forEach((function(t){return r.geojson.features.push({type:"Feature",properties:{ele:i.properties.ele},geometry:{type:"Polygon",coordinates:t}})})):r.geojson.features.push(i)},i=0;i<t.layers.contour.length;i++)n(i);else"no contours! (zoom=".concat(e[0],")")}},{key:"_buildContours",value:function(t,r){var n=Lt()(this.geojson.features.map((function(t){return t.properties.ele}))).sort((function(t,e){return t-e}));return e._addBottomEle(this.geojson,this.bottomTiles,n),e._getContours(n,this.geojson,t,r*r*2e6)}},{key:"build",value:function(t,e){var r=this.isDebug?{tiles:this.tiles}:void 0,n=this._buildModelThree(this._buildContours(t.feature,e),t.northWest,t.southEast);this.onVectorDem&&this.onVectorDem(n),this.watcher&&this.watcher({what:"dem-vec",data:n,debug:r})}},{key:"_buildModelThree",value:function(t,e,r){for(var n,i,o,a,s,u=this,f=(n=[2300184,15557462],i=t.length,a=(o=function(t){return[t>>16,(65280&t)>>8,255&t]})(n[0]),s=o(n[1]-n[0]),function(t){return(a[0]+Math.floor(t*s[0]/i)<<16)+(a[1]+Math.floor(t*s[1]/i)<<8)+(a[2]+Math.floor(t*s[2]/i))}),l=[],h=function(n,i){var o=Ot(u._buildSlice(n,i,f(i),t,e,r),2),a=o[0],s=o[1];a.forEach((function(t){l.push(t)})),l.push(s)},c=0;c<t.length;c++){var p=t[c].geometry.geometry;if("Polygon"===p.type)h(p.coordinates,c);else if("MultiPolygon"===p.type)for(var d=0;d<p.coordinates.length;d++)h(p.coordinates[d],c)}return l}},{key:"_buildSlice",value:function(e,r,n,i,o,a){var s=this,u=new t.Shape,f=[new t.BufferGeometry],l=r,h=-i[l].ele*this.unitsPerMeter,c=function(e,r){return e.setAttribute("position",new t.BufferAttribute(new Float32Array(r),3))},p=[];e[0].forEach((function(t,e){var r=Ot(s.projectCoord(t,o,a),2),n=r[0],i=r[1];p.push(-n,i,h),0===e?u.moveTo(-n,i):u.lineTo(-n,i)})),c(f[0],p);for(var d=1;d<e.length;d++){var y=new t.Path;f.push(new t.BufferGeometry);for(var g=[],v=0;v<e[d].length;v++){var b=Ot(this.projectCoord(e[d][v],o,a),2),m=b[0],w=b[1];g.push(-m,w,h),0===v?y.moveTo(-m,w):y.lineTo(-m,w)}c(f[d],g),u.holes.push(y)}var x=[];f.forEach((function(e,r){var n=new t.Line(f[0],new t.LineBasicMaterial({color:13421772}));n.rotation.y=Math.PI,n.name="dem-vec-line-".concat(i[l].ele,"-").concat(n.uuid),x.push(n)}));var _=new t.ExtrudeGeometry(u,{depth:i[l+1]?this.unitsPerMeter*(i[l+1].ele-i[l].ele):this.unitsPerMeter*(i[l].ele-i[l-1].ele),bevelEnabled:!1}),E=new t.Mesh(_,new t.MeshBasicMaterial({color:n,wireframe:!1}));return E.rotation.y=Math.PI,E.position.z=-h,E.name="dem-vec-shade-".concat(i[l].ele,"-").concat(E.uuid),[x,E]}}],i=[{key:"_addBottomEle",value:function(t,e,r){e.forEach((function(e){for(var n=e.properties.ele,i=r[0];i<n;i+=10)t.features.push({type:"Feature",geometry:e.geometry,properties:{ele:i}})}))}},{key:"_getContours",value:function(t,e,r,n){for(var i=[],o=function(r){var n=t[r],o=e.features.filter((function(t){return t.properties.ele===n}));try{var a=S(o).features,s=a.reduce((function(t,e){return It(t,e)}),a[0]);if(s){var u=Mt(s.geometry);i.push({geometry:s,ele:n,area:u})}}catch(t){t.message}},a=0;a<t.length;a++)o(a);return i}}],n&&Ft(r.prototype,n),i&&Ft(r,i),Object.defineProperty(r,"prototype",{writable:!1}),e}();const Dt=Ut;function Vt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(o.push(n.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(t,e)||qt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qt(t,e){if(t){if("string"==typeof t)return zt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?zt(t,e):void 0}}function zt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Gt(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Wt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Gt(o,n,i,a,s,"next",t)}function s(t){Gt(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Ht(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Yt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var $t="1.4.5-dev.5",Xt=function(){},Jt=function(){function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ht(this,r),this.version=$t,console.info("ThreeGeo ".concat($t," with THREE r").concat(t.REVISION));var n={unitsSide:1,tokenMapbox:"",isNode:!1,isDebug:!1,apiVector:"mapbox-terrain-vector",apiRgb:"mapbox-terrain-rgb",apiSatellite:"mapbox-satellite"},i=Object.assign({},n,e);this.constUnitsSide=i.unitsSide,this.tokenMapbox=i.tokenMapbox,this.isNode=i.useNodePixels||i.isNode,this.isDebug=i.isDebug,this.apiVector=i.apiVector,this.apiRgb=i.apiRgb,this.apiSatellite=i.apiSatellite,this.isDebug&&console.warn("`isDebug` is true; terrains support `.userData.debug()`.")}var n,i,o,a,s;return n=r,i=[{key:"getProjection",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.constUnitsSide,i=ot.originRadiusToBbox(t,e),o=r._getUnitsPerMeter(n,e);return{proj:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return r._proj(t,e,i,n)},projInv:function(e,n){return r._projInv(e,n,t,o)},bbox:i,unitsPerMeter:o}}},{key:"getTerrain",value:function(t,e,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise((function(a,s){try{var u=r._createWatcher(o,a);if(!u)return;var f=i.constUnitsSide,l=r._getUnitsPerMeter(f,e),h=function(t,e,n){return r._projectCoord(f,t,e,n)},c=i.tokenMapbox,p=i.isNode,d=i.isDebug,y=i.apiRgb,g=i.apiSatellite,v=i.apiVector,b=o.onRgbDem,m=o.onSatelliteMat,w=o.onVectorDem,x=r.getBbox(t,e),_=r.getZoomposCovered(x.feature,n);b&&new St({unitsPerMeter:l,projectCoord:h,token:c,isNode:p,isDebug:d,apiRgb:y,apiSatellite:g,onRgbDem:b,onSatelliteMat:m,watcher:u}).fetch(_,x),w&&new Dt({unitsPerMeter:l,projectCoord:h,token:c,isNode:p,isDebug:d,apiVector:v,onVectorDem:w,watcher:u}).fetch(_,x,e)}catch(t){console.error("err:",t),s(t)}}))}},{key:"getTerrainRgb",value:(s=Wt(regeneratorRuntime.mark((function t(e,n,i){var o,a,s,u,f=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=f.length>3&&void 0!==f[3]?f[3]:void 0,t.next=3,this.getTerrain(e,n,i,{onRgbDem:function(){},onSatelliteMat:function(){}});case 3:return a=t.sent,s=a.rgbDem,u=a.debug,t.abrupt("return",o?o(s):r._createDemGroup("dem-rgb",s,u));case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return s.apply(this,arguments)})},{key:"getTerrainVector",value:(a=Wt(regeneratorRuntime.mark((function t(e,n,i){var o,a,s,u,f=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=f.length>3&&void 0!==f[3]?f[3]:void 0,t.next=3,this.getTerrain(e,n,i,{onVectorDem:function(){}});case 3:return a=t.sent,s=a.vectorDem,u=a.debug,t.abrupt("return",o?o(s):r._createDemGroup("dem-vec",s,u));case 7:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return a.apply(this,arguments)})},{key:"setApiVector",value:function(t){this.apiVector=t}},{key:"setApiRgb",value:function(t){this.apiRgb=t}},{key:"setApiSatellite",value:function(t){this.apiSatellite=t}}],o=[{key:"_getUnitsPerMeter",value:function(t,e){return t/(e*Math.pow(2,.5)*1e3)}},{key:"_projectCoord",value:function(t,e,r,n){return[t*((e[0]-r[0])/(n[0]-r[0])-.5),t*(-.5-(e[1]-n[1])/(n[1]-r[1]))]}},{key:"_proj",value:function(t,e,r,n){var i=Vt(t,2),o=i[0],a=i[1],s=Vt(r,4),u=s[0],f=s[1],l=s[2],h=s[3],c=Vt(this._projectCoord(n,[a,o],[u,h],[l,f]),2),p=c[0],d=c[1],y=e?Xt(p,d,o,a,e):void 0;return void 0!==y?[p,d,y]:[p,d]}},{key:"_projInv",value:function(t,e,r,n){var i=ot.translateTurfObject(ot.createTurfPoint(r),t,e,0,n).geometry.coordinates;return[i[1],i[0]]}},{key:"getZoomposCovered",value:function(t,r){var n={min_zoom:r,max_zoom:r};return e.tiles(t.geometry,n).map((function(t){var e=Vt(t,3),r=e[0],n=e[1];return[e[2],r,n]}))}},{key:"getBbox",value:function(t,e){var r={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}},n=Vt(ot.originRadiusToBbox(t,e),4),i=n[0],o=n[1],a=n[2],s=[i,n[3]],u=[a,o];return r.geometry.coordinates[0]=[s,[u[0],s[1]],u,[s[0],u[1]],s],{feature:r,northWest:s,southEast:u}}},{key:"_createWatcher",value:function(t,e){var r=!!t.onVectorDem,n=!!t.onRgbDem,i={vectorDem:[],rgbDem:[],debug:null},o=function(){return!r&&!n};return o()?(e(i),null):function(t){var a=t.what,s=t.data,u=t.debug;i.debug=u,"dem-vec"===a&&(r=!1,i.vectorDem=s),"dem-rgb"===a&&(n=!1,i.rgbDem=s),o()&&e(i)}}},{key:"_createDemGroup",value:function(e,r,n){var i=new t.Group;i.name=e,i.userData.debug=function(){return n||console.warn("Use the `isDebug` option to enable `.userData.debug()`."),n};var o,a=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=qt(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(r);try{for(a.s();!(o=a.n()).done;){var s=o.value;i.add(s)}}catch(t){a.e(t)}finally{a.f()}return i}}],i&&Yt(n.prototype,i),o&&Yt(n,o),Object.defineProperty(n,"prototype",{writable:!1}),r}();Jt.Utils=ot,Jt.Laser=b;const Zt=Jt})(),i=i.default})()})); |